babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202
  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, Immutable } 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. /**
  20922. * Use this function to overload the renderList array at rendering time.
  20923. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20924. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20925. * the cube (if the RTT is a cube, else layerOrFace=0).
  20926. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20927. */
  20928. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20929. private _hookArray;
  20930. /**
  20931. * Define if particles should be rendered in your texture.
  20932. */
  20933. renderParticles: boolean;
  20934. /**
  20935. * Define if sprites should be rendered in your texture.
  20936. */
  20937. renderSprites: boolean;
  20938. /**
  20939. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20940. */
  20941. coordinatesMode: number;
  20942. /**
  20943. * Define the camera used to render the texture.
  20944. */
  20945. activeCamera: Nullable<Camera>;
  20946. /**
  20947. * Override the render function of the texture with your own one.
  20948. */
  20949. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20950. /**
  20951. * Define if camera post processes should be use while rendering the texture.
  20952. */
  20953. useCameraPostProcesses: boolean;
  20954. /**
  20955. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20956. */
  20957. ignoreCameraViewport: boolean;
  20958. private _postProcessManager;
  20959. private _postProcesses;
  20960. private _resizeObserver;
  20961. /**
  20962. * An event triggered when the texture is unbind.
  20963. */
  20964. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20965. /**
  20966. * An event triggered when the texture is unbind.
  20967. */
  20968. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20969. private _onAfterUnbindObserver;
  20970. /**
  20971. * Set a after unbind callback in the texture.
  20972. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20973. */
  20974. set onAfterUnbind(callback: () => void);
  20975. /**
  20976. * An event triggered before rendering the texture
  20977. */
  20978. onBeforeRenderObservable: Observable<number>;
  20979. private _onBeforeRenderObserver;
  20980. /**
  20981. * Set a before render callback in the texture.
  20982. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20983. */
  20984. set onBeforeRender(callback: (faceIndex: number) => void);
  20985. /**
  20986. * An event triggered after rendering the texture
  20987. */
  20988. onAfterRenderObservable: Observable<number>;
  20989. private _onAfterRenderObserver;
  20990. /**
  20991. * Set a after render callback in the texture.
  20992. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20993. */
  20994. set onAfterRender(callback: (faceIndex: number) => void);
  20995. /**
  20996. * An event triggered after the texture clear
  20997. */
  20998. onClearObservable: Observable<Engine>;
  20999. private _onClearObserver;
  21000. /**
  21001. * Set a clear callback in the texture.
  21002. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21003. */
  21004. set onClear(callback: (Engine: Engine) => void);
  21005. /**
  21006. * An event triggered when the texture is resized.
  21007. */
  21008. onResizeObservable: Observable<RenderTargetTexture>;
  21009. /**
  21010. * Define the clear color of the Render Target if it should be different from the scene.
  21011. */
  21012. clearColor: Color4;
  21013. protected _size: number | {
  21014. width: number;
  21015. height: number;
  21016. layers?: number;
  21017. };
  21018. protected _initialSizeParameter: number | {
  21019. width: number;
  21020. height: number;
  21021. } | {
  21022. ratio: number;
  21023. };
  21024. protected _sizeRatio: Nullable<number>;
  21025. /** @hidden */
  21026. _generateMipMaps: boolean;
  21027. protected _renderingManager: RenderingManager;
  21028. /** @hidden */
  21029. _waitingRenderList: string[];
  21030. protected _doNotChangeAspectRatio: boolean;
  21031. protected _currentRefreshId: number;
  21032. protected _refreshRate: number;
  21033. protected _textureMatrix: Matrix;
  21034. protected _samples: number;
  21035. protected _renderTargetOptions: RenderTargetCreationOptions;
  21036. /**
  21037. * Gets render target creation options that were used.
  21038. */
  21039. get renderTargetOptions(): RenderTargetCreationOptions;
  21040. protected _engine: Engine;
  21041. protected _onRatioRescale(): void;
  21042. /**
  21043. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21044. * It must define where the camera used to render the texture is set
  21045. */
  21046. boundingBoxPosition: Vector3;
  21047. private _boundingBoxSize;
  21048. /**
  21049. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21050. * When defined, the cubemap will switch to local mode
  21051. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21052. * @example https://www.babylonjs-playground.com/#RNASML
  21053. */
  21054. set boundingBoxSize(value: Vector3);
  21055. get boundingBoxSize(): Vector3;
  21056. /**
  21057. * In case the RTT has been created with a depth texture, get the associated
  21058. * depth texture.
  21059. * Otherwise, return null.
  21060. */
  21061. get depthStencilTexture(): Nullable<InternalTexture>;
  21062. /**
  21063. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21064. * or used a shadow, depth texture...
  21065. * @param name The friendly name of the texture
  21066. * @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)
  21067. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21068. * @param generateMipMaps True if mip maps need to be generated after render.
  21069. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21070. * @param type The type of the buffer in the RTT (int, half float, float...)
  21071. * @param isCube True if a cube texture needs to be created
  21072. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21073. * @param generateDepthBuffer True to generate a depth buffer
  21074. * @param generateStencilBuffer True to generate a stencil buffer
  21075. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21076. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21077. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21078. */
  21079. constructor(name: string, size: number | {
  21080. width: number;
  21081. height: number;
  21082. layers?: number;
  21083. } | {
  21084. ratio: number;
  21085. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21086. /**
  21087. * Creates a depth stencil texture.
  21088. * This is only available in WebGL 2 or with the depth texture extension available.
  21089. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21090. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21091. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21092. */
  21093. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21094. private _processSizeParameter;
  21095. /**
  21096. * Define the number of samples to use in case of MSAA.
  21097. * It defaults to one meaning no MSAA has been enabled.
  21098. */
  21099. get samples(): number;
  21100. set samples(value: number);
  21101. /**
  21102. * Resets the refresh counter of the texture and start bak from scratch.
  21103. * Could be useful to regenerate the texture if it is setup to render only once.
  21104. */
  21105. resetRefreshCounter(): void;
  21106. /**
  21107. * Define the refresh rate of the texture or the rendering frequency.
  21108. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21109. */
  21110. get refreshRate(): number;
  21111. set refreshRate(value: number);
  21112. /**
  21113. * Adds a post process to the render target rendering passes.
  21114. * @param postProcess define the post process to add
  21115. */
  21116. addPostProcess(postProcess: PostProcess): void;
  21117. /**
  21118. * Clear all the post processes attached to the render target
  21119. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21120. */
  21121. clearPostProcesses(dispose?: boolean): void;
  21122. /**
  21123. * Remove one of the post process from the list of attached post processes to the texture
  21124. * @param postProcess define the post process to remove from the list
  21125. */
  21126. removePostProcess(postProcess: PostProcess): void;
  21127. /** @hidden */
  21128. _shouldRender(): boolean;
  21129. /**
  21130. * Gets the actual render size of the texture.
  21131. * @returns the width of the render size
  21132. */
  21133. getRenderSize(): number;
  21134. /**
  21135. * Gets the actual render width of the texture.
  21136. * @returns the width of the render size
  21137. */
  21138. getRenderWidth(): number;
  21139. /**
  21140. * Gets the actual render height of the texture.
  21141. * @returns the height of the render size
  21142. */
  21143. getRenderHeight(): number;
  21144. /**
  21145. * Gets the actual number of layers of the texture.
  21146. * @returns the number of layers
  21147. */
  21148. getRenderLayers(): number;
  21149. /**
  21150. * Get if the texture can be rescaled or not.
  21151. */
  21152. get canRescale(): boolean;
  21153. /**
  21154. * Resize the texture using a ratio.
  21155. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21156. */
  21157. scale(ratio: number): void;
  21158. /**
  21159. * Get the texture reflection matrix used to rotate/transform the reflection.
  21160. * @returns the reflection matrix
  21161. */
  21162. getReflectionTextureMatrix(): Matrix;
  21163. /**
  21164. * Resize the texture to a new desired size.
  21165. * Be carrefull as it will recreate all the data in the new texture.
  21166. * @param size Define the new size. It can be:
  21167. * - a number for squared texture,
  21168. * - an object containing { width: number, height: number }
  21169. * - or an object containing a ratio { ratio: number }
  21170. */
  21171. resize(size: number | {
  21172. width: number;
  21173. height: number;
  21174. } | {
  21175. ratio: number;
  21176. }): void;
  21177. private _defaultRenderListPrepared;
  21178. /**
  21179. * Renders all the objects from the render list into the texture.
  21180. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21181. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21182. */
  21183. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21184. private _bestReflectionRenderTargetDimension;
  21185. private _prepareRenderingManager;
  21186. /**
  21187. * @hidden
  21188. * @param faceIndex face index to bind to if this is a cubetexture
  21189. * @param layer defines the index of the texture to bind in the array
  21190. */
  21191. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21192. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21193. private renderToTarget;
  21194. /**
  21195. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21196. * This allowed control for front to back rendering or reversly depending of the special needs.
  21197. *
  21198. * @param renderingGroupId The rendering group id corresponding to its index
  21199. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21200. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21201. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21202. */
  21203. 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;
  21204. /**
  21205. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21206. *
  21207. * @param renderingGroupId The rendering group id corresponding to its index
  21208. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21209. */
  21210. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21211. /**
  21212. * Clones the texture.
  21213. * @returns the cloned texture
  21214. */
  21215. clone(): RenderTargetTexture;
  21216. /**
  21217. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21218. * @returns The JSON representation of the texture
  21219. */
  21220. serialize(): any;
  21221. /**
  21222. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21223. */
  21224. disposeFramebufferObjects(): void;
  21225. /**
  21226. * Dispose the texture and release its associated resources.
  21227. */
  21228. dispose(): void;
  21229. /** @hidden */
  21230. _rebuild(): void;
  21231. /**
  21232. * Clear the info related to rendering groups preventing retention point in material dispose.
  21233. */
  21234. freeRenderingGroups(): void;
  21235. /**
  21236. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21237. * @returns the view count
  21238. */
  21239. getViewCount(): number;
  21240. }
  21241. }
  21242. declare module "babylonjs/Materials/material" {
  21243. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21244. import { SmartArray } from "babylonjs/Misc/smartArray";
  21245. import { Observable } from "babylonjs/Misc/observable";
  21246. import { Nullable } from "babylonjs/types";
  21247. import { Scene } from "babylonjs/scene";
  21248. import { Matrix } from "babylonjs/Maths/math.vector";
  21249. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21251. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21252. import { Effect } from "babylonjs/Materials/effect";
  21253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21254. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21255. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21256. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21257. import { Mesh } from "babylonjs/Meshes/mesh";
  21258. import { Animation } from "babylonjs/Animations/animation";
  21259. /**
  21260. * Options for compiling materials.
  21261. */
  21262. export interface IMaterialCompilationOptions {
  21263. /**
  21264. * Defines whether clip planes are enabled.
  21265. */
  21266. clipPlane: boolean;
  21267. /**
  21268. * Defines whether instances are enabled.
  21269. */
  21270. useInstances: boolean;
  21271. }
  21272. /**
  21273. * Base class for the main features of a material in Babylon.js
  21274. */
  21275. export class Material implements IAnimatable {
  21276. /**
  21277. * Returns the triangle fill mode
  21278. */
  21279. static readonly TriangleFillMode: number;
  21280. /**
  21281. * Returns the wireframe mode
  21282. */
  21283. static readonly WireFrameFillMode: number;
  21284. /**
  21285. * Returns the point fill mode
  21286. */
  21287. static readonly PointFillMode: number;
  21288. /**
  21289. * Returns the point list draw mode
  21290. */
  21291. static readonly PointListDrawMode: number;
  21292. /**
  21293. * Returns the line list draw mode
  21294. */
  21295. static readonly LineListDrawMode: number;
  21296. /**
  21297. * Returns the line loop draw mode
  21298. */
  21299. static readonly LineLoopDrawMode: number;
  21300. /**
  21301. * Returns the line strip draw mode
  21302. */
  21303. static readonly LineStripDrawMode: number;
  21304. /**
  21305. * Returns the triangle strip draw mode
  21306. */
  21307. static readonly TriangleStripDrawMode: number;
  21308. /**
  21309. * Returns the triangle fan draw mode
  21310. */
  21311. static readonly TriangleFanDrawMode: number;
  21312. /**
  21313. * Stores the clock-wise side orientation
  21314. */
  21315. static readonly ClockWiseSideOrientation: number;
  21316. /**
  21317. * Stores the counter clock-wise side orientation
  21318. */
  21319. static readonly CounterClockWiseSideOrientation: number;
  21320. /**
  21321. * The dirty texture flag value
  21322. */
  21323. static readonly TextureDirtyFlag: number;
  21324. /**
  21325. * The dirty light flag value
  21326. */
  21327. static readonly LightDirtyFlag: number;
  21328. /**
  21329. * The dirty fresnel flag value
  21330. */
  21331. static readonly FresnelDirtyFlag: number;
  21332. /**
  21333. * The dirty attribute flag value
  21334. */
  21335. static readonly AttributesDirtyFlag: number;
  21336. /**
  21337. * The dirty misc flag value
  21338. */
  21339. static readonly MiscDirtyFlag: number;
  21340. /**
  21341. * The all dirty flag value
  21342. */
  21343. static readonly AllDirtyFlag: number;
  21344. /**
  21345. * The ID of the material
  21346. */
  21347. id: string;
  21348. /**
  21349. * Gets or sets the unique id of the material
  21350. */
  21351. uniqueId: number;
  21352. /**
  21353. * The name of the material
  21354. */
  21355. name: string;
  21356. /**
  21357. * Gets or sets user defined metadata
  21358. */
  21359. metadata: any;
  21360. /**
  21361. * For internal use only. Please do not use.
  21362. */
  21363. reservedDataStore: any;
  21364. /**
  21365. * Specifies if the ready state should be checked on each call
  21366. */
  21367. checkReadyOnEveryCall: boolean;
  21368. /**
  21369. * Specifies if the ready state should be checked once
  21370. */
  21371. checkReadyOnlyOnce: boolean;
  21372. /**
  21373. * The state of the material
  21374. */
  21375. state: string;
  21376. /**
  21377. * The alpha value of the material
  21378. */
  21379. protected _alpha: number;
  21380. /**
  21381. * List of inspectable custom properties (used by the Inspector)
  21382. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21383. */
  21384. inspectableCustomProperties: IInspectable[];
  21385. /**
  21386. * Sets the alpha value of the material
  21387. */
  21388. set alpha(value: number);
  21389. /**
  21390. * Gets the alpha value of the material
  21391. */
  21392. get alpha(): number;
  21393. /**
  21394. * Specifies if back face culling is enabled
  21395. */
  21396. protected _backFaceCulling: boolean;
  21397. /**
  21398. * Sets the back-face culling state
  21399. */
  21400. set backFaceCulling(value: boolean);
  21401. /**
  21402. * Gets the back-face culling state
  21403. */
  21404. get backFaceCulling(): boolean;
  21405. /**
  21406. * Stores the value for side orientation
  21407. */
  21408. sideOrientation: number;
  21409. /**
  21410. * Callback triggered when the material is compiled
  21411. */
  21412. onCompiled: Nullable<(effect: Effect) => void>;
  21413. /**
  21414. * Callback triggered when an error occurs
  21415. */
  21416. onError: Nullable<(effect: Effect, errors: string) => void>;
  21417. /**
  21418. * Callback triggered to get the render target textures
  21419. */
  21420. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21421. /**
  21422. * Gets a boolean indicating that current material needs to register RTT
  21423. */
  21424. get hasRenderTargetTextures(): boolean;
  21425. /**
  21426. * Specifies if the material should be serialized
  21427. */
  21428. doNotSerialize: boolean;
  21429. /**
  21430. * @hidden
  21431. */
  21432. _storeEffectOnSubMeshes: boolean;
  21433. /**
  21434. * Stores the animations for the material
  21435. */
  21436. animations: Nullable<Array<Animation>>;
  21437. /**
  21438. * An event triggered when the material is disposed
  21439. */
  21440. onDisposeObservable: Observable<Material>;
  21441. /**
  21442. * An observer which watches for dispose events
  21443. */
  21444. private _onDisposeObserver;
  21445. private _onUnBindObservable;
  21446. /**
  21447. * Called during a dispose event
  21448. */
  21449. set onDispose(callback: () => void);
  21450. private _onBindObservable;
  21451. /**
  21452. * An event triggered when the material is bound
  21453. */
  21454. get onBindObservable(): Observable<AbstractMesh>;
  21455. /**
  21456. * An observer which watches for bind events
  21457. */
  21458. private _onBindObserver;
  21459. /**
  21460. * Called during a bind event
  21461. */
  21462. set onBind(callback: (Mesh: AbstractMesh) => void);
  21463. /**
  21464. * An event triggered when the material is unbound
  21465. */
  21466. get onUnBindObservable(): Observable<Material>;
  21467. /**
  21468. * Stores the value of the alpha mode
  21469. */
  21470. private _alphaMode;
  21471. /**
  21472. * Sets the value of the alpha mode.
  21473. *
  21474. * | Value | Type | Description |
  21475. * | --- | --- | --- |
  21476. * | 0 | ALPHA_DISABLE | |
  21477. * | 1 | ALPHA_ADD | |
  21478. * | 2 | ALPHA_COMBINE | |
  21479. * | 3 | ALPHA_SUBTRACT | |
  21480. * | 4 | ALPHA_MULTIPLY | |
  21481. * | 5 | ALPHA_MAXIMIZED | |
  21482. * | 6 | ALPHA_ONEONE | |
  21483. * | 7 | ALPHA_PREMULTIPLIED | |
  21484. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21485. * | 9 | ALPHA_INTERPOLATE | |
  21486. * | 10 | ALPHA_SCREENMODE | |
  21487. *
  21488. */
  21489. set alphaMode(value: number);
  21490. /**
  21491. * Gets the value of the alpha mode
  21492. */
  21493. get alphaMode(): number;
  21494. /**
  21495. * Stores the state of the need depth pre-pass value
  21496. */
  21497. private _needDepthPrePass;
  21498. /**
  21499. * Sets the need depth pre-pass value
  21500. */
  21501. set needDepthPrePass(value: boolean);
  21502. /**
  21503. * Gets the depth pre-pass value
  21504. */
  21505. get needDepthPrePass(): boolean;
  21506. /**
  21507. * Specifies if depth writing should be disabled
  21508. */
  21509. disableDepthWrite: boolean;
  21510. /**
  21511. * Specifies if depth writing should be forced
  21512. */
  21513. forceDepthWrite: boolean;
  21514. /**
  21515. * Specifies the depth function that should be used. 0 means the default engine function
  21516. */
  21517. depthFunction: number;
  21518. /**
  21519. * Specifies if there should be a separate pass for culling
  21520. */
  21521. separateCullingPass: boolean;
  21522. /**
  21523. * Stores the state specifing if fog should be enabled
  21524. */
  21525. private _fogEnabled;
  21526. /**
  21527. * Sets the state for enabling fog
  21528. */
  21529. set fogEnabled(value: boolean);
  21530. /**
  21531. * Gets the value of the fog enabled state
  21532. */
  21533. get fogEnabled(): boolean;
  21534. /**
  21535. * Stores the size of points
  21536. */
  21537. pointSize: number;
  21538. /**
  21539. * Stores the z offset value
  21540. */
  21541. zOffset: number;
  21542. /**
  21543. * Gets a value specifying if wireframe mode is enabled
  21544. */
  21545. get wireframe(): boolean;
  21546. /**
  21547. * Sets the state of wireframe mode
  21548. */
  21549. set wireframe(value: boolean);
  21550. /**
  21551. * Gets the value specifying if point clouds are enabled
  21552. */
  21553. get pointsCloud(): boolean;
  21554. /**
  21555. * Sets the state of point cloud mode
  21556. */
  21557. set pointsCloud(value: boolean);
  21558. /**
  21559. * Gets the material fill mode
  21560. */
  21561. get fillMode(): number;
  21562. /**
  21563. * Sets the material fill mode
  21564. */
  21565. set fillMode(value: number);
  21566. /**
  21567. * @hidden
  21568. * Stores the effects for the material
  21569. */
  21570. _effect: Nullable<Effect>;
  21571. /**
  21572. * Specifies if uniform buffers should be used
  21573. */
  21574. private _useUBO;
  21575. /**
  21576. * Stores a reference to the scene
  21577. */
  21578. private _scene;
  21579. /**
  21580. * Stores the fill mode state
  21581. */
  21582. private _fillMode;
  21583. /**
  21584. * Specifies if the depth write state should be cached
  21585. */
  21586. private _cachedDepthWriteState;
  21587. /**
  21588. * Specifies if the depth function state should be cached
  21589. */
  21590. private _cachedDepthFunctionState;
  21591. /**
  21592. * Stores the uniform buffer
  21593. */
  21594. protected _uniformBuffer: UniformBuffer;
  21595. /** @hidden */
  21596. _indexInSceneMaterialArray: number;
  21597. /** @hidden */
  21598. meshMap: Nullable<{
  21599. [id: string]: AbstractMesh | undefined;
  21600. }>;
  21601. /**
  21602. * Creates a material instance
  21603. * @param name defines the name of the material
  21604. * @param scene defines the scene to reference
  21605. * @param doNotAdd specifies if the material should be added to the scene
  21606. */
  21607. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21608. /**
  21609. * Returns a string representation of the current material
  21610. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21611. * @returns a string with material information
  21612. */
  21613. toString(fullDetails?: boolean): string;
  21614. /**
  21615. * Gets the class name of the material
  21616. * @returns a string with the class name of the material
  21617. */
  21618. getClassName(): string;
  21619. /**
  21620. * Specifies if updates for the material been locked
  21621. */
  21622. get isFrozen(): boolean;
  21623. /**
  21624. * Locks updates for the material
  21625. */
  21626. freeze(): void;
  21627. /**
  21628. * Unlocks updates for the material
  21629. */
  21630. unfreeze(): void;
  21631. /**
  21632. * Specifies if the material is ready to be used
  21633. * @param mesh defines the mesh to check
  21634. * @param useInstances specifies if instances should be used
  21635. * @returns a boolean indicating if the material is ready to be used
  21636. */
  21637. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21638. /**
  21639. * Specifies that the submesh is ready to be used
  21640. * @param mesh defines the mesh to check
  21641. * @param subMesh defines which submesh to check
  21642. * @param useInstances specifies that instances should be used
  21643. * @returns a boolean indicating that the submesh is ready or not
  21644. */
  21645. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21646. /**
  21647. * Returns the material effect
  21648. * @returns the effect associated with the material
  21649. */
  21650. getEffect(): Nullable<Effect>;
  21651. /**
  21652. * Returns the current scene
  21653. * @returns a Scene
  21654. */
  21655. getScene(): Scene;
  21656. /**
  21657. * Specifies if the material will require alpha blending
  21658. * @returns a boolean specifying if alpha blending is needed
  21659. */
  21660. needAlphaBlending(): boolean;
  21661. /**
  21662. * Specifies if the mesh will require alpha blending
  21663. * @param mesh defines the mesh to check
  21664. * @returns a boolean specifying if alpha blending is needed for the mesh
  21665. */
  21666. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21667. /**
  21668. * Specifies if this material should be rendered in alpha test mode
  21669. * @returns a boolean specifying if an alpha test is needed.
  21670. */
  21671. needAlphaTesting(): boolean;
  21672. /**
  21673. * Gets the texture used for the alpha test
  21674. * @returns the texture to use for alpha testing
  21675. */
  21676. getAlphaTestTexture(): Nullable<BaseTexture>;
  21677. /**
  21678. * Marks the material to indicate that it needs to be re-calculated
  21679. */
  21680. markDirty(): void;
  21681. /** @hidden */
  21682. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21683. /**
  21684. * Binds the material to the mesh
  21685. * @param world defines the world transformation matrix
  21686. * @param mesh defines the mesh to bind the material to
  21687. */
  21688. bind(world: Matrix, mesh?: Mesh): void;
  21689. /**
  21690. * Binds the submesh to the material
  21691. * @param world defines the world transformation matrix
  21692. * @param mesh defines the mesh containing the submesh
  21693. * @param subMesh defines the submesh to bind the material to
  21694. */
  21695. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21696. /**
  21697. * Binds the world matrix to the material
  21698. * @param world defines the world transformation matrix
  21699. */
  21700. bindOnlyWorldMatrix(world: Matrix): void;
  21701. /**
  21702. * Binds the scene's uniform buffer to the effect.
  21703. * @param effect defines the effect to bind to the scene uniform buffer
  21704. * @param sceneUbo defines the uniform buffer storing scene data
  21705. */
  21706. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21707. /**
  21708. * Binds the view matrix to the effect
  21709. * @param effect defines the effect to bind the view matrix to
  21710. */
  21711. bindView(effect: Effect): void;
  21712. /**
  21713. * Binds the view projection matrix to the effect
  21714. * @param effect defines the effect to bind the view projection matrix to
  21715. */
  21716. bindViewProjection(effect: Effect): void;
  21717. /**
  21718. * Specifies if material alpha testing should be turned on for the mesh
  21719. * @param mesh defines the mesh to check
  21720. */
  21721. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21722. /**
  21723. * Processes to execute after binding the material to a mesh
  21724. * @param mesh defines the rendered mesh
  21725. */
  21726. protected _afterBind(mesh?: Mesh): void;
  21727. /**
  21728. * Unbinds the material from the mesh
  21729. */
  21730. unbind(): void;
  21731. /**
  21732. * Gets the active textures from the material
  21733. * @returns an array of textures
  21734. */
  21735. getActiveTextures(): BaseTexture[];
  21736. /**
  21737. * Specifies if the material uses a texture
  21738. * @param texture defines the texture to check against the material
  21739. * @returns a boolean specifying if the material uses the texture
  21740. */
  21741. hasTexture(texture: BaseTexture): boolean;
  21742. /**
  21743. * Makes a duplicate of the material, and gives it a new name
  21744. * @param name defines the new name for the duplicated material
  21745. * @returns the cloned material
  21746. */
  21747. clone(name: string): Nullable<Material>;
  21748. /**
  21749. * Gets the meshes bound to the material
  21750. * @returns an array of meshes bound to the material
  21751. */
  21752. getBindedMeshes(): AbstractMesh[];
  21753. /**
  21754. * Force shader compilation
  21755. * @param mesh defines the mesh associated with this material
  21756. * @param onCompiled defines a function to execute once the material is compiled
  21757. * @param options defines the options to configure the compilation
  21758. * @param onError defines a function to execute if the material fails compiling
  21759. */
  21760. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21761. /**
  21762. * Force shader compilation
  21763. * @param mesh defines the mesh that will use this material
  21764. * @param options defines additional options for compiling the shaders
  21765. * @returns a promise that resolves when the compilation completes
  21766. */
  21767. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21768. private static readonly _AllDirtyCallBack;
  21769. private static readonly _ImageProcessingDirtyCallBack;
  21770. private static readonly _TextureDirtyCallBack;
  21771. private static readonly _FresnelDirtyCallBack;
  21772. private static readonly _MiscDirtyCallBack;
  21773. private static readonly _LightsDirtyCallBack;
  21774. private static readonly _AttributeDirtyCallBack;
  21775. private static _FresnelAndMiscDirtyCallBack;
  21776. private static _TextureAndMiscDirtyCallBack;
  21777. private static readonly _DirtyCallbackArray;
  21778. private static readonly _RunDirtyCallBacks;
  21779. /**
  21780. * Marks a define in the material to indicate that it needs to be re-computed
  21781. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21782. */
  21783. markAsDirty(flag: number): void;
  21784. /**
  21785. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21786. * @param func defines a function which checks material defines against the submeshes
  21787. */
  21788. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21789. /**
  21790. * Indicates that we need to re-calculated for all submeshes
  21791. */
  21792. protected _markAllSubMeshesAsAllDirty(): void;
  21793. /**
  21794. * Indicates that image processing needs to be re-calculated for all submeshes
  21795. */
  21796. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21797. /**
  21798. * Indicates that textures need to be re-calculated for all submeshes
  21799. */
  21800. protected _markAllSubMeshesAsTexturesDirty(): void;
  21801. /**
  21802. * Indicates that fresnel needs to be re-calculated for all submeshes
  21803. */
  21804. protected _markAllSubMeshesAsFresnelDirty(): void;
  21805. /**
  21806. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21807. */
  21808. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21809. /**
  21810. * Indicates that lights need to be re-calculated for all submeshes
  21811. */
  21812. protected _markAllSubMeshesAsLightsDirty(): void;
  21813. /**
  21814. * Indicates that attributes need to be re-calculated for all submeshes
  21815. */
  21816. protected _markAllSubMeshesAsAttributesDirty(): void;
  21817. /**
  21818. * Indicates that misc needs to be re-calculated for all submeshes
  21819. */
  21820. protected _markAllSubMeshesAsMiscDirty(): void;
  21821. /**
  21822. * Indicates that textures and misc need to be re-calculated for all submeshes
  21823. */
  21824. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21825. /**
  21826. * Disposes the material
  21827. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21828. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21829. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21830. */
  21831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21832. /** @hidden */
  21833. private releaseVertexArrayObject;
  21834. /**
  21835. * Serializes this material
  21836. * @returns the serialized material object
  21837. */
  21838. serialize(): any;
  21839. /**
  21840. * Creates a material from parsed material data
  21841. * @param parsedMaterial defines parsed material data
  21842. * @param scene defines the hosting scene
  21843. * @param rootUrl defines the root URL to use to load textures
  21844. * @returns a new material
  21845. */
  21846. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21847. }
  21848. }
  21849. declare module "babylonjs/Materials/multiMaterial" {
  21850. import { Nullable } from "babylonjs/types";
  21851. import { Scene } from "babylonjs/scene";
  21852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21853. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21855. import { Material } from "babylonjs/Materials/material";
  21856. /**
  21857. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21858. * separate meshes. This can be use to improve performances.
  21859. * @see http://doc.babylonjs.com/how_to/multi_materials
  21860. */
  21861. export class MultiMaterial extends Material {
  21862. private _subMaterials;
  21863. /**
  21864. * Gets or Sets the list of Materials used within the multi material.
  21865. * They need to be ordered according to the submeshes order in the associated mesh
  21866. */
  21867. get subMaterials(): Nullable<Material>[];
  21868. set subMaterials(value: Nullable<Material>[]);
  21869. /**
  21870. * Function used to align with Node.getChildren()
  21871. * @returns the list of Materials used within the multi material
  21872. */
  21873. getChildren(): Nullable<Material>[];
  21874. /**
  21875. * Instantiates a new Multi Material
  21876. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21877. * separate meshes. This can be use to improve performances.
  21878. * @see http://doc.babylonjs.com/how_to/multi_materials
  21879. * @param name Define the name in the scene
  21880. * @param scene Define the scene the material belongs to
  21881. */
  21882. constructor(name: string, scene: Scene);
  21883. private _hookArray;
  21884. /**
  21885. * Get one of the submaterial by its index in the submaterials array
  21886. * @param index The index to look the sub material at
  21887. * @returns The Material if the index has been defined
  21888. */
  21889. getSubMaterial(index: number): Nullable<Material>;
  21890. /**
  21891. * Get the list of active textures for the whole sub materials list.
  21892. * @returns All the textures that will be used during the rendering
  21893. */
  21894. getActiveTextures(): BaseTexture[];
  21895. /**
  21896. * Gets the current class name of the material e.g. "MultiMaterial"
  21897. * Mainly use in serialization.
  21898. * @returns the class name
  21899. */
  21900. getClassName(): string;
  21901. /**
  21902. * Checks if the material is ready to render the requested sub mesh
  21903. * @param mesh Define the mesh the submesh belongs to
  21904. * @param subMesh Define the sub mesh to look readyness for
  21905. * @param useInstances Define whether or not the material is used with instances
  21906. * @returns true if ready, otherwise false
  21907. */
  21908. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21909. /**
  21910. * Clones the current material and its related sub materials
  21911. * @param name Define the name of the newly cloned material
  21912. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21913. * @returns the cloned material
  21914. */
  21915. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21916. /**
  21917. * Serializes the materials into a JSON representation.
  21918. * @returns the JSON representation
  21919. */
  21920. serialize(): any;
  21921. /**
  21922. * Dispose the material and release its associated resources
  21923. * @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)
  21924. * @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)
  21925. * @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)
  21926. */
  21927. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21928. /**
  21929. * Creates a MultiMaterial from parsed MultiMaterial data.
  21930. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21931. * @param scene defines the hosting scene
  21932. * @returns a new MultiMaterial
  21933. */
  21934. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21935. }
  21936. }
  21937. declare module "babylonjs/Meshes/subMesh" {
  21938. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21939. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21940. import { Engine } from "babylonjs/Engines/engine";
  21941. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21942. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21943. import { Effect } from "babylonjs/Materials/effect";
  21944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21945. import { Plane } from "babylonjs/Maths/math.plane";
  21946. import { Collider } from "babylonjs/Collisions/collider";
  21947. import { Material } from "babylonjs/Materials/material";
  21948. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21950. import { Mesh } from "babylonjs/Meshes/mesh";
  21951. import { Ray } from "babylonjs/Culling/ray";
  21952. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21953. /**
  21954. * Base class for submeshes
  21955. */
  21956. export class BaseSubMesh {
  21957. /** @hidden */
  21958. _materialDefines: Nullable<MaterialDefines>;
  21959. /** @hidden */
  21960. _materialEffect: Nullable<Effect>;
  21961. /**
  21962. * Gets material defines used by the effect associated to the sub mesh
  21963. */
  21964. get materialDefines(): Nullable<MaterialDefines>;
  21965. /**
  21966. * Sets material defines used by the effect associated to the sub mesh
  21967. */
  21968. set materialDefines(defines: Nullable<MaterialDefines>);
  21969. /**
  21970. * Gets associated effect
  21971. */
  21972. get effect(): Nullable<Effect>;
  21973. /**
  21974. * Sets associated effect (effect used to render this submesh)
  21975. * @param effect defines the effect to associate with
  21976. * @param defines defines the set of defines used to compile this effect
  21977. */
  21978. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21979. }
  21980. /**
  21981. * Defines a subdivision inside a mesh
  21982. */
  21983. export class SubMesh extends BaseSubMesh implements ICullable {
  21984. /** the material index to use */
  21985. materialIndex: number;
  21986. /** vertex index start */
  21987. verticesStart: number;
  21988. /** vertices count */
  21989. verticesCount: number;
  21990. /** index start */
  21991. indexStart: number;
  21992. /** indices count */
  21993. indexCount: number;
  21994. /** @hidden */
  21995. _linesIndexCount: number;
  21996. private _mesh;
  21997. private _renderingMesh;
  21998. private _boundingInfo;
  21999. private _linesIndexBuffer;
  22000. /** @hidden */
  22001. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22002. /** @hidden */
  22003. _trianglePlanes: Plane[];
  22004. /** @hidden */
  22005. _lastColliderTransformMatrix: Nullable<Matrix>;
  22006. /** @hidden */
  22007. _renderId: number;
  22008. /** @hidden */
  22009. _alphaIndex: number;
  22010. /** @hidden */
  22011. _distanceToCamera: number;
  22012. /** @hidden */
  22013. _id: number;
  22014. private _currentMaterial;
  22015. /**
  22016. * Add a new submesh to a mesh
  22017. * @param materialIndex defines the material index to use
  22018. * @param verticesStart defines vertex index start
  22019. * @param verticesCount defines vertices count
  22020. * @param indexStart defines index start
  22021. * @param indexCount defines indices count
  22022. * @param mesh defines the parent mesh
  22023. * @param renderingMesh defines an optional rendering mesh
  22024. * @param createBoundingBox defines if bounding box should be created for this submesh
  22025. * @returns the new submesh
  22026. */
  22027. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22028. /**
  22029. * Creates a new submesh
  22030. * @param materialIndex defines the material index to use
  22031. * @param verticesStart defines vertex index start
  22032. * @param verticesCount defines vertices count
  22033. * @param indexStart defines index start
  22034. * @param indexCount defines indices count
  22035. * @param mesh defines the parent mesh
  22036. * @param renderingMesh defines an optional rendering mesh
  22037. * @param createBoundingBox defines if bounding box should be created for this submesh
  22038. */
  22039. constructor(
  22040. /** the material index to use */
  22041. materialIndex: number,
  22042. /** vertex index start */
  22043. verticesStart: number,
  22044. /** vertices count */
  22045. verticesCount: number,
  22046. /** index start */
  22047. indexStart: number,
  22048. /** indices count */
  22049. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22050. /**
  22051. * Returns true if this submesh covers the entire parent mesh
  22052. * @ignorenaming
  22053. */
  22054. get IsGlobal(): boolean;
  22055. /**
  22056. * Returns the submesh BoudingInfo object
  22057. * @returns current bounding info (or mesh's one if the submesh is global)
  22058. */
  22059. getBoundingInfo(): BoundingInfo;
  22060. /**
  22061. * Sets the submesh BoundingInfo
  22062. * @param boundingInfo defines the new bounding info to use
  22063. * @returns the SubMesh
  22064. */
  22065. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22066. /**
  22067. * Returns the mesh of the current submesh
  22068. * @return the parent mesh
  22069. */
  22070. getMesh(): AbstractMesh;
  22071. /**
  22072. * Returns the rendering mesh of the submesh
  22073. * @returns the rendering mesh (could be different from parent mesh)
  22074. */
  22075. getRenderingMesh(): Mesh;
  22076. /**
  22077. * Returns the submesh material
  22078. * @returns null or the current material
  22079. */
  22080. getMaterial(): Nullable<Material>;
  22081. /**
  22082. * Sets a new updated BoundingInfo object to the submesh
  22083. * @param data defines an optional position array to use to determine the bounding info
  22084. * @returns the SubMesh
  22085. */
  22086. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22087. /** @hidden */
  22088. _checkCollision(collider: Collider): boolean;
  22089. /**
  22090. * Updates the submesh BoundingInfo
  22091. * @param world defines the world matrix to use to update the bounding info
  22092. * @returns the submesh
  22093. */
  22094. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22095. /**
  22096. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22097. * @param frustumPlanes defines the frustum planes
  22098. * @returns true if the submesh is intersecting with the frustum
  22099. */
  22100. isInFrustum(frustumPlanes: Plane[]): boolean;
  22101. /**
  22102. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22103. * @param frustumPlanes defines the frustum planes
  22104. * @returns true if the submesh is inside the frustum
  22105. */
  22106. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22107. /**
  22108. * Renders the submesh
  22109. * @param enableAlphaMode defines if alpha needs to be used
  22110. * @returns the submesh
  22111. */
  22112. render(enableAlphaMode: boolean): SubMesh;
  22113. /**
  22114. * @hidden
  22115. */
  22116. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22117. /**
  22118. * Checks if the submesh intersects with a ray
  22119. * @param ray defines the ray to test
  22120. * @returns true is the passed ray intersects the submesh bounding box
  22121. */
  22122. canIntersects(ray: Ray): boolean;
  22123. /**
  22124. * Intersects current submesh with a ray
  22125. * @param ray defines the ray to test
  22126. * @param positions defines mesh's positions array
  22127. * @param indices defines mesh's indices array
  22128. * @param fastCheck defines if only bounding info should be used
  22129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22130. * @returns intersection info or null if no intersection
  22131. */
  22132. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22133. /** @hidden */
  22134. private _intersectLines;
  22135. /** @hidden */
  22136. private _intersectUnIndexedLines;
  22137. /** @hidden */
  22138. private _intersectTriangles;
  22139. /** @hidden */
  22140. private _intersectUnIndexedTriangles;
  22141. /** @hidden */
  22142. _rebuild(): void;
  22143. /**
  22144. * Creates a new submesh from the passed mesh
  22145. * @param newMesh defines the new hosting mesh
  22146. * @param newRenderingMesh defines an optional rendering mesh
  22147. * @returns the new submesh
  22148. */
  22149. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22150. /**
  22151. * Release associated resources
  22152. */
  22153. dispose(): void;
  22154. /**
  22155. * Gets the class name
  22156. * @returns the string "SubMesh".
  22157. */
  22158. getClassName(): string;
  22159. /**
  22160. * Creates a new submesh from indices data
  22161. * @param materialIndex the index of the main mesh material
  22162. * @param startIndex the index where to start the copy in the mesh indices array
  22163. * @param indexCount the number of indices to copy then from the startIndex
  22164. * @param mesh the main mesh to create the submesh from
  22165. * @param renderingMesh the optional rendering mesh
  22166. * @returns a new submesh
  22167. */
  22168. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22169. }
  22170. }
  22171. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22172. /**
  22173. * Class used to represent data loading progression
  22174. */
  22175. export class SceneLoaderFlags {
  22176. private static _ForceFullSceneLoadingForIncremental;
  22177. private static _ShowLoadingScreen;
  22178. private static _CleanBoneMatrixWeights;
  22179. private static _loggingLevel;
  22180. /**
  22181. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22182. */
  22183. static get ForceFullSceneLoadingForIncremental(): boolean;
  22184. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22185. /**
  22186. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22187. */
  22188. static get ShowLoadingScreen(): boolean;
  22189. static set ShowLoadingScreen(value: boolean);
  22190. /**
  22191. * Defines the current logging level (while loading the scene)
  22192. * @ignorenaming
  22193. */
  22194. static get loggingLevel(): number;
  22195. static set loggingLevel(value: number);
  22196. /**
  22197. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22198. */
  22199. static get CleanBoneMatrixWeights(): boolean;
  22200. static set CleanBoneMatrixWeights(value: boolean);
  22201. }
  22202. }
  22203. declare module "babylonjs/Meshes/geometry" {
  22204. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22205. import { Scene } from "babylonjs/scene";
  22206. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22207. import { Engine } from "babylonjs/Engines/engine";
  22208. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22209. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22210. import { Effect } from "babylonjs/Materials/effect";
  22211. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22212. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22213. import { Mesh } from "babylonjs/Meshes/mesh";
  22214. /**
  22215. * Class used to store geometry data (vertex buffers + index buffer)
  22216. */
  22217. export class Geometry implements IGetSetVerticesData {
  22218. /**
  22219. * Gets or sets the ID of the geometry
  22220. */
  22221. id: string;
  22222. /**
  22223. * Gets or sets the unique ID of the geometry
  22224. */
  22225. uniqueId: number;
  22226. /**
  22227. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22228. */
  22229. delayLoadState: number;
  22230. /**
  22231. * Gets the file containing the data to load when running in delay load state
  22232. */
  22233. delayLoadingFile: Nullable<string>;
  22234. /**
  22235. * Callback called when the geometry is updated
  22236. */
  22237. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22238. private _scene;
  22239. private _engine;
  22240. private _meshes;
  22241. private _totalVertices;
  22242. /** @hidden */
  22243. _indices: IndicesArray;
  22244. /** @hidden */
  22245. _vertexBuffers: {
  22246. [key: string]: VertexBuffer;
  22247. };
  22248. private _isDisposed;
  22249. private _extend;
  22250. private _boundingBias;
  22251. /** @hidden */
  22252. _delayInfo: Array<string>;
  22253. private _indexBuffer;
  22254. private _indexBufferIsUpdatable;
  22255. /** @hidden */
  22256. _boundingInfo: Nullable<BoundingInfo>;
  22257. /** @hidden */
  22258. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22259. /** @hidden */
  22260. _softwareSkinningFrameId: number;
  22261. private _vertexArrayObjects;
  22262. private _updatable;
  22263. /** @hidden */
  22264. _positions: Nullable<Vector3[]>;
  22265. /**
  22266. * 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
  22267. */
  22268. get boundingBias(): Vector2;
  22269. /**
  22270. * 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
  22271. */
  22272. set boundingBias(value: Vector2);
  22273. /**
  22274. * Static function used to attach a new empty geometry to a mesh
  22275. * @param mesh defines the mesh to attach the geometry to
  22276. * @returns the new Geometry
  22277. */
  22278. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22279. /**
  22280. * Creates a new geometry
  22281. * @param id defines the unique ID
  22282. * @param scene defines the hosting scene
  22283. * @param vertexData defines the VertexData used to get geometry data
  22284. * @param updatable defines if geometry must be updatable (false by default)
  22285. * @param mesh defines the mesh that will be associated with the geometry
  22286. */
  22287. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22288. /**
  22289. * Gets the current extend of the geometry
  22290. */
  22291. get extend(): {
  22292. minimum: Vector3;
  22293. maximum: Vector3;
  22294. };
  22295. /**
  22296. * Gets the hosting scene
  22297. * @returns the hosting Scene
  22298. */
  22299. getScene(): Scene;
  22300. /**
  22301. * Gets the hosting engine
  22302. * @returns the hosting Engine
  22303. */
  22304. getEngine(): Engine;
  22305. /**
  22306. * Defines if the geometry is ready to use
  22307. * @returns true if the geometry is ready to be used
  22308. */
  22309. isReady(): boolean;
  22310. /**
  22311. * Gets a value indicating that the geometry should not be serialized
  22312. */
  22313. get doNotSerialize(): boolean;
  22314. /** @hidden */
  22315. _rebuild(): void;
  22316. /**
  22317. * Affects all geometry data in one call
  22318. * @param vertexData defines the geometry data
  22319. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22320. */
  22321. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22322. /**
  22323. * Set specific vertex data
  22324. * @param kind defines the data kind (Position, normal, etc...)
  22325. * @param data defines the vertex data to use
  22326. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22327. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22328. */
  22329. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22330. /**
  22331. * Removes a specific vertex data
  22332. * @param kind defines the data kind (Position, normal, etc...)
  22333. */
  22334. removeVerticesData(kind: string): void;
  22335. /**
  22336. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22337. * @param buffer defines the vertex buffer to use
  22338. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22339. */
  22340. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22341. /**
  22342. * Update a specific vertex buffer
  22343. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22344. * It will do nothing if the buffer is not updatable
  22345. * @param kind defines the data kind (Position, normal, etc...)
  22346. * @param data defines the data to use
  22347. * @param offset defines the offset in the target buffer where to store the data
  22348. * @param useBytes set to true if the offset is in bytes
  22349. */
  22350. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22351. /**
  22352. * Update a specific vertex buffer
  22353. * This function will create a new buffer if the current one is not updatable
  22354. * @param kind defines the data kind (Position, normal, etc...)
  22355. * @param data defines the data to use
  22356. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22357. */
  22358. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22359. private _updateBoundingInfo;
  22360. /** @hidden */
  22361. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22362. /**
  22363. * Gets total number of vertices
  22364. * @returns the total number of vertices
  22365. */
  22366. getTotalVertices(): number;
  22367. /**
  22368. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22369. * @param kind defines the data kind (Position, normal, etc...)
  22370. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22371. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22372. * @returns a float array containing vertex data
  22373. */
  22374. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22375. /**
  22376. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22377. * @param kind defines the data kind (Position, normal, etc...)
  22378. * @returns true if the vertex buffer with the specified kind is updatable
  22379. */
  22380. isVertexBufferUpdatable(kind: string): boolean;
  22381. /**
  22382. * Gets a specific vertex buffer
  22383. * @param kind defines the data kind (Position, normal, etc...)
  22384. * @returns a VertexBuffer
  22385. */
  22386. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22387. /**
  22388. * Returns all vertex buffers
  22389. * @return an object holding all vertex buffers indexed by kind
  22390. */
  22391. getVertexBuffers(): Nullable<{
  22392. [key: string]: VertexBuffer;
  22393. }>;
  22394. /**
  22395. * Gets a boolean indicating if specific vertex buffer is present
  22396. * @param kind defines the data kind (Position, normal, etc...)
  22397. * @returns true if data is present
  22398. */
  22399. isVerticesDataPresent(kind: string): boolean;
  22400. /**
  22401. * Gets a list of all attached data kinds (Position, normal, etc...)
  22402. * @returns a list of string containing all kinds
  22403. */
  22404. getVerticesDataKinds(): string[];
  22405. /**
  22406. * Update index buffer
  22407. * @param indices defines the indices to store in the index buffer
  22408. * @param offset defines the offset in the target buffer where to store the data
  22409. * @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)
  22410. */
  22411. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22412. /**
  22413. * Creates a new index buffer
  22414. * @param indices defines the indices to store in the index buffer
  22415. * @param totalVertices defines the total number of vertices (could be null)
  22416. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22417. */
  22418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22419. /**
  22420. * Return the total number of indices
  22421. * @returns the total number of indices
  22422. */
  22423. getTotalIndices(): number;
  22424. /**
  22425. * Gets the index buffer array
  22426. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22427. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22428. * @returns the index buffer array
  22429. */
  22430. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22431. /**
  22432. * Gets the index buffer
  22433. * @return the index buffer
  22434. */
  22435. getIndexBuffer(): Nullable<DataBuffer>;
  22436. /** @hidden */
  22437. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22438. /**
  22439. * Release the associated resources for a specific mesh
  22440. * @param mesh defines the source mesh
  22441. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22442. */
  22443. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22444. /**
  22445. * Apply current geometry to a given mesh
  22446. * @param mesh defines the mesh to apply geometry to
  22447. */
  22448. applyToMesh(mesh: Mesh): void;
  22449. private _updateExtend;
  22450. private _applyToMesh;
  22451. private notifyUpdate;
  22452. /**
  22453. * Load the geometry if it was flagged as delay loaded
  22454. * @param scene defines the hosting scene
  22455. * @param onLoaded defines a callback called when the geometry is loaded
  22456. */
  22457. load(scene: Scene, onLoaded?: () => void): void;
  22458. private _queueLoad;
  22459. /**
  22460. * Invert the geometry to move from a right handed system to a left handed one.
  22461. */
  22462. toLeftHanded(): void;
  22463. /** @hidden */
  22464. _resetPointsArrayCache(): void;
  22465. /** @hidden */
  22466. _generatePointsArray(): boolean;
  22467. /**
  22468. * Gets a value indicating if the geometry is disposed
  22469. * @returns true if the geometry was disposed
  22470. */
  22471. isDisposed(): boolean;
  22472. private _disposeVertexArrayObjects;
  22473. /**
  22474. * Free all associated resources
  22475. */
  22476. dispose(): void;
  22477. /**
  22478. * Clone the current geometry into a new geometry
  22479. * @param id defines the unique ID of the new geometry
  22480. * @returns a new geometry object
  22481. */
  22482. copy(id: string): Geometry;
  22483. /**
  22484. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22485. * @return a JSON representation of the current geometry data (without the vertices data)
  22486. */
  22487. serialize(): any;
  22488. private toNumberArray;
  22489. /**
  22490. * Serialize all vertices data into a JSON oject
  22491. * @returns a JSON representation of the current geometry data
  22492. */
  22493. serializeVerticeData(): any;
  22494. /**
  22495. * Extracts a clone of a mesh geometry
  22496. * @param mesh defines the source mesh
  22497. * @param id defines the unique ID of the new geometry object
  22498. * @returns the new geometry object
  22499. */
  22500. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22501. /**
  22502. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22503. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22504. * Be aware Math.random() could cause collisions, but:
  22505. * "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"
  22506. * @returns a string containing a new GUID
  22507. */
  22508. static RandomId(): string;
  22509. /** @hidden */
  22510. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22511. private static _CleanMatricesWeights;
  22512. /**
  22513. * Create a new geometry from persisted data (Using .babylon file format)
  22514. * @param parsedVertexData defines the persisted data
  22515. * @param scene defines the hosting scene
  22516. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22517. * @returns the new geometry object
  22518. */
  22519. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22520. }
  22521. }
  22522. declare module "babylonjs/Meshes/mesh.vertexData" {
  22523. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22524. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22525. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22526. import { Geometry } from "babylonjs/Meshes/geometry";
  22527. import { Mesh } from "babylonjs/Meshes/mesh";
  22528. /**
  22529. * Define an interface for all classes that will get and set the data on vertices
  22530. */
  22531. export interface IGetSetVerticesData {
  22532. /**
  22533. * Gets a boolean indicating if specific vertex data is present
  22534. * @param kind defines the vertex data kind to use
  22535. * @returns true is data kind is present
  22536. */
  22537. isVerticesDataPresent(kind: string): boolean;
  22538. /**
  22539. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22540. * @param kind defines the data kind (Position, normal, etc...)
  22541. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22542. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22543. * @returns a float array containing vertex data
  22544. */
  22545. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22546. /**
  22547. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22548. * @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.
  22549. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22550. * @returns the indices array or an empty array if the mesh has no geometry
  22551. */
  22552. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22553. /**
  22554. * Set specific vertex data
  22555. * @param kind defines the data kind (Position, normal, etc...)
  22556. * @param data defines the vertex data to use
  22557. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22558. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22559. */
  22560. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22561. /**
  22562. * Update a specific associated vertex buffer
  22563. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22564. * - VertexBuffer.PositionKind
  22565. * - VertexBuffer.UVKind
  22566. * - VertexBuffer.UV2Kind
  22567. * - VertexBuffer.UV3Kind
  22568. * - VertexBuffer.UV4Kind
  22569. * - VertexBuffer.UV5Kind
  22570. * - VertexBuffer.UV6Kind
  22571. * - VertexBuffer.ColorKind
  22572. * - VertexBuffer.MatricesIndicesKind
  22573. * - VertexBuffer.MatricesIndicesExtraKind
  22574. * - VertexBuffer.MatricesWeightsKind
  22575. * - VertexBuffer.MatricesWeightsExtraKind
  22576. * @param data defines the data source
  22577. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22578. * @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)
  22579. */
  22580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22581. /**
  22582. * Creates a new index buffer
  22583. * @param indices defines the indices to store in the index buffer
  22584. * @param totalVertices defines the total number of vertices (could be null)
  22585. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22586. */
  22587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22588. }
  22589. /**
  22590. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22591. */
  22592. export class VertexData {
  22593. /**
  22594. * Mesh side orientation : usually the external or front surface
  22595. */
  22596. static readonly FRONTSIDE: number;
  22597. /**
  22598. * Mesh side orientation : usually the internal or back surface
  22599. */
  22600. static readonly BACKSIDE: number;
  22601. /**
  22602. * Mesh side orientation : both internal and external or front and back surfaces
  22603. */
  22604. static readonly DOUBLESIDE: number;
  22605. /**
  22606. * Mesh side orientation : by default, `FRONTSIDE`
  22607. */
  22608. static readonly DEFAULTSIDE: number;
  22609. /**
  22610. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22611. */
  22612. positions: Nullable<FloatArray>;
  22613. /**
  22614. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22615. */
  22616. normals: Nullable<FloatArray>;
  22617. /**
  22618. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22619. */
  22620. tangents: Nullable<FloatArray>;
  22621. /**
  22622. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22623. */
  22624. uvs: Nullable<FloatArray>;
  22625. /**
  22626. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22627. */
  22628. uvs2: Nullable<FloatArray>;
  22629. /**
  22630. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22631. */
  22632. uvs3: Nullable<FloatArray>;
  22633. /**
  22634. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22635. */
  22636. uvs4: Nullable<FloatArray>;
  22637. /**
  22638. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22639. */
  22640. uvs5: Nullable<FloatArray>;
  22641. /**
  22642. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22643. */
  22644. uvs6: Nullable<FloatArray>;
  22645. /**
  22646. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22647. */
  22648. colors: Nullable<FloatArray>;
  22649. /**
  22650. * 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).
  22651. */
  22652. matricesIndices: Nullable<FloatArray>;
  22653. /**
  22654. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22655. */
  22656. matricesWeights: Nullable<FloatArray>;
  22657. /**
  22658. * An array extending the number of possible indices
  22659. */
  22660. matricesIndicesExtra: Nullable<FloatArray>;
  22661. /**
  22662. * An array extending the number of possible weights when the number of indices is extended
  22663. */
  22664. matricesWeightsExtra: Nullable<FloatArray>;
  22665. /**
  22666. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22667. */
  22668. indices: Nullable<IndicesArray>;
  22669. /**
  22670. * Uses the passed data array to set the set the values for the specified kind of data
  22671. * @param data a linear array of floating numbers
  22672. * @param kind the type of data that is being set, eg positions, colors etc
  22673. */
  22674. set(data: FloatArray, kind: string): void;
  22675. /**
  22676. * Associates the vertexData to the passed Mesh.
  22677. * Sets it as updatable or not (default `false`)
  22678. * @param mesh the mesh the vertexData is applied to
  22679. * @param updatable when used and having the value true allows new data to update the vertexData
  22680. * @returns the VertexData
  22681. */
  22682. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22683. /**
  22684. * Associates the vertexData to the passed Geometry.
  22685. * Sets it as updatable or not (default `false`)
  22686. * @param geometry the geometry the vertexData is applied to
  22687. * @param updatable when used and having the value true allows new data to update the vertexData
  22688. * @returns VertexData
  22689. */
  22690. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22691. /**
  22692. * Updates the associated mesh
  22693. * @param mesh the mesh to be updated
  22694. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22695. * @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
  22696. * @returns VertexData
  22697. */
  22698. updateMesh(mesh: Mesh): VertexData;
  22699. /**
  22700. * Updates the associated geometry
  22701. * @param geometry the geometry to be updated
  22702. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22703. * @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
  22704. * @returns VertexData.
  22705. */
  22706. updateGeometry(geometry: Geometry): VertexData;
  22707. private _applyTo;
  22708. private _update;
  22709. /**
  22710. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22711. * @param matrix the transforming matrix
  22712. * @returns the VertexData
  22713. */
  22714. transform(matrix: Matrix): VertexData;
  22715. /**
  22716. * Merges the passed VertexData into the current one
  22717. * @param other the VertexData to be merged into the current one
  22718. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22719. * @returns the modified VertexData
  22720. */
  22721. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22722. private _mergeElement;
  22723. private _validate;
  22724. /**
  22725. * Serializes the VertexData
  22726. * @returns a serialized object
  22727. */
  22728. serialize(): any;
  22729. /**
  22730. * Extracts the vertexData from a mesh
  22731. * @param mesh the mesh from which to extract the VertexData
  22732. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22733. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22734. * @returns the object VertexData associated to the passed mesh
  22735. */
  22736. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22737. /**
  22738. * Extracts the vertexData from the geometry
  22739. * @param geometry the geometry from which to extract the VertexData
  22740. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22741. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22742. * @returns the object VertexData associated to the passed mesh
  22743. */
  22744. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22745. private static _ExtractFrom;
  22746. /**
  22747. * Creates the VertexData for a Ribbon
  22748. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22749. * * pathArray array of paths, each of which an array of successive Vector3
  22750. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22751. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22752. * * 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
  22753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22754. * * 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)
  22755. * * 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)
  22756. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22757. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22758. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22759. * @returns the VertexData of the ribbon
  22760. */
  22761. static CreateRibbon(options: {
  22762. pathArray: Vector3[][];
  22763. closeArray?: boolean;
  22764. closePath?: boolean;
  22765. offset?: number;
  22766. sideOrientation?: number;
  22767. frontUVs?: Vector4;
  22768. backUVs?: Vector4;
  22769. invertUV?: boolean;
  22770. uvs?: Vector2[];
  22771. colors?: Color4[];
  22772. }): VertexData;
  22773. /**
  22774. * Creates the VertexData for a box
  22775. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22776. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22777. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22778. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22779. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22780. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22781. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22783. * * 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)
  22784. * * 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)
  22785. * @returns the VertexData of the box
  22786. */
  22787. static CreateBox(options: {
  22788. size?: number;
  22789. width?: number;
  22790. height?: number;
  22791. depth?: number;
  22792. faceUV?: Vector4[];
  22793. faceColors?: Color4[];
  22794. sideOrientation?: number;
  22795. frontUVs?: Vector4;
  22796. backUVs?: Vector4;
  22797. }): VertexData;
  22798. /**
  22799. * Creates the VertexData for a tiled box
  22800. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22801. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22802. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22803. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22805. * @returns the VertexData of the box
  22806. */
  22807. static CreateTiledBox(options: {
  22808. pattern?: number;
  22809. width?: number;
  22810. height?: number;
  22811. depth?: number;
  22812. tileSize?: number;
  22813. tileWidth?: number;
  22814. tileHeight?: number;
  22815. alignHorizontal?: number;
  22816. alignVertical?: number;
  22817. faceUV?: Vector4[];
  22818. faceColors?: Color4[];
  22819. sideOrientation?: number;
  22820. }): VertexData;
  22821. /**
  22822. * Creates the VertexData for a tiled plane
  22823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22824. * * pattern a limited pattern arrangement depending on the number
  22825. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22826. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22827. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22829. * * 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)
  22830. * * 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)
  22831. * @returns the VertexData of the tiled plane
  22832. */
  22833. static CreateTiledPlane(options: {
  22834. pattern?: number;
  22835. tileSize?: number;
  22836. tileWidth?: number;
  22837. tileHeight?: number;
  22838. size?: number;
  22839. width?: number;
  22840. height?: number;
  22841. alignHorizontal?: number;
  22842. alignVertical?: number;
  22843. sideOrientation?: number;
  22844. frontUVs?: Vector4;
  22845. backUVs?: Vector4;
  22846. }): VertexData;
  22847. /**
  22848. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22849. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22850. * * segments sets the number of horizontal strips optional, default 32
  22851. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22852. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22853. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22854. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22855. * * 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
  22856. * * 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
  22857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22858. * * 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)
  22859. * * 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)
  22860. * @returns the VertexData of the ellipsoid
  22861. */
  22862. static CreateSphere(options: {
  22863. segments?: number;
  22864. diameter?: number;
  22865. diameterX?: number;
  22866. diameterY?: number;
  22867. diameterZ?: number;
  22868. arc?: number;
  22869. slice?: number;
  22870. sideOrientation?: number;
  22871. frontUVs?: Vector4;
  22872. backUVs?: Vector4;
  22873. }): VertexData;
  22874. /**
  22875. * Creates the VertexData for a cylinder, cone or prism
  22876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22877. * * height sets the height (y direction) of the cylinder, optional, default 2
  22878. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22879. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22880. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22881. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22882. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22883. * * 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
  22884. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22885. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22886. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22887. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22888. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22889. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22890. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22891. * @returns the VertexData of the cylinder, cone or prism
  22892. */
  22893. static CreateCylinder(options: {
  22894. height?: number;
  22895. diameterTop?: number;
  22896. diameterBottom?: number;
  22897. diameter?: number;
  22898. tessellation?: number;
  22899. subdivisions?: number;
  22900. arc?: number;
  22901. faceColors?: Color4[];
  22902. faceUV?: Vector4[];
  22903. hasRings?: boolean;
  22904. enclose?: boolean;
  22905. sideOrientation?: number;
  22906. frontUVs?: Vector4;
  22907. backUVs?: Vector4;
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData for a torus
  22911. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22912. * * diameter the diameter of the torus, optional default 1
  22913. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22914. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22916. * * 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)
  22917. * * 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)
  22918. * @returns the VertexData of the torus
  22919. */
  22920. static CreateTorus(options: {
  22921. diameter?: number;
  22922. thickness?: number;
  22923. tessellation?: number;
  22924. sideOrientation?: number;
  22925. frontUVs?: Vector4;
  22926. backUVs?: Vector4;
  22927. }): VertexData;
  22928. /**
  22929. * Creates the VertexData of the LineSystem
  22930. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22931. * - lines an array of lines, each line being an array of successive Vector3
  22932. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22933. * @returns the VertexData of the LineSystem
  22934. */
  22935. static CreateLineSystem(options: {
  22936. lines: Vector3[][];
  22937. colors?: Nullable<Color4[][]>;
  22938. }): VertexData;
  22939. /**
  22940. * Create the VertexData for a DashedLines
  22941. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22942. * - points an array successive Vector3
  22943. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22944. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22945. * - dashNb the intended total number of dashes, optional, default 200
  22946. * @returns the VertexData for the DashedLines
  22947. */
  22948. static CreateDashedLines(options: {
  22949. points: Vector3[];
  22950. dashSize?: number;
  22951. gapSize?: number;
  22952. dashNb?: number;
  22953. }): VertexData;
  22954. /**
  22955. * Creates the VertexData for a Ground
  22956. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22957. * - width the width (x direction) of the ground, optional, default 1
  22958. * - height the height (z direction) of the ground, optional, default 1
  22959. * - subdivisions the number of subdivisions per side, optional, default 1
  22960. * @returns the VertexData of the Ground
  22961. */
  22962. static CreateGround(options: {
  22963. width?: number;
  22964. height?: number;
  22965. subdivisions?: number;
  22966. subdivisionsX?: number;
  22967. subdivisionsY?: number;
  22968. }): VertexData;
  22969. /**
  22970. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22971. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22972. * * xmin the ground minimum X coordinate, optional, default -1
  22973. * * zmin the ground minimum Z coordinate, optional, default -1
  22974. * * xmax the ground maximum X coordinate, optional, default 1
  22975. * * zmax the ground maximum Z coordinate, optional, default 1
  22976. * * 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}
  22977. * * 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}
  22978. * @returns the VertexData of the TiledGround
  22979. */
  22980. static CreateTiledGround(options: {
  22981. xmin: number;
  22982. zmin: number;
  22983. xmax: number;
  22984. zmax: number;
  22985. subdivisions?: {
  22986. w: number;
  22987. h: number;
  22988. };
  22989. precision?: {
  22990. w: number;
  22991. h: number;
  22992. };
  22993. }): VertexData;
  22994. /**
  22995. * Creates the VertexData of the Ground designed from a heightmap
  22996. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22997. * * width the width (x direction) of the ground
  22998. * * height the height (z direction) of the ground
  22999. * * subdivisions the number of subdivisions per side
  23000. * * minHeight the minimum altitude on the ground, optional, default 0
  23001. * * maxHeight the maximum altitude on the ground, optional default 1
  23002. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23003. * * buffer the array holding the image color data
  23004. * * bufferWidth the width of image
  23005. * * bufferHeight the height of image
  23006. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23007. * @returns the VertexData of the Ground designed from a heightmap
  23008. */
  23009. static CreateGroundFromHeightMap(options: {
  23010. width: number;
  23011. height: number;
  23012. subdivisions: number;
  23013. minHeight: number;
  23014. maxHeight: number;
  23015. colorFilter: Color3;
  23016. buffer: Uint8Array;
  23017. bufferWidth: number;
  23018. bufferHeight: number;
  23019. alphaFilter: number;
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData for a Plane
  23023. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23024. * * size sets the width and height of the plane to the value of size, optional default 1
  23025. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23026. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23028. * * 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)
  23029. * * 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)
  23030. * @returns the VertexData of the box
  23031. */
  23032. static CreatePlane(options: {
  23033. size?: number;
  23034. width?: number;
  23035. height?: number;
  23036. sideOrientation?: number;
  23037. frontUVs?: Vector4;
  23038. backUVs?: Vector4;
  23039. }): VertexData;
  23040. /**
  23041. * Creates the VertexData of the Disc or regular Polygon
  23042. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23043. * * radius the radius of the disc, optional default 0.5
  23044. * * tessellation the number of polygon sides, optional, default 64
  23045. * * 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
  23046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23047. * * 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)
  23048. * * 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)
  23049. * @returns the VertexData of the box
  23050. */
  23051. static CreateDisc(options: {
  23052. radius?: number;
  23053. tessellation?: number;
  23054. arc?: number;
  23055. sideOrientation?: number;
  23056. frontUVs?: Vector4;
  23057. backUVs?: Vector4;
  23058. }): VertexData;
  23059. /**
  23060. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23061. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23062. * @param polygon a mesh built from polygonTriangulation.build()
  23063. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23064. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23065. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23066. * @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)
  23067. * @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)
  23068. * @returns the VertexData of the Polygon
  23069. */
  23070. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23071. /**
  23072. * Creates the VertexData of the IcoSphere
  23073. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23074. * * radius the radius of the IcoSphere, optional default 1
  23075. * * radiusX allows stretching in the x direction, optional, default radius
  23076. * * radiusY allows stretching in the y direction, optional, default radius
  23077. * * radiusZ allows stretching in the z direction, optional, default radius
  23078. * * flat when true creates a flat shaded mesh, optional, default true
  23079. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23081. * * 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)
  23082. * * 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)
  23083. * @returns the VertexData of the IcoSphere
  23084. */
  23085. static CreateIcoSphere(options: {
  23086. radius?: number;
  23087. radiusX?: number;
  23088. radiusY?: number;
  23089. radiusZ?: number;
  23090. flat?: boolean;
  23091. subdivisions?: number;
  23092. sideOrientation?: number;
  23093. frontUVs?: Vector4;
  23094. backUVs?: Vector4;
  23095. }): VertexData;
  23096. /**
  23097. * Creates the VertexData for a Polyhedron
  23098. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23099. * * type provided types are:
  23100. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23101. * * 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)
  23102. * * size the size of the IcoSphere, optional default 1
  23103. * * sizeX allows stretching in the x direction, optional, default size
  23104. * * sizeY allows stretching in the y direction, optional, default size
  23105. * * sizeZ allows stretching in the z direction, optional, default size
  23106. * * 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
  23107. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23108. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23109. * * flat when true creates a flat shaded mesh, optional, default true
  23110. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23112. * * 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)
  23113. * * 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)
  23114. * @returns the VertexData of the Polyhedron
  23115. */
  23116. static CreatePolyhedron(options: {
  23117. type?: number;
  23118. size?: number;
  23119. sizeX?: number;
  23120. sizeY?: number;
  23121. sizeZ?: number;
  23122. custom?: any;
  23123. faceUV?: Vector4[];
  23124. faceColors?: Color4[];
  23125. flat?: boolean;
  23126. sideOrientation?: number;
  23127. frontUVs?: Vector4;
  23128. backUVs?: Vector4;
  23129. }): VertexData;
  23130. /**
  23131. * Creates the VertexData for a TorusKnot
  23132. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23133. * * radius the radius of the torus knot, optional, default 2
  23134. * * tube the thickness of the tube, optional, default 0.5
  23135. * * radialSegments the number of sides on each tube segments, optional, default 32
  23136. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23137. * * p the number of windings around the z axis, optional, default 2
  23138. * * q the number of windings around the x axis, optional, default 3
  23139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23140. * * 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)
  23141. * * 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)
  23142. * @returns the VertexData of the Torus Knot
  23143. */
  23144. static CreateTorusKnot(options: {
  23145. radius?: number;
  23146. tube?: number;
  23147. radialSegments?: number;
  23148. tubularSegments?: number;
  23149. p?: number;
  23150. q?: number;
  23151. sideOrientation?: number;
  23152. frontUVs?: Vector4;
  23153. backUVs?: Vector4;
  23154. }): VertexData;
  23155. /**
  23156. * Compute normals for given positions and indices
  23157. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23158. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23159. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23160. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23161. * * facetNormals : optional array of facet normals (vector3)
  23162. * * facetPositions : optional array of facet positions (vector3)
  23163. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23164. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23165. * * bInfo : optional bounding info, required for facetPartitioning computation
  23166. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23167. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23168. * * useRightHandedSystem: optional boolean to for right handed system computation
  23169. * * depthSort : optional boolean to enable the facet depth sort computation
  23170. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23171. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23172. */
  23173. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23174. facetNormals?: any;
  23175. facetPositions?: any;
  23176. facetPartitioning?: any;
  23177. ratio?: number;
  23178. bInfo?: any;
  23179. bbSize?: Vector3;
  23180. subDiv?: any;
  23181. useRightHandedSystem?: boolean;
  23182. depthSort?: boolean;
  23183. distanceTo?: Vector3;
  23184. depthSortedFacets?: any;
  23185. }): void;
  23186. /** @hidden */
  23187. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23188. /**
  23189. * Applies VertexData created from the imported parameters to the geometry
  23190. * @param parsedVertexData the parsed data from an imported file
  23191. * @param geometry the geometry to apply the VertexData to
  23192. */
  23193. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23194. }
  23195. }
  23196. declare module "babylonjs/Morph/morphTarget" {
  23197. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23198. import { Observable } from "babylonjs/Misc/observable";
  23199. import { Nullable, FloatArray } from "babylonjs/types";
  23200. import { Scene } from "babylonjs/scene";
  23201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23202. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23203. /**
  23204. * Defines a target to use with MorphTargetManager
  23205. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23206. */
  23207. export class MorphTarget implements IAnimatable {
  23208. /** defines the name of the target */
  23209. name: string;
  23210. /**
  23211. * Gets or sets the list of animations
  23212. */
  23213. animations: import("babylonjs/Animations/animation").Animation[];
  23214. private _scene;
  23215. private _positions;
  23216. private _normals;
  23217. private _tangents;
  23218. private _uvs;
  23219. private _influence;
  23220. private _uniqueId;
  23221. /**
  23222. * Observable raised when the influence changes
  23223. */
  23224. onInfluenceChanged: Observable<boolean>;
  23225. /** @hidden */
  23226. _onDataLayoutChanged: Observable<void>;
  23227. /**
  23228. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23229. */
  23230. get influence(): number;
  23231. set influence(influence: number);
  23232. /**
  23233. * Gets or sets the id of the morph Target
  23234. */
  23235. id: string;
  23236. private _animationPropertiesOverride;
  23237. /**
  23238. * Gets or sets the animation properties override
  23239. */
  23240. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23241. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23242. /**
  23243. * Creates a new MorphTarget
  23244. * @param name defines the name of the target
  23245. * @param influence defines the influence to use
  23246. * @param scene defines the scene the morphtarget belongs to
  23247. */
  23248. constructor(
  23249. /** defines the name of the target */
  23250. name: string, influence?: number, scene?: Nullable<Scene>);
  23251. /**
  23252. * Gets the unique ID of this manager
  23253. */
  23254. get uniqueId(): number;
  23255. /**
  23256. * Gets a boolean defining if the target contains position data
  23257. */
  23258. get hasPositions(): boolean;
  23259. /**
  23260. * Gets a boolean defining if the target contains normal data
  23261. */
  23262. get hasNormals(): boolean;
  23263. /**
  23264. * Gets a boolean defining if the target contains tangent data
  23265. */
  23266. get hasTangents(): boolean;
  23267. /**
  23268. * Gets a boolean defining if the target contains texture coordinates data
  23269. */
  23270. get hasUVs(): boolean;
  23271. /**
  23272. * Affects position data to this target
  23273. * @param data defines the position data to use
  23274. */
  23275. setPositions(data: Nullable<FloatArray>): void;
  23276. /**
  23277. * Gets the position data stored in this target
  23278. * @returns a FloatArray containing the position data (or null if not present)
  23279. */
  23280. getPositions(): Nullable<FloatArray>;
  23281. /**
  23282. * Affects normal data to this target
  23283. * @param data defines the normal data to use
  23284. */
  23285. setNormals(data: Nullable<FloatArray>): void;
  23286. /**
  23287. * Gets the normal data stored in this target
  23288. * @returns a FloatArray containing the normal data (or null if not present)
  23289. */
  23290. getNormals(): Nullable<FloatArray>;
  23291. /**
  23292. * Affects tangent data to this target
  23293. * @param data defines the tangent data to use
  23294. */
  23295. setTangents(data: Nullable<FloatArray>): void;
  23296. /**
  23297. * Gets the tangent data stored in this target
  23298. * @returns a FloatArray containing the tangent data (or null if not present)
  23299. */
  23300. getTangents(): Nullable<FloatArray>;
  23301. /**
  23302. * Affects texture coordinates data to this target
  23303. * @param data defines the texture coordinates data to use
  23304. */
  23305. setUVs(data: Nullable<FloatArray>): void;
  23306. /**
  23307. * Gets the texture coordinates data stored in this target
  23308. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23309. */
  23310. getUVs(): Nullable<FloatArray>;
  23311. /**
  23312. * Clone the current target
  23313. * @returns a new MorphTarget
  23314. */
  23315. clone(): MorphTarget;
  23316. /**
  23317. * Serializes the current target into a Serialization object
  23318. * @returns the serialized object
  23319. */
  23320. serialize(): any;
  23321. /**
  23322. * Returns the string "MorphTarget"
  23323. * @returns "MorphTarget"
  23324. */
  23325. getClassName(): string;
  23326. /**
  23327. * Creates a new target from serialized data
  23328. * @param serializationObject defines the serialized data to use
  23329. * @returns a new MorphTarget
  23330. */
  23331. static Parse(serializationObject: any): MorphTarget;
  23332. /**
  23333. * Creates a MorphTarget from mesh data
  23334. * @param mesh defines the source mesh
  23335. * @param name defines the name to use for the new target
  23336. * @param influence defines the influence to attach to the target
  23337. * @returns a new MorphTarget
  23338. */
  23339. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23340. }
  23341. }
  23342. declare module "babylonjs/Morph/morphTargetManager" {
  23343. import { Nullable } from "babylonjs/types";
  23344. import { Scene } from "babylonjs/scene";
  23345. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23346. /**
  23347. * This class is used to deform meshes using morphing between different targets
  23348. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23349. */
  23350. export class MorphTargetManager {
  23351. private _targets;
  23352. private _targetInfluenceChangedObservers;
  23353. private _targetDataLayoutChangedObservers;
  23354. private _activeTargets;
  23355. private _scene;
  23356. private _influences;
  23357. private _supportsNormals;
  23358. private _supportsTangents;
  23359. private _supportsUVs;
  23360. private _vertexCount;
  23361. private _uniqueId;
  23362. private _tempInfluences;
  23363. /**
  23364. * Gets or sets a boolean indicating if normals must be morphed
  23365. */
  23366. enableNormalMorphing: boolean;
  23367. /**
  23368. * Gets or sets a boolean indicating if tangents must be morphed
  23369. */
  23370. enableTangentMorphing: boolean;
  23371. /**
  23372. * Gets or sets a boolean indicating if UV must be morphed
  23373. */
  23374. enableUVMorphing: boolean;
  23375. /**
  23376. * Creates a new MorphTargetManager
  23377. * @param scene defines the current scene
  23378. */
  23379. constructor(scene?: Nullable<Scene>);
  23380. /**
  23381. * Gets the unique ID of this manager
  23382. */
  23383. get uniqueId(): number;
  23384. /**
  23385. * Gets the number of vertices handled by this manager
  23386. */
  23387. get vertexCount(): number;
  23388. /**
  23389. * Gets a boolean indicating if this manager supports morphing of normals
  23390. */
  23391. get supportsNormals(): boolean;
  23392. /**
  23393. * Gets a boolean indicating if this manager supports morphing of tangents
  23394. */
  23395. get supportsTangents(): boolean;
  23396. /**
  23397. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23398. */
  23399. get supportsUVs(): boolean;
  23400. /**
  23401. * Gets the number of targets stored in this manager
  23402. */
  23403. get numTargets(): number;
  23404. /**
  23405. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23406. */
  23407. get numInfluencers(): number;
  23408. /**
  23409. * Gets the list of influences (one per target)
  23410. */
  23411. get influences(): Float32Array;
  23412. /**
  23413. * Gets the active target at specified index. An active target is a target with an influence > 0
  23414. * @param index defines the index to check
  23415. * @returns the requested target
  23416. */
  23417. getActiveTarget(index: number): MorphTarget;
  23418. /**
  23419. * Gets the target at specified index
  23420. * @param index defines the index to check
  23421. * @returns the requested target
  23422. */
  23423. getTarget(index: number): MorphTarget;
  23424. /**
  23425. * Add a new target to this manager
  23426. * @param target defines the target to add
  23427. */
  23428. addTarget(target: MorphTarget): void;
  23429. /**
  23430. * Removes a target from the manager
  23431. * @param target defines the target to remove
  23432. */
  23433. removeTarget(target: MorphTarget): void;
  23434. /**
  23435. * Clone the current manager
  23436. * @returns a new MorphTargetManager
  23437. */
  23438. clone(): MorphTargetManager;
  23439. /**
  23440. * Serializes the current manager into a Serialization object
  23441. * @returns the serialized object
  23442. */
  23443. serialize(): any;
  23444. private _syncActiveTargets;
  23445. /**
  23446. * Syncrhonize the targets with all the meshes using this morph target manager
  23447. */
  23448. synchronize(): void;
  23449. /**
  23450. * Creates a new MorphTargetManager from serialized data
  23451. * @param serializationObject defines the serialized data
  23452. * @param scene defines the hosting scene
  23453. * @returns the new MorphTargetManager
  23454. */
  23455. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23456. }
  23457. }
  23458. declare module "babylonjs/Meshes/meshLODLevel" {
  23459. import { Mesh } from "babylonjs/Meshes/mesh";
  23460. import { Nullable } from "babylonjs/types";
  23461. /**
  23462. * Class used to represent a specific level of detail of a mesh
  23463. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23464. */
  23465. export class MeshLODLevel {
  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. * Creates a new LOD level
  23472. * @param distance defines the distance where this level should star being displayed
  23473. * @param mesh defines the mesh to use to render this level
  23474. */
  23475. constructor(
  23476. /** Defines the distance where this level should start being displayed */
  23477. distance: number,
  23478. /** Defines the mesh to use to render this level */
  23479. mesh: Nullable<Mesh>);
  23480. }
  23481. }
  23482. declare module "babylonjs/Meshes/groundMesh" {
  23483. import { Scene } from "babylonjs/scene";
  23484. import { Vector3 } from "babylonjs/Maths/math.vector";
  23485. import { Mesh } from "babylonjs/Meshes/mesh";
  23486. /**
  23487. * Mesh representing the gorund
  23488. */
  23489. export class GroundMesh extends Mesh {
  23490. /** If octree should be generated */
  23491. generateOctree: boolean;
  23492. private _heightQuads;
  23493. /** @hidden */
  23494. _subdivisionsX: number;
  23495. /** @hidden */
  23496. _subdivisionsY: number;
  23497. /** @hidden */
  23498. _width: number;
  23499. /** @hidden */
  23500. _height: number;
  23501. /** @hidden */
  23502. _minX: number;
  23503. /** @hidden */
  23504. _maxX: number;
  23505. /** @hidden */
  23506. _minZ: number;
  23507. /** @hidden */
  23508. _maxZ: number;
  23509. constructor(name: string, scene: Scene);
  23510. /**
  23511. * "GroundMesh"
  23512. * @returns "GroundMesh"
  23513. */
  23514. getClassName(): string;
  23515. /**
  23516. * The minimum of x and y subdivisions
  23517. */
  23518. get subdivisions(): number;
  23519. /**
  23520. * X subdivisions
  23521. */
  23522. get subdivisionsX(): number;
  23523. /**
  23524. * Y subdivisions
  23525. */
  23526. get subdivisionsY(): number;
  23527. /**
  23528. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23529. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23530. * @param chunksCount the number of subdivisions for x and y
  23531. * @param octreeBlocksSize (Default: 32)
  23532. */
  23533. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23534. /**
  23535. * Returns a height (y) value in the Worl system :
  23536. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23537. * @param x x coordinate
  23538. * @param z z coordinate
  23539. * @returns the ground y position if (x, z) are outside the ground surface.
  23540. */
  23541. getHeightAtCoordinates(x: number, z: number): number;
  23542. /**
  23543. * Returns a normalized vector (Vector3) orthogonal to the ground
  23544. * at the ground coordinates (x, z) expressed in the World system.
  23545. * @param x x coordinate
  23546. * @param z z coordinate
  23547. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23548. */
  23549. getNormalAtCoordinates(x: number, z: number): Vector3;
  23550. /**
  23551. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23552. * at the ground coordinates (x, z) expressed in the World system.
  23553. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23554. * @param x x coordinate
  23555. * @param z z coordinate
  23556. * @param ref vector to store the result
  23557. * @returns the GroundMesh.
  23558. */
  23559. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23560. /**
  23561. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23562. * if the ground has been updated.
  23563. * This can be used in the render loop.
  23564. * @returns the GroundMesh.
  23565. */
  23566. updateCoordinateHeights(): GroundMesh;
  23567. private _getFacetAt;
  23568. private _initHeightQuads;
  23569. private _computeHeightQuads;
  23570. /**
  23571. * Serializes this ground mesh
  23572. * @param serializationObject object to write serialization to
  23573. */
  23574. serialize(serializationObject: any): void;
  23575. /**
  23576. * Parses a serialized ground mesh
  23577. * @param parsedMesh the serialized mesh
  23578. * @param scene the scene to create the ground mesh in
  23579. * @returns the created ground mesh
  23580. */
  23581. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23582. }
  23583. }
  23584. declare module "babylonjs/Physics/physicsJoint" {
  23585. import { Vector3 } from "babylonjs/Maths/math.vector";
  23586. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23587. /**
  23588. * Interface for Physics-Joint data
  23589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23590. */
  23591. export interface PhysicsJointData {
  23592. /**
  23593. * The main pivot of the joint
  23594. */
  23595. mainPivot?: Vector3;
  23596. /**
  23597. * The connected pivot of the joint
  23598. */
  23599. connectedPivot?: Vector3;
  23600. /**
  23601. * The main axis of the joint
  23602. */
  23603. mainAxis?: Vector3;
  23604. /**
  23605. * The connected axis of the joint
  23606. */
  23607. connectedAxis?: Vector3;
  23608. /**
  23609. * The collision of the joint
  23610. */
  23611. collision?: boolean;
  23612. /**
  23613. * Native Oimo/Cannon/Energy data
  23614. */
  23615. nativeParams?: any;
  23616. }
  23617. /**
  23618. * This is a holder class for the physics joint created by the physics plugin
  23619. * It holds a set of functions to control the underlying joint
  23620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23621. */
  23622. export class PhysicsJoint {
  23623. /**
  23624. * The type of the physics joint
  23625. */
  23626. type: number;
  23627. /**
  23628. * The data for the physics joint
  23629. */
  23630. jointData: PhysicsJointData;
  23631. private _physicsJoint;
  23632. protected _physicsPlugin: IPhysicsEnginePlugin;
  23633. /**
  23634. * Initializes the physics joint
  23635. * @param type The type of the physics joint
  23636. * @param jointData The data for the physics joint
  23637. */
  23638. constructor(
  23639. /**
  23640. * The type of the physics joint
  23641. */
  23642. type: number,
  23643. /**
  23644. * The data for the physics joint
  23645. */
  23646. jointData: PhysicsJointData);
  23647. /**
  23648. * Gets the physics joint
  23649. */
  23650. get physicsJoint(): any;
  23651. /**
  23652. * Sets the physics joint
  23653. */
  23654. set physicsJoint(newJoint: any);
  23655. /**
  23656. * Sets the physics plugin
  23657. */
  23658. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23659. /**
  23660. * Execute a function that is physics-plugin specific.
  23661. * @param {Function} func the function that will be executed.
  23662. * It accepts two parameters: the physics world and the physics joint
  23663. */
  23664. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23665. /**
  23666. * Distance-Joint type
  23667. */
  23668. static DistanceJoint: number;
  23669. /**
  23670. * Hinge-Joint type
  23671. */
  23672. static HingeJoint: number;
  23673. /**
  23674. * Ball-and-Socket joint type
  23675. */
  23676. static BallAndSocketJoint: number;
  23677. /**
  23678. * Wheel-Joint type
  23679. */
  23680. static WheelJoint: number;
  23681. /**
  23682. * Slider-Joint type
  23683. */
  23684. static SliderJoint: number;
  23685. /**
  23686. * Prismatic-Joint type
  23687. */
  23688. static PrismaticJoint: number;
  23689. /**
  23690. * Universal-Joint type
  23691. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23692. */
  23693. static UniversalJoint: number;
  23694. /**
  23695. * Hinge-Joint 2 type
  23696. */
  23697. static Hinge2Joint: number;
  23698. /**
  23699. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23700. */
  23701. static PointToPointJoint: number;
  23702. /**
  23703. * Spring-Joint type
  23704. */
  23705. static SpringJoint: number;
  23706. /**
  23707. * Lock-Joint type
  23708. */
  23709. static LockJoint: number;
  23710. }
  23711. /**
  23712. * A class representing a physics distance joint
  23713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23714. */
  23715. export class DistanceJoint extends PhysicsJoint {
  23716. /**
  23717. *
  23718. * @param jointData The data for the Distance-Joint
  23719. */
  23720. constructor(jointData: DistanceJointData);
  23721. /**
  23722. * Update the predefined distance.
  23723. * @param maxDistance The maximum preferred distance
  23724. * @param minDistance The minimum preferred distance
  23725. */
  23726. updateDistance(maxDistance: number, minDistance?: number): void;
  23727. }
  23728. /**
  23729. * Represents a Motor-Enabled Joint
  23730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23731. */
  23732. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23733. /**
  23734. * Initializes the Motor-Enabled Joint
  23735. * @param type The type of the joint
  23736. * @param jointData The physica joint data for the joint
  23737. */
  23738. constructor(type: number, jointData: PhysicsJointData);
  23739. /**
  23740. * Set the motor values.
  23741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23742. * @param force the force to apply
  23743. * @param maxForce max force for this motor.
  23744. */
  23745. setMotor(force?: number, maxForce?: number): void;
  23746. /**
  23747. * Set the motor's limits.
  23748. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23749. * @param upperLimit The upper limit of the motor
  23750. * @param lowerLimit The lower limit of the motor
  23751. */
  23752. setLimit(upperLimit: number, lowerLimit?: number): void;
  23753. }
  23754. /**
  23755. * This class represents a single physics Hinge-Joint
  23756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23757. */
  23758. export class HingeJoint extends MotorEnabledJoint {
  23759. /**
  23760. * Initializes the Hinge-Joint
  23761. * @param jointData The joint data for the Hinge-Joint
  23762. */
  23763. constructor(jointData: PhysicsJointData);
  23764. /**
  23765. * Set the motor values.
  23766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23767. * @param {number} force the force to apply
  23768. * @param {number} maxForce max force for this motor.
  23769. */
  23770. setMotor(force?: number, maxForce?: number): void;
  23771. /**
  23772. * Set the motor's limits.
  23773. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23774. * @param upperLimit The upper limit of the motor
  23775. * @param lowerLimit The lower limit of the motor
  23776. */
  23777. setLimit(upperLimit: number, lowerLimit?: number): void;
  23778. }
  23779. /**
  23780. * This class represents a dual hinge physics joint (same as wheel joint)
  23781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23782. */
  23783. export class Hinge2Joint extends MotorEnabledJoint {
  23784. /**
  23785. * Initializes the Hinge2-Joint
  23786. * @param jointData The joint data for the Hinge2-Joint
  23787. */
  23788. constructor(jointData: PhysicsJointData);
  23789. /**
  23790. * Set the motor values.
  23791. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23792. * @param {number} targetSpeed the speed the motor is to reach
  23793. * @param {number} maxForce max force for this motor.
  23794. * @param {motorIndex} the motor's index, 0 or 1.
  23795. */
  23796. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23797. /**
  23798. * Set the motor limits.
  23799. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23800. * @param {number} upperLimit the upper limit
  23801. * @param {number} lowerLimit lower limit
  23802. * @param {motorIndex} the motor's index, 0 or 1.
  23803. */
  23804. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23805. }
  23806. /**
  23807. * Interface for a motor enabled joint
  23808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23809. */
  23810. export interface IMotorEnabledJoint {
  23811. /**
  23812. * Physics joint
  23813. */
  23814. physicsJoint: any;
  23815. /**
  23816. * Sets the motor of the motor-enabled joint
  23817. * @param force The force of the motor
  23818. * @param maxForce The maximum force of the motor
  23819. * @param motorIndex The index of the motor
  23820. */
  23821. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23822. /**
  23823. * Sets the limit of the motor
  23824. * @param upperLimit The upper limit of the motor
  23825. * @param lowerLimit The lower limit of the motor
  23826. * @param motorIndex The index of the motor
  23827. */
  23828. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23829. }
  23830. /**
  23831. * Joint data for a Distance-Joint
  23832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23833. */
  23834. export interface DistanceJointData extends PhysicsJointData {
  23835. /**
  23836. * Max distance the 2 joint objects can be apart
  23837. */
  23838. maxDistance: number;
  23839. }
  23840. /**
  23841. * Joint data from a spring joint
  23842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23843. */
  23844. export interface SpringJointData extends PhysicsJointData {
  23845. /**
  23846. * Length of the spring
  23847. */
  23848. length: number;
  23849. /**
  23850. * Stiffness of the spring
  23851. */
  23852. stiffness: number;
  23853. /**
  23854. * Damping of the spring
  23855. */
  23856. damping: number;
  23857. /** this callback will be called when applying the force to the impostors. */
  23858. forceApplicationCallback: () => void;
  23859. }
  23860. }
  23861. declare module "babylonjs/Physics/physicsRaycastResult" {
  23862. import { Vector3 } from "babylonjs/Maths/math.vector";
  23863. /**
  23864. * Holds the data for the raycast result
  23865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23866. */
  23867. export class PhysicsRaycastResult {
  23868. private _hasHit;
  23869. private _hitDistance;
  23870. private _hitNormalWorld;
  23871. private _hitPointWorld;
  23872. private _rayFromWorld;
  23873. private _rayToWorld;
  23874. /**
  23875. * Gets if there was a hit
  23876. */
  23877. get hasHit(): boolean;
  23878. /**
  23879. * Gets the distance from the hit
  23880. */
  23881. get hitDistance(): number;
  23882. /**
  23883. * Gets the hit normal/direction in the world
  23884. */
  23885. get hitNormalWorld(): Vector3;
  23886. /**
  23887. * Gets the hit point in the world
  23888. */
  23889. get hitPointWorld(): Vector3;
  23890. /**
  23891. * Gets the ray "start point" of the ray in the world
  23892. */
  23893. get rayFromWorld(): Vector3;
  23894. /**
  23895. * Gets the ray "end point" of the ray in the world
  23896. */
  23897. get rayToWorld(): Vector3;
  23898. /**
  23899. * Sets the hit data (normal & point in world space)
  23900. * @param hitNormalWorld defines the normal in world space
  23901. * @param hitPointWorld defines the point in world space
  23902. */
  23903. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23904. /**
  23905. * Sets the distance from the start point to the hit point
  23906. * @param distance
  23907. */
  23908. setHitDistance(distance: number): void;
  23909. /**
  23910. * Calculates the distance manually
  23911. */
  23912. calculateHitDistance(): void;
  23913. /**
  23914. * Resets all the values to default
  23915. * @param from The from point on world space
  23916. * @param to The to point on world space
  23917. */
  23918. reset(from?: Vector3, to?: Vector3): void;
  23919. }
  23920. /**
  23921. * Interface for the size containing width and height
  23922. */
  23923. interface IXYZ {
  23924. /**
  23925. * X
  23926. */
  23927. x: number;
  23928. /**
  23929. * Y
  23930. */
  23931. y: number;
  23932. /**
  23933. * Z
  23934. */
  23935. z: number;
  23936. }
  23937. }
  23938. declare module "babylonjs/Physics/IPhysicsEngine" {
  23939. import { Nullable } from "babylonjs/types";
  23940. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23942. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23943. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23944. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23945. /**
  23946. * Interface used to describe a physics joint
  23947. */
  23948. export interface PhysicsImpostorJoint {
  23949. /** Defines the main impostor to which the joint is linked */
  23950. mainImpostor: PhysicsImpostor;
  23951. /** Defines the impostor that is connected to the main impostor using this joint */
  23952. connectedImpostor: PhysicsImpostor;
  23953. /** Defines the joint itself */
  23954. joint: PhysicsJoint;
  23955. }
  23956. /** @hidden */
  23957. export interface IPhysicsEnginePlugin {
  23958. world: any;
  23959. name: string;
  23960. setGravity(gravity: Vector3): void;
  23961. setTimeStep(timeStep: number): void;
  23962. getTimeStep(): number;
  23963. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23964. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23965. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23966. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23967. removePhysicsBody(impostor: PhysicsImpostor): void;
  23968. generateJoint(joint: PhysicsImpostorJoint): void;
  23969. removeJoint(joint: PhysicsImpostorJoint): void;
  23970. isSupported(): boolean;
  23971. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23972. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23973. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23974. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23975. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23976. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23977. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23978. getBodyMass(impostor: PhysicsImpostor): number;
  23979. getBodyFriction(impostor: PhysicsImpostor): number;
  23980. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23981. getBodyRestitution(impostor: PhysicsImpostor): number;
  23982. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23983. getBodyPressure?(impostor: PhysicsImpostor): number;
  23984. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23985. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23986. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23987. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23988. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23989. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23990. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23991. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23992. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23993. sleepBody(impostor: PhysicsImpostor): void;
  23994. wakeUpBody(impostor: PhysicsImpostor): void;
  23995. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23996. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23997. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23998. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23999. getRadius(impostor: PhysicsImpostor): number;
  24000. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24001. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24002. dispose(): void;
  24003. }
  24004. /**
  24005. * Interface used to define a physics engine
  24006. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24007. */
  24008. export interface IPhysicsEngine {
  24009. /**
  24010. * Gets the gravity vector used by the simulation
  24011. */
  24012. gravity: Vector3;
  24013. /**
  24014. * Sets the gravity vector used by the simulation
  24015. * @param gravity defines the gravity vector to use
  24016. */
  24017. setGravity(gravity: Vector3): void;
  24018. /**
  24019. * Set the time step of the physics engine.
  24020. * Default is 1/60.
  24021. * To slow it down, enter 1/600 for example.
  24022. * To speed it up, 1/30
  24023. * @param newTimeStep the new timestep to apply to this world.
  24024. */
  24025. setTimeStep(newTimeStep: number): void;
  24026. /**
  24027. * Get the time step of the physics engine.
  24028. * @returns the current time step
  24029. */
  24030. getTimeStep(): number;
  24031. /**
  24032. * Set the sub time step of the physics engine.
  24033. * Default is 0 meaning there is no sub steps
  24034. * To increase physics resolution precision, set a small value (like 1 ms)
  24035. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24036. */
  24037. setSubTimeStep(subTimeStep: number): void;
  24038. /**
  24039. * Get the sub time step of the physics engine.
  24040. * @returns the current sub time step
  24041. */
  24042. getSubTimeStep(): number;
  24043. /**
  24044. * Release all resources
  24045. */
  24046. dispose(): void;
  24047. /**
  24048. * Gets the name of the current physics plugin
  24049. * @returns the name of the plugin
  24050. */
  24051. getPhysicsPluginName(): string;
  24052. /**
  24053. * Adding a new impostor for the impostor tracking.
  24054. * This will be done by the impostor itself.
  24055. * @param impostor the impostor to add
  24056. */
  24057. addImpostor(impostor: PhysicsImpostor): void;
  24058. /**
  24059. * Remove an impostor from the engine.
  24060. * This impostor and its mesh will not longer be updated by the physics engine.
  24061. * @param impostor the impostor to remove
  24062. */
  24063. removeImpostor(impostor: PhysicsImpostor): void;
  24064. /**
  24065. * Add a joint to the physics engine
  24066. * @param mainImpostor defines the main impostor to which the joint is added.
  24067. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24068. * @param joint defines the joint that will connect both impostors.
  24069. */
  24070. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24071. /**
  24072. * Removes a joint from the simulation
  24073. * @param mainImpostor defines the impostor used with the joint
  24074. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24075. * @param joint defines the joint to remove
  24076. */
  24077. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24078. /**
  24079. * Gets the current plugin used to run the simulation
  24080. * @returns current plugin
  24081. */
  24082. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24083. /**
  24084. * Gets the list of physic impostors
  24085. * @returns an array of PhysicsImpostor
  24086. */
  24087. getImpostors(): Array<PhysicsImpostor>;
  24088. /**
  24089. * Gets the impostor for a physics enabled object
  24090. * @param object defines the object impersonated by the impostor
  24091. * @returns the PhysicsImpostor or null if not found
  24092. */
  24093. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24094. /**
  24095. * Gets the impostor for a physics body object
  24096. * @param body defines physics body used by the impostor
  24097. * @returns the PhysicsImpostor or null if not found
  24098. */
  24099. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24100. /**
  24101. * Does a raycast in the physics world
  24102. * @param from when should the ray start?
  24103. * @param to when should the ray end?
  24104. * @returns PhysicsRaycastResult
  24105. */
  24106. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24107. /**
  24108. * Called by the scene. No need to call it.
  24109. * @param delta defines the timespam between frames
  24110. */
  24111. _step(delta: number): void;
  24112. }
  24113. }
  24114. declare module "babylonjs/Physics/physicsImpostor" {
  24115. import { Nullable, IndicesArray } from "babylonjs/types";
  24116. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24117. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24119. import { Scene } from "babylonjs/scene";
  24120. import { Bone } from "babylonjs/Bones/bone";
  24121. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24122. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24123. import { Space } from "babylonjs/Maths/math.axis";
  24124. /**
  24125. * The interface for the physics imposter parameters
  24126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24127. */
  24128. export interface PhysicsImpostorParameters {
  24129. /**
  24130. * The mass of the physics imposter
  24131. */
  24132. mass: number;
  24133. /**
  24134. * The friction of the physics imposter
  24135. */
  24136. friction?: number;
  24137. /**
  24138. * The coefficient of restitution of the physics imposter
  24139. */
  24140. restitution?: number;
  24141. /**
  24142. * The native options of the physics imposter
  24143. */
  24144. nativeOptions?: any;
  24145. /**
  24146. * Specifies if the parent should be ignored
  24147. */
  24148. ignoreParent?: boolean;
  24149. /**
  24150. * Specifies if bi-directional transformations should be disabled
  24151. */
  24152. disableBidirectionalTransformation?: boolean;
  24153. /**
  24154. * The pressure inside the physics imposter, soft object only
  24155. */
  24156. pressure?: number;
  24157. /**
  24158. * The stiffness the physics imposter, soft object only
  24159. */
  24160. stiffness?: number;
  24161. /**
  24162. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24163. */
  24164. velocityIterations?: number;
  24165. /**
  24166. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24167. */
  24168. positionIterations?: number;
  24169. /**
  24170. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24171. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24172. * Add to fix multiple points
  24173. */
  24174. fixedPoints?: number;
  24175. /**
  24176. * The collision margin around a soft object
  24177. */
  24178. margin?: number;
  24179. /**
  24180. * The collision margin around a soft object
  24181. */
  24182. damping?: number;
  24183. /**
  24184. * The path for a rope based on an extrusion
  24185. */
  24186. path?: any;
  24187. /**
  24188. * The shape of an extrusion used for a rope based on an extrusion
  24189. */
  24190. shape?: any;
  24191. }
  24192. /**
  24193. * Interface for a physics-enabled object
  24194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24195. */
  24196. export interface IPhysicsEnabledObject {
  24197. /**
  24198. * The position of the physics-enabled object
  24199. */
  24200. position: Vector3;
  24201. /**
  24202. * The rotation of the physics-enabled object
  24203. */
  24204. rotationQuaternion: Nullable<Quaternion>;
  24205. /**
  24206. * The scale of the physics-enabled object
  24207. */
  24208. scaling: Vector3;
  24209. /**
  24210. * The rotation of the physics-enabled object
  24211. */
  24212. rotation?: Vector3;
  24213. /**
  24214. * The parent of the physics-enabled object
  24215. */
  24216. parent?: any;
  24217. /**
  24218. * The bounding info of the physics-enabled object
  24219. * @returns The bounding info of the physics-enabled object
  24220. */
  24221. getBoundingInfo(): BoundingInfo;
  24222. /**
  24223. * Computes the world matrix
  24224. * @param force Specifies if the world matrix should be computed by force
  24225. * @returns A world matrix
  24226. */
  24227. computeWorldMatrix(force: boolean): Matrix;
  24228. /**
  24229. * Gets the world matrix
  24230. * @returns A world matrix
  24231. */
  24232. getWorldMatrix?(): Matrix;
  24233. /**
  24234. * Gets the child meshes
  24235. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24236. * @returns An array of abstract meshes
  24237. */
  24238. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24239. /**
  24240. * Gets the vertex data
  24241. * @param kind The type of vertex data
  24242. * @returns A nullable array of numbers, or a float32 array
  24243. */
  24244. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24245. /**
  24246. * Gets the indices from the mesh
  24247. * @returns A nullable array of index arrays
  24248. */
  24249. getIndices?(): Nullable<IndicesArray>;
  24250. /**
  24251. * Gets the scene from the mesh
  24252. * @returns the indices array or null
  24253. */
  24254. getScene?(): Scene;
  24255. /**
  24256. * Gets the absolute position from the mesh
  24257. * @returns the absolute position
  24258. */
  24259. getAbsolutePosition(): Vector3;
  24260. /**
  24261. * Gets the absolute pivot point from the mesh
  24262. * @returns the absolute pivot point
  24263. */
  24264. getAbsolutePivotPoint(): Vector3;
  24265. /**
  24266. * Rotates the mesh
  24267. * @param axis The axis of rotation
  24268. * @param amount The amount of rotation
  24269. * @param space The space of the rotation
  24270. * @returns The rotation transform node
  24271. */
  24272. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24273. /**
  24274. * Translates the mesh
  24275. * @param axis The axis of translation
  24276. * @param distance The distance of translation
  24277. * @param space The space of the translation
  24278. * @returns The transform node
  24279. */
  24280. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24281. /**
  24282. * Sets the absolute position of the mesh
  24283. * @param absolutePosition The absolute position of the mesh
  24284. * @returns The transform node
  24285. */
  24286. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24287. /**
  24288. * Gets the class name of the mesh
  24289. * @returns The class name
  24290. */
  24291. getClassName(): string;
  24292. }
  24293. /**
  24294. * Represents a physics imposter
  24295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24296. */
  24297. export class PhysicsImpostor {
  24298. /**
  24299. * The physics-enabled object used as the physics imposter
  24300. */
  24301. object: IPhysicsEnabledObject;
  24302. /**
  24303. * The type of the physics imposter
  24304. */
  24305. type: number;
  24306. private _options;
  24307. private _scene?;
  24308. /**
  24309. * The default object size of the imposter
  24310. */
  24311. static DEFAULT_OBJECT_SIZE: Vector3;
  24312. /**
  24313. * The identity quaternion of the imposter
  24314. */
  24315. static IDENTITY_QUATERNION: Quaternion;
  24316. /** @hidden */
  24317. _pluginData: any;
  24318. private _physicsEngine;
  24319. private _physicsBody;
  24320. private _bodyUpdateRequired;
  24321. private _onBeforePhysicsStepCallbacks;
  24322. private _onAfterPhysicsStepCallbacks;
  24323. /** @hidden */
  24324. _onPhysicsCollideCallbacks: Array<{
  24325. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24326. otherImpostors: Array<PhysicsImpostor>;
  24327. }>;
  24328. private _deltaPosition;
  24329. private _deltaRotation;
  24330. private _deltaRotationConjugated;
  24331. /** @hidden */
  24332. _isFromLine: boolean;
  24333. private _parent;
  24334. private _isDisposed;
  24335. private static _tmpVecs;
  24336. private static _tmpQuat;
  24337. /**
  24338. * Specifies if the physics imposter is disposed
  24339. */
  24340. get isDisposed(): boolean;
  24341. /**
  24342. * Gets the mass of the physics imposter
  24343. */
  24344. get mass(): number;
  24345. set mass(value: number);
  24346. /**
  24347. * Gets the coefficient of friction
  24348. */
  24349. get friction(): number;
  24350. /**
  24351. * Sets the coefficient of friction
  24352. */
  24353. set friction(value: number);
  24354. /**
  24355. * Gets the coefficient of restitution
  24356. */
  24357. get restitution(): number;
  24358. /**
  24359. * Sets the coefficient of restitution
  24360. */
  24361. set restitution(value: number);
  24362. /**
  24363. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24364. */
  24365. get pressure(): number;
  24366. /**
  24367. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24368. */
  24369. set pressure(value: number);
  24370. /**
  24371. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24372. */
  24373. get stiffness(): number;
  24374. /**
  24375. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24376. */
  24377. set stiffness(value: number);
  24378. /**
  24379. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24380. */
  24381. get velocityIterations(): number;
  24382. /**
  24383. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24384. */
  24385. set velocityIterations(value: number);
  24386. /**
  24387. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24388. */
  24389. get positionIterations(): number;
  24390. /**
  24391. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24392. */
  24393. set positionIterations(value: number);
  24394. /**
  24395. * The unique id of the physics imposter
  24396. * set by the physics engine when adding this impostor to the array
  24397. */
  24398. uniqueId: number;
  24399. /**
  24400. * @hidden
  24401. */
  24402. soft: boolean;
  24403. /**
  24404. * @hidden
  24405. */
  24406. segments: number;
  24407. private _joints;
  24408. /**
  24409. * Initializes the physics imposter
  24410. * @param object The physics-enabled object used as the physics imposter
  24411. * @param type The type of the physics imposter
  24412. * @param _options The options for the physics imposter
  24413. * @param _scene The Babylon scene
  24414. */
  24415. constructor(
  24416. /**
  24417. * The physics-enabled object used as the physics imposter
  24418. */
  24419. object: IPhysicsEnabledObject,
  24420. /**
  24421. * The type of the physics imposter
  24422. */
  24423. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24424. /**
  24425. * This function will completly initialize this impostor.
  24426. * It will create a new body - but only if this mesh has no parent.
  24427. * If it has, this impostor will not be used other than to define the impostor
  24428. * of the child mesh.
  24429. * @hidden
  24430. */
  24431. _init(): void;
  24432. private _getPhysicsParent;
  24433. /**
  24434. * Should a new body be generated.
  24435. * @returns boolean specifying if body initialization is required
  24436. */
  24437. isBodyInitRequired(): boolean;
  24438. /**
  24439. * Sets the updated scaling
  24440. * @param updated Specifies if the scaling is updated
  24441. */
  24442. setScalingUpdated(): void;
  24443. /**
  24444. * Force a regeneration of this or the parent's impostor's body.
  24445. * Use under cautious - This will remove all joints already implemented.
  24446. */
  24447. forceUpdate(): void;
  24448. /**
  24449. * Gets the body that holds this impostor. Either its own, or its parent.
  24450. */
  24451. get physicsBody(): any;
  24452. /**
  24453. * Get the parent of the physics imposter
  24454. * @returns Physics imposter or null
  24455. */
  24456. get parent(): Nullable<PhysicsImpostor>;
  24457. /**
  24458. * Sets the parent of the physics imposter
  24459. */
  24460. set parent(value: Nullable<PhysicsImpostor>);
  24461. /**
  24462. * Set the physics body. Used mainly by the physics engine/plugin
  24463. */
  24464. set physicsBody(physicsBody: any);
  24465. /**
  24466. * Resets the update flags
  24467. */
  24468. resetUpdateFlags(): void;
  24469. /**
  24470. * Gets the object extend size
  24471. * @returns the object extend size
  24472. */
  24473. getObjectExtendSize(): Vector3;
  24474. /**
  24475. * Gets the object center
  24476. * @returns The object center
  24477. */
  24478. getObjectCenter(): Vector3;
  24479. /**
  24480. * Get a specific parameter from the options parameters
  24481. * @param paramName The object parameter name
  24482. * @returns The object parameter
  24483. */
  24484. getParam(paramName: string): any;
  24485. /**
  24486. * Sets a specific parameter in the options given to the physics plugin
  24487. * @param paramName The parameter name
  24488. * @param value The value of the parameter
  24489. */
  24490. setParam(paramName: string, value: number): void;
  24491. /**
  24492. * Specifically change the body's mass option. Won't recreate the physics body object
  24493. * @param mass The mass of the physics imposter
  24494. */
  24495. setMass(mass: number): void;
  24496. /**
  24497. * Gets the linear velocity
  24498. * @returns linear velocity or null
  24499. */
  24500. getLinearVelocity(): Nullable<Vector3>;
  24501. /**
  24502. * Sets the linear velocity
  24503. * @param velocity linear velocity or null
  24504. */
  24505. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24506. /**
  24507. * Gets the angular velocity
  24508. * @returns angular velocity or null
  24509. */
  24510. getAngularVelocity(): Nullable<Vector3>;
  24511. /**
  24512. * Sets the angular velocity
  24513. * @param velocity The velocity or null
  24514. */
  24515. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24516. /**
  24517. * Execute a function with the physics plugin native code
  24518. * Provide a function the will have two variables - the world object and the physics body object
  24519. * @param func The function to execute with the physics plugin native code
  24520. */
  24521. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24522. /**
  24523. * Register a function that will be executed before the physics world is stepping forward
  24524. * @param func The function to execute before the physics world is stepped forward
  24525. */
  24526. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24527. /**
  24528. * Unregister a function that will be executed before the physics world is stepping forward
  24529. * @param func The function to execute before the physics world is stepped forward
  24530. */
  24531. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24532. /**
  24533. * Register a function that will be executed after the physics step
  24534. * @param func The function to execute after physics step
  24535. */
  24536. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24537. /**
  24538. * Unregisters a function that will be executed after the physics step
  24539. * @param func The function to execute after physics step
  24540. */
  24541. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24542. /**
  24543. * register a function that will be executed when this impostor collides against a different body
  24544. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24545. * @param func Callback that is executed on collision
  24546. */
  24547. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24548. /**
  24549. * Unregisters the physics imposter on contact
  24550. * @param collideAgainst The physics object to collide against
  24551. * @param func Callback to execute on collision
  24552. */
  24553. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24554. private _tmpQuat;
  24555. private _tmpQuat2;
  24556. /**
  24557. * Get the parent rotation
  24558. * @returns The parent rotation
  24559. */
  24560. getParentsRotation(): Quaternion;
  24561. /**
  24562. * this function is executed by the physics engine.
  24563. */
  24564. beforeStep: () => void;
  24565. /**
  24566. * this function is executed by the physics engine
  24567. */
  24568. afterStep: () => void;
  24569. /**
  24570. * Legacy collision detection event support
  24571. */
  24572. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24573. /**
  24574. * event and body object due to cannon's event-based architecture.
  24575. */
  24576. onCollide: (e: {
  24577. body: any;
  24578. }) => void;
  24579. /**
  24580. * Apply a force
  24581. * @param force The force to apply
  24582. * @param contactPoint The contact point for the force
  24583. * @returns The physics imposter
  24584. */
  24585. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24586. /**
  24587. * Apply an impulse
  24588. * @param force The impulse force
  24589. * @param contactPoint The contact point for the impulse force
  24590. * @returns The physics imposter
  24591. */
  24592. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24593. /**
  24594. * A help function to create a joint
  24595. * @param otherImpostor A physics imposter used to create a joint
  24596. * @param jointType The type of joint
  24597. * @param jointData The data for the joint
  24598. * @returns The physics imposter
  24599. */
  24600. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24601. /**
  24602. * Add a joint to this impostor with a different impostor
  24603. * @param otherImpostor A physics imposter used to add a joint
  24604. * @param joint The joint to add
  24605. * @returns The physics imposter
  24606. */
  24607. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24608. /**
  24609. * Add an anchor to a cloth impostor
  24610. * @param otherImpostor rigid impostor to anchor to
  24611. * @param width ratio across width from 0 to 1
  24612. * @param height ratio up height from 0 to 1
  24613. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24614. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24615. * @returns impostor the soft imposter
  24616. */
  24617. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24618. /**
  24619. * Add a hook to a rope impostor
  24620. * @param otherImpostor rigid impostor to anchor to
  24621. * @param length ratio across rope from 0 to 1
  24622. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24623. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24624. * @returns impostor the rope imposter
  24625. */
  24626. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24627. /**
  24628. * Will keep this body still, in a sleep mode.
  24629. * @returns the physics imposter
  24630. */
  24631. sleep(): PhysicsImpostor;
  24632. /**
  24633. * Wake the body up.
  24634. * @returns The physics imposter
  24635. */
  24636. wakeUp(): PhysicsImpostor;
  24637. /**
  24638. * Clones the physics imposter
  24639. * @param newObject The physics imposter clones to this physics-enabled object
  24640. * @returns A nullable physics imposter
  24641. */
  24642. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24643. /**
  24644. * Disposes the physics imposter
  24645. */
  24646. dispose(): void;
  24647. /**
  24648. * Sets the delta position
  24649. * @param position The delta position amount
  24650. */
  24651. setDeltaPosition(position: Vector3): void;
  24652. /**
  24653. * Sets the delta rotation
  24654. * @param rotation The delta rotation amount
  24655. */
  24656. setDeltaRotation(rotation: Quaternion): void;
  24657. /**
  24658. * Gets the box size of the physics imposter and stores the result in the input parameter
  24659. * @param result Stores the box size
  24660. * @returns The physics imposter
  24661. */
  24662. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24663. /**
  24664. * Gets the radius of the physics imposter
  24665. * @returns Radius of the physics imposter
  24666. */
  24667. getRadius(): number;
  24668. /**
  24669. * Sync a bone with this impostor
  24670. * @param bone The bone to sync to the impostor.
  24671. * @param boneMesh The mesh that the bone is influencing.
  24672. * @param jointPivot The pivot of the joint / bone in local space.
  24673. * @param distToJoint Optional distance from the impostor to the joint.
  24674. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24675. */
  24676. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24677. /**
  24678. * Sync impostor to a bone
  24679. * @param bone The bone that the impostor will be synced to.
  24680. * @param boneMesh The mesh that the bone is influencing.
  24681. * @param jointPivot The pivot of the joint / bone in local space.
  24682. * @param distToJoint Optional distance from the impostor to the joint.
  24683. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24684. * @param boneAxis Optional vector3 axis the bone is aligned with
  24685. */
  24686. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24687. /**
  24688. * No-Imposter type
  24689. */
  24690. static NoImpostor: number;
  24691. /**
  24692. * Sphere-Imposter type
  24693. */
  24694. static SphereImpostor: number;
  24695. /**
  24696. * Box-Imposter type
  24697. */
  24698. static BoxImpostor: number;
  24699. /**
  24700. * Plane-Imposter type
  24701. */
  24702. static PlaneImpostor: number;
  24703. /**
  24704. * Mesh-imposter type
  24705. */
  24706. static MeshImpostor: number;
  24707. /**
  24708. * Capsule-Impostor type (Ammo.js plugin only)
  24709. */
  24710. static CapsuleImpostor: number;
  24711. /**
  24712. * Cylinder-Imposter type
  24713. */
  24714. static CylinderImpostor: number;
  24715. /**
  24716. * Particle-Imposter type
  24717. */
  24718. static ParticleImpostor: number;
  24719. /**
  24720. * Heightmap-Imposter type
  24721. */
  24722. static HeightmapImpostor: number;
  24723. /**
  24724. * ConvexHull-Impostor type (Ammo.js plugin only)
  24725. */
  24726. static ConvexHullImpostor: number;
  24727. /**
  24728. * Custom-Imposter type (Ammo.js plugin only)
  24729. */
  24730. static CustomImpostor: number;
  24731. /**
  24732. * Rope-Imposter type
  24733. */
  24734. static RopeImpostor: number;
  24735. /**
  24736. * Cloth-Imposter type
  24737. */
  24738. static ClothImpostor: number;
  24739. /**
  24740. * Softbody-Imposter type
  24741. */
  24742. static SoftbodyImpostor: number;
  24743. }
  24744. }
  24745. declare module "babylonjs/Meshes/mesh" {
  24746. import { Observable } from "babylonjs/Misc/observable";
  24747. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24748. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24749. import { Camera } from "babylonjs/Cameras/camera";
  24750. import { Scene } from "babylonjs/scene";
  24751. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24752. import { Color4 } from "babylonjs/Maths/math.color";
  24753. import { Engine } from "babylonjs/Engines/engine";
  24754. import { Node } from "babylonjs/node";
  24755. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24756. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24757. import { Buffer } from "babylonjs/Meshes/buffer";
  24758. import { Geometry } from "babylonjs/Meshes/geometry";
  24759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24761. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24762. import { Effect } from "babylonjs/Materials/effect";
  24763. import { Material } from "babylonjs/Materials/material";
  24764. import { Skeleton } from "babylonjs/Bones/skeleton";
  24765. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24766. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24767. import { Path3D } from "babylonjs/Maths/math.path";
  24768. import { Plane } from "babylonjs/Maths/math.plane";
  24769. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24770. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24771. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24772. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24773. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24774. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24775. /**
  24776. * @hidden
  24777. **/
  24778. export class _CreationDataStorage {
  24779. closePath?: boolean;
  24780. closeArray?: boolean;
  24781. idx: number[];
  24782. dashSize: number;
  24783. gapSize: number;
  24784. path3D: Path3D;
  24785. pathArray: Vector3[][];
  24786. arc: number;
  24787. radius: number;
  24788. cap: number;
  24789. tessellation: number;
  24790. }
  24791. /**
  24792. * @hidden
  24793. **/
  24794. class _InstanceDataStorage {
  24795. visibleInstances: any;
  24796. batchCache: _InstancesBatch;
  24797. instancesBufferSize: number;
  24798. instancesBuffer: Nullable<Buffer>;
  24799. instancesData: Float32Array;
  24800. overridenInstanceCount: number;
  24801. isFrozen: boolean;
  24802. previousBatch: Nullable<_InstancesBatch>;
  24803. hardwareInstancedRendering: boolean;
  24804. sideOrientation: number;
  24805. manualUpdate: boolean;
  24806. }
  24807. /**
  24808. * @hidden
  24809. **/
  24810. export class _InstancesBatch {
  24811. mustReturn: boolean;
  24812. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24813. renderSelf: boolean[];
  24814. hardwareInstancedRendering: boolean[];
  24815. }
  24816. /**
  24817. * Class used to represent renderable models
  24818. */
  24819. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24820. /**
  24821. * Mesh side orientation : usually the external or front surface
  24822. */
  24823. static readonly FRONTSIDE: number;
  24824. /**
  24825. * Mesh side orientation : usually the internal or back surface
  24826. */
  24827. static readonly BACKSIDE: number;
  24828. /**
  24829. * Mesh side orientation : both internal and external or front and back surfaces
  24830. */
  24831. static readonly DOUBLESIDE: number;
  24832. /**
  24833. * Mesh side orientation : by default, `FRONTSIDE`
  24834. */
  24835. static readonly DEFAULTSIDE: number;
  24836. /**
  24837. * Mesh cap setting : no cap
  24838. */
  24839. static readonly NO_CAP: number;
  24840. /**
  24841. * Mesh cap setting : one cap at the beginning of the mesh
  24842. */
  24843. static readonly CAP_START: number;
  24844. /**
  24845. * Mesh cap setting : one cap at the end of the mesh
  24846. */
  24847. static readonly CAP_END: number;
  24848. /**
  24849. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24850. */
  24851. static readonly CAP_ALL: number;
  24852. /**
  24853. * Mesh pattern setting : no flip or rotate
  24854. */
  24855. static readonly NO_FLIP: number;
  24856. /**
  24857. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24858. */
  24859. static readonly FLIP_TILE: number;
  24860. /**
  24861. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24862. */
  24863. static readonly ROTATE_TILE: number;
  24864. /**
  24865. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24866. */
  24867. static readonly FLIP_ROW: number;
  24868. /**
  24869. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24870. */
  24871. static readonly ROTATE_ROW: number;
  24872. /**
  24873. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24874. */
  24875. static readonly FLIP_N_ROTATE_TILE: number;
  24876. /**
  24877. * Mesh pattern setting : rotate pattern and rotate
  24878. */
  24879. static readonly FLIP_N_ROTATE_ROW: number;
  24880. /**
  24881. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24882. */
  24883. static readonly CENTER: number;
  24884. /**
  24885. * Mesh tile positioning : part tiles on left
  24886. */
  24887. static readonly LEFT: number;
  24888. /**
  24889. * Mesh tile positioning : part tiles on right
  24890. */
  24891. static readonly RIGHT: number;
  24892. /**
  24893. * Mesh tile positioning : part tiles on top
  24894. */
  24895. static readonly TOP: number;
  24896. /**
  24897. * Mesh tile positioning : part tiles on bottom
  24898. */
  24899. static readonly BOTTOM: number;
  24900. /**
  24901. * Gets the default side orientation.
  24902. * @param orientation the orientation to value to attempt to get
  24903. * @returns the default orientation
  24904. * @hidden
  24905. */
  24906. static _GetDefaultSideOrientation(orientation?: number): number;
  24907. private _internalMeshDataInfo;
  24908. /**
  24909. * An event triggered before rendering the mesh
  24910. */
  24911. get onBeforeRenderObservable(): Observable<Mesh>;
  24912. /**
  24913. * An event triggered before binding the mesh
  24914. */
  24915. get onBeforeBindObservable(): Observable<Mesh>;
  24916. /**
  24917. * An event triggered after rendering the mesh
  24918. */
  24919. get onAfterRenderObservable(): Observable<Mesh>;
  24920. /**
  24921. * An event triggered before drawing the mesh
  24922. */
  24923. get onBeforeDrawObservable(): Observable<Mesh>;
  24924. private _onBeforeDrawObserver;
  24925. /**
  24926. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24927. */
  24928. set onBeforeDraw(callback: () => void);
  24929. get hasInstances(): boolean;
  24930. /**
  24931. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24932. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24933. */
  24934. delayLoadState: number;
  24935. /**
  24936. * Gets the list of instances created from this mesh
  24937. * it is not supposed to be modified manually.
  24938. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24939. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24940. */
  24941. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24942. /**
  24943. * Gets the file containing delay loading data for this mesh
  24944. */
  24945. delayLoadingFile: string;
  24946. /** @hidden */
  24947. _binaryInfo: any;
  24948. /**
  24949. * User defined function used to change how LOD level selection is done
  24950. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24951. */
  24952. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24953. /**
  24954. * Gets or sets the morph target manager
  24955. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24956. */
  24957. get morphTargetManager(): Nullable<MorphTargetManager>;
  24958. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24959. /** @hidden */
  24960. _creationDataStorage: Nullable<_CreationDataStorage>;
  24961. /** @hidden */
  24962. _geometry: Nullable<Geometry>;
  24963. /** @hidden */
  24964. _delayInfo: Array<string>;
  24965. /** @hidden */
  24966. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24967. /** @hidden */
  24968. _instanceDataStorage: _InstanceDataStorage;
  24969. private _effectiveMaterial;
  24970. /** @hidden */
  24971. _shouldGenerateFlatShading: boolean;
  24972. /** @hidden */
  24973. _originalBuilderSideOrientation: number;
  24974. /**
  24975. * Use this property to change the original side orientation defined at construction time
  24976. */
  24977. overrideMaterialSideOrientation: Nullable<number>;
  24978. /**
  24979. * Gets the source mesh (the one used to clone this one from)
  24980. */
  24981. get source(): Nullable<Mesh>;
  24982. /**
  24983. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24984. */
  24985. get isUnIndexed(): boolean;
  24986. set isUnIndexed(value: boolean);
  24987. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24988. get worldMatrixInstancedBuffer(): Float32Array;
  24989. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24990. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24991. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24992. /**
  24993. * @constructor
  24994. * @param name The value used by scene.getMeshByName() to do a lookup.
  24995. * @param scene The scene to add this mesh to.
  24996. * @param parent The parent of this mesh, if it has one
  24997. * @param source An optional Mesh from which geometry is shared, cloned.
  24998. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24999. * When false, achieved by calling a clone(), also passing False.
  25000. * This will make creation of children, recursive.
  25001. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25002. */
  25003. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25004. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25005. doNotInstantiate: boolean;
  25006. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25007. /**
  25008. * Gets the class name
  25009. * @returns the string "Mesh".
  25010. */
  25011. getClassName(): string;
  25012. /** @hidden */
  25013. get _isMesh(): boolean;
  25014. /**
  25015. * Returns a description of this mesh
  25016. * @param fullDetails define if full details about this mesh must be used
  25017. * @returns a descriptive string representing this mesh
  25018. */
  25019. toString(fullDetails?: boolean): string;
  25020. /** @hidden */
  25021. _unBindEffect(): void;
  25022. /**
  25023. * Gets a boolean indicating if this mesh has LOD
  25024. */
  25025. get hasLODLevels(): boolean;
  25026. /**
  25027. * Gets the list of MeshLODLevel associated with the current mesh
  25028. * @returns an array of MeshLODLevel
  25029. */
  25030. getLODLevels(): MeshLODLevel[];
  25031. private _sortLODLevels;
  25032. /**
  25033. * Add a mesh as LOD level triggered at the given distance.
  25034. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25035. * @param distance The distance from the center of the object to show this level
  25036. * @param mesh The mesh to be added as LOD level (can be null)
  25037. * @return This mesh (for chaining)
  25038. */
  25039. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25040. /**
  25041. * Returns the LOD level mesh at the passed distance or null if not found.
  25042. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25043. * @param distance The distance from the center of the object to show this level
  25044. * @returns a Mesh or `null`
  25045. */
  25046. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25047. /**
  25048. * Remove a mesh from the LOD array
  25049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25050. * @param mesh defines the mesh to be removed
  25051. * @return This mesh (for chaining)
  25052. */
  25053. removeLODLevel(mesh: Mesh): Mesh;
  25054. /**
  25055. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25056. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25057. * @param camera defines the camera to use to compute distance
  25058. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25059. * @return This mesh (for chaining)
  25060. */
  25061. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25062. /**
  25063. * Gets the mesh internal Geometry object
  25064. */
  25065. get geometry(): Nullable<Geometry>;
  25066. /**
  25067. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25068. * @returns the total number of vertices
  25069. */
  25070. getTotalVertices(): number;
  25071. /**
  25072. * Returns the content of an associated vertex buffer
  25073. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25074. * - VertexBuffer.PositionKind
  25075. * - VertexBuffer.UVKind
  25076. * - VertexBuffer.UV2Kind
  25077. * - VertexBuffer.UV3Kind
  25078. * - VertexBuffer.UV4Kind
  25079. * - VertexBuffer.UV5Kind
  25080. * - VertexBuffer.UV6Kind
  25081. * - VertexBuffer.ColorKind
  25082. * - VertexBuffer.MatricesIndicesKind
  25083. * - VertexBuffer.MatricesIndicesExtraKind
  25084. * - VertexBuffer.MatricesWeightsKind
  25085. * - VertexBuffer.MatricesWeightsExtraKind
  25086. * @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
  25087. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25088. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25089. */
  25090. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25091. /**
  25092. * Returns the mesh VertexBuffer object from the requested `kind`
  25093. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25094. * - VertexBuffer.PositionKind
  25095. * - VertexBuffer.NormalKind
  25096. * - VertexBuffer.UVKind
  25097. * - VertexBuffer.UV2Kind
  25098. * - VertexBuffer.UV3Kind
  25099. * - VertexBuffer.UV4Kind
  25100. * - VertexBuffer.UV5Kind
  25101. * - VertexBuffer.UV6Kind
  25102. * - VertexBuffer.ColorKind
  25103. * - VertexBuffer.MatricesIndicesKind
  25104. * - VertexBuffer.MatricesIndicesExtraKind
  25105. * - VertexBuffer.MatricesWeightsKind
  25106. * - VertexBuffer.MatricesWeightsExtraKind
  25107. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25108. */
  25109. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25110. /**
  25111. * Tests if a specific vertex buffer is associated with this mesh
  25112. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25113. * - VertexBuffer.PositionKind
  25114. * - VertexBuffer.NormalKind
  25115. * - VertexBuffer.UVKind
  25116. * - VertexBuffer.UV2Kind
  25117. * - VertexBuffer.UV3Kind
  25118. * - VertexBuffer.UV4Kind
  25119. * - VertexBuffer.UV5Kind
  25120. * - VertexBuffer.UV6Kind
  25121. * - VertexBuffer.ColorKind
  25122. * - VertexBuffer.MatricesIndicesKind
  25123. * - VertexBuffer.MatricesIndicesExtraKind
  25124. * - VertexBuffer.MatricesWeightsKind
  25125. * - VertexBuffer.MatricesWeightsExtraKind
  25126. * @returns a boolean
  25127. */
  25128. isVerticesDataPresent(kind: string): boolean;
  25129. /**
  25130. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25131. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25132. * - VertexBuffer.PositionKind
  25133. * - VertexBuffer.UVKind
  25134. * - VertexBuffer.UV2Kind
  25135. * - VertexBuffer.UV3Kind
  25136. * - VertexBuffer.UV4Kind
  25137. * - VertexBuffer.UV5Kind
  25138. * - VertexBuffer.UV6Kind
  25139. * - VertexBuffer.ColorKind
  25140. * - VertexBuffer.MatricesIndicesKind
  25141. * - VertexBuffer.MatricesIndicesExtraKind
  25142. * - VertexBuffer.MatricesWeightsKind
  25143. * - VertexBuffer.MatricesWeightsExtraKind
  25144. * @returns a boolean
  25145. */
  25146. isVertexBufferUpdatable(kind: string): boolean;
  25147. /**
  25148. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25149. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25150. * - VertexBuffer.PositionKind
  25151. * - VertexBuffer.NormalKind
  25152. * - VertexBuffer.UVKind
  25153. * - VertexBuffer.UV2Kind
  25154. * - VertexBuffer.UV3Kind
  25155. * - VertexBuffer.UV4Kind
  25156. * - VertexBuffer.UV5Kind
  25157. * - VertexBuffer.UV6Kind
  25158. * - VertexBuffer.ColorKind
  25159. * - VertexBuffer.MatricesIndicesKind
  25160. * - VertexBuffer.MatricesIndicesExtraKind
  25161. * - VertexBuffer.MatricesWeightsKind
  25162. * - VertexBuffer.MatricesWeightsExtraKind
  25163. * @returns an array of strings
  25164. */
  25165. getVerticesDataKinds(): string[];
  25166. /**
  25167. * Returns a positive integer : the total number of indices in this mesh geometry.
  25168. * @returns the numner of indices or zero if the mesh has no geometry.
  25169. */
  25170. getTotalIndices(): number;
  25171. /**
  25172. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25173. * @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.
  25174. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25175. * @returns the indices array or an empty array if the mesh has no geometry
  25176. */
  25177. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25178. get isBlocked(): boolean;
  25179. /**
  25180. * Determine if the current mesh is ready to be rendered
  25181. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25182. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25183. * @returns true if all associated assets are ready (material, textures, shaders)
  25184. */
  25185. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25186. /**
  25187. * 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.
  25188. */
  25189. get areNormalsFrozen(): boolean;
  25190. /**
  25191. * 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.
  25192. * @returns the current mesh
  25193. */
  25194. freezeNormals(): Mesh;
  25195. /**
  25196. * 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
  25197. * @returns the current mesh
  25198. */
  25199. unfreezeNormals(): Mesh;
  25200. /**
  25201. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25202. */
  25203. set overridenInstanceCount(count: number);
  25204. /** @hidden */
  25205. _preActivate(): Mesh;
  25206. /** @hidden */
  25207. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25208. /** @hidden */
  25209. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25210. /**
  25211. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25212. * This means the mesh underlying bounding box and sphere are recomputed.
  25213. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25214. * @returns the current mesh
  25215. */
  25216. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25217. /** @hidden */
  25218. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25219. /**
  25220. * This function will subdivide the mesh into multiple submeshes
  25221. * @param count defines the expected number of submeshes
  25222. */
  25223. subdivide(count: number): void;
  25224. /**
  25225. * Copy a FloatArray into a specific associated vertex buffer
  25226. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25227. * - VertexBuffer.PositionKind
  25228. * - VertexBuffer.UVKind
  25229. * - VertexBuffer.UV2Kind
  25230. * - VertexBuffer.UV3Kind
  25231. * - VertexBuffer.UV4Kind
  25232. * - VertexBuffer.UV5Kind
  25233. * - VertexBuffer.UV6Kind
  25234. * - VertexBuffer.ColorKind
  25235. * - VertexBuffer.MatricesIndicesKind
  25236. * - VertexBuffer.MatricesIndicesExtraKind
  25237. * - VertexBuffer.MatricesWeightsKind
  25238. * - VertexBuffer.MatricesWeightsExtraKind
  25239. * @param data defines the data source
  25240. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25241. * @param stride defines the data stride size (can be null)
  25242. * @returns the current mesh
  25243. */
  25244. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25245. /**
  25246. * Delete a vertex buffer associated with this mesh
  25247. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25248. * - VertexBuffer.PositionKind
  25249. * - VertexBuffer.UVKind
  25250. * - VertexBuffer.UV2Kind
  25251. * - VertexBuffer.UV3Kind
  25252. * - VertexBuffer.UV4Kind
  25253. * - VertexBuffer.UV5Kind
  25254. * - VertexBuffer.UV6Kind
  25255. * - VertexBuffer.ColorKind
  25256. * - VertexBuffer.MatricesIndicesKind
  25257. * - VertexBuffer.MatricesIndicesExtraKind
  25258. * - VertexBuffer.MatricesWeightsKind
  25259. * - VertexBuffer.MatricesWeightsExtraKind
  25260. */
  25261. removeVerticesData(kind: string): void;
  25262. /**
  25263. * Flags an associated vertex buffer as updatable
  25264. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25265. * - VertexBuffer.PositionKind
  25266. * - VertexBuffer.UVKind
  25267. * - VertexBuffer.UV2Kind
  25268. * - VertexBuffer.UV3Kind
  25269. * - VertexBuffer.UV4Kind
  25270. * - VertexBuffer.UV5Kind
  25271. * - VertexBuffer.UV6Kind
  25272. * - VertexBuffer.ColorKind
  25273. * - VertexBuffer.MatricesIndicesKind
  25274. * - VertexBuffer.MatricesIndicesExtraKind
  25275. * - VertexBuffer.MatricesWeightsKind
  25276. * - VertexBuffer.MatricesWeightsExtraKind
  25277. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25278. */
  25279. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25280. /**
  25281. * Sets the mesh global Vertex Buffer
  25282. * @param buffer defines the buffer to use
  25283. * @returns the current mesh
  25284. */
  25285. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25286. /**
  25287. * Update a specific associated vertex buffer
  25288. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25289. * - VertexBuffer.PositionKind
  25290. * - VertexBuffer.UVKind
  25291. * - VertexBuffer.UV2Kind
  25292. * - VertexBuffer.UV3Kind
  25293. * - VertexBuffer.UV4Kind
  25294. * - VertexBuffer.UV5Kind
  25295. * - VertexBuffer.UV6Kind
  25296. * - VertexBuffer.ColorKind
  25297. * - VertexBuffer.MatricesIndicesKind
  25298. * - VertexBuffer.MatricesIndicesExtraKind
  25299. * - VertexBuffer.MatricesWeightsKind
  25300. * - VertexBuffer.MatricesWeightsExtraKind
  25301. * @param data defines the data source
  25302. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25303. * @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)
  25304. * @returns the current mesh
  25305. */
  25306. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25307. /**
  25308. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25309. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25310. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25311. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25312. * @returns the current mesh
  25313. */
  25314. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25315. /**
  25316. * Creates a un-shared specific occurence of the geometry for the mesh.
  25317. * @returns the current mesh
  25318. */
  25319. makeGeometryUnique(): Mesh;
  25320. /**
  25321. * Set the index buffer of this mesh
  25322. * @param indices defines the source data
  25323. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25324. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25325. * @returns the current mesh
  25326. */
  25327. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25328. /**
  25329. * Update the current index buffer
  25330. * @param indices defines the source data
  25331. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25332. * @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)
  25333. * @returns the current mesh
  25334. */
  25335. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25336. /**
  25337. * Invert the geometry to move from a right handed system to a left handed one.
  25338. * @returns the current mesh
  25339. */
  25340. toLeftHanded(): Mesh;
  25341. /** @hidden */
  25342. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25343. /** @hidden */
  25344. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25345. /**
  25346. * Registers for this mesh a javascript function called just before the rendering process
  25347. * @param func defines the function to call before rendering this mesh
  25348. * @returns the current mesh
  25349. */
  25350. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25351. /**
  25352. * Disposes a previously registered javascript function called before the rendering
  25353. * @param func defines the function to remove
  25354. * @returns the current mesh
  25355. */
  25356. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25357. /**
  25358. * Registers for this mesh a javascript function called just after the rendering is complete
  25359. * @param func defines the function to call after rendering this mesh
  25360. * @returns the current mesh
  25361. */
  25362. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25363. /**
  25364. * Disposes a previously registered javascript function called after the rendering.
  25365. * @param func defines the function to remove
  25366. * @returns the current mesh
  25367. */
  25368. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25369. /** @hidden */
  25370. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25371. /** @hidden */
  25372. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25373. /** @hidden */
  25374. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25375. /** @hidden */
  25376. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25377. /** @hidden */
  25378. _rebuild(): void;
  25379. /** @hidden */
  25380. _freeze(): void;
  25381. /** @hidden */
  25382. _unFreeze(): void;
  25383. /**
  25384. * 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
  25385. * @param subMesh defines the subMesh to render
  25386. * @param enableAlphaMode defines if alpha mode can be changed
  25387. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25388. * @returns the current mesh
  25389. */
  25390. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25391. private _onBeforeDraw;
  25392. /**
  25393. * Renormalize the mesh and patch it up if there are no weights
  25394. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25395. * However in the case of zero weights then we set just a single influence to 1.
  25396. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25397. */
  25398. cleanMatrixWeights(): void;
  25399. private normalizeSkinFourWeights;
  25400. private normalizeSkinWeightsAndExtra;
  25401. /**
  25402. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25403. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25404. * the user know there was an issue with importing the mesh
  25405. * @returns a validation object with skinned, valid and report string
  25406. */
  25407. validateSkinning(): {
  25408. skinned: boolean;
  25409. valid: boolean;
  25410. report: string;
  25411. };
  25412. /** @hidden */
  25413. _checkDelayState(): Mesh;
  25414. private _queueLoad;
  25415. /**
  25416. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25417. * A mesh is in the frustum if its bounding box intersects the frustum
  25418. * @param frustumPlanes defines the frustum to test
  25419. * @returns true if the mesh is in the frustum planes
  25420. */
  25421. isInFrustum(frustumPlanes: Plane[]): boolean;
  25422. /**
  25423. * Sets the mesh material by the material or multiMaterial `id` property
  25424. * @param id is a string identifying the material or the multiMaterial
  25425. * @returns the current mesh
  25426. */
  25427. setMaterialByID(id: string): Mesh;
  25428. /**
  25429. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25430. * @returns an array of IAnimatable
  25431. */
  25432. getAnimatables(): IAnimatable[];
  25433. /**
  25434. * Modifies the mesh geometry according to the passed transformation matrix.
  25435. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25436. * The mesh normals are modified using the same transformation.
  25437. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25438. * @param transform defines the transform matrix to use
  25439. * @see http://doc.babylonjs.com/resources/baking_transformations
  25440. * @returns the current mesh
  25441. */
  25442. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25443. /**
  25444. * Modifies the mesh geometry according to its own current World Matrix.
  25445. * The mesh World Matrix is then reset.
  25446. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25448. * @see http://doc.babylonjs.com/resources/baking_transformations
  25449. * @returns the current mesh
  25450. */
  25451. bakeCurrentTransformIntoVertices(): Mesh;
  25452. /** @hidden */
  25453. get _positions(): Nullable<Vector3[]>;
  25454. /** @hidden */
  25455. _resetPointsArrayCache(): Mesh;
  25456. /** @hidden */
  25457. _generatePointsArray(): boolean;
  25458. /**
  25459. * Returns a new Mesh object generated from the current mesh properties.
  25460. * This method must not get confused with createInstance()
  25461. * @param name is a string, the name given to the new mesh
  25462. * @param newParent can be any Node object (default `null`)
  25463. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25464. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25465. * @returns a new mesh
  25466. */
  25467. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25468. /**
  25469. * Releases resources associated with this mesh.
  25470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25472. */
  25473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25474. /** @hidden */
  25475. _disposeInstanceSpecificData(): void;
  25476. /**
  25477. * Modifies the mesh geometry according to a displacement map.
  25478. * 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.
  25479. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25480. * @param url is a string, the URL from the image file is to be downloaded.
  25481. * @param minHeight is the lower limit of the displacement.
  25482. * @param maxHeight is the upper limit of the displacement.
  25483. * @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.
  25484. * @param uvOffset is an optional vector2 used to offset UV.
  25485. * @param uvScale is an optional vector2 used to scale UV.
  25486. * @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.
  25487. * @returns the Mesh.
  25488. */
  25489. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25490. /**
  25491. * Modifies the mesh geometry according to a displacementMap buffer.
  25492. * 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.
  25493. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25494. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25495. * @param heightMapWidth is the width of the buffer image.
  25496. * @param heightMapHeight is the height of the buffer image.
  25497. * @param minHeight is the lower limit of the displacement.
  25498. * @param maxHeight is the upper limit of the displacement.
  25499. * @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.
  25500. * @param uvOffset is an optional vector2 used to offset UV.
  25501. * @param uvScale is an optional vector2 used to scale UV.
  25502. * @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.
  25503. * @returns the Mesh.
  25504. */
  25505. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25506. /**
  25507. * Modify the mesh to get a flat shading rendering.
  25508. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25509. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25510. * @returns current mesh
  25511. */
  25512. convertToFlatShadedMesh(): Mesh;
  25513. /**
  25514. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25515. * In other words, more vertices, no more indices and a single bigger VBO.
  25516. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25517. * @returns current mesh
  25518. */
  25519. convertToUnIndexedMesh(): Mesh;
  25520. /**
  25521. * Inverses facet orientations.
  25522. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25523. * @param flipNormals will also inverts the normals
  25524. * @returns current mesh
  25525. */
  25526. flipFaces(flipNormals?: boolean): Mesh;
  25527. /**
  25528. * Increase the number of facets and hence vertices in a mesh
  25529. * Vertex normals are interpolated from existing vertex normals
  25530. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25531. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25532. */
  25533. increaseVertices(numberPerEdge: number): void;
  25534. /**
  25535. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25536. * This will undo any application of covertToFlatShadedMesh
  25537. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25538. */
  25539. forceSharedVertices(): void;
  25540. /** @hidden */
  25541. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25542. /** @hidden */
  25543. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25544. /**
  25545. * Creates a new InstancedMesh object from the mesh model.
  25546. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25547. * @param name defines the name of the new instance
  25548. * @returns a new InstancedMesh
  25549. */
  25550. createInstance(name: string): InstancedMesh;
  25551. /**
  25552. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25553. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25554. * @returns the current mesh
  25555. */
  25556. synchronizeInstances(): Mesh;
  25557. /**
  25558. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25559. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25560. * This should be used together with the simplification to avoid disappearing triangles.
  25561. * @param successCallback an optional success callback to be called after the optimization finished.
  25562. * @returns the current mesh
  25563. */
  25564. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25565. /**
  25566. * Serialize current mesh
  25567. * @param serializationObject defines the object which will receive the serialization data
  25568. */
  25569. serialize(serializationObject: any): void;
  25570. /** @hidden */
  25571. _syncGeometryWithMorphTargetManager(): void;
  25572. /** @hidden */
  25573. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25574. /**
  25575. * Returns a new Mesh object parsed from the source provided.
  25576. * @param parsedMesh is the source
  25577. * @param scene defines the hosting scene
  25578. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25579. * @returns a new Mesh
  25580. */
  25581. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25582. /**
  25583. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25584. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25585. * @param name defines the name of the mesh to create
  25586. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25587. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25588. * @param closePath creates a seam between the first and the last points of each path of the path array
  25589. * @param offset is taken in account only if the `pathArray` is containing a single path
  25590. * @param scene defines the hosting scene
  25591. * @param updatable defines if the mesh must be flagged as updatable
  25592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25593. * @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)
  25594. * @returns a new Mesh
  25595. */
  25596. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25597. /**
  25598. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25599. * @param name defines the name of the mesh to create
  25600. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25601. * @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
  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 CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25608. /**
  25609. * Creates a box 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 size sets the size (float) of each box side (default 1)
  25612. * @param scene defines the hosting scene
  25613. * @param updatable defines if the mesh must be flagged as updatable
  25614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25615. * @returns a new Mesh
  25616. */
  25617. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25618. /**
  25619. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25620. * @param name defines the name of the mesh to create
  25621. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25622. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25623. * @param scene defines the hosting scene
  25624. * @param updatable defines if the mesh must be flagged as updatable
  25625. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25626. * @returns a new Mesh
  25627. */
  25628. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25629. /**
  25630. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25631. * @param name defines the name of the mesh to create
  25632. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25633. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25634. * @param scene defines the hosting scene
  25635. * @returns a new Mesh
  25636. */
  25637. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25638. /**
  25639. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25640. * @param name defines the name of the mesh to create
  25641. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25642. * @param diameterTop set the top cap diameter (floats, default 1)
  25643. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25644. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25645. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25646. * @param scene defines the hosting scene
  25647. * @param updatable defines if the mesh must be flagged as updatable
  25648. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25649. * @returns a new Mesh
  25650. */
  25651. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25652. /**
  25653. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25654. * @param name defines the name of the mesh to create
  25655. * @param diameter sets the diameter size (float) of the torus (default 1)
  25656. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25657. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25658. * @param scene defines the hosting scene
  25659. * @param updatable defines if the mesh must be flagged as updatable
  25660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25661. * @returns a new Mesh
  25662. */
  25663. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25664. /**
  25665. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25666. * @param name defines the name of the mesh to create
  25667. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25668. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25669. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25670. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25671. * @param p the number of windings on X axis (positive integers, default 2)
  25672. * @param q the number of windings on Y axis (positive integers, default 3)
  25673. * @param scene defines the hosting scene
  25674. * @param updatable defines if the mesh must be flagged as updatable
  25675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25676. * @returns a new Mesh
  25677. */
  25678. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25679. /**
  25680. * Creates a 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 scene defines the hosting scene
  25684. * @param updatable defines if the mesh must be flagged as updatable
  25685. * @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).
  25686. * @returns a new Mesh
  25687. */
  25688. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25689. /**
  25690. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25691. * @param name defines the name of the mesh to create
  25692. * @param points is an array successive Vector3
  25693. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25694. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25695. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25696. * @param scene defines the hosting scene
  25697. * @param updatable defines if the mesh must be flagged as updatable
  25698. * @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)
  25699. * @returns a new Mesh
  25700. */
  25701. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25702. /**
  25703. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25704. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25705. * 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.
  25706. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25707. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25708. * Remember you can only change the shape positions, not their number when updating a polygon.
  25709. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25710. * @param name defines the name of the mesh to create
  25711. * @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
  25712. * @param scene defines the hosting scene
  25713. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25714. * @param updatable defines if the mesh must be flagged as updatable
  25715. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25716. * @param earcutInjection can be used to inject your own earcut reference
  25717. * @returns a new Mesh
  25718. */
  25719. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25720. /**
  25721. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25722. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25723. * @param name defines the name of the mesh to create
  25724. * @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
  25725. * @param depth defines the height of extrusion
  25726. * @param scene defines the hosting scene
  25727. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25728. * @param updatable defines if the mesh must be flagged as updatable
  25729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25730. * @param earcutInjection can be used to inject your own earcut reference
  25731. * @returns a new Mesh
  25732. */
  25733. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25734. /**
  25735. * Creates an extruded shape mesh.
  25736. * 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
  25737. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25738. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25739. * @param name defines the name of the mesh to create
  25740. * @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
  25741. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25742. * @param scale is the value to scale the shape
  25743. * @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
  25744. * @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
  25745. * @param scene defines the hosting scene
  25746. * @param updatable defines if the mesh must be flagged as updatable
  25747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25748. * @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)
  25749. * @returns a new Mesh
  25750. */
  25751. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25752. /**
  25753. * Creates an custom extruded shape mesh.
  25754. * The custom extrusion is a parametric shape.
  25755. * It has no predefined shape. Its final shape will depend on the input parameters.
  25756. * Please consider using the same method from the MeshBuilder class instead
  25757. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25758. * @param name defines the name of the mesh to create
  25759. * @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
  25760. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25761. * @param scaleFunction is a custom Javascript function called on each path point
  25762. * @param rotationFunction is a custom Javascript function called on each path point
  25763. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25764. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25765. * @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
  25766. * @param scene defines the hosting scene
  25767. * @param updatable defines if the mesh must be flagged as updatable
  25768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25769. * @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)
  25770. * @returns a new Mesh
  25771. */
  25772. 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;
  25773. /**
  25774. * Creates lathe mesh.
  25775. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25776. * Please consider using the same method from the MeshBuilder class instead
  25777. * @param name defines the name of the mesh to create
  25778. * @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
  25779. * @param radius is the radius value of the lathe
  25780. * @param tessellation is the side number of the lathe.
  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 CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25787. /**
  25788. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25789. * @param name defines the name of the mesh to create
  25790. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25791. * @param scene defines the hosting scene
  25792. * @param updatable defines if the mesh must be flagged as updatable
  25793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25794. * @returns a new Mesh
  25795. */
  25796. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25797. /**
  25798. * Creates a ground mesh.
  25799. * Please consider using the same method from the MeshBuilder class instead
  25800. * @param name defines the name of the mesh to create
  25801. * @param width set the width of the ground
  25802. * @param height set the height of the ground
  25803. * @param subdivisions sets the number of subdivisions per side
  25804. * @param scene defines the hosting scene
  25805. * @param updatable defines if the mesh must be flagged as updatable
  25806. * @returns a new Mesh
  25807. */
  25808. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25809. /**
  25810. * Creates a tiled ground mesh.
  25811. * Please consider using the same method from the MeshBuilder class instead
  25812. * @param name defines the name of the mesh to create
  25813. * @param xmin set the ground minimum X coordinate
  25814. * @param zmin set the ground minimum Y coordinate
  25815. * @param xmax set the ground maximum X coordinate
  25816. * @param zmax set the ground maximum Z coordinate
  25817. * @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
  25818. * @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
  25819. * @param scene defines the hosting scene
  25820. * @param updatable defines if the mesh must be flagged as updatable
  25821. * @returns a new Mesh
  25822. */
  25823. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25824. w: number;
  25825. h: number;
  25826. }, precision: {
  25827. w: number;
  25828. h: number;
  25829. }, scene: Scene, updatable?: boolean): Mesh;
  25830. /**
  25831. * Creates a ground mesh from a height map.
  25832. * Please consider using the same method from the MeshBuilder class instead
  25833. * @see http://doc.babylonjs.com/babylon101/height_map
  25834. * @param name defines the name of the mesh to create
  25835. * @param url sets the URL of the height map image resource
  25836. * @param width set the ground width size
  25837. * @param height set the ground height size
  25838. * @param subdivisions sets the number of subdivision per side
  25839. * @param minHeight is the minimum altitude on the ground
  25840. * @param maxHeight is the maximum altitude on the ground
  25841. * @param scene defines the hosting scene
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25844. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25845. * @returns a new Mesh
  25846. */
  25847. 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;
  25848. /**
  25849. * Creates a tube mesh.
  25850. * The tube is a parametric shape.
  25851. * It has no predefined shape. Its final shape will depend on the input parameters.
  25852. * Please consider using the same method from the MeshBuilder class instead
  25853. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25854. * @param name defines the name of the mesh to create
  25855. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25856. * @param radius sets the tube radius size
  25857. * @param tessellation is the number of sides on the tubular surface
  25858. * @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
  25859. * @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
  25860. * @param scene defines the hosting scene
  25861. * @param updatable defines if the mesh must be flagged as updatable
  25862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25863. * @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)
  25864. * @returns a new Mesh
  25865. */
  25866. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25867. (i: number, distance: number): number;
  25868. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25869. /**
  25870. * Creates a polyhedron mesh.
  25871. * Please consider using the same method from the MeshBuilder class instead.
  25872. * * 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
  25873. * * The parameter `size` (positive float, default 1) sets the polygon size
  25874. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25875. * * 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`
  25876. * * 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
  25877. * * 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)`)
  25878. * * 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
  25879. * * 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
  25880. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25881. * * If you create a double-sided mesh, you can choose what parts of 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
  25882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25883. * @param name defines the name of the mesh to create
  25884. * @param options defines the options used to create the mesh
  25885. * @param scene defines the hosting scene
  25886. * @returns a new Mesh
  25887. */
  25888. static CreatePolyhedron(name: string, options: {
  25889. type?: number;
  25890. size?: number;
  25891. sizeX?: number;
  25892. sizeY?: number;
  25893. sizeZ?: number;
  25894. custom?: any;
  25895. faceUV?: Vector4[];
  25896. faceColors?: Color4[];
  25897. updatable?: boolean;
  25898. sideOrientation?: number;
  25899. }, scene: Scene): Mesh;
  25900. /**
  25901. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25902. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25903. * * 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`)
  25904. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25905. * * 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
  25906. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25907. * * If you create a double-sided mesh, you can choose what parts of 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
  25908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25909. * @param name defines the name of the mesh
  25910. * @param options defines the options used to create the mesh
  25911. * @param scene defines the hosting scene
  25912. * @returns a new Mesh
  25913. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25914. */
  25915. static CreateIcoSphere(name: string, options: {
  25916. radius?: number;
  25917. flat?: boolean;
  25918. subdivisions?: number;
  25919. sideOrientation?: number;
  25920. updatable?: boolean;
  25921. }, scene: Scene): Mesh;
  25922. /**
  25923. * Creates a decal mesh.
  25924. * Please consider using the same method from the MeshBuilder class instead.
  25925. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25926. * @param name defines the name of the mesh
  25927. * @param sourceMesh defines the mesh receiving the decal
  25928. * @param position sets the position of the decal in world coordinates
  25929. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25930. * @param size sets the decal scaling
  25931. * @param angle sets the angle to rotate the decal
  25932. * @returns a new Mesh
  25933. */
  25934. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25935. /**
  25936. * Prepare internal position array for software CPU skinning
  25937. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25938. */
  25939. setPositionsForCPUSkinning(): Float32Array;
  25940. /**
  25941. * Prepare internal normal array for software CPU skinning
  25942. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25943. */
  25944. setNormalsForCPUSkinning(): Float32Array;
  25945. /**
  25946. * Updates the vertex buffer by applying transformation from the bones
  25947. * @param skeleton defines the skeleton to apply to current mesh
  25948. * @returns the current mesh
  25949. */
  25950. applySkeleton(skeleton: Skeleton): Mesh;
  25951. /**
  25952. * 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
  25953. * @param meshes defines the list of meshes to scan
  25954. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25955. */
  25956. static MinMax(meshes: AbstractMesh[]): {
  25957. min: Vector3;
  25958. max: Vector3;
  25959. };
  25960. /**
  25961. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25962. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25963. * @returns a vector3
  25964. */
  25965. static Center(meshesOrMinMaxVector: {
  25966. min: Vector3;
  25967. max: Vector3;
  25968. } | AbstractMesh[]): Vector3;
  25969. /**
  25970. * Merge the array of meshes into a single mesh for performance reasons.
  25971. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25972. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25973. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25974. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25975. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25976. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25977. * @returns a new mesh
  25978. */
  25979. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25980. /** @hidden */
  25981. addInstance(instance: InstancedMesh): void;
  25982. /** @hidden */
  25983. removeInstance(instance: InstancedMesh): void;
  25984. }
  25985. }
  25986. declare module "babylonjs/Cameras/camera" {
  25987. import { SmartArray } from "babylonjs/Misc/smartArray";
  25988. import { Observable } from "babylonjs/Misc/observable";
  25989. import { Nullable } from "babylonjs/types";
  25990. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25991. import { Scene } from "babylonjs/scene";
  25992. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25993. import { Node } from "babylonjs/node";
  25994. import { Mesh } from "babylonjs/Meshes/mesh";
  25995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25996. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25997. import { Viewport } from "babylonjs/Maths/math.viewport";
  25998. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26000. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26001. import { Ray } from "babylonjs/Culling/ray";
  26002. /**
  26003. * This is the base class of all the camera used in the application.
  26004. * @see http://doc.babylonjs.com/features/cameras
  26005. */
  26006. export class Camera extends Node {
  26007. /** @hidden */
  26008. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26009. /**
  26010. * This is the default projection mode used by the cameras.
  26011. * It helps recreating a feeling of perspective and better appreciate depth.
  26012. * This is the best way to simulate real life cameras.
  26013. */
  26014. static readonly PERSPECTIVE_CAMERA: number;
  26015. /**
  26016. * This helps creating camera with an orthographic mode.
  26017. * 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.
  26018. */
  26019. static readonly ORTHOGRAPHIC_CAMERA: number;
  26020. /**
  26021. * This is the default FOV mode for perspective cameras.
  26022. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26023. */
  26024. static readonly FOVMODE_VERTICAL_FIXED: number;
  26025. /**
  26026. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26027. */
  26028. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26029. /**
  26030. * This specifies ther is no need for a camera rig.
  26031. * Basically only one eye is rendered corresponding to the camera.
  26032. */
  26033. static readonly RIG_MODE_NONE: number;
  26034. /**
  26035. * Simulates a camera Rig with one blue eye and one red eye.
  26036. * This can be use with 3d blue and red glasses.
  26037. */
  26038. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26039. /**
  26040. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26041. */
  26042. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26043. /**
  26044. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26045. */
  26046. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26047. /**
  26048. * Defines that both eyes of the camera will be rendered over under each other.
  26049. */
  26050. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26051. /**
  26052. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26053. */
  26054. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26055. /**
  26056. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26057. */
  26058. static readonly RIG_MODE_VR: number;
  26059. /**
  26060. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26061. */
  26062. static readonly RIG_MODE_WEBVR: number;
  26063. /**
  26064. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26065. */
  26066. static readonly RIG_MODE_CUSTOM: number;
  26067. /**
  26068. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26069. */
  26070. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26071. /**
  26072. * Define the input manager associated with the camera.
  26073. */
  26074. inputs: CameraInputsManager<Camera>;
  26075. /** @hidden */
  26076. _position: Vector3;
  26077. /**
  26078. * Define the current local position of the camera in the scene
  26079. */
  26080. get position(): Vector3;
  26081. set position(newPosition: Vector3);
  26082. /**
  26083. * The vector the camera should consider as up.
  26084. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26085. */
  26086. upVector: Vector3;
  26087. /**
  26088. * Define the current limit on the left side for an orthographic camera
  26089. * In scene unit
  26090. */
  26091. orthoLeft: Nullable<number>;
  26092. /**
  26093. * Define the current limit on the right side for an orthographic camera
  26094. * In scene unit
  26095. */
  26096. orthoRight: Nullable<number>;
  26097. /**
  26098. * Define the current limit on the bottom side for an orthographic camera
  26099. * In scene unit
  26100. */
  26101. orthoBottom: Nullable<number>;
  26102. /**
  26103. * Define the current limit on the top side for an orthographic camera
  26104. * In scene unit
  26105. */
  26106. orthoTop: Nullable<number>;
  26107. /**
  26108. * Field Of View is set in Radians. (default is 0.8)
  26109. */
  26110. fov: number;
  26111. /**
  26112. * Define the minimum distance the camera can see from.
  26113. * This is important to note that the depth buffer are not infinite and the closer it starts
  26114. * the more your scene might encounter depth fighting issue.
  26115. */
  26116. minZ: number;
  26117. /**
  26118. * Define the maximum distance the camera can see to.
  26119. * This is important to note that the depth buffer are not infinite and the further it end
  26120. * the more your scene might encounter depth fighting issue.
  26121. */
  26122. maxZ: number;
  26123. /**
  26124. * Define the default inertia of the camera.
  26125. * This helps giving a smooth feeling to the camera movement.
  26126. */
  26127. inertia: number;
  26128. /**
  26129. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26130. */
  26131. mode: number;
  26132. /**
  26133. * Define wether the camera is intermediate.
  26134. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26135. */
  26136. isIntermediate: boolean;
  26137. /**
  26138. * Define the viewport of the camera.
  26139. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26140. */
  26141. viewport: Viewport;
  26142. /**
  26143. * Restricts the camera to viewing objects with the same layerMask.
  26144. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26145. */
  26146. layerMask: number;
  26147. /**
  26148. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26149. */
  26150. fovMode: number;
  26151. /**
  26152. * Rig mode of the camera.
  26153. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26154. * This is normally controlled byt the camera themselves as internal use.
  26155. */
  26156. cameraRigMode: number;
  26157. /**
  26158. * Defines the distance between both "eyes" in case of a RIG
  26159. */
  26160. interaxialDistance: number;
  26161. /**
  26162. * Defines if stereoscopic rendering is done side by side or over under.
  26163. */
  26164. isStereoscopicSideBySide: boolean;
  26165. /**
  26166. * 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
  26167. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26168. * else in the scene. (Eg. security camera)
  26169. *
  26170. * 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)
  26171. */
  26172. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26173. /**
  26174. * When set, the camera will render to this render target instead of the default canvas
  26175. *
  26176. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26177. */
  26178. outputRenderTarget: Nullable<RenderTargetTexture>;
  26179. /**
  26180. * Observable triggered when the camera view matrix has changed.
  26181. */
  26182. onViewMatrixChangedObservable: Observable<Camera>;
  26183. /**
  26184. * Observable triggered when the camera Projection matrix has changed.
  26185. */
  26186. onProjectionMatrixChangedObservable: Observable<Camera>;
  26187. /**
  26188. * Observable triggered when the inputs have been processed.
  26189. */
  26190. onAfterCheckInputsObservable: Observable<Camera>;
  26191. /**
  26192. * Observable triggered when reset has been called and applied to the camera.
  26193. */
  26194. onRestoreStateObservable: Observable<Camera>;
  26195. /** @hidden */
  26196. _cameraRigParams: any;
  26197. /** @hidden */
  26198. _rigCameras: Camera[];
  26199. /** @hidden */
  26200. _rigPostProcess: Nullable<PostProcess>;
  26201. protected _webvrViewMatrix: Matrix;
  26202. /** @hidden */
  26203. _skipRendering: boolean;
  26204. /** @hidden */
  26205. _projectionMatrix: Matrix;
  26206. /** @hidden */
  26207. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26208. /** @hidden */
  26209. _activeMeshes: SmartArray<AbstractMesh>;
  26210. protected _globalPosition: Vector3;
  26211. /** @hidden */
  26212. _computedViewMatrix: Matrix;
  26213. private _doNotComputeProjectionMatrix;
  26214. private _transformMatrix;
  26215. private _frustumPlanes;
  26216. private _refreshFrustumPlanes;
  26217. private _storedFov;
  26218. private _stateStored;
  26219. /**
  26220. * Instantiates a new camera object.
  26221. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26222. * @see http://doc.babylonjs.com/features/cameras
  26223. * @param name Defines the name of the camera in the scene
  26224. * @param position Defines the position of the camera
  26225. * @param scene Defines the scene the camera belongs too
  26226. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26227. */
  26228. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26229. /**
  26230. * Store current camera state (fov, position, etc..)
  26231. * @returns the camera
  26232. */
  26233. storeState(): Camera;
  26234. /**
  26235. * Restores the camera state values if it has been stored. You must call storeState() first
  26236. */
  26237. protected _restoreStateValues(): boolean;
  26238. /**
  26239. * Restored camera state. You must call storeState() first.
  26240. * @returns true if restored and false otherwise
  26241. */
  26242. restoreState(): boolean;
  26243. /**
  26244. * Gets the class name of the camera.
  26245. * @returns the class name
  26246. */
  26247. getClassName(): string;
  26248. /** @hidden */
  26249. readonly _isCamera: boolean;
  26250. /**
  26251. * Gets a string representation of the camera useful for debug purpose.
  26252. * @param fullDetails Defines that a more verboe level of logging is required
  26253. * @returns the string representation
  26254. */
  26255. toString(fullDetails?: boolean): string;
  26256. /**
  26257. * Gets the current world space position of the camera.
  26258. */
  26259. get globalPosition(): Vector3;
  26260. /**
  26261. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26262. * @returns the active meshe list
  26263. */
  26264. getActiveMeshes(): SmartArray<AbstractMesh>;
  26265. /**
  26266. * Check wether a mesh is part of the current active mesh list of the camera
  26267. * @param mesh Defines the mesh to check
  26268. * @returns true if active, false otherwise
  26269. */
  26270. isActiveMesh(mesh: Mesh): boolean;
  26271. /**
  26272. * Is this camera ready to be used/rendered
  26273. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26274. * @return true if the camera is ready
  26275. */
  26276. isReady(completeCheck?: boolean): boolean;
  26277. /** @hidden */
  26278. _initCache(): void;
  26279. /** @hidden */
  26280. _updateCache(ignoreParentClass?: boolean): void;
  26281. /** @hidden */
  26282. _isSynchronized(): boolean;
  26283. /** @hidden */
  26284. _isSynchronizedViewMatrix(): boolean;
  26285. /** @hidden */
  26286. _isSynchronizedProjectionMatrix(): boolean;
  26287. /**
  26288. * Attach the input controls to a specific dom element to get the input from.
  26289. * @param element Defines the element the controls should be listened from
  26290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26291. */
  26292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26293. /**
  26294. * Detach the current controls from the specified dom element.
  26295. * @param element Defines the element to stop listening the inputs from
  26296. */
  26297. detachControl(element: HTMLElement): void;
  26298. /**
  26299. * Update the camera state according to the different inputs gathered during the frame.
  26300. */
  26301. update(): void;
  26302. /** @hidden */
  26303. _checkInputs(): void;
  26304. /** @hidden */
  26305. get rigCameras(): Camera[];
  26306. /**
  26307. * Gets the post process used by the rig cameras
  26308. */
  26309. get rigPostProcess(): Nullable<PostProcess>;
  26310. /**
  26311. * Internal, gets the first post proces.
  26312. * @returns the first post process to be run on this camera.
  26313. */
  26314. _getFirstPostProcess(): Nullable<PostProcess>;
  26315. private _cascadePostProcessesToRigCams;
  26316. /**
  26317. * Attach a post process to the camera.
  26318. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26319. * @param postProcess The post process to attach to the camera
  26320. * @param insertAt The position of the post process in case several of them are in use in the scene
  26321. * @returns the position the post process has been inserted at
  26322. */
  26323. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26324. /**
  26325. * Detach a post process to the camera.
  26326. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26327. * @param postProcess The post process to detach from the camera
  26328. */
  26329. detachPostProcess(postProcess: PostProcess): void;
  26330. /**
  26331. * Gets the current world matrix of the camera
  26332. */
  26333. getWorldMatrix(): Matrix;
  26334. /** @hidden */
  26335. _getViewMatrix(): Matrix;
  26336. /**
  26337. * Gets the current view matrix of the camera.
  26338. * @param force forces the camera to recompute the matrix without looking at the cached state
  26339. * @returns the view matrix
  26340. */
  26341. getViewMatrix(force?: boolean): Matrix;
  26342. /**
  26343. * Freeze the projection matrix.
  26344. * It will prevent the cache check of the camera projection compute and can speed up perf
  26345. * if no parameter of the camera are meant to change
  26346. * @param projection Defines manually a projection if necessary
  26347. */
  26348. freezeProjectionMatrix(projection?: Matrix): void;
  26349. /**
  26350. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26351. */
  26352. unfreezeProjectionMatrix(): void;
  26353. /**
  26354. * Gets the current projection matrix of the camera.
  26355. * @param force forces the camera to recompute the matrix without looking at the cached state
  26356. * @returns the projection matrix
  26357. */
  26358. getProjectionMatrix(force?: boolean): Matrix;
  26359. /**
  26360. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26361. * @returns a Matrix
  26362. */
  26363. getTransformationMatrix(): Matrix;
  26364. private _updateFrustumPlanes;
  26365. /**
  26366. * Checks if a cullable object (mesh...) is in the camera frustum
  26367. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26368. * @param target The object to check
  26369. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26370. * @returns true if the object is in frustum otherwise false
  26371. */
  26372. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26373. /**
  26374. * Checks if a cullable object (mesh...) is in the camera frustum
  26375. * Unlike isInFrustum this cheks the full bounding box
  26376. * @param target The object to check
  26377. * @returns true if the object is in frustum otherwise false
  26378. */
  26379. isCompletelyInFrustum(target: ICullable): boolean;
  26380. /**
  26381. * Gets a ray in the forward direction from the camera.
  26382. * @param length Defines the length of the ray to create
  26383. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26384. * @param origin Defines the start point of the ray which defaults to the camera position
  26385. * @returns the forward ray
  26386. */
  26387. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26388. /**
  26389. * Releases resources associated with this node.
  26390. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26391. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26392. */
  26393. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26394. /** @hidden */
  26395. _isLeftCamera: boolean;
  26396. /**
  26397. * Gets the left camera of a rig setup in case of Rigged Camera
  26398. */
  26399. get isLeftCamera(): boolean;
  26400. /** @hidden */
  26401. _isRightCamera: boolean;
  26402. /**
  26403. * Gets the right camera of a rig setup in case of Rigged Camera
  26404. */
  26405. get isRightCamera(): boolean;
  26406. /**
  26407. * Gets the left camera of a rig setup in case of Rigged Camera
  26408. */
  26409. get leftCamera(): Nullable<FreeCamera>;
  26410. /**
  26411. * Gets the right camera of a rig setup in case of Rigged Camera
  26412. */
  26413. get rightCamera(): Nullable<FreeCamera>;
  26414. /**
  26415. * Gets the left camera target of a rig setup in case of Rigged Camera
  26416. * @returns the target position
  26417. */
  26418. getLeftTarget(): Nullable<Vector3>;
  26419. /**
  26420. * Gets the right camera target of a rig setup in case of Rigged Camera
  26421. * @returns the target position
  26422. */
  26423. getRightTarget(): Nullable<Vector3>;
  26424. /**
  26425. * @hidden
  26426. */
  26427. setCameraRigMode(mode: number, rigParams: any): void;
  26428. /** @hidden */
  26429. static _setStereoscopicRigMode(camera: Camera): void;
  26430. /** @hidden */
  26431. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26432. /** @hidden */
  26433. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26434. /** @hidden */
  26435. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26436. /** @hidden */
  26437. _getVRProjectionMatrix(): Matrix;
  26438. protected _updateCameraRotationMatrix(): void;
  26439. protected _updateWebVRCameraRotationMatrix(): void;
  26440. /**
  26441. * This function MUST be overwritten by the different WebVR cameras available.
  26442. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26443. * @hidden
  26444. */
  26445. _getWebVRProjectionMatrix(): Matrix;
  26446. /**
  26447. * This function MUST be overwritten by the different WebVR cameras available.
  26448. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26449. * @hidden
  26450. */
  26451. _getWebVRViewMatrix(): Matrix;
  26452. /** @hidden */
  26453. setCameraRigParameter(name: string, value: any): void;
  26454. /**
  26455. * needs to be overridden by children so sub has required properties to be copied
  26456. * @hidden
  26457. */
  26458. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26459. /**
  26460. * May need to be overridden by children
  26461. * @hidden
  26462. */
  26463. _updateRigCameras(): void;
  26464. /** @hidden */
  26465. _setupInputs(): void;
  26466. /**
  26467. * Serialiaze the camera setup to a json represention
  26468. * @returns the JSON representation
  26469. */
  26470. serialize(): any;
  26471. /**
  26472. * Clones the current camera.
  26473. * @param name The cloned camera name
  26474. * @returns the cloned camera
  26475. */
  26476. clone(name: string): Camera;
  26477. /**
  26478. * Gets the direction of the camera relative to a given local axis.
  26479. * @param localAxis Defines the reference axis to provide a relative direction.
  26480. * @return the direction
  26481. */
  26482. getDirection(localAxis: Vector3): Vector3;
  26483. /**
  26484. * Returns the current camera absolute rotation
  26485. */
  26486. get absoluteRotation(): Quaternion;
  26487. /**
  26488. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26489. * @param localAxis Defines the reference axis to provide a relative direction.
  26490. * @param result Defines the vector to store the result in
  26491. */
  26492. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26493. /**
  26494. * Gets a camera constructor for a given camera type
  26495. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26496. * @param name The name of the camera the result will be able to instantiate
  26497. * @param scene The scene the result will construct the camera in
  26498. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26499. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26500. * @returns a factory method to construc the camera
  26501. */
  26502. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26503. /**
  26504. * Compute the world matrix of the camera.
  26505. * @returns the camera world matrix
  26506. */
  26507. computeWorldMatrix(): Matrix;
  26508. /**
  26509. * Parse a JSON and creates the camera from the parsed information
  26510. * @param parsedCamera The JSON to parse
  26511. * @param scene The scene to instantiate the camera in
  26512. * @returns the newly constructed camera
  26513. */
  26514. static Parse(parsedCamera: any, scene: Scene): Camera;
  26515. }
  26516. }
  26517. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26518. import { Nullable } from "babylonjs/types";
  26519. import { Scene } from "babylonjs/scene";
  26520. import { Vector4 } from "babylonjs/Maths/math.vector";
  26521. import { Mesh } from "babylonjs/Meshes/mesh";
  26522. /**
  26523. * Class containing static functions to help procedurally build meshes
  26524. */
  26525. export class DiscBuilder {
  26526. /**
  26527. * Creates a plane polygonal mesh. By default, this is a disc
  26528. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26529. * * 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
  26530. * * 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
  26531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26534. * @param name defines the name of the mesh
  26535. * @param options defines the options used to create the mesh
  26536. * @param scene defines the hosting scene
  26537. * @returns the plane polygonal mesh
  26538. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26539. */
  26540. static CreateDisc(name: string, options: {
  26541. radius?: number;
  26542. tessellation?: number;
  26543. arc?: number;
  26544. updatable?: boolean;
  26545. sideOrientation?: number;
  26546. frontUVs?: Vector4;
  26547. backUVs?: Vector4;
  26548. }, scene?: Nullable<Scene>): Mesh;
  26549. }
  26550. }
  26551. declare module "babylonjs/Materials/fresnelParameters" {
  26552. import { Color3 } from "babylonjs/Maths/math.color";
  26553. /**
  26554. * This represents all the required information to add a fresnel effect on a material:
  26555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26556. */
  26557. export class FresnelParameters {
  26558. private _isEnabled;
  26559. /**
  26560. * Define if the fresnel effect is enable or not.
  26561. */
  26562. get isEnabled(): boolean;
  26563. set isEnabled(value: boolean);
  26564. /**
  26565. * Define the color used on edges (grazing angle)
  26566. */
  26567. leftColor: Color3;
  26568. /**
  26569. * Define the color used on center
  26570. */
  26571. rightColor: Color3;
  26572. /**
  26573. * Define bias applied to computed fresnel term
  26574. */
  26575. bias: number;
  26576. /**
  26577. * Defined the power exponent applied to fresnel term
  26578. */
  26579. power: number;
  26580. /**
  26581. * Clones the current fresnel and its valuues
  26582. * @returns a clone fresnel configuration
  26583. */
  26584. clone(): FresnelParameters;
  26585. /**
  26586. * Serializes the current fresnel parameters to a JSON representation.
  26587. * @return the JSON serialization
  26588. */
  26589. serialize(): any;
  26590. /**
  26591. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26592. * @param parsedFresnelParameters Define the JSON representation
  26593. * @returns the parsed parameters
  26594. */
  26595. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26596. }
  26597. }
  26598. declare module "babylonjs/Materials/pushMaterial" {
  26599. import { Nullable } from "babylonjs/types";
  26600. import { Scene } from "babylonjs/scene";
  26601. import { Matrix } from "babylonjs/Maths/math.vector";
  26602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26603. import { Mesh } from "babylonjs/Meshes/mesh";
  26604. import { Material } from "babylonjs/Materials/material";
  26605. import { Effect } from "babylonjs/Materials/effect";
  26606. /**
  26607. * Base class of materials working in push mode in babylon JS
  26608. * @hidden
  26609. */
  26610. export class PushMaterial extends Material {
  26611. protected _activeEffect: Effect;
  26612. protected _normalMatrix: Matrix;
  26613. /**
  26614. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26615. * This means that the material can keep using a previous shader while a new one is being compiled.
  26616. * This is mostly used when shader parallel compilation is supported (true by default)
  26617. */
  26618. allowShaderHotSwapping: boolean;
  26619. constructor(name: string, scene: Scene);
  26620. getEffect(): Effect;
  26621. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26622. /**
  26623. * Binds the given world matrix to the active effect
  26624. *
  26625. * @param world the matrix to bind
  26626. */
  26627. bindOnlyWorldMatrix(world: Matrix): void;
  26628. /**
  26629. * Binds the given normal matrix to the active effect
  26630. *
  26631. * @param normalMatrix the matrix to bind
  26632. */
  26633. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26634. bind(world: Matrix, mesh?: Mesh): void;
  26635. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26636. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26637. }
  26638. }
  26639. declare module "babylonjs/Materials/materialFlags" {
  26640. /**
  26641. * This groups all the flags used to control the materials channel.
  26642. */
  26643. export class MaterialFlags {
  26644. private static _DiffuseTextureEnabled;
  26645. /**
  26646. * Are diffuse textures enabled in the application.
  26647. */
  26648. static get DiffuseTextureEnabled(): boolean;
  26649. static set DiffuseTextureEnabled(value: boolean);
  26650. private static _AmbientTextureEnabled;
  26651. /**
  26652. * Are ambient textures enabled in the application.
  26653. */
  26654. static get AmbientTextureEnabled(): boolean;
  26655. static set AmbientTextureEnabled(value: boolean);
  26656. private static _OpacityTextureEnabled;
  26657. /**
  26658. * Are opacity textures enabled in the application.
  26659. */
  26660. static get OpacityTextureEnabled(): boolean;
  26661. static set OpacityTextureEnabled(value: boolean);
  26662. private static _ReflectionTextureEnabled;
  26663. /**
  26664. * Are reflection textures enabled in the application.
  26665. */
  26666. static get ReflectionTextureEnabled(): boolean;
  26667. static set ReflectionTextureEnabled(value: boolean);
  26668. private static _EmissiveTextureEnabled;
  26669. /**
  26670. * Are emissive textures enabled in the application.
  26671. */
  26672. static get EmissiveTextureEnabled(): boolean;
  26673. static set EmissiveTextureEnabled(value: boolean);
  26674. private static _SpecularTextureEnabled;
  26675. /**
  26676. * Are specular textures enabled in the application.
  26677. */
  26678. static get SpecularTextureEnabled(): boolean;
  26679. static set SpecularTextureEnabled(value: boolean);
  26680. private static _BumpTextureEnabled;
  26681. /**
  26682. * Are bump textures enabled in the application.
  26683. */
  26684. static get BumpTextureEnabled(): boolean;
  26685. static set BumpTextureEnabled(value: boolean);
  26686. private static _LightmapTextureEnabled;
  26687. /**
  26688. * Are lightmap textures enabled in the application.
  26689. */
  26690. static get LightmapTextureEnabled(): boolean;
  26691. static set LightmapTextureEnabled(value: boolean);
  26692. private static _RefractionTextureEnabled;
  26693. /**
  26694. * Are refraction textures enabled in the application.
  26695. */
  26696. static get RefractionTextureEnabled(): boolean;
  26697. static set RefractionTextureEnabled(value: boolean);
  26698. private static _ColorGradingTextureEnabled;
  26699. /**
  26700. * Are color grading textures enabled in the application.
  26701. */
  26702. static get ColorGradingTextureEnabled(): boolean;
  26703. static set ColorGradingTextureEnabled(value: boolean);
  26704. private static _FresnelEnabled;
  26705. /**
  26706. * Are fresnels enabled in the application.
  26707. */
  26708. static get FresnelEnabled(): boolean;
  26709. static set FresnelEnabled(value: boolean);
  26710. private static _ClearCoatTextureEnabled;
  26711. /**
  26712. * Are clear coat textures enabled in the application.
  26713. */
  26714. static get ClearCoatTextureEnabled(): boolean;
  26715. static set ClearCoatTextureEnabled(value: boolean);
  26716. private static _ClearCoatBumpTextureEnabled;
  26717. /**
  26718. * Are clear coat bump textures enabled in the application.
  26719. */
  26720. static get ClearCoatBumpTextureEnabled(): boolean;
  26721. static set ClearCoatBumpTextureEnabled(value: boolean);
  26722. private static _ClearCoatTintTextureEnabled;
  26723. /**
  26724. * Are clear coat tint textures enabled in the application.
  26725. */
  26726. static get ClearCoatTintTextureEnabled(): boolean;
  26727. static set ClearCoatTintTextureEnabled(value: boolean);
  26728. private static _SheenTextureEnabled;
  26729. /**
  26730. * Are sheen textures enabled in the application.
  26731. */
  26732. static get SheenTextureEnabled(): boolean;
  26733. static set SheenTextureEnabled(value: boolean);
  26734. private static _AnisotropicTextureEnabled;
  26735. /**
  26736. * Are anisotropic textures enabled in the application.
  26737. */
  26738. static get AnisotropicTextureEnabled(): boolean;
  26739. static set AnisotropicTextureEnabled(value: boolean);
  26740. private static _ThicknessTextureEnabled;
  26741. /**
  26742. * Are thickness textures enabled in the application.
  26743. */
  26744. static get ThicknessTextureEnabled(): boolean;
  26745. static set ThicknessTextureEnabled(value: boolean);
  26746. }
  26747. }
  26748. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26749. /** @hidden */
  26750. export var defaultFragmentDeclaration: {
  26751. name: string;
  26752. shader: string;
  26753. };
  26754. }
  26755. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26756. /** @hidden */
  26757. export var defaultUboDeclaration: {
  26758. name: string;
  26759. shader: string;
  26760. };
  26761. }
  26762. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26763. /** @hidden */
  26764. export var lightFragmentDeclaration: {
  26765. name: string;
  26766. shader: string;
  26767. };
  26768. }
  26769. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26770. /** @hidden */
  26771. export var lightUboDeclaration: {
  26772. name: string;
  26773. shader: string;
  26774. };
  26775. }
  26776. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26777. /** @hidden */
  26778. export var lightsFragmentFunctions: {
  26779. name: string;
  26780. shader: string;
  26781. };
  26782. }
  26783. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26784. /** @hidden */
  26785. export var shadowsFragmentFunctions: {
  26786. name: string;
  26787. shader: string;
  26788. };
  26789. }
  26790. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26791. /** @hidden */
  26792. export var fresnelFunction: {
  26793. name: string;
  26794. shader: string;
  26795. };
  26796. }
  26797. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26798. /** @hidden */
  26799. export var reflectionFunction: {
  26800. name: string;
  26801. shader: string;
  26802. };
  26803. }
  26804. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26805. /** @hidden */
  26806. export var bumpFragmentFunctions: {
  26807. name: string;
  26808. shader: string;
  26809. };
  26810. }
  26811. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26812. /** @hidden */
  26813. export var logDepthDeclaration: {
  26814. name: string;
  26815. shader: string;
  26816. };
  26817. }
  26818. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26819. /** @hidden */
  26820. export var bumpFragment: {
  26821. name: string;
  26822. shader: string;
  26823. };
  26824. }
  26825. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26826. /** @hidden */
  26827. export var depthPrePass: {
  26828. name: string;
  26829. shader: string;
  26830. };
  26831. }
  26832. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26833. /** @hidden */
  26834. export var lightFragment: {
  26835. name: string;
  26836. shader: string;
  26837. };
  26838. }
  26839. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26840. /** @hidden */
  26841. export var logDepthFragment: {
  26842. name: string;
  26843. shader: string;
  26844. };
  26845. }
  26846. declare module "babylonjs/Shaders/default.fragment" {
  26847. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26848. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26850. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26851. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26852. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26853. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26854. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26855. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26856. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26857. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26858. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26859. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26860. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26861. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26862. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26863. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26864. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26865. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26866. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26867. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26868. /** @hidden */
  26869. export var defaultPixelShader: {
  26870. name: string;
  26871. shader: string;
  26872. };
  26873. }
  26874. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26875. /** @hidden */
  26876. export var defaultVertexDeclaration: {
  26877. name: string;
  26878. shader: string;
  26879. };
  26880. }
  26881. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26882. /** @hidden */
  26883. export var bumpVertexDeclaration: {
  26884. name: string;
  26885. shader: string;
  26886. };
  26887. }
  26888. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26889. /** @hidden */
  26890. export var bumpVertex: {
  26891. name: string;
  26892. shader: string;
  26893. };
  26894. }
  26895. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26896. /** @hidden */
  26897. export var fogVertex: {
  26898. name: string;
  26899. shader: string;
  26900. };
  26901. }
  26902. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26903. /** @hidden */
  26904. export var shadowsVertex: {
  26905. name: string;
  26906. shader: string;
  26907. };
  26908. }
  26909. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26910. /** @hidden */
  26911. export var pointCloudVertex: {
  26912. name: string;
  26913. shader: string;
  26914. };
  26915. }
  26916. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26917. /** @hidden */
  26918. export var logDepthVertex: {
  26919. name: string;
  26920. shader: string;
  26921. };
  26922. }
  26923. declare module "babylonjs/Shaders/default.vertex" {
  26924. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26925. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26926. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26927. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26928. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26929. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26930. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26931. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26932. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26933. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26934. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26935. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26936. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26938. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26939. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26940. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26941. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26942. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26943. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26944. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26945. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26946. /** @hidden */
  26947. export var defaultVertexShader: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Materials/standardMaterial" {
  26953. import { SmartArray } from "babylonjs/Misc/smartArray";
  26954. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26955. import { Nullable } from "babylonjs/types";
  26956. import { Scene } from "babylonjs/scene";
  26957. import { Matrix } from "babylonjs/Maths/math.vector";
  26958. import { Color3 } from "babylonjs/Maths/math.color";
  26959. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26961. import { Mesh } from "babylonjs/Meshes/mesh";
  26962. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26963. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26964. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26965. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26966. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26969. import "babylonjs/Shaders/default.fragment";
  26970. import "babylonjs/Shaders/default.vertex";
  26971. /** @hidden */
  26972. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26973. MAINUV1: boolean;
  26974. MAINUV2: boolean;
  26975. DIFFUSE: boolean;
  26976. DIFFUSEDIRECTUV: number;
  26977. AMBIENT: boolean;
  26978. AMBIENTDIRECTUV: number;
  26979. OPACITY: boolean;
  26980. OPACITYDIRECTUV: number;
  26981. OPACITYRGB: boolean;
  26982. REFLECTION: boolean;
  26983. EMISSIVE: boolean;
  26984. EMISSIVEDIRECTUV: number;
  26985. SPECULAR: boolean;
  26986. SPECULARDIRECTUV: number;
  26987. BUMP: boolean;
  26988. BUMPDIRECTUV: number;
  26989. PARALLAX: boolean;
  26990. PARALLAXOCCLUSION: boolean;
  26991. SPECULAROVERALPHA: boolean;
  26992. CLIPPLANE: boolean;
  26993. CLIPPLANE2: boolean;
  26994. CLIPPLANE3: boolean;
  26995. CLIPPLANE4: boolean;
  26996. CLIPPLANE5: boolean;
  26997. CLIPPLANE6: boolean;
  26998. ALPHATEST: boolean;
  26999. DEPTHPREPASS: boolean;
  27000. ALPHAFROMDIFFUSE: boolean;
  27001. POINTSIZE: boolean;
  27002. FOG: boolean;
  27003. SPECULARTERM: boolean;
  27004. DIFFUSEFRESNEL: boolean;
  27005. OPACITYFRESNEL: boolean;
  27006. REFLECTIONFRESNEL: boolean;
  27007. REFRACTIONFRESNEL: boolean;
  27008. EMISSIVEFRESNEL: boolean;
  27009. FRESNEL: boolean;
  27010. NORMAL: boolean;
  27011. UV1: boolean;
  27012. UV2: boolean;
  27013. VERTEXCOLOR: boolean;
  27014. VERTEXALPHA: boolean;
  27015. NUM_BONE_INFLUENCERS: number;
  27016. BonesPerMesh: number;
  27017. BONETEXTURE: boolean;
  27018. INSTANCES: boolean;
  27019. GLOSSINESS: boolean;
  27020. ROUGHNESS: boolean;
  27021. EMISSIVEASILLUMINATION: boolean;
  27022. LINKEMISSIVEWITHDIFFUSE: boolean;
  27023. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27024. LIGHTMAP: boolean;
  27025. LIGHTMAPDIRECTUV: number;
  27026. OBJECTSPACE_NORMALMAP: boolean;
  27027. USELIGHTMAPASSHADOWMAP: boolean;
  27028. REFLECTIONMAP_3D: boolean;
  27029. REFLECTIONMAP_SPHERICAL: boolean;
  27030. REFLECTIONMAP_PLANAR: boolean;
  27031. REFLECTIONMAP_CUBIC: boolean;
  27032. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27033. REFLECTIONMAP_PROJECTION: boolean;
  27034. REFLECTIONMAP_SKYBOX: boolean;
  27035. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27036. REFLECTIONMAP_EXPLICIT: boolean;
  27037. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27038. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27039. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27040. INVERTCUBICMAP: boolean;
  27041. LOGARITHMICDEPTH: boolean;
  27042. REFRACTION: boolean;
  27043. REFRACTIONMAP_3D: boolean;
  27044. REFLECTIONOVERALPHA: boolean;
  27045. TWOSIDEDLIGHTING: boolean;
  27046. SHADOWFLOAT: boolean;
  27047. MORPHTARGETS: boolean;
  27048. MORPHTARGETS_NORMAL: boolean;
  27049. MORPHTARGETS_TANGENT: boolean;
  27050. MORPHTARGETS_UV: boolean;
  27051. NUM_MORPH_INFLUENCERS: number;
  27052. NONUNIFORMSCALING: boolean;
  27053. PREMULTIPLYALPHA: boolean;
  27054. IMAGEPROCESSING: boolean;
  27055. VIGNETTE: boolean;
  27056. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27057. VIGNETTEBLENDMODEOPAQUE: boolean;
  27058. TONEMAPPING: boolean;
  27059. TONEMAPPING_ACES: boolean;
  27060. CONTRAST: boolean;
  27061. COLORCURVES: boolean;
  27062. COLORGRADING: boolean;
  27063. COLORGRADING3D: boolean;
  27064. SAMPLER3DGREENDEPTH: boolean;
  27065. SAMPLER3DBGRMAP: boolean;
  27066. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27067. MULTIVIEW: boolean;
  27068. /**
  27069. * If the reflection texture on this material is in linear color space
  27070. * @hidden
  27071. */
  27072. IS_REFLECTION_LINEAR: boolean;
  27073. /**
  27074. * If the refraction texture on this material is in linear color space
  27075. * @hidden
  27076. */
  27077. IS_REFRACTION_LINEAR: boolean;
  27078. EXPOSURE: boolean;
  27079. constructor();
  27080. setReflectionMode(modeToEnable: string): void;
  27081. }
  27082. /**
  27083. * This is the default material used in Babylon. It is the best trade off between quality
  27084. * and performances.
  27085. * @see http://doc.babylonjs.com/babylon101/materials
  27086. */
  27087. export class StandardMaterial extends PushMaterial {
  27088. private _diffuseTexture;
  27089. /**
  27090. * The basic texture of the material as viewed under a light.
  27091. */
  27092. diffuseTexture: Nullable<BaseTexture>;
  27093. private _ambientTexture;
  27094. /**
  27095. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27096. */
  27097. ambientTexture: Nullable<BaseTexture>;
  27098. private _opacityTexture;
  27099. /**
  27100. * Define the transparency of the material from a texture.
  27101. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27102. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27103. */
  27104. opacityTexture: Nullable<BaseTexture>;
  27105. private _reflectionTexture;
  27106. /**
  27107. * Define the texture used to display the reflection.
  27108. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27109. */
  27110. reflectionTexture: Nullable<BaseTexture>;
  27111. private _emissiveTexture;
  27112. /**
  27113. * Define texture of the material as if self lit.
  27114. * This will be mixed in the final result even in the absence of light.
  27115. */
  27116. emissiveTexture: Nullable<BaseTexture>;
  27117. private _specularTexture;
  27118. /**
  27119. * Define how the color and intensity of the highlight given by the light in the material.
  27120. */
  27121. specularTexture: Nullable<BaseTexture>;
  27122. private _bumpTexture;
  27123. /**
  27124. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27125. * 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.
  27126. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27127. */
  27128. bumpTexture: Nullable<BaseTexture>;
  27129. private _lightmapTexture;
  27130. /**
  27131. * Complex lighting can be computationally expensive to compute at runtime.
  27132. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27133. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27134. */
  27135. lightmapTexture: Nullable<BaseTexture>;
  27136. private _refractionTexture;
  27137. /**
  27138. * Define the texture used to display the refraction.
  27139. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27140. */
  27141. refractionTexture: Nullable<BaseTexture>;
  27142. /**
  27143. * The color of the material lit by the environmental background lighting.
  27144. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27145. */
  27146. ambientColor: Color3;
  27147. /**
  27148. * The basic color of the material as viewed under a light.
  27149. */
  27150. diffuseColor: Color3;
  27151. /**
  27152. * Define how the color and intensity of the highlight given by the light in the material.
  27153. */
  27154. specularColor: Color3;
  27155. /**
  27156. * Define the color of the material as if self lit.
  27157. * This will be mixed in the final result even in the absence of light.
  27158. */
  27159. emissiveColor: Color3;
  27160. /**
  27161. * Defines how sharp are the highlights in the material.
  27162. * The bigger the value the sharper giving a more glossy feeling to the result.
  27163. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27164. */
  27165. specularPower: number;
  27166. private _useAlphaFromDiffuseTexture;
  27167. /**
  27168. * Does the transparency come from the diffuse texture alpha channel.
  27169. */
  27170. useAlphaFromDiffuseTexture: boolean;
  27171. private _useEmissiveAsIllumination;
  27172. /**
  27173. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27174. */
  27175. useEmissiveAsIllumination: boolean;
  27176. private _linkEmissiveWithDiffuse;
  27177. /**
  27178. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27179. * the emissive level when the final color is close to one.
  27180. */
  27181. linkEmissiveWithDiffuse: boolean;
  27182. private _useSpecularOverAlpha;
  27183. /**
  27184. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27185. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27186. */
  27187. useSpecularOverAlpha: boolean;
  27188. private _useReflectionOverAlpha;
  27189. /**
  27190. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27191. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27192. */
  27193. useReflectionOverAlpha: boolean;
  27194. private _disableLighting;
  27195. /**
  27196. * Does lights from the scene impacts this material.
  27197. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27198. */
  27199. disableLighting: boolean;
  27200. private _useObjectSpaceNormalMap;
  27201. /**
  27202. * Allows using an object space normal map (instead of tangent space).
  27203. */
  27204. useObjectSpaceNormalMap: boolean;
  27205. private _useParallax;
  27206. /**
  27207. * Is parallax enabled or not.
  27208. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27209. */
  27210. useParallax: boolean;
  27211. private _useParallaxOcclusion;
  27212. /**
  27213. * Is parallax occlusion enabled or not.
  27214. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27215. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27216. */
  27217. useParallaxOcclusion: boolean;
  27218. /**
  27219. * 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.
  27220. */
  27221. parallaxScaleBias: number;
  27222. private _roughness;
  27223. /**
  27224. * Helps to define how blurry the reflections should appears in the material.
  27225. */
  27226. roughness: number;
  27227. /**
  27228. * In case of refraction, define the value of the index of refraction.
  27229. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27230. */
  27231. indexOfRefraction: number;
  27232. /**
  27233. * Invert the refraction texture alongside the y axis.
  27234. * It can be useful with procedural textures or probe for instance.
  27235. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27236. */
  27237. invertRefractionY: boolean;
  27238. /**
  27239. * Defines the alpha limits in alpha test mode.
  27240. */
  27241. alphaCutOff: number;
  27242. private _useLightmapAsShadowmap;
  27243. /**
  27244. * In case of light mapping, define whether the map contains light or shadow informations.
  27245. */
  27246. useLightmapAsShadowmap: boolean;
  27247. private _diffuseFresnelParameters;
  27248. /**
  27249. * Define the diffuse fresnel parameters of the material.
  27250. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27251. */
  27252. diffuseFresnelParameters: FresnelParameters;
  27253. private _opacityFresnelParameters;
  27254. /**
  27255. * Define the opacity fresnel parameters of the material.
  27256. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27257. */
  27258. opacityFresnelParameters: FresnelParameters;
  27259. private _reflectionFresnelParameters;
  27260. /**
  27261. * Define the reflection fresnel parameters of the material.
  27262. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27263. */
  27264. reflectionFresnelParameters: FresnelParameters;
  27265. private _refractionFresnelParameters;
  27266. /**
  27267. * Define the refraction fresnel parameters of the material.
  27268. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27269. */
  27270. refractionFresnelParameters: FresnelParameters;
  27271. private _emissiveFresnelParameters;
  27272. /**
  27273. * Define the emissive fresnel parameters of the material.
  27274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27275. */
  27276. emissiveFresnelParameters: FresnelParameters;
  27277. private _useReflectionFresnelFromSpecular;
  27278. /**
  27279. * If true automatically deducts the fresnels values from the material specularity.
  27280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27281. */
  27282. useReflectionFresnelFromSpecular: boolean;
  27283. private _useGlossinessFromSpecularMapAlpha;
  27284. /**
  27285. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27286. */
  27287. useGlossinessFromSpecularMapAlpha: boolean;
  27288. private _maxSimultaneousLights;
  27289. /**
  27290. * Defines the maximum number of lights that can be used in the material
  27291. */
  27292. maxSimultaneousLights: number;
  27293. private _invertNormalMapX;
  27294. /**
  27295. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27296. */
  27297. invertNormalMapX: boolean;
  27298. private _invertNormalMapY;
  27299. /**
  27300. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27301. */
  27302. invertNormalMapY: boolean;
  27303. private _twoSidedLighting;
  27304. /**
  27305. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27306. */
  27307. twoSidedLighting: boolean;
  27308. /**
  27309. * Default configuration related to image processing available in the standard Material.
  27310. */
  27311. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27312. /**
  27313. * Gets the image processing configuration used either in this material.
  27314. */
  27315. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27316. /**
  27317. * Sets the Default image processing configuration used either in the this material.
  27318. *
  27319. * If sets to null, the scene one is in use.
  27320. */
  27321. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27322. /**
  27323. * Keep track of the image processing observer to allow dispose and replace.
  27324. */
  27325. private _imageProcessingObserver;
  27326. /**
  27327. * Attaches a new image processing configuration to the Standard Material.
  27328. * @param configuration
  27329. */
  27330. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27331. /**
  27332. * Gets wether the color curves effect is enabled.
  27333. */
  27334. get cameraColorCurvesEnabled(): boolean;
  27335. /**
  27336. * Sets wether the color curves effect is enabled.
  27337. */
  27338. set cameraColorCurvesEnabled(value: boolean);
  27339. /**
  27340. * Gets wether the color grading effect is enabled.
  27341. */
  27342. get cameraColorGradingEnabled(): boolean;
  27343. /**
  27344. * Gets wether the color grading effect is enabled.
  27345. */
  27346. set cameraColorGradingEnabled(value: boolean);
  27347. /**
  27348. * Gets wether tonemapping is enabled or not.
  27349. */
  27350. get cameraToneMappingEnabled(): boolean;
  27351. /**
  27352. * Sets wether tonemapping is enabled or not
  27353. */
  27354. set cameraToneMappingEnabled(value: boolean);
  27355. /**
  27356. * The camera exposure used on this material.
  27357. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27358. * This corresponds to a photographic exposure.
  27359. */
  27360. get cameraExposure(): number;
  27361. /**
  27362. * The camera exposure used on this material.
  27363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27364. * This corresponds to a photographic exposure.
  27365. */
  27366. set cameraExposure(value: number);
  27367. /**
  27368. * Gets The camera contrast used on this material.
  27369. */
  27370. get cameraContrast(): number;
  27371. /**
  27372. * Sets The camera contrast used on this material.
  27373. */
  27374. set cameraContrast(value: number);
  27375. /**
  27376. * Gets the Color Grading 2D Lookup Texture.
  27377. */
  27378. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27379. /**
  27380. * Sets the Color Grading 2D Lookup Texture.
  27381. */
  27382. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27383. /**
  27384. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27385. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27386. * 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;
  27387. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27388. */
  27389. get cameraColorCurves(): Nullable<ColorCurves>;
  27390. /**
  27391. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27392. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27393. * 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;
  27394. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27395. */
  27396. set cameraColorCurves(value: Nullable<ColorCurves>);
  27397. /**
  27398. * Custom callback helping to override the default shader used in the material.
  27399. */
  27400. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27401. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27402. protected _worldViewProjectionMatrix: Matrix;
  27403. protected _globalAmbientColor: Color3;
  27404. protected _useLogarithmicDepth: boolean;
  27405. protected _rebuildInParallel: boolean;
  27406. /**
  27407. * Instantiates a new standard material.
  27408. * This is the default material used in Babylon. It is the best trade off between quality
  27409. * and performances.
  27410. * @see http://doc.babylonjs.com/babylon101/materials
  27411. * @param name Define the name of the material in the scene
  27412. * @param scene Define the scene the material belong to
  27413. */
  27414. constructor(name: string, scene: Scene);
  27415. /**
  27416. * Gets a boolean indicating that current material needs to register RTT
  27417. */
  27418. get hasRenderTargetTextures(): boolean;
  27419. /**
  27420. * Gets the current class name of the material e.g. "StandardMaterial"
  27421. * Mainly use in serialization.
  27422. * @returns the class name
  27423. */
  27424. getClassName(): string;
  27425. /**
  27426. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27427. * You can try switching to logarithmic depth.
  27428. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27429. */
  27430. get useLogarithmicDepth(): boolean;
  27431. set useLogarithmicDepth(value: boolean);
  27432. /**
  27433. * Specifies if the material will require alpha blending
  27434. * @returns a boolean specifying if alpha blending is needed
  27435. */
  27436. needAlphaBlending(): boolean;
  27437. /**
  27438. * Specifies if this material should be rendered in alpha test mode
  27439. * @returns a boolean specifying if an alpha test is needed.
  27440. */
  27441. needAlphaTesting(): boolean;
  27442. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27443. /**
  27444. * Get the texture used for alpha test purpose.
  27445. * @returns the diffuse texture in case of the standard material.
  27446. */
  27447. getAlphaTestTexture(): Nullable<BaseTexture>;
  27448. /**
  27449. * Get if the submesh is ready to be used and all its information available.
  27450. * Child classes can use it to update shaders
  27451. * @param mesh defines the mesh to check
  27452. * @param subMesh defines which submesh to check
  27453. * @param useInstances specifies that instances should be used
  27454. * @returns a boolean indicating that the submesh is ready or not
  27455. */
  27456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27457. /**
  27458. * Builds the material UBO layouts.
  27459. * Used internally during the effect preparation.
  27460. */
  27461. buildUniformLayout(): void;
  27462. /**
  27463. * Unbinds the material from the mesh
  27464. */
  27465. unbind(): void;
  27466. /**
  27467. * Binds the submesh to this material by preparing the effect and shader to draw
  27468. * @param world defines the world transformation matrix
  27469. * @param mesh defines the mesh containing the submesh
  27470. * @param subMesh defines the submesh to bind the material to
  27471. */
  27472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27473. /**
  27474. * Get the list of animatables in the material.
  27475. * @returns the list of animatables object used in the material
  27476. */
  27477. getAnimatables(): IAnimatable[];
  27478. /**
  27479. * Gets the active textures from the material
  27480. * @returns an array of textures
  27481. */
  27482. getActiveTextures(): BaseTexture[];
  27483. /**
  27484. * Specifies if the material uses a texture
  27485. * @param texture defines the texture to check against the material
  27486. * @returns a boolean specifying if the material uses the texture
  27487. */
  27488. hasTexture(texture: BaseTexture): boolean;
  27489. /**
  27490. * Disposes the material
  27491. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27492. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27493. */
  27494. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27495. /**
  27496. * Makes a duplicate of the material, and gives it a new name
  27497. * @param name defines the new name for the duplicated material
  27498. * @returns the cloned material
  27499. */
  27500. clone(name: string): StandardMaterial;
  27501. /**
  27502. * Serializes this material in a JSON representation
  27503. * @returns the serialized material object
  27504. */
  27505. serialize(): any;
  27506. /**
  27507. * Creates a standard material from parsed material data
  27508. * @param source defines the JSON representation of the material
  27509. * @param scene defines the hosting scene
  27510. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27511. * @returns a new standard material
  27512. */
  27513. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27514. /**
  27515. * Are diffuse textures enabled in the application.
  27516. */
  27517. static get DiffuseTextureEnabled(): boolean;
  27518. static set DiffuseTextureEnabled(value: boolean);
  27519. /**
  27520. * Are ambient textures enabled in the application.
  27521. */
  27522. static get AmbientTextureEnabled(): boolean;
  27523. static set AmbientTextureEnabled(value: boolean);
  27524. /**
  27525. * Are opacity textures enabled in the application.
  27526. */
  27527. static get OpacityTextureEnabled(): boolean;
  27528. static set OpacityTextureEnabled(value: boolean);
  27529. /**
  27530. * Are reflection textures enabled in the application.
  27531. */
  27532. static get ReflectionTextureEnabled(): boolean;
  27533. static set ReflectionTextureEnabled(value: boolean);
  27534. /**
  27535. * Are emissive textures enabled in the application.
  27536. */
  27537. static get EmissiveTextureEnabled(): boolean;
  27538. static set EmissiveTextureEnabled(value: boolean);
  27539. /**
  27540. * Are specular textures enabled in the application.
  27541. */
  27542. static get SpecularTextureEnabled(): boolean;
  27543. static set SpecularTextureEnabled(value: boolean);
  27544. /**
  27545. * Are bump textures enabled in the application.
  27546. */
  27547. static get BumpTextureEnabled(): boolean;
  27548. static set BumpTextureEnabled(value: boolean);
  27549. /**
  27550. * Are lightmap textures enabled in the application.
  27551. */
  27552. static get LightmapTextureEnabled(): boolean;
  27553. static set LightmapTextureEnabled(value: boolean);
  27554. /**
  27555. * Are refraction textures enabled in the application.
  27556. */
  27557. static get RefractionTextureEnabled(): boolean;
  27558. static set RefractionTextureEnabled(value: boolean);
  27559. /**
  27560. * Are color grading textures enabled in the application.
  27561. */
  27562. static get ColorGradingTextureEnabled(): boolean;
  27563. static set ColorGradingTextureEnabled(value: boolean);
  27564. /**
  27565. * Are fresnels enabled in the application.
  27566. */
  27567. static get FresnelEnabled(): boolean;
  27568. static set FresnelEnabled(value: boolean);
  27569. }
  27570. }
  27571. declare module "babylonjs/Particles/solidParticleSystem" {
  27572. import { Nullable } from "babylonjs/types";
  27573. import { Vector3 } from "babylonjs/Maths/math.vector";
  27574. import { Mesh } from "babylonjs/Meshes/mesh";
  27575. import { Scene, IDisposable } from "babylonjs/scene";
  27576. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27577. import { Material } from "babylonjs/Materials/material";
  27578. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27579. /**
  27580. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27581. *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.
  27582. * The SPS is also a particle system. It provides some methods to manage the particles.
  27583. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27584. *
  27585. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27586. */
  27587. export class SolidParticleSystem implements IDisposable {
  27588. /**
  27589. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27590. * Example : var p = SPS.particles[i];
  27591. */
  27592. particles: SolidParticle[];
  27593. /**
  27594. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27595. */
  27596. nbParticles: number;
  27597. /**
  27598. * If the particles must ever face the camera (default false). Useful for planar particles.
  27599. */
  27600. billboard: boolean;
  27601. /**
  27602. * Recompute normals when adding a shape
  27603. */
  27604. recomputeNormals: boolean;
  27605. /**
  27606. * This a counter ofr your own usage. It's not set by any SPS functions.
  27607. */
  27608. counter: number;
  27609. /**
  27610. * The SPS name. This name is also given to the underlying mesh.
  27611. */
  27612. name: string;
  27613. /**
  27614. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27615. */
  27616. mesh: Mesh;
  27617. /**
  27618. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27619. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27620. */
  27621. vars: any;
  27622. /**
  27623. * This array is populated when the SPS is set as 'pickable'.
  27624. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27625. * Each element of this array is an object `{idx: int, faceId: int}`.
  27626. * `idx` is the picked particle index in the `SPS.particles` array
  27627. * `faceId` is the picked face index counted within this particle.
  27628. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27629. */
  27630. pickedParticles: {
  27631. idx: number;
  27632. faceId: number;
  27633. }[];
  27634. /**
  27635. * This array is populated when `enableDepthSort` is set to true.
  27636. * Each element of this array is an instance of the class DepthSortedParticle.
  27637. */
  27638. depthSortedParticles: DepthSortedParticle[];
  27639. /**
  27640. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27641. * @hidden
  27642. */
  27643. _bSphereOnly: boolean;
  27644. /**
  27645. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27646. * @hidden
  27647. */
  27648. _bSphereRadiusFactor: number;
  27649. private _scene;
  27650. private _positions;
  27651. private _indices;
  27652. private _normals;
  27653. private _colors;
  27654. private _uvs;
  27655. private _indices32;
  27656. private _positions32;
  27657. private _normals32;
  27658. private _fixedNormal32;
  27659. private _colors32;
  27660. private _uvs32;
  27661. private _index;
  27662. private _updatable;
  27663. private _pickable;
  27664. private _isVisibilityBoxLocked;
  27665. private _alwaysVisible;
  27666. private _depthSort;
  27667. private _expandable;
  27668. private _shapeCounter;
  27669. private _copy;
  27670. private _color;
  27671. private _computeParticleColor;
  27672. private _computeParticleTexture;
  27673. private _computeParticleRotation;
  27674. private _computeParticleVertex;
  27675. private _computeBoundingBox;
  27676. private _depthSortParticles;
  27677. private _camera;
  27678. private _mustUnrotateFixedNormals;
  27679. private _particlesIntersect;
  27680. private _needs32Bits;
  27681. private _isNotBuilt;
  27682. private _lastParticleId;
  27683. private _idxOfId;
  27684. private _multimaterialEnabled;
  27685. private _useModelMaterial;
  27686. private _indicesByMaterial;
  27687. private _materialIndexes;
  27688. private _depthSortFunction;
  27689. private _materialSortFunction;
  27690. private _materials;
  27691. private _multimaterial;
  27692. private _materialIndexesById;
  27693. private _defaultMaterial;
  27694. private _autoUpdateSubMeshes;
  27695. /**
  27696. * Creates a SPS (Solid Particle System) object.
  27697. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27698. * @param scene (Scene) is the scene in which the SPS is added.
  27699. * @param options defines the options of the sps e.g.
  27700. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27701. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27702. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27703. * * 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.
  27704. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27705. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27706. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27707. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27708. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27709. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27710. */
  27711. constructor(name: string, scene: Scene, options?: {
  27712. updatable?: boolean;
  27713. isPickable?: boolean;
  27714. enableDepthSort?: boolean;
  27715. particleIntersection?: boolean;
  27716. boundingSphereOnly?: boolean;
  27717. bSphereRadiusFactor?: number;
  27718. expandable?: boolean;
  27719. useModelMaterial?: boolean;
  27720. enableMultiMaterial?: boolean;
  27721. });
  27722. /**
  27723. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27724. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27725. * @returns the created mesh
  27726. */
  27727. buildMesh(): Mesh;
  27728. /**
  27729. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27730. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27731. * Thus the particles generated from `digest()` have their property `position` set yet.
  27732. * @param mesh ( Mesh ) is the mesh to be digested
  27733. * @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
  27734. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27735. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27736. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27737. * @returns the current SPS
  27738. */
  27739. digest(mesh: Mesh, options?: {
  27740. facetNb?: number;
  27741. number?: number;
  27742. delta?: number;
  27743. storage?: [];
  27744. }): SolidParticleSystem;
  27745. /**
  27746. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27747. * @hidden
  27748. */
  27749. private _unrotateFixedNormals;
  27750. /**
  27751. * Resets the temporary working copy particle
  27752. * @hidden
  27753. */
  27754. private _resetCopy;
  27755. /**
  27756. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27757. * @param p the current index in the positions array to be updated
  27758. * @param ind the current index in the indices array
  27759. * @param shape a Vector3 array, the shape geometry
  27760. * @param positions the positions array to be updated
  27761. * @param meshInd the shape indices array
  27762. * @param indices the indices array to be updated
  27763. * @param meshUV the shape uv array
  27764. * @param uvs the uv array to be updated
  27765. * @param meshCol the shape color array
  27766. * @param colors the color array to be updated
  27767. * @param meshNor the shape normals array
  27768. * @param normals the normals array to be updated
  27769. * @param idx the particle index
  27770. * @param idxInShape the particle index in its shape
  27771. * @param options the addShape() method passed options
  27772. * @model the particle model
  27773. * @hidden
  27774. */
  27775. private _meshBuilder;
  27776. /**
  27777. * Returns a shape Vector3 array from positions float array
  27778. * @param positions float array
  27779. * @returns a vector3 array
  27780. * @hidden
  27781. */
  27782. private _posToShape;
  27783. /**
  27784. * Returns a shapeUV array from a float uvs (array deep copy)
  27785. * @param uvs as a float array
  27786. * @returns a shapeUV array
  27787. * @hidden
  27788. */
  27789. private _uvsToShapeUV;
  27790. /**
  27791. * Adds a new particle object in the particles array
  27792. * @param idx particle index in particles array
  27793. * @param id particle id
  27794. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27795. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27796. * @param model particle ModelShape object
  27797. * @param shapeId model shape identifier
  27798. * @param idxInShape index of the particle in the current model
  27799. * @param bInfo model bounding info object
  27800. * @param storage target storage array, if any
  27801. * @hidden
  27802. */
  27803. private _addParticle;
  27804. /**
  27805. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27806. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27807. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27808. * @param nb (positive integer) the number of particles to be created from this model
  27809. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27810. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27811. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27812. * @returns the number of shapes in the system
  27813. */
  27814. addShape(mesh: Mesh, nb: number, options?: {
  27815. positionFunction?: any;
  27816. vertexFunction?: any;
  27817. storage?: [];
  27818. }): number;
  27819. /**
  27820. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27821. * @hidden
  27822. */
  27823. private _rebuildParticle;
  27824. /**
  27825. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27826. * @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.
  27827. * @returns the SPS.
  27828. */
  27829. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27830. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27831. * Returns an array with the removed particles.
  27832. * 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.
  27833. * The SPS can't be empty so at least one particle needs to remain in place.
  27834. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27835. * @param start index of the first particle to remove
  27836. * @param end index of the last particle to remove (included)
  27837. * @returns an array populated with the removed particles
  27838. */
  27839. removeParticles(start: number, end: number): SolidParticle[];
  27840. /**
  27841. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27842. * @param solidParticleArray an array populated with Solid Particles objects
  27843. * @returns the SPS
  27844. */
  27845. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27846. /**
  27847. * Creates a new particle and modifies the SPS mesh geometry :
  27848. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27849. * - calls _addParticle() to populate the particle array
  27850. * factorized code from addShape() and insertParticlesFromArray()
  27851. * @param idx particle index in the particles array
  27852. * @param i particle index in its shape
  27853. * @param modelShape particle ModelShape object
  27854. * @param shape shape vertex array
  27855. * @param meshInd shape indices array
  27856. * @param meshUV shape uv array
  27857. * @param meshCol shape color array
  27858. * @param meshNor shape normals array
  27859. * @param bbInfo shape bounding info
  27860. * @param storage target particle storage
  27861. * @options addShape() passed options
  27862. * @hidden
  27863. */
  27864. private _insertNewParticle;
  27865. /**
  27866. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27867. * This method calls `updateParticle()` for each particle of the SPS.
  27868. * For an animated SPS, it is usually called within the render loop.
  27869. * 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.
  27870. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27871. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27872. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27873. * @returns the SPS.
  27874. */
  27875. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27876. /**
  27877. * Disposes the SPS.
  27878. */
  27879. dispose(): void;
  27880. /**
  27881. * Returns a SolidParticle object from its identifier : particle.id
  27882. * @param id (integer) the particle Id
  27883. * @returns the searched particle or null if not found in the SPS.
  27884. */
  27885. getParticleById(id: number): Nullable<SolidParticle>;
  27886. /**
  27887. * Returns a new array populated with the particles having the passed shapeId.
  27888. * @param shapeId (integer) the shape identifier
  27889. * @returns a new solid particle array
  27890. */
  27891. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27892. /**
  27893. * Populates the passed array "ref" with the particles having the passed shapeId.
  27894. * @param shapeId the shape identifier
  27895. * @returns the SPS
  27896. * @param ref
  27897. */
  27898. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27899. /**
  27900. * Computes the required SubMeshes according the materials assigned to the particles.
  27901. * @returns the solid particle system.
  27902. * Does nothing if called before the SPS mesh is built.
  27903. */
  27904. computeSubMeshes(): SolidParticleSystem;
  27905. /**
  27906. * Sorts the solid particles by material when MultiMaterial is enabled.
  27907. * Updates the indices32 array.
  27908. * Updates the indicesByMaterial array.
  27909. * Updates the mesh indices array.
  27910. * @returns the SPS
  27911. * @hidden
  27912. */
  27913. private _sortParticlesByMaterial;
  27914. /**
  27915. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27916. * @hidden
  27917. */
  27918. private _setMaterialIndexesById;
  27919. /**
  27920. * Returns an array with unique values of Materials from the passed array
  27921. * @param array the material array to be checked and filtered
  27922. * @hidden
  27923. */
  27924. private _filterUniqueMaterialId;
  27925. /**
  27926. * Sets a new Standard Material as _defaultMaterial if not already set.
  27927. * @hidden
  27928. */
  27929. private _setDefaultMaterial;
  27930. /**
  27931. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27932. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27933. * @returns the SPS.
  27934. */
  27935. refreshVisibleSize(): SolidParticleSystem;
  27936. /**
  27937. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27938. * @param size the size (float) of the visibility box
  27939. * note : this doesn't lock the SPS mesh bounding box.
  27940. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27941. */
  27942. setVisibilityBox(size: number): void;
  27943. /**
  27944. * Gets whether the SPS as always visible or not
  27945. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27946. */
  27947. get isAlwaysVisible(): boolean;
  27948. /**
  27949. * Sets the SPS as always visible or not
  27950. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27951. */
  27952. set isAlwaysVisible(val: boolean);
  27953. /**
  27954. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27955. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27956. */
  27957. set isVisibilityBoxLocked(val: boolean);
  27958. /**
  27959. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27960. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27961. */
  27962. get isVisibilityBoxLocked(): boolean;
  27963. /**
  27964. * Tells to `setParticles()` to compute the particle rotations or not.
  27965. * Default value : true. The SPS is faster when it's set to false.
  27966. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27967. */
  27968. set computeParticleRotation(val: boolean);
  27969. /**
  27970. * Tells to `setParticles()` to compute the particle colors or not.
  27971. * Default value : true. The SPS is faster when it's set to false.
  27972. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27973. */
  27974. set computeParticleColor(val: boolean);
  27975. set computeParticleTexture(val: boolean);
  27976. /**
  27977. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27978. * Default value : false. The SPS is faster when it's set to false.
  27979. * Note : the particle custom vertex positions aren't stored values.
  27980. */
  27981. set computeParticleVertex(val: boolean);
  27982. /**
  27983. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27984. */
  27985. set computeBoundingBox(val: boolean);
  27986. /**
  27987. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27988. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27989. * Default : `true`
  27990. */
  27991. set depthSortParticles(val: boolean);
  27992. /**
  27993. * Gets if `setParticles()` computes the particle rotations or not.
  27994. * Default value : true. The SPS is faster when it's set to false.
  27995. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27996. */
  27997. get computeParticleRotation(): boolean;
  27998. /**
  27999. * Gets if `setParticles()` computes the particle colors or not.
  28000. * Default value : true. The SPS is faster when it's set to false.
  28001. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28002. */
  28003. get computeParticleColor(): boolean;
  28004. /**
  28005. * Gets if `setParticles()` computes the particle textures or not.
  28006. * Default value : true. The SPS is faster when it's set to false.
  28007. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28008. */
  28009. get computeParticleTexture(): boolean;
  28010. /**
  28011. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28012. * Default value : false. The SPS is faster when it's set to false.
  28013. * Note : the particle custom vertex positions aren't stored values.
  28014. */
  28015. get computeParticleVertex(): boolean;
  28016. /**
  28017. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28018. */
  28019. get computeBoundingBox(): boolean;
  28020. /**
  28021. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28022. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28023. * Default : `true`
  28024. */
  28025. get depthSortParticles(): boolean;
  28026. /**
  28027. * Gets if the SPS is created as expandable at construction time.
  28028. * Default : `false`
  28029. */
  28030. get expandable(): boolean;
  28031. /**
  28032. * Gets if the SPS supports the Multi Materials
  28033. */
  28034. get multimaterialEnabled(): boolean;
  28035. /**
  28036. * Gets if the SPS uses the model materials for its own multimaterial.
  28037. */
  28038. get useModelMaterial(): boolean;
  28039. /**
  28040. * The SPS used material array.
  28041. */
  28042. get materials(): Material[];
  28043. /**
  28044. * Sets the SPS MultiMaterial from the passed materials.
  28045. * Note : the passed array is internally copied and not used then by reference.
  28046. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28047. */
  28048. setMultiMaterial(materials: Material[]): void;
  28049. /**
  28050. * The SPS computed multimaterial object
  28051. */
  28052. get multimaterial(): MultiMaterial;
  28053. set multimaterial(mm: MultiMaterial);
  28054. /**
  28055. * If the subMeshes must be updated on the next call to setParticles()
  28056. */
  28057. get autoUpdateSubMeshes(): boolean;
  28058. set autoUpdateSubMeshes(val: boolean);
  28059. /**
  28060. * This function does nothing. It may be overwritten to set all the particle first values.
  28061. * The SPS doesn't call this function, you may have to call it by your own.
  28062. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28063. */
  28064. initParticles(): void;
  28065. /**
  28066. * This function does nothing. It may be overwritten to recycle a particle.
  28067. * The SPS doesn't call this function, you may have to call it by your own.
  28068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28069. * @param particle The particle to recycle
  28070. * @returns the recycled particle
  28071. */
  28072. recycleParticle(particle: SolidParticle): SolidParticle;
  28073. /**
  28074. * Updates a particle : this function should be overwritten by the user.
  28075. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28077. * @example : just set a particle position or velocity and recycle conditions
  28078. * @param particle The particle to update
  28079. * @returns the updated particle
  28080. */
  28081. updateParticle(particle: SolidParticle): SolidParticle;
  28082. /**
  28083. * Updates a vertex of a particle : it can be overwritten by the user.
  28084. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28085. * @param particle the current particle
  28086. * @param vertex the current index of the current particle
  28087. * @param pt the index of the current vertex in the particle shape
  28088. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28089. * @example : just set a vertex particle position
  28090. * @returns the updated vertex
  28091. */
  28092. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28093. /**
  28094. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28095. * This does nothing and may be overwritten by the user.
  28096. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28097. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28098. * @param update the boolean update value actually passed to setParticles()
  28099. */
  28100. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28101. /**
  28102. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28103. * This will be passed three parameters.
  28104. * This does nothing and may be overwritten by the user.
  28105. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28106. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28107. * @param update the boolean update value actually passed to setParticles()
  28108. */
  28109. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28110. }
  28111. }
  28112. declare module "babylonjs/Particles/solidParticle" {
  28113. import { Nullable } from "babylonjs/types";
  28114. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28115. import { Color4 } from "babylonjs/Maths/math.color";
  28116. import { Mesh } from "babylonjs/Meshes/mesh";
  28117. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28118. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28119. import { Plane } from "babylonjs/Maths/math.plane";
  28120. import { Material } from "babylonjs/Materials/material";
  28121. /**
  28122. * Represents one particle of a solid particle system.
  28123. */
  28124. export class SolidParticle {
  28125. /**
  28126. * particle global index
  28127. */
  28128. idx: number;
  28129. /**
  28130. * particle identifier
  28131. */
  28132. id: number;
  28133. /**
  28134. * The color of the particle
  28135. */
  28136. color: Nullable<Color4>;
  28137. /**
  28138. * The world space position of the particle.
  28139. */
  28140. position: Vector3;
  28141. /**
  28142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28143. */
  28144. rotation: Vector3;
  28145. /**
  28146. * The world space rotation quaternion of the particle.
  28147. */
  28148. rotationQuaternion: Nullable<Quaternion>;
  28149. /**
  28150. * The scaling of the particle.
  28151. */
  28152. scaling: Vector3;
  28153. /**
  28154. * The uvs of the particle.
  28155. */
  28156. uvs: Vector4;
  28157. /**
  28158. * The current speed of the particle.
  28159. */
  28160. velocity: Vector3;
  28161. /**
  28162. * The pivot point in the particle local space.
  28163. */
  28164. pivot: Vector3;
  28165. /**
  28166. * Must the particle be translated from its pivot point in its local space ?
  28167. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28168. * Default : false
  28169. */
  28170. translateFromPivot: boolean;
  28171. /**
  28172. * Is the particle active or not ?
  28173. */
  28174. alive: boolean;
  28175. /**
  28176. * Is the particle visible or not ?
  28177. */
  28178. isVisible: boolean;
  28179. /**
  28180. * Index of this particle in the global "positions" array (Internal use)
  28181. * @hidden
  28182. */
  28183. _pos: number;
  28184. /**
  28185. * @hidden Index of this particle in the global "indices" array (Internal use)
  28186. */
  28187. _ind: number;
  28188. /**
  28189. * @hidden ModelShape of this particle (Internal use)
  28190. */
  28191. _model: ModelShape;
  28192. /**
  28193. * ModelShape id of this particle
  28194. */
  28195. shapeId: number;
  28196. /**
  28197. * Index of the particle in its shape id
  28198. */
  28199. idxInShape: number;
  28200. /**
  28201. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28202. */
  28203. _modelBoundingInfo: BoundingInfo;
  28204. /**
  28205. * @hidden Particle BoundingInfo object (Internal use)
  28206. */
  28207. _boundingInfo: BoundingInfo;
  28208. /**
  28209. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28210. */
  28211. _sps: SolidParticleSystem;
  28212. /**
  28213. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28214. */
  28215. _stillInvisible: boolean;
  28216. /**
  28217. * @hidden Last computed particle rotation matrix
  28218. */
  28219. _rotationMatrix: number[];
  28220. /**
  28221. * Parent particle Id, if any.
  28222. * Default null.
  28223. */
  28224. parentId: Nullable<number>;
  28225. /**
  28226. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28227. */
  28228. materialIndex: Nullable<number>;
  28229. /**
  28230. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28231. * The possible values are :
  28232. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28233. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28234. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28236. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28237. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28238. * */
  28239. cullingStrategy: number;
  28240. /**
  28241. * @hidden Internal global position in the SPS.
  28242. */
  28243. _globalPosition: Vector3;
  28244. /**
  28245. * Creates a Solid Particle object.
  28246. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28247. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28248. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28249. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28250. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28251. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28252. * @param shapeId (integer) is the model shape identifier in the SPS.
  28253. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28254. * @param sps defines the sps it is associated to
  28255. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28256. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28257. */
  28258. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28259. /**
  28260. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28261. * @param target the particle target
  28262. * @returns the current particle
  28263. */
  28264. copyToRef(target: SolidParticle): SolidParticle;
  28265. /**
  28266. * Legacy support, changed scale to scaling
  28267. */
  28268. get scale(): Vector3;
  28269. /**
  28270. * Legacy support, changed scale to scaling
  28271. */
  28272. set scale(scale: Vector3);
  28273. /**
  28274. * Legacy support, changed quaternion to rotationQuaternion
  28275. */
  28276. get quaternion(): Nullable<Quaternion>;
  28277. /**
  28278. * Legacy support, changed quaternion to rotationQuaternion
  28279. */
  28280. set quaternion(q: Nullable<Quaternion>);
  28281. /**
  28282. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28283. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28284. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28285. * @returns true if it intersects
  28286. */
  28287. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28288. /**
  28289. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28290. * A particle is in the frustum if its bounding box intersects the frustum
  28291. * @param frustumPlanes defines the frustum to test
  28292. * @returns true if the particle is in the frustum planes
  28293. */
  28294. isInFrustum(frustumPlanes: Plane[]): boolean;
  28295. /**
  28296. * get the rotation matrix of the particle
  28297. * @hidden
  28298. */
  28299. getRotationMatrix(m: Matrix): void;
  28300. }
  28301. /**
  28302. * Represents the shape of the model used by one particle of a solid particle system.
  28303. * SPS internal tool, don't use it manually.
  28304. */
  28305. export class ModelShape {
  28306. /**
  28307. * The shape id
  28308. * @hidden
  28309. */
  28310. shapeID: number;
  28311. /**
  28312. * flat array of model positions (internal use)
  28313. * @hidden
  28314. */
  28315. _shape: Vector3[];
  28316. /**
  28317. * flat array of model UVs (internal use)
  28318. * @hidden
  28319. */
  28320. _shapeUV: number[];
  28321. /**
  28322. * color array of the model
  28323. * @hidden
  28324. */
  28325. _shapeColors: number[];
  28326. /**
  28327. * indices array of the model
  28328. * @hidden
  28329. */
  28330. _indices: number[];
  28331. /**
  28332. * normals array of the model
  28333. * @hidden
  28334. */
  28335. _normals: number[];
  28336. /**
  28337. * length of the shape in the model indices array (internal use)
  28338. * @hidden
  28339. */
  28340. _indicesLength: number;
  28341. /**
  28342. * Custom position function (internal use)
  28343. * @hidden
  28344. */
  28345. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28346. /**
  28347. * Custom vertex function (internal use)
  28348. * @hidden
  28349. */
  28350. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28351. /**
  28352. * Model material (internal use)
  28353. * @hidden
  28354. */
  28355. _material: Nullable<Material>;
  28356. /**
  28357. * 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.
  28358. * SPS internal tool, don't use it manually.
  28359. * @hidden
  28360. */
  28361. 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>);
  28362. }
  28363. /**
  28364. * Represents a Depth Sorted Particle in the solid particle system.
  28365. * @hidden
  28366. */
  28367. export class DepthSortedParticle {
  28368. /**
  28369. * Index of the particle in the "indices" array
  28370. */
  28371. ind: number;
  28372. /**
  28373. * Length of the particle shape in the "indices" array
  28374. */
  28375. indicesLength: number;
  28376. /**
  28377. * Squared distance from the particle to the camera
  28378. */
  28379. sqDistance: number;
  28380. /**
  28381. * Material index when used with MultiMaterials
  28382. */
  28383. materialIndex: number;
  28384. /**
  28385. * Creates a new sorted particle
  28386. * @param materialIndex
  28387. */
  28388. constructor(ind: number, indLength: number, materialIndex: number);
  28389. }
  28390. }
  28391. declare module "babylonjs/Collisions/meshCollisionData" {
  28392. import { Collider } from "babylonjs/Collisions/collider";
  28393. import { Vector3 } from "babylonjs/Maths/math.vector";
  28394. import { Nullable } from "babylonjs/types";
  28395. import { Observer } from "babylonjs/Misc/observable";
  28396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28397. /**
  28398. * @hidden
  28399. */
  28400. export class _MeshCollisionData {
  28401. _checkCollisions: boolean;
  28402. _collisionMask: number;
  28403. _collisionGroup: number;
  28404. _collider: Nullable<Collider>;
  28405. _oldPositionForCollisions: Vector3;
  28406. _diffPositionForCollisions: Vector3;
  28407. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28408. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28409. }
  28410. }
  28411. declare module "babylonjs/Meshes/abstractMesh" {
  28412. import { Observable } from "babylonjs/Misc/observable";
  28413. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28414. import { Camera } from "babylonjs/Cameras/camera";
  28415. import { Scene, IDisposable } from "babylonjs/scene";
  28416. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28417. import { Node } from "babylonjs/node";
  28418. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28419. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28421. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28422. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28423. import { Material } from "babylonjs/Materials/material";
  28424. import { Light } from "babylonjs/Lights/light";
  28425. import { Skeleton } from "babylonjs/Bones/skeleton";
  28426. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28427. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28428. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28429. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28430. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28431. import { Plane } from "babylonjs/Maths/math.plane";
  28432. import { Ray } from "babylonjs/Culling/ray";
  28433. import { Collider } from "babylonjs/Collisions/collider";
  28434. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28435. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28436. /** @hidden */
  28437. class _FacetDataStorage {
  28438. facetPositions: Vector3[];
  28439. facetNormals: Vector3[];
  28440. facetPartitioning: number[][];
  28441. facetNb: number;
  28442. partitioningSubdivisions: number;
  28443. partitioningBBoxRatio: number;
  28444. facetDataEnabled: boolean;
  28445. facetParameters: any;
  28446. bbSize: Vector3;
  28447. subDiv: {
  28448. max: number;
  28449. X: number;
  28450. Y: number;
  28451. Z: number;
  28452. };
  28453. facetDepthSort: boolean;
  28454. facetDepthSortEnabled: boolean;
  28455. depthSortedIndices: IndicesArray;
  28456. depthSortedFacets: {
  28457. ind: number;
  28458. sqDistance: number;
  28459. }[];
  28460. facetDepthSortFunction: (f1: {
  28461. ind: number;
  28462. sqDistance: number;
  28463. }, f2: {
  28464. ind: number;
  28465. sqDistance: number;
  28466. }) => number;
  28467. facetDepthSortFrom: Vector3;
  28468. facetDepthSortOrigin: Vector3;
  28469. invertedMatrix: Matrix;
  28470. }
  28471. /**
  28472. * @hidden
  28473. **/
  28474. class _InternalAbstractMeshDataInfo {
  28475. _hasVertexAlpha: boolean;
  28476. _useVertexColors: boolean;
  28477. _numBoneInfluencers: number;
  28478. _applyFog: boolean;
  28479. _receiveShadows: boolean;
  28480. _facetData: _FacetDataStorage;
  28481. _visibility: number;
  28482. _skeleton: Nullable<Skeleton>;
  28483. _layerMask: number;
  28484. _computeBonesUsingShaders: boolean;
  28485. _isActive: boolean;
  28486. _onlyForInstances: boolean;
  28487. _isActiveIntermediate: boolean;
  28488. _onlyForInstancesIntermediate: boolean;
  28489. _actAsRegularMesh: boolean;
  28490. }
  28491. /**
  28492. * Class used to store all common mesh properties
  28493. */
  28494. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28495. /** No occlusion */
  28496. static OCCLUSION_TYPE_NONE: number;
  28497. /** Occlusion set to optimisitic */
  28498. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28499. /** Occlusion set to strict */
  28500. static OCCLUSION_TYPE_STRICT: number;
  28501. /** Use an accurante occlusion algorithm */
  28502. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28503. /** Use a conservative occlusion algorithm */
  28504. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28505. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28506. * Test order :
  28507. * Is the bounding sphere outside the frustum ?
  28508. * If not, are the bounding box vertices outside the frustum ?
  28509. * It not, then the cullable object is in the frustum.
  28510. */
  28511. static readonly CULLINGSTRATEGY_STANDARD: number;
  28512. /** Culling strategy : Bounding Sphere Only.
  28513. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28514. * It's also less accurate than the standard because some not visible objects can still be selected.
  28515. * Test : is the bounding sphere outside the frustum ?
  28516. * If not, then the cullable object is in the frustum.
  28517. */
  28518. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28519. /** Culling strategy : Optimistic Inclusion.
  28520. * This in an inclusion test first, then the standard exclusion test.
  28521. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28522. * 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.
  28523. * Anyway, it's as accurate as the standard strategy.
  28524. * Test :
  28525. * Is the cullable object bounding sphere center in the frustum ?
  28526. * If not, apply the default culling strategy.
  28527. */
  28528. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28529. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28530. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28531. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28532. * 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.
  28533. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28534. * Test :
  28535. * Is the cullable object bounding sphere center in the frustum ?
  28536. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28537. */
  28538. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28539. /**
  28540. * No billboard
  28541. */
  28542. static get BILLBOARDMODE_NONE(): number;
  28543. /** Billboard on X axis */
  28544. static get BILLBOARDMODE_X(): number;
  28545. /** Billboard on Y axis */
  28546. static get BILLBOARDMODE_Y(): number;
  28547. /** Billboard on Z axis */
  28548. static get BILLBOARDMODE_Z(): number;
  28549. /** Billboard on all axes */
  28550. static get BILLBOARDMODE_ALL(): number;
  28551. /** Billboard on using position instead of orientation */
  28552. static get BILLBOARDMODE_USE_POSITION(): number;
  28553. /** @hidden */
  28554. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28555. /**
  28556. * The culling strategy to use to check whether the mesh must be rendered or not.
  28557. * This value can be changed at any time and will be used on the next render mesh selection.
  28558. * The possible values are :
  28559. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28560. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28561. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28562. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28563. * Please read each static variable documentation to get details about the culling process.
  28564. * */
  28565. cullingStrategy: number;
  28566. /**
  28567. * Gets the number of facets in the mesh
  28568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28569. */
  28570. get facetNb(): number;
  28571. /**
  28572. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28574. */
  28575. get partitioningSubdivisions(): number;
  28576. set partitioningSubdivisions(nb: number);
  28577. /**
  28578. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28579. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28581. */
  28582. get partitioningBBoxRatio(): number;
  28583. set partitioningBBoxRatio(ratio: number);
  28584. /**
  28585. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28586. * Works only for updatable meshes.
  28587. * Doesn't work with multi-materials
  28588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28589. */
  28590. get mustDepthSortFacets(): boolean;
  28591. set mustDepthSortFacets(sort: boolean);
  28592. /**
  28593. * The location (Vector3) where the facet depth sort must be computed from.
  28594. * By default, the active camera position.
  28595. * Used only when facet depth sort is enabled
  28596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28597. */
  28598. get facetDepthSortFrom(): Vector3;
  28599. set facetDepthSortFrom(location: Vector3);
  28600. /**
  28601. * gets a boolean indicating if facetData is enabled
  28602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28603. */
  28604. get isFacetDataEnabled(): boolean;
  28605. /** @hidden */
  28606. _updateNonUniformScalingState(value: boolean): boolean;
  28607. /**
  28608. * An event triggered when this mesh collides with another one
  28609. */
  28610. onCollideObservable: Observable<AbstractMesh>;
  28611. /** Set a function to call when this mesh collides with another one */
  28612. set onCollide(callback: () => void);
  28613. /**
  28614. * An event triggered when the collision's position changes
  28615. */
  28616. onCollisionPositionChangeObservable: Observable<Vector3>;
  28617. /** Set a function to call when the collision's position changes */
  28618. set onCollisionPositionChange(callback: () => void);
  28619. /**
  28620. * An event triggered when material is changed
  28621. */
  28622. onMaterialChangedObservable: Observable<AbstractMesh>;
  28623. /**
  28624. * Gets or sets the orientation for POV movement & rotation
  28625. */
  28626. definedFacingForward: boolean;
  28627. /** @hidden */
  28628. _occlusionQuery: Nullable<WebGLQuery>;
  28629. /** @hidden */
  28630. _renderingGroup: Nullable<RenderingGroup>;
  28631. /**
  28632. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28633. */
  28634. get visibility(): number;
  28635. /**
  28636. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28637. */
  28638. set visibility(value: number);
  28639. /** Gets or sets the alpha index used to sort transparent meshes
  28640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28641. */
  28642. alphaIndex: number;
  28643. /**
  28644. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28645. */
  28646. isVisible: boolean;
  28647. /**
  28648. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28649. */
  28650. isPickable: boolean;
  28651. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28652. showSubMeshesBoundingBox: boolean;
  28653. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28654. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28655. */
  28656. isBlocker: boolean;
  28657. /**
  28658. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28659. */
  28660. enablePointerMoveEvents: boolean;
  28661. /**
  28662. * Specifies the rendering group id for this mesh (0 by default)
  28663. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28664. */
  28665. renderingGroupId: number;
  28666. private _material;
  28667. /** Gets or sets current material */
  28668. get material(): Nullable<Material>;
  28669. set material(value: Nullable<Material>);
  28670. /**
  28671. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28672. * @see http://doc.babylonjs.com/babylon101/shadows
  28673. */
  28674. get receiveShadows(): boolean;
  28675. set receiveShadows(value: boolean);
  28676. /** Defines color to use when rendering outline */
  28677. outlineColor: Color3;
  28678. /** Define width to use when rendering outline */
  28679. outlineWidth: number;
  28680. /** Defines color to use when rendering overlay */
  28681. overlayColor: Color3;
  28682. /** Defines alpha to use when rendering overlay */
  28683. overlayAlpha: number;
  28684. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28685. get hasVertexAlpha(): boolean;
  28686. set hasVertexAlpha(value: boolean);
  28687. /** 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) */
  28688. get useVertexColors(): boolean;
  28689. set useVertexColors(value: boolean);
  28690. /**
  28691. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28692. */
  28693. get computeBonesUsingShaders(): boolean;
  28694. set computeBonesUsingShaders(value: boolean);
  28695. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28696. get numBoneInfluencers(): number;
  28697. set numBoneInfluencers(value: number);
  28698. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28699. get applyFog(): boolean;
  28700. set applyFog(value: boolean);
  28701. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28702. useOctreeForRenderingSelection: boolean;
  28703. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28704. useOctreeForPicking: boolean;
  28705. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28706. useOctreeForCollisions: boolean;
  28707. /**
  28708. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28709. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28710. */
  28711. get layerMask(): number;
  28712. set layerMask(value: number);
  28713. /**
  28714. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28715. */
  28716. alwaysSelectAsActiveMesh: boolean;
  28717. /**
  28718. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28719. */
  28720. doNotSyncBoundingInfo: boolean;
  28721. /**
  28722. * Gets or sets the current action manager
  28723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28724. */
  28725. actionManager: Nullable<AbstractActionManager>;
  28726. private _meshCollisionData;
  28727. /**
  28728. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28729. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28730. */
  28731. ellipsoid: Vector3;
  28732. /**
  28733. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28735. */
  28736. ellipsoidOffset: Vector3;
  28737. /**
  28738. * Gets or sets a collision mask used to mask collisions (default is -1).
  28739. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28740. */
  28741. get collisionMask(): number;
  28742. set collisionMask(mask: number);
  28743. /**
  28744. * Gets or sets the current collision group mask (-1 by default).
  28745. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28746. */
  28747. get collisionGroup(): number;
  28748. set collisionGroup(mask: number);
  28749. /**
  28750. * Defines edge width used when edgesRenderer is enabled
  28751. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28752. */
  28753. edgesWidth: number;
  28754. /**
  28755. * Defines edge color used when edgesRenderer is enabled
  28756. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28757. */
  28758. edgesColor: Color4;
  28759. /** @hidden */
  28760. _edgesRenderer: Nullable<IEdgesRenderer>;
  28761. /** @hidden */
  28762. _masterMesh: Nullable<AbstractMesh>;
  28763. /** @hidden */
  28764. _boundingInfo: Nullable<BoundingInfo>;
  28765. /** @hidden */
  28766. _renderId: number;
  28767. /**
  28768. * Gets or sets the list of subMeshes
  28769. * @see http://doc.babylonjs.com/how_to/multi_materials
  28770. */
  28771. subMeshes: SubMesh[];
  28772. /** @hidden */
  28773. _intersectionsInProgress: AbstractMesh[];
  28774. /** @hidden */
  28775. _unIndexed: boolean;
  28776. /** @hidden */
  28777. _lightSources: Light[];
  28778. /** Gets the list of lights affecting that mesh */
  28779. get lightSources(): Light[];
  28780. /** @hidden */
  28781. get _positions(): Nullable<Vector3[]>;
  28782. /** @hidden */
  28783. _waitingData: {
  28784. lods: Nullable<any>;
  28785. actions: Nullable<any>;
  28786. freezeWorldMatrix: Nullable<boolean>;
  28787. };
  28788. /** @hidden */
  28789. _bonesTransformMatrices: Nullable<Float32Array>;
  28790. /** @hidden */
  28791. _transformMatrixTexture: Nullable<RawTexture>;
  28792. /**
  28793. * Gets or sets a skeleton to apply skining transformations
  28794. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28795. */
  28796. set skeleton(value: Nullable<Skeleton>);
  28797. get skeleton(): Nullable<Skeleton>;
  28798. /**
  28799. * An event triggered when the mesh is rebuilt.
  28800. */
  28801. onRebuildObservable: Observable<AbstractMesh>;
  28802. /**
  28803. * Creates a new AbstractMesh
  28804. * @param name defines the name of the mesh
  28805. * @param scene defines the hosting scene
  28806. */
  28807. constructor(name: string, scene?: Nullable<Scene>);
  28808. /**
  28809. * Returns the string "AbstractMesh"
  28810. * @returns "AbstractMesh"
  28811. */
  28812. getClassName(): string;
  28813. /**
  28814. * Gets a string representation of the current mesh
  28815. * @param fullDetails defines a boolean indicating if full details must be included
  28816. * @returns a string representation of the current mesh
  28817. */
  28818. toString(fullDetails?: boolean): string;
  28819. /**
  28820. * @hidden
  28821. */
  28822. protected _getEffectiveParent(): Nullable<Node>;
  28823. /** @hidden */
  28824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28825. /** @hidden */
  28826. _rebuild(): void;
  28827. /** @hidden */
  28828. _resyncLightSources(): void;
  28829. /** @hidden */
  28830. _resyncLightSource(light: Light): void;
  28831. /** @hidden */
  28832. _unBindEffect(): void;
  28833. /** @hidden */
  28834. _removeLightSource(light: Light, dispose: boolean): void;
  28835. private _markSubMeshesAsDirty;
  28836. /** @hidden */
  28837. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28838. /** @hidden */
  28839. _markSubMeshesAsAttributesDirty(): void;
  28840. /** @hidden */
  28841. _markSubMeshesAsMiscDirty(): void;
  28842. /**
  28843. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28844. */
  28845. get scaling(): Vector3;
  28846. set scaling(newScaling: Vector3);
  28847. /**
  28848. * Returns true if the mesh is blocked. Implemented by child classes
  28849. */
  28850. get isBlocked(): boolean;
  28851. /**
  28852. * Returns the mesh itself by default. Implemented by child classes
  28853. * @param camera defines the camera to use to pick the right LOD level
  28854. * @returns the currentAbstractMesh
  28855. */
  28856. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28857. /**
  28858. * Returns 0 by default. Implemented by child classes
  28859. * @returns an integer
  28860. */
  28861. getTotalVertices(): number;
  28862. /**
  28863. * Returns a positive integer : the total number of indices in this mesh geometry.
  28864. * @returns the numner of indices or zero if the mesh has no geometry.
  28865. */
  28866. getTotalIndices(): number;
  28867. /**
  28868. * Returns null by default. Implemented by child classes
  28869. * @returns null
  28870. */
  28871. getIndices(): Nullable<IndicesArray>;
  28872. /**
  28873. * Returns the array of the requested vertex data kind. Implemented by child classes
  28874. * @param kind defines the vertex data kind to use
  28875. * @returns null
  28876. */
  28877. getVerticesData(kind: string): Nullable<FloatArray>;
  28878. /**
  28879. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28880. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28881. * Note that a new underlying VertexBuffer object is created each call.
  28882. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28883. * @param kind defines vertex data kind:
  28884. * * VertexBuffer.PositionKind
  28885. * * VertexBuffer.UVKind
  28886. * * VertexBuffer.UV2Kind
  28887. * * VertexBuffer.UV3Kind
  28888. * * VertexBuffer.UV4Kind
  28889. * * VertexBuffer.UV5Kind
  28890. * * VertexBuffer.UV6Kind
  28891. * * VertexBuffer.ColorKind
  28892. * * VertexBuffer.MatricesIndicesKind
  28893. * * VertexBuffer.MatricesIndicesExtraKind
  28894. * * VertexBuffer.MatricesWeightsKind
  28895. * * VertexBuffer.MatricesWeightsExtraKind
  28896. * @param data defines the data source
  28897. * @param updatable defines if the data must be flagged as updatable (or static)
  28898. * @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
  28899. * @returns the current mesh
  28900. */
  28901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28902. /**
  28903. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28904. * If the mesh has no geometry, it is simply returned as it is.
  28905. * @param kind defines vertex data kind:
  28906. * * VertexBuffer.PositionKind
  28907. * * VertexBuffer.UVKind
  28908. * * VertexBuffer.UV2Kind
  28909. * * VertexBuffer.UV3Kind
  28910. * * VertexBuffer.UV4Kind
  28911. * * VertexBuffer.UV5Kind
  28912. * * VertexBuffer.UV6Kind
  28913. * * VertexBuffer.ColorKind
  28914. * * VertexBuffer.MatricesIndicesKind
  28915. * * VertexBuffer.MatricesIndicesExtraKind
  28916. * * VertexBuffer.MatricesWeightsKind
  28917. * * VertexBuffer.MatricesWeightsExtraKind
  28918. * @param data defines the data source
  28919. * @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
  28920. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28921. * @returns the current mesh
  28922. */
  28923. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28924. /**
  28925. * Sets the mesh indices,
  28926. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28927. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28928. * @param totalVertices Defines the total number of vertices
  28929. * @returns the current mesh
  28930. */
  28931. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28932. /**
  28933. * Gets a boolean indicating if specific vertex data is present
  28934. * @param kind defines the vertex data kind to use
  28935. * @returns true is data kind is present
  28936. */
  28937. isVerticesDataPresent(kind: string): boolean;
  28938. /**
  28939. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28940. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28941. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28942. * @returns a BoundingInfo
  28943. */
  28944. getBoundingInfo(): BoundingInfo;
  28945. /**
  28946. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28947. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28948. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28949. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28950. * @returns the current mesh
  28951. */
  28952. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28953. /**
  28954. * Overwrite the current bounding info
  28955. * @param boundingInfo defines the new bounding info
  28956. * @returns the current mesh
  28957. */
  28958. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28959. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28960. get useBones(): boolean;
  28961. /** @hidden */
  28962. _preActivate(): void;
  28963. /** @hidden */
  28964. _preActivateForIntermediateRendering(renderId: number): void;
  28965. /** @hidden */
  28966. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28967. /** @hidden */
  28968. _postActivate(): void;
  28969. /** @hidden */
  28970. _freeze(): void;
  28971. /** @hidden */
  28972. _unFreeze(): void;
  28973. /**
  28974. * Gets the current world matrix
  28975. * @returns a Matrix
  28976. */
  28977. getWorldMatrix(): Matrix;
  28978. /** @hidden */
  28979. _getWorldMatrixDeterminant(): number;
  28980. /**
  28981. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28982. */
  28983. get isAnInstance(): boolean;
  28984. /**
  28985. * Gets a boolean indicating if this mesh has instances
  28986. */
  28987. get hasInstances(): boolean;
  28988. /**
  28989. * Perform relative position change from the point of view of behind the front of the mesh.
  28990. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28991. * Supports definition of mesh facing forward or backward
  28992. * @param amountRight defines the distance on the right axis
  28993. * @param amountUp defines the distance on the up axis
  28994. * @param amountForward defines the distance on the forward axis
  28995. * @returns the current mesh
  28996. */
  28997. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28998. /**
  28999. * Calculate relative position change from the point of view of behind the front of the mesh.
  29000. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29001. * Supports definition of mesh facing forward or backward
  29002. * @param amountRight defines the distance on the right axis
  29003. * @param amountUp defines the distance on the up axis
  29004. * @param amountForward defines the distance on the forward axis
  29005. * @returns the new displacement vector
  29006. */
  29007. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29008. /**
  29009. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29010. * Supports definition of mesh facing forward or backward
  29011. * @param flipBack defines the flip
  29012. * @param twirlClockwise defines the twirl
  29013. * @param tiltRight defines the tilt
  29014. * @returns the current mesh
  29015. */
  29016. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29017. /**
  29018. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29019. * Supports definition of mesh facing forward or backward.
  29020. * @param flipBack defines the flip
  29021. * @param twirlClockwise defines the twirl
  29022. * @param tiltRight defines the tilt
  29023. * @returns the new rotation vector
  29024. */
  29025. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29026. /**
  29027. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29028. * This means the mesh underlying bounding box and sphere are recomputed.
  29029. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29030. * @returns the current mesh
  29031. */
  29032. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29033. /** @hidden */
  29034. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29035. /** @hidden */
  29036. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29037. /** @hidden */
  29038. _updateBoundingInfo(): AbstractMesh;
  29039. /** @hidden */
  29040. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29041. /** @hidden */
  29042. protected _afterComputeWorldMatrix(): void;
  29043. /** @hidden */
  29044. get _effectiveMesh(): AbstractMesh;
  29045. /**
  29046. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29047. * A mesh is in the frustum if its bounding box intersects the frustum
  29048. * @param frustumPlanes defines the frustum to test
  29049. * @returns true if the mesh is in the frustum planes
  29050. */
  29051. isInFrustum(frustumPlanes: Plane[]): boolean;
  29052. /**
  29053. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29054. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29055. * @param frustumPlanes defines the frustum to test
  29056. * @returns true if the mesh is completely in the frustum planes
  29057. */
  29058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29059. /**
  29060. * True if the mesh intersects another mesh or a SolidParticle object
  29061. * @param mesh defines a target mesh or SolidParticle to test
  29062. * @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)
  29063. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29064. * @returns true if there is an intersection
  29065. */
  29066. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29067. /**
  29068. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29069. * @param point defines the point to test
  29070. * @returns true if there is an intersection
  29071. */
  29072. intersectsPoint(point: Vector3): boolean;
  29073. /**
  29074. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29076. */
  29077. get checkCollisions(): boolean;
  29078. set checkCollisions(collisionEnabled: boolean);
  29079. /**
  29080. * Gets Collider object used to compute collisions (not physics)
  29081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29082. */
  29083. get collider(): Nullable<Collider>;
  29084. /**
  29085. * Move the mesh using collision engine
  29086. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29087. * @param displacement defines the requested displacement vector
  29088. * @returns the current mesh
  29089. */
  29090. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29091. private _onCollisionPositionChange;
  29092. /** @hidden */
  29093. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29094. /** @hidden */
  29095. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29096. /** @hidden */
  29097. _checkCollision(collider: Collider): AbstractMesh;
  29098. /** @hidden */
  29099. _generatePointsArray(): boolean;
  29100. /**
  29101. * Checks if the passed Ray intersects with the mesh
  29102. * @param ray defines the ray to use
  29103. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29104. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29105. * @returns the picking info
  29106. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29107. */
  29108. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29109. /**
  29110. * Clones the current mesh
  29111. * @param name defines the mesh name
  29112. * @param newParent defines the new mesh parent
  29113. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29114. * @returns the new mesh
  29115. */
  29116. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29117. /**
  29118. * Disposes all the submeshes of the current meshnp
  29119. * @returns the current mesh
  29120. */
  29121. releaseSubMeshes(): AbstractMesh;
  29122. /**
  29123. * Releases resources associated with this abstract mesh.
  29124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29126. */
  29127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29128. /**
  29129. * Adds the passed mesh as a child to the current mesh
  29130. * @param mesh defines the child mesh
  29131. * @returns the current mesh
  29132. */
  29133. addChild(mesh: AbstractMesh): AbstractMesh;
  29134. /**
  29135. * Removes the passed mesh from the current mesh children list
  29136. * @param mesh defines the child mesh
  29137. * @returns the current mesh
  29138. */
  29139. removeChild(mesh: AbstractMesh): AbstractMesh;
  29140. /** @hidden */
  29141. private _initFacetData;
  29142. /**
  29143. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29144. * This method can be called within the render loop.
  29145. * 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
  29146. * @returns the current mesh
  29147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29148. */
  29149. updateFacetData(): AbstractMesh;
  29150. /**
  29151. * Returns the facetLocalNormals array.
  29152. * The normals are expressed in the mesh local spac
  29153. * @returns an array of Vector3
  29154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29155. */
  29156. getFacetLocalNormals(): Vector3[];
  29157. /**
  29158. * Returns the facetLocalPositions array.
  29159. * The facet positions are expressed in the mesh local space
  29160. * @returns an array of Vector3
  29161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29162. */
  29163. getFacetLocalPositions(): Vector3[];
  29164. /**
  29165. * Returns the facetLocalPartioning array
  29166. * @returns an array of array of numbers
  29167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29168. */
  29169. getFacetLocalPartitioning(): number[][];
  29170. /**
  29171. * Returns the i-th facet position in the world system.
  29172. * This method allocates a new Vector3 per call
  29173. * @param i defines the facet index
  29174. * @returns a new Vector3
  29175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29176. */
  29177. getFacetPosition(i: number): Vector3;
  29178. /**
  29179. * Sets the reference Vector3 with the i-th facet position in the world system
  29180. * @param i defines the facet index
  29181. * @param ref defines the target vector
  29182. * @returns the current mesh
  29183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29184. */
  29185. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29186. /**
  29187. * Returns the i-th facet normal in the world system.
  29188. * This method allocates a new Vector3 per call
  29189. * @param i defines the facet index
  29190. * @returns a new Vector3
  29191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29192. */
  29193. getFacetNormal(i: number): Vector3;
  29194. /**
  29195. * Sets the reference Vector3 with the i-th facet normal in the world system
  29196. * @param i defines the facet index
  29197. * @param ref defines the target vector
  29198. * @returns the current mesh
  29199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29200. */
  29201. getFacetNormalToRef(i: number, ref: Vector3): this;
  29202. /**
  29203. * 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)
  29204. * @param x defines x coordinate
  29205. * @param y defines y coordinate
  29206. * @param z defines z coordinate
  29207. * @returns the array of facet indexes
  29208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29209. */
  29210. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29211. /**
  29212. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29213. * @param projected sets as the (x,y,z) world projection on the facet
  29214. * @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
  29215. * @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
  29216. * @param x defines x coordinate
  29217. * @param y defines y coordinate
  29218. * @param z defines z coordinate
  29219. * @returns the face index if found (or null instead)
  29220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29221. */
  29222. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29223. /**
  29224. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29225. * @param projected sets as the (x,y,z) local projection on the facet
  29226. * @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
  29227. * @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
  29228. * @param x defines x coordinate
  29229. * @param y defines y coordinate
  29230. * @param z defines z coordinate
  29231. * @returns the face index if found (or null instead)
  29232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29233. */
  29234. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29235. /**
  29236. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29237. * @returns the parameters
  29238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29239. */
  29240. getFacetDataParameters(): any;
  29241. /**
  29242. * Disables the feature FacetData and frees the related memory
  29243. * @returns the current mesh
  29244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29245. */
  29246. disableFacetData(): AbstractMesh;
  29247. /**
  29248. * Updates the AbstractMesh indices array
  29249. * @param indices defines the data source
  29250. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29251. * @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)
  29252. * @returns the current mesh
  29253. */
  29254. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29255. /**
  29256. * Creates new normals data for the mesh
  29257. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29258. * @returns the current mesh
  29259. */
  29260. createNormals(updatable: boolean): AbstractMesh;
  29261. /**
  29262. * Align the mesh with a normal
  29263. * @param normal defines the normal to use
  29264. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29265. * @returns the current mesh
  29266. */
  29267. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29268. /** @hidden */
  29269. _checkOcclusionQuery(): boolean;
  29270. /**
  29271. * Disables the mesh edge rendering mode
  29272. * @returns the currentAbstractMesh
  29273. */
  29274. disableEdgesRendering(): AbstractMesh;
  29275. /**
  29276. * Enables the edge rendering mode on the mesh.
  29277. * This mode makes the mesh edges visible
  29278. * @param epsilon defines the maximal distance between two angles to detect a face
  29279. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29280. * @returns the currentAbstractMesh
  29281. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29282. */
  29283. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29284. }
  29285. }
  29286. declare module "babylonjs/Actions/actionEvent" {
  29287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29288. import { Nullable } from "babylonjs/types";
  29289. import { Sprite } from "babylonjs/Sprites/sprite";
  29290. import { Scene } from "babylonjs/scene";
  29291. import { Vector2 } from "babylonjs/Maths/math.vector";
  29292. /**
  29293. * Interface used to define ActionEvent
  29294. */
  29295. export interface IActionEvent {
  29296. /** The mesh or sprite that triggered the action */
  29297. source: any;
  29298. /** The X mouse cursor position at the time of the event */
  29299. pointerX: number;
  29300. /** The Y mouse cursor position at the time of the event */
  29301. pointerY: number;
  29302. /** The mesh that is currently pointed at (can be null) */
  29303. meshUnderPointer: Nullable<AbstractMesh>;
  29304. /** the original (browser) event that triggered the ActionEvent */
  29305. sourceEvent?: any;
  29306. /** additional data for the event */
  29307. additionalData?: any;
  29308. }
  29309. /**
  29310. * ActionEvent is the event being sent when an action is triggered.
  29311. */
  29312. export class ActionEvent implements IActionEvent {
  29313. /** The mesh or sprite that triggered the action */
  29314. source: any;
  29315. /** The X mouse cursor position at the time of the event */
  29316. pointerX: number;
  29317. /** The Y mouse cursor position at the time of the event */
  29318. pointerY: number;
  29319. /** The mesh that is currently pointed at (can be null) */
  29320. meshUnderPointer: Nullable<AbstractMesh>;
  29321. /** the original (browser) event that triggered the ActionEvent */
  29322. sourceEvent?: any;
  29323. /** additional data for the event */
  29324. additionalData?: any;
  29325. /**
  29326. * Creates a new ActionEvent
  29327. * @param source The mesh or sprite that triggered the action
  29328. * @param pointerX The X mouse cursor position at the time of the event
  29329. * @param pointerY The Y mouse cursor position at the time of the event
  29330. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29331. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29332. * @param additionalData additional data for the event
  29333. */
  29334. constructor(
  29335. /** The mesh or sprite that triggered the action */
  29336. source: any,
  29337. /** The X mouse cursor position at the time of the event */
  29338. pointerX: number,
  29339. /** The Y mouse cursor position at the time of the event */
  29340. pointerY: number,
  29341. /** The mesh that is currently pointed at (can be null) */
  29342. meshUnderPointer: Nullable<AbstractMesh>,
  29343. /** the original (browser) event that triggered the ActionEvent */
  29344. sourceEvent?: any,
  29345. /** additional data for the event */
  29346. additionalData?: any);
  29347. /**
  29348. * Helper function to auto-create an ActionEvent from a source mesh.
  29349. * @param source The source mesh that triggered the event
  29350. * @param evt The original (browser) event
  29351. * @param additionalData additional data for the event
  29352. * @returns the new ActionEvent
  29353. */
  29354. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29355. /**
  29356. * Helper function to auto-create an ActionEvent from a source sprite
  29357. * @param source The source sprite that triggered the event
  29358. * @param scene Scene associated with the sprite
  29359. * @param evt The original (browser) event
  29360. * @param additionalData additional data for the event
  29361. * @returns the new ActionEvent
  29362. */
  29363. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29364. /**
  29365. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29366. * @param scene the scene where the event occurred
  29367. * @param evt The original (browser) event
  29368. * @returns the new ActionEvent
  29369. */
  29370. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29371. /**
  29372. * Helper function to auto-create an ActionEvent from a primitive
  29373. * @param prim defines the target primitive
  29374. * @param pointerPos defines the pointer position
  29375. * @param evt The original (browser) event
  29376. * @param additionalData additional data for the event
  29377. * @returns the new ActionEvent
  29378. */
  29379. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29380. }
  29381. }
  29382. declare module "babylonjs/Actions/abstractActionManager" {
  29383. import { IDisposable } from "babylonjs/scene";
  29384. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29385. import { IAction } from "babylonjs/Actions/action";
  29386. import { Nullable } from "babylonjs/types";
  29387. /**
  29388. * Abstract class used to decouple action Manager from scene and meshes.
  29389. * Do not instantiate.
  29390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29391. */
  29392. export abstract class AbstractActionManager implements IDisposable {
  29393. /** Gets the list of active triggers */
  29394. static Triggers: {
  29395. [key: string]: number;
  29396. };
  29397. /** Gets the cursor to use when hovering items */
  29398. hoverCursor: string;
  29399. /** Gets the list of actions */
  29400. actions: IAction[];
  29401. /**
  29402. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29403. */
  29404. isRecursive: boolean;
  29405. /**
  29406. * Releases all associated resources
  29407. */
  29408. abstract dispose(): void;
  29409. /**
  29410. * Does this action manager has pointer triggers
  29411. */
  29412. abstract get hasPointerTriggers(): boolean;
  29413. /**
  29414. * Does this action manager has pick triggers
  29415. */
  29416. abstract get hasPickTriggers(): boolean;
  29417. /**
  29418. * Process a specific trigger
  29419. * @param trigger defines the trigger to process
  29420. * @param evt defines the event details to be processed
  29421. */
  29422. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29423. /**
  29424. * Does this action manager handles actions of any of the given triggers
  29425. * @param triggers defines the triggers to be tested
  29426. * @return a boolean indicating whether one (or more) of the triggers is handled
  29427. */
  29428. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29429. /**
  29430. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29431. * speed.
  29432. * @param triggerA defines the trigger to be tested
  29433. * @param triggerB defines the trigger to be tested
  29434. * @return a boolean indicating whether one (or more) of the triggers is handled
  29435. */
  29436. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29437. /**
  29438. * Does this action manager handles actions of a given trigger
  29439. * @param trigger defines the trigger to be tested
  29440. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29441. * @return whether the trigger is handled
  29442. */
  29443. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29444. /**
  29445. * Serialize this manager to a JSON object
  29446. * @param name defines the property name to store this manager
  29447. * @returns a JSON representation of this manager
  29448. */
  29449. abstract serialize(name: string): any;
  29450. /**
  29451. * Registers an action to this action manager
  29452. * @param action defines the action to be registered
  29453. * @return the action amended (prepared) after registration
  29454. */
  29455. abstract registerAction(action: IAction): Nullable<IAction>;
  29456. /**
  29457. * Unregisters an action to this action manager
  29458. * @param action defines the action to be unregistered
  29459. * @return a boolean indicating whether the action has been unregistered
  29460. */
  29461. abstract unregisterAction(action: IAction): Boolean;
  29462. /**
  29463. * Does exist one action manager with at least one trigger
  29464. **/
  29465. static get HasTriggers(): boolean;
  29466. /**
  29467. * Does exist one action manager with at least one pick trigger
  29468. **/
  29469. static get HasPickTriggers(): boolean;
  29470. /**
  29471. * Does exist one action manager that handles actions of a given trigger
  29472. * @param trigger defines the trigger to be tested
  29473. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29474. **/
  29475. static HasSpecificTrigger(trigger: number): boolean;
  29476. }
  29477. }
  29478. declare module "babylonjs/node" {
  29479. import { Scene } from "babylonjs/scene";
  29480. import { Nullable } from "babylonjs/types";
  29481. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29482. import { Engine } from "babylonjs/Engines/engine";
  29483. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29484. import { Observable } from "babylonjs/Misc/observable";
  29485. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29486. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29487. import { Animatable } from "babylonjs/Animations/animatable";
  29488. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29489. import { Animation } from "babylonjs/Animations/animation";
  29490. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29492. /**
  29493. * Defines how a node can be built from a string name.
  29494. */
  29495. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29496. /**
  29497. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29498. */
  29499. export class Node implements IBehaviorAware<Node> {
  29500. /** @hidden */
  29501. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29502. private static _NodeConstructors;
  29503. /**
  29504. * Add a new node constructor
  29505. * @param type defines the type name of the node to construct
  29506. * @param constructorFunc defines the constructor function
  29507. */
  29508. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29509. /**
  29510. * Returns a node constructor based on type name
  29511. * @param type defines the type name
  29512. * @param name defines the new node name
  29513. * @param scene defines the hosting scene
  29514. * @param options defines optional options to transmit to constructors
  29515. * @returns the new constructor or null
  29516. */
  29517. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29518. /**
  29519. * Gets or sets the name of the node
  29520. */
  29521. name: string;
  29522. /**
  29523. * Gets or sets the id of the node
  29524. */
  29525. id: string;
  29526. /**
  29527. * Gets or sets the unique id of the node
  29528. */
  29529. uniqueId: number;
  29530. /**
  29531. * Gets or sets a string used to store user defined state for the node
  29532. */
  29533. state: string;
  29534. /**
  29535. * Gets or sets an object used to store user defined information for the node
  29536. */
  29537. metadata: any;
  29538. /**
  29539. * For internal use only. Please do not use.
  29540. */
  29541. reservedDataStore: any;
  29542. /**
  29543. * List of inspectable custom properties (used by the Inspector)
  29544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29545. */
  29546. inspectableCustomProperties: IInspectable[];
  29547. private _doNotSerialize;
  29548. /**
  29549. * Gets or sets a boolean used to define if the node must be serialized
  29550. */
  29551. get doNotSerialize(): boolean;
  29552. set doNotSerialize(value: boolean);
  29553. /** @hidden */
  29554. _isDisposed: boolean;
  29555. /**
  29556. * Gets a list of Animations associated with the node
  29557. */
  29558. animations: import("babylonjs/Animations/animation").Animation[];
  29559. protected _ranges: {
  29560. [name: string]: Nullable<AnimationRange>;
  29561. };
  29562. /**
  29563. * Callback raised when the node is ready to be used
  29564. */
  29565. onReady: Nullable<(node: Node) => void>;
  29566. private _isEnabled;
  29567. private _isParentEnabled;
  29568. private _isReady;
  29569. /** @hidden */
  29570. _currentRenderId: number;
  29571. private _parentUpdateId;
  29572. /** @hidden */
  29573. _childUpdateId: number;
  29574. /** @hidden */
  29575. _waitingParentId: Nullable<string>;
  29576. /** @hidden */
  29577. _scene: Scene;
  29578. /** @hidden */
  29579. _cache: any;
  29580. private _parentNode;
  29581. private _children;
  29582. /** @hidden */
  29583. _worldMatrix: Matrix;
  29584. /** @hidden */
  29585. _worldMatrixDeterminant: number;
  29586. /** @hidden */
  29587. _worldMatrixDeterminantIsDirty: boolean;
  29588. /** @hidden */
  29589. private _sceneRootNodesIndex;
  29590. /**
  29591. * Gets a boolean indicating if the node has been disposed
  29592. * @returns true if the node was disposed
  29593. */
  29594. isDisposed(): boolean;
  29595. /**
  29596. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29597. * @see https://doc.babylonjs.com/how_to/parenting
  29598. */
  29599. set parent(parent: Nullable<Node>);
  29600. get parent(): Nullable<Node>;
  29601. /** @hidden */
  29602. _addToSceneRootNodes(): void;
  29603. /** @hidden */
  29604. _removeFromSceneRootNodes(): void;
  29605. private _animationPropertiesOverride;
  29606. /**
  29607. * Gets or sets the animation properties override
  29608. */
  29609. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29610. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29611. /**
  29612. * Gets a string idenfifying the name of the class
  29613. * @returns "Node" string
  29614. */
  29615. getClassName(): string;
  29616. /** @hidden */
  29617. readonly _isNode: boolean;
  29618. /**
  29619. * An event triggered when the mesh is disposed
  29620. */
  29621. onDisposeObservable: Observable<Node>;
  29622. private _onDisposeObserver;
  29623. /**
  29624. * Sets a callback that will be raised when the node will be disposed
  29625. */
  29626. set onDispose(callback: () => void);
  29627. /**
  29628. * Creates a new Node
  29629. * @param name the name and id to be given to this node
  29630. * @param scene the scene this node will be added to
  29631. */
  29632. constructor(name: string, scene?: Nullable<Scene>);
  29633. /**
  29634. * Gets the scene of the node
  29635. * @returns a scene
  29636. */
  29637. getScene(): Scene;
  29638. /**
  29639. * Gets the engine of the node
  29640. * @returns a Engine
  29641. */
  29642. getEngine(): Engine;
  29643. private _behaviors;
  29644. /**
  29645. * Attach a behavior to the node
  29646. * @see http://doc.babylonjs.com/features/behaviour
  29647. * @param behavior defines the behavior to attach
  29648. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29649. * @returns the current Node
  29650. */
  29651. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29652. /**
  29653. * Remove an attached behavior
  29654. * @see http://doc.babylonjs.com/features/behaviour
  29655. * @param behavior defines the behavior to attach
  29656. * @returns the current Node
  29657. */
  29658. removeBehavior(behavior: Behavior<Node>): Node;
  29659. /**
  29660. * Gets the list of attached behaviors
  29661. * @see http://doc.babylonjs.com/features/behaviour
  29662. */
  29663. get behaviors(): Behavior<Node>[];
  29664. /**
  29665. * Gets an attached behavior by name
  29666. * @param name defines the name of the behavior to look for
  29667. * @see http://doc.babylonjs.com/features/behaviour
  29668. * @returns null if behavior was not found else the requested behavior
  29669. */
  29670. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29671. /**
  29672. * Returns the latest update of the World matrix
  29673. * @returns a Matrix
  29674. */
  29675. getWorldMatrix(): Matrix;
  29676. /** @hidden */
  29677. _getWorldMatrixDeterminant(): number;
  29678. /**
  29679. * Returns directly the latest state of the mesh World matrix.
  29680. * A Matrix is returned.
  29681. */
  29682. get worldMatrixFromCache(): Matrix;
  29683. /** @hidden */
  29684. _initCache(): void;
  29685. /** @hidden */
  29686. updateCache(force?: boolean): void;
  29687. /** @hidden */
  29688. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29689. /** @hidden */
  29690. _updateCache(ignoreParentClass?: boolean): void;
  29691. /** @hidden */
  29692. _isSynchronized(): boolean;
  29693. /** @hidden */
  29694. _markSyncedWithParent(): void;
  29695. /** @hidden */
  29696. isSynchronizedWithParent(): boolean;
  29697. /** @hidden */
  29698. isSynchronized(): boolean;
  29699. /**
  29700. * Is this node ready to be used/rendered
  29701. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29702. * @return true if the node is ready
  29703. */
  29704. isReady(completeCheck?: boolean): boolean;
  29705. /**
  29706. * Is this node enabled?
  29707. * 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
  29708. * @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
  29709. * @return whether this node (and its parent) is enabled
  29710. */
  29711. isEnabled(checkAncestors?: boolean): boolean;
  29712. /** @hidden */
  29713. protected _syncParentEnabledState(): void;
  29714. /**
  29715. * Set the enabled state of this node
  29716. * @param value defines the new enabled state
  29717. */
  29718. setEnabled(value: boolean): void;
  29719. /**
  29720. * Is this node a descendant of the given node?
  29721. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29722. * @param ancestor defines the parent node to inspect
  29723. * @returns a boolean indicating if this node is a descendant of the given node
  29724. */
  29725. isDescendantOf(ancestor: Node): boolean;
  29726. /** @hidden */
  29727. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29728. /**
  29729. * Will return all nodes that have this node as ascendant
  29730. * @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
  29731. * @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
  29732. * @return all children nodes of all types
  29733. */
  29734. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29735. /**
  29736. * Get all child-meshes of this node
  29737. * @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)
  29738. * @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
  29739. * @returns an array of AbstractMesh
  29740. */
  29741. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29742. /**
  29743. * Get all direct children of this node
  29744. * @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
  29745. * @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)
  29746. * @returns an array of Node
  29747. */
  29748. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29749. /** @hidden */
  29750. _setReady(state: boolean): void;
  29751. /**
  29752. * Get an animation by name
  29753. * @param name defines the name of the animation to look for
  29754. * @returns null if not found else the requested animation
  29755. */
  29756. getAnimationByName(name: string): Nullable<Animation>;
  29757. /**
  29758. * Creates an animation range for this node
  29759. * @param name defines the name of the range
  29760. * @param from defines the starting key
  29761. * @param to defines the end key
  29762. */
  29763. createAnimationRange(name: string, from: number, to: number): void;
  29764. /**
  29765. * Delete a specific animation range
  29766. * @param name defines the name of the range to delete
  29767. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29768. */
  29769. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29770. /**
  29771. * Get an animation range by name
  29772. * @param name defines the name of the animation range to look for
  29773. * @returns null if not found else the requested animation range
  29774. */
  29775. getAnimationRange(name: string): Nullable<AnimationRange>;
  29776. /**
  29777. * Gets the list of all animation ranges defined on this node
  29778. * @returns an array
  29779. */
  29780. getAnimationRanges(): Nullable<AnimationRange>[];
  29781. /**
  29782. * Will start the animation sequence
  29783. * @param name defines the range frames for animation sequence
  29784. * @param loop defines if the animation should loop (false by default)
  29785. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29786. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29787. * @returns the object created for this animation. If range does not exist, it will return null
  29788. */
  29789. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29790. /**
  29791. * Serialize animation ranges into a JSON compatible object
  29792. * @returns serialization object
  29793. */
  29794. serializeAnimationRanges(): any;
  29795. /**
  29796. * Computes the world matrix of the node
  29797. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29798. * @returns the world matrix
  29799. */
  29800. computeWorldMatrix(force?: boolean): Matrix;
  29801. /**
  29802. * Releases resources associated with this node.
  29803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29805. */
  29806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29807. /**
  29808. * Parse animation range data from a serialization object and store them into a given node
  29809. * @param node defines where to store the animation ranges
  29810. * @param parsedNode defines the serialization object to read data from
  29811. * @param scene defines the hosting scene
  29812. */
  29813. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29814. /**
  29815. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29816. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29817. * @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
  29818. * @returns the new bounding vectors
  29819. */
  29820. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29821. min: Vector3;
  29822. max: Vector3;
  29823. };
  29824. }
  29825. }
  29826. declare module "babylonjs/Animations/animation" {
  29827. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29828. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29829. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29830. import { Nullable } from "babylonjs/types";
  29831. import { Scene } from "babylonjs/scene";
  29832. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29833. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29834. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29835. import { Node } from "babylonjs/node";
  29836. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29837. import { Size } from "babylonjs/Maths/math.size";
  29838. import { Animatable } from "babylonjs/Animations/animatable";
  29839. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29840. /**
  29841. * @hidden
  29842. */
  29843. export class _IAnimationState {
  29844. key: number;
  29845. repeatCount: number;
  29846. workValue?: any;
  29847. loopMode?: number;
  29848. offsetValue?: any;
  29849. highLimitValue?: any;
  29850. }
  29851. /**
  29852. * Class used to store any kind of animation
  29853. */
  29854. export class Animation {
  29855. /**Name of the animation */
  29856. name: string;
  29857. /**Property to animate */
  29858. targetProperty: string;
  29859. /**The frames per second of the animation */
  29860. framePerSecond: number;
  29861. /**The data type of the animation */
  29862. dataType: number;
  29863. /**The loop mode of the animation */
  29864. loopMode?: number | undefined;
  29865. /**Specifies if blending should be enabled */
  29866. enableBlending?: boolean | undefined;
  29867. /**
  29868. * Use matrix interpolation instead of using direct key value when animating matrices
  29869. */
  29870. static AllowMatricesInterpolation: boolean;
  29871. /**
  29872. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29873. */
  29874. static AllowMatrixDecomposeForInterpolation: boolean;
  29875. /**
  29876. * Stores the key frames of the animation
  29877. */
  29878. private _keys;
  29879. /**
  29880. * Stores the easing function of the animation
  29881. */
  29882. private _easingFunction;
  29883. /**
  29884. * @hidden Internal use only
  29885. */
  29886. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29887. /**
  29888. * The set of event that will be linked to this animation
  29889. */
  29890. private _events;
  29891. /**
  29892. * Stores an array of target property paths
  29893. */
  29894. targetPropertyPath: string[];
  29895. /**
  29896. * Stores the blending speed of the animation
  29897. */
  29898. blendingSpeed: number;
  29899. /**
  29900. * Stores the animation ranges for the animation
  29901. */
  29902. private _ranges;
  29903. /**
  29904. * @hidden Internal use
  29905. */
  29906. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29907. /**
  29908. * Sets up an animation
  29909. * @param property The property to animate
  29910. * @param animationType The animation type to apply
  29911. * @param framePerSecond The frames per second of the animation
  29912. * @param easingFunction The easing function used in the animation
  29913. * @returns The created animation
  29914. */
  29915. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29916. /**
  29917. * Create and start an animation on a node
  29918. * @param name defines the name of the global animation that will be run on all nodes
  29919. * @param node defines the root node where the animation will take place
  29920. * @param targetProperty defines property to animate
  29921. * @param framePerSecond defines the number of frame per second yo use
  29922. * @param totalFrame defines the number of frames in total
  29923. * @param from defines the initial value
  29924. * @param to defines the final value
  29925. * @param loopMode defines which loop mode you want to use (off by default)
  29926. * @param easingFunction defines the easing function to use (linear by default)
  29927. * @param onAnimationEnd defines the callback to call when animation end
  29928. * @returns the animatable created for this animation
  29929. */
  29930. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29931. /**
  29932. * Create and start an animation on a node and its descendants
  29933. * @param name defines the name of the global animation that will be run on all nodes
  29934. * @param node defines the root node where the animation will take place
  29935. * @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
  29936. * @param targetProperty defines property to animate
  29937. * @param framePerSecond defines the number of frame per second to use
  29938. * @param totalFrame defines the number of frames in total
  29939. * @param from defines the initial value
  29940. * @param to defines the final value
  29941. * @param loopMode defines which loop mode you want to use (off by default)
  29942. * @param easingFunction defines the easing function to use (linear by default)
  29943. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29944. * @returns the list of animatables created for all nodes
  29945. * @example https://www.babylonjs-playground.com/#MH0VLI
  29946. */
  29947. 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[]>;
  29948. /**
  29949. * Creates a new animation, merges it with the existing animations and starts it
  29950. * @param name Name of the animation
  29951. * @param node Node which contains the scene that begins the animations
  29952. * @param targetProperty Specifies which property to animate
  29953. * @param framePerSecond The frames per second of the animation
  29954. * @param totalFrame The total number of frames
  29955. * @param from The frame at the beginning of the animation
  29956. * @param to The frame at the end of the animation
  29957. * @param loopMode Specifies the loop mode of the animation
  29958. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29959. * @param onAnimationEnd Callback to run once the animation is complete
  29960. * @returns Nullable animation
  29961. */
  29962. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29963. /**
  29964. * Transition property of an host to the target Value
  29965. * @param property The property to transition
  29966. * @param targetValue The target Value of the property
  29967. * @param host The object where the property to animate belongs
  29968. * @param scene Scene used to run the animation
  29969. * @param frameRate Framerate (in frame/s) to use
  29970. * @param transition The transition type we want to use
  29971. * @param duration The duration of the animation, in milliseconds
  29972. * @param onAnimationEnd Callback trigger at the end of the animation
  29973. * @returns Nullable animation
  29974. */
  29975. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29976. /**
  29977. * Return the array of runtime animations currently using this animation
  29978. */
  29979. get runtimeAnimations(): RuntimeAnimation[];
  29980. /**
  29981. * Specifies if any of the runtime animations are currently running
  29982. */
  29983. get hasRunningRuntimeAnimations(): boolean;
  29984. /**
  29985. * Initializes the animation
  29986. * @param name Name of the animation
  29987. * @param targetProperty Property to animate
  29988. * @param framePerSecond The frames per second of the animation
  29989. * @param dataType The data type of the animation
  29990. * @param loopMode The loop mode of the animation
  29991. * @param enableBlending Specifies if blending should be enabled
  29992. */
  29993. constructor(
  29994. /**Name of the animation */
  29995. name: string,
  29996. /**Property to animate */
  29997. targetProperty: string,
  29998. /**The frames per second of the animation */
  29999. framePerSecond: number,
  30000. /**The data type of the animation */
  30001. dataType: number,
  30002. /**The loop mode of the animation */
  30003. loopMode?: number | undefined,
  30004. /**Specifies if blending should be enabled */
  30005. enableBlending?: boolean | undefined);
  30006. /**
  30007. * Converts the animation to a string
  30008. * @param fullDetails support for multiple levels of logging within scene loading
  30009. * @returns String form of the animation
  30010. */
  30011. toString(fullDetails?: boolean): string;
  30012. /**
  30013. * Add an event to this animation
  30014. * @param event Event to add
  30015. */
  30016. addEvent(event: AnimationEvent): void;
  30017. /**
  30018. * Remove all events found at the given frame
  30019. * @param frame The frame to remove events from
  30020. */
  30021. removeEvents(frame: number): void;
  30022. /**
  30023. * Retrieves all the events from the animation
  30024. * @returns Events from the animation
  30025. */
  30026. getEvents(): AnimationEvent[];
  30027. /**
  30028. * Creates an animation range
  30029. * @param name Name of the animation range
  30030. * @param from Starting frame of the animation range
  30031. * @param to Ending frame of the animation
  30032. */
  30033. createRange(name: string, from: number, to: number): void;
  30034. /**
  30035. * Deletes an animation range by name
  30036. * @param name Name of the animation range to delete
  30037. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30038. */
  30039. deleteRange(name: string, deleteFrames?: boolean): void;
  30040. /**
  30041. * Gets the animation range by name, or null if not defined
  30042. * @param name Name of the animation range
  30043. * @returns Nullable animation range
  30044. */
  30045. getRange(name: string): Nullable<AnimationRange>;
  30046. /**
  30047. * Gets the key frames from the animation
  30048. * @returns The key frames of the animation
  30049. */
  30050. getKeys(): Array<IAnimationKey>;
  30051. /**
  30052. * Gets the highest frame rate of the animation
  30053. * @returns Highest frame rate of the animation
  30054. */
  30055. getHighestFrame(): number;
  30056. /**
  30057. * Gets the easing function of the animation
  30058. * @returns Easing function of the animation
  30059. */
  30060. getEasingFunction(): IEasingFunction;
  30061. /**
  30062. * Sets the easing function of the animation
  30063. * @param easingFunction A custom mathematical formula for animation
  30064. */
  30065. setEasingFunction(easingFunction: EasingFunction): void;
  30066. /**
  30067. * Interpolates a scalar linearly
  30068. * @param startValue Start value of the animation curve
  30069. * @param endValue End value of the animation curve
  30070. * @param gradient Scalar amount to interpolate
  30071. * @returns Interpolated scalar value
  30072. */
  30073. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30074. /**
  30075. * Interpolates a scalar cubically
  30076. * @param startValue Start value of the animation curve
  30077. * @param outTangent End tangent of the animation
  30078. * @param endValue End value of the animation curve
  30079. * @param inTangent Start tangent of the animation curve
  30080. * @param gradient Scalar amount to interpolate
  30081. * @returns Interpolated scalar value
  30082. */
  30083. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30084. /**
  30085. * Interpolates a quaternion using a spherical linear interpolation
  30086. * @param startValue Start value of the animation curve
  30087. * @param endValue End value of the animation curve
  30088. * @param gradient Scalar amount to interpolate
  30089. * @returns Interpolated quaternion value
  30090. */
  30091. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30092. /**
  30093. * Interpolates a quaternion cubically
  30094. * @param startValue Start value of the animation curve
  30095. * @param outTangent End tangent of the animation curve
  30096. * @param endValue End value of the animation curve
  30097. * @param inTangent Start tangent of the animation curve
  30098. * @param gradient Scalar amount to interpolate
  30099. * @returns Interpolated quaternion value
  30100. */
  30101. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30102. /**
  30103. * Interpolates a Vector3 linearl
  30104. * @param startValue Start value of the animation curve
  30105. * @param endValue End value of the animation curve
  30106. * @param gradient Scalar amount to interpolate
  30107. * @returns Interpolated scalar value
  30108. */
  30109. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30110. /**
  30111. * Interpolates a Vector3 cubically
  30112. * @param startValue Start value of the animation curve
  30113. * @param outTangent End tangent of the animation
  30114. * @param endValue End value of the animation curve
  30115. * @param inTangent Start tangent of the animation curve
  30116. * @param gradient Scalar amount to interpolate
  30117. * @returns InterpolatedVector3 value
  30118. */
  30119. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30120. /**
  30121. * Interpolates a Vector2 linearly
  30122. * @param startValue Start value of the animation curve
  30123. * @param endValue End value of the animation curve
  30124. * @param gradient Scalar amount to interpolate
  30125. * @returns Interpolated Vector2 value
  30126. */
  30127. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30128. /**
  30129. * Interpolates a Vector2 cubically
  30130. * @param startValue Start value of the animation curve
  30131. * @param outTangent End tangent of the animation
  30132. * @param endValue End value of the animation curve
  30133. * @param inTangent Start tangent of the animation curve
  30134. * @param gradient Scalar amount to interpolate
  30135. * @returns Interpolated Vector2 value
  30136. */
  30137. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30138. /**
  30139. * Interpolates a size linearly
  30140. * @param startValue Start value of the animation curve
  30141. * @param endValue End value of the animation curve
  30142. * @param gradient Scalar amount to interpolate
  30143. * @returns Interpolated Size value
  30144. */
  30145. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30146. /**
  30147. * Interpolates a Color3 linearly
  30148. * @param startValue Start value of the animation curve
  30149. * @param endValue End value of the animation curve
  30150. * @param gradient Scalar amount to interpolate
  30151. * @returns Interpolated Color3 value
  30152. */
  30153. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30154. /**
  30155. * Interpolates a Color4 linearly
  30156. * @param startValue Start value of the animation curve
  30157. * @param endValue End value of the animation curve
  30158. * @param gradient Scalar amount to interpolate
  30159. * @returns Interpolated Color3 value
  30160. */
  30161. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30162. /**
  30163. * @hidden Internal use only
  30164. */
  30165. _getKeyValue(value: any): any;
  30166. /**
  30167. * @hidden Internal use only
  30168. */
  30169. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30170. /**
  30171. * Defines the function to use to interpolate matrices
  30172. * @param startValue defines the start matrix
  30173. * @param endValue defines the end matrix
  30174. * @param gradient defines the gradient between both matrices
  30175. * @param result defines an optional target matrix where to store the interpolation
  30176. * @returns the interpolated matrix
  30177. */
  30178. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30179. /**
  30180. * Makes a copy of the animation
  30181. * @returns Cloned animation
  30182. */
  30183. clone(): Animation;
  30184. /**
  30185. * Sets the key frames of the animation
  30186. * @param values The animation key frames to set
  30187. */
  30188. setKeys(values: Array<IAnimationKey>): void;
  30189. /**
  30190. * Serializes the animation to an object
  30191. * @returns Serialized object
  30192. */
  30193. serialize(): any;
  30194. /**
  30195. * Float animation type
  30196. */
  30197. static readonly ANIMATIONTYPE_FLOAT: number;
  30198. /**
  30199. * Vector3 animation type
  30200. */
  30201. static readonly ANIMATIONTYPE_VECTOR3: number;
  30202. /**
  30203. * Quaternion animation type
  30204. */
  30205. static readonly ANIMATIONTYPE_QUATERNION: number;
  30206. /**
  30207. * Matrix animation type
  30208. */
  30209. static readonly ANIMATIONTYPE_MATRIX: number;
  30210. /**
  30211. * Color3 animation type
  30212. */
  30213. static readonly ANIMATIONTYPE_COLOR3: number;
  30214. /**
  30215. * Color3 animation type
  30216. */
  30217. static readonly ANIMATIONTYPE_COLOR4: number;
  30218. /**
  30219. * Vector2 animation type
  30220. */
  30221. static readonly ANIMATIONTYPE_VECTOR2: number;
  30222. /**
  30223. * Size animation type
  30224. */
  30225. static readonly ANIMATIONTYPE_SIZE: number;
  30226. /**
  30227. * Relative Loop Mode
  30228. */
  30229. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30230. /**
  30231. * Cycle Loop Mode
  30232. */
  30233. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30234. /**
  30235. * Constant Loop Mode
  30236. */
  30237. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30238. /** @hidden */
  30239. static _UniversalLerp(left: any, right: any, amount: number): any;
  30240. /**
  30241. * Parses an animation object and creates an animation
  30242. * @param parsedAnimation Parsed animation object
  30243. * @returns Animation object
  30244. */
  30245. static Parse(parsedAnimation: any): Animation;
  30246. /**
  30247. * Appends the serialized animations from the source animations
  30248. * @param source Source containing the animations
  30249. * @param destination Target to store the animations
  30250. */
  30251. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30252. }
  30253. }
  30254. declare module "babylonjs/Animations/animatable.interface" {
  30255. import { Nullable } from "babylonjs/types";
  30256. import { Animation } from "babylonjs/Animations/animation";
  30257. /**
  30258. * Interface containing an array of animations
  30259. */
  30260. export interface IAnimatable {
  30261. /**
  30262. * Array of animations
  30263. */
  30264. animations: Nullable<Array<Animation>>;
  30265. }
  30266. }
  30267. declare module "babylonjs/Misc/decorators" {
  30268. import { Nullable } from "babylonjs/types";
  30269. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30270. import { Scene } from "babylonjs/scene";
  30271. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30272. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30273. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30274. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30275. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30276. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30277. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30278. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30279. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30280. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30281. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30282. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30283. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30284. /**
  30285. * Decorator used to define property that can be serialized as reference to a camera
  30286. * @param sourceName defines the name of the property to decorate
  30287. */
  30288. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30289. /**
  30290. * Class used to help serialization objects
  30291. */
  30292. export class SerializationHelper {
  30293. /** @hidden */
  30294. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30295. /** @hidden */
  30296. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30297. /** @hidden */
  30298. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30299. /** @hidden */
  30300. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30301. /**
  30302. * Appends the serialized animations from the source animations
  30303. * @param source Source containing the animations
  30304. * @param destination Target to store the animations
  30305. */
  30306. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30307. /**
  30308. * Static function used to serialized a specific entity
  30309. * @param entity defines the entity to serialize
  30310. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30311. * @returns a JSON compatible object representing the serialization of the entity
  30312. */
  30313. static Serialize<T>(entity: T, serializationObject?: any): any;
  30314. /**
  30315. * Creates a new entity from a serialization data object
  30316. * @param creationFunction defines a function used to instanciated the new entity
  30317. * @param source defines the source serialization data
  30318. * @param scene defines the hosting scene
  30319. * @param rootUrl defines the root url for resources
  30320. * @returns a new entity
  30321. */
  30322. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30323. /**
  30324. * Clones an object
  30325. * @param creationFunction defines the function used to instanciate the new object
  30326. * @param source defines the source object
  30327. * @returns the cloned object
  30328. */
  30329. static Clone<T>(creationFunction: () => T, source: T): T;
  30330. /**
  30331. * Instanciates a new object based on a source one (some data will be shared between both object)
  30332. * @param creationFunction defines the function used to instanciate the new object
  30333. * @param source defines the source object
  30334. * @returns the new object
  30335. */
  30336. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30337. }
  30338. }
  30339. declare module "babylonjs/Misc/guid" {
  30340. /**
  30341. * Class used to manipulate GUIDs
  30342. */
  30343. export class GUID {
  30344. /**
  30345. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30346. * Be aware Math.random() could cause collisions, but:
  30347. * "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"
  30348. * @returns a pseudo random id
  30349. */
  30350. static RandomId(): string;
  30351. }
  30352. }
  30353. declare module "babylonjs/Materials/Textures/baseTexture" {
  30354. import { Observable } from "babylonjs/Misc/observable";
  30355. import { Nullable } from "babylonjs/types";
  30356. import { Scene } from "babylonjs/scene";
  30357. import { Matrix } from "babylonjs/Maths/math.vector";
  30358. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30359. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30360. import { ISize } from "babylonjs/Maths/math.size";
  30361. import "babylonjs/Misc/fileTools";
  30362. /**
  30363. * Base class of all the textures in babylon.
  30364. * It groups all the common properties the materials, post process, lights... might need
  30365. * in order to make a correct use of the texture.
  30366. */
  30367. export class BaseTexture implements IAnimatable {
  30368. /**
  30369. * Default anisotropic filtering level for the application.
  30370. * It is set to 4 as a good tradeoff between perf and quality.
  30371. */
  30372. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30373. /**
  30374. * Gets or sets the unique id of the texture
  30375. */
  30376. uniqueId: number;
  30377. /**
  30378. * Define the name of the texture.
  30379. */
  30380. name: string;
  30381. /**
  30382. * Gets or sets an object used to store user defined information.
  30383. */
  30384. metadata: any;
  30385. /**
  30386. * For internal use only. Please do not use.
  30387. */
  30388. reservedDataStore: any;
  30389. private _hasAlpha;
  30390. /**
  30391. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30392. */
  30393. set hasAlpha(value: boolean);
  30394. get hasAlpha(): boolean;
  30395. /**
  30396. * Defines if the alpha value should be determined via the rgb values.
  30397. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30398. */
  30399. getAlphaFromRGB: boolean;
  30400. /**
  30401. * Intensity or strength of the texture.
  30402. * It is commonly used by materials to fine tune the intensity of the texture
  30403. */
  30404. level: number;
  30405. /**
  30406. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30407. * This is part of the texture as textures usually maps to one uv set.
  30408. */
  30409. coordinatesIndex: number;
  30410. private _coordinatesMode;
  30411. /**
  30412. * How a texture is mapped.
  30413. *
  30414. * | Value | Type | Description |
  30415. * | ----- | ----------------------------------- | ----------- |
  30416. * | 0 | EXPLICIT_MODE | |
  30417. * | 1 | SPHERICAL_MODE | |
  30418. * | 2 | PLANAR_MODE | |
  30419. * | 3 | CUBIC_MODE | |
  30420. * | 4 | PROJECTION_MODE | |
  30421. * | 5 | SKYBOX_MODE | |
  30422. * | 6 | INVCUBIC_MODE | |
  30423. * | 7 | EQUIRECTANGULAR_MODE | |
  30424. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30425. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30426. */
  30427. set coordinatesMode(value: number);
  30428. get coordinatesMode(): number;
  30429. /**
  30430. * | Value | Type | Description |
  30431. * | ----- | ------------------ | ----------- |
  30432. * | 0 | CLAMP_ADDRESSMODE | |
  30433. * | 1 | WRAP_ADDRESSMODE | |
  30434. * | 2 | MIRROR_ADDRESSMODE | |
  30435. */
  30436. wrapU: number;
  30437. /**
  30438. * | Value | Type | Description |
  30439. * | ----- | ------------------ | ----------- |
  30440. * | 0 | CLAMP_ADDRESSMODE | |
  30441. * | 1 | WRAP_ADDRESSMODE | |
  30442. * | 2 | MIRROR_ADDRESSMODE | |
  30443. */
  30444. wrapV: number;
  30445. /**
  30446. * | Value | Type | Description |
  30447. * | ----- | ------------------ | ----------- |
  30448. * | 0 | CLAMP_ADDRESSMODE | |
  30449. * | 1 | WRAP_ADDRESSMODE | |
  30450. * | 2 | MIRROR_ADDRESSMODE | |
  30451. */
  30452. wrapR: number;
  30453. /**
  30454. * With compliant hardware and browser (supporting anisotropic filtering)
  30455. * this defines the level of anisotropic filtering in the texture.
  30456. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30457. */
  30458. anisotropicFilteringLevel: number;
  30459. /**
  30460. * Define if the texture is a cube texture or if false a 2d texture.
  30461. */
  30462. get isCube(): boolean;
  30463. set isCube(value: boolean);
  30464. /**
  30465. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30466. */
  30467. get is3D(): boolean;
  30468. set is3D(value: boolean);
  30469. /**
  30470. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30471. */
  30472. get is2DArray(): boolean;
  30473. set is2DArray(value: boolean);
  30474. /**
  30475. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30476. * HDR texture are usually stored in linear space.
  30477. * This only impacts the PBR and Background materials
  30478. */
  30479. gammaSpace: boolean;
  30480. /**
  30481. * Gets or sets whether or not the texture contains RGBD data.
  30482. */
  30483. get isRGBD(): boolean;
  30484. set isRGBD(value: boolean);
  30485. /**
  30486. * Is Z inverted in the texture (useful in a cube texture).
  30487. */
  30488. invertZ: boolean;
  30489. /**
  30490. * Are mip maps generated for this texture or not.
  30491. */
  30492. get noMipmap(): boolean;
  30493. /**
  30494. * @hidden
  30495. */
  30496. lodLevelInAlpha: boolean;
  30497. /**
  30498. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30499. */
  30500. get lodGenerationOffset(): number;
  30501. set lodGenerationOffset(value: number);
  30502. /**
  30503. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30504. */
  30505. get lodGenerationScale(): number;
  30506. set lodGenerationScale(value: number);
  30507. /**
  30508. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30509. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30510. * average roughness values.
  30511. */
  30512. get linearSpecularLOD(): boolean;
  30513. set linearSpecularLOD(value: boolean);
  30514. /**
  30515. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30516. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30517. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30518. */
  30519. get irradianceTexture(): Nullable<BaseTexture>;
  30520. set irradianceTexture(value: Nullable<BaseTexture>);
  30521. /**
  30522. * Define if the texture is a render target.
  30523. */
  30524. isRenderTarget: boolean;
  30525. /**
  30526. * Define the unique id of the texture in the scene.
  30527. */
  30528. get uid(): string;
  30529. /**
  30530. * Return a string representation of the texture.
  30531. * @returns the texture as a string
  30532. */
  30533. toString(): string;
  30534. /**
  30535. * Get the class name of the texture.
  30536. * @returns "BaseTexture"
  30537. */
  30538. getClassName(): string;
  30539. /**
  30540. * Define the list of animation attached to the texture.
  30541. */
  30542. animations: import("babylonjs/Animations/animation").Animation[];
  30543. /**
  30544. * An event triggered when the texture is disposed.
  30545. */
  30546. onDisposeObservable: Observable<BaseTexture>;
  30547. private _onDisposeObserver;
  30548. /**
  30549. * Callback triggered when the texture has been disposed.
  30550. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30551. */
  30552. set onDispose(callback: () => void);
  30553. /**
  30554. * Define the current state of the loading sequence when in delayed load mode.
  30555. */
  30556. delayLoadState: number;
  30557. private _scene;
  30558. /** @hidden */
  30559. _texture: Nullable<InternalTexture>;
  30560. private _uid;
  30561. /**
  30562. * Define if the texture is preventinga material to render or not.
  30563. * If not and the texture is not ready, the engine will use a default black texture instead.
  30564. */
  30565. get isBlocking(): boolean;
  30566. /**
  30567. * Instantiates a new BaseTexture.
  30568. * Base class of all the textures in babylon.
  30569. * It groups all the common properties the materials, post process, lights... might need
  30570. * in order to make a correct use of the texture.
  30571. * @param scene Define the scene the texture blongs to
  30572. */
  30573. constructor(scene: Nullable<Scene>);
  30574. /**
  30575. * Get the scene the texture belongs to.
  30576. * @returns the scene or null if undefined
  30577. */
  30578. getScene(): Nullable<Scene>;
  30579. /**
  30580. * Get the texture transform matrix used to offset tile the texture for istance.
  30581. * @returns the transformation matrix
  30582. */
  30583. getTextureMatrix(): Matrix;
  30584. /**
  30585. * Get the texture reflection matrix used to rotate/transform the reflection.
  30586. * @returns the reflection matrix
  30587. */
  30588. getReflectionTextureMatrix(): Matrix;
  30589. /**
  30590. * Get the underlying lower level texture from Babylon.
  30591. * @returns the insternal texture
  30592. */
  30593. getInternalTexture(): Nullable<InternalTexture>;
  30594. /**
  30595. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30596. * @returns true if ready or not blocking
  30597. */
  30598. isReadyOrNotBlocking(): boolean;
  30599. /**
  30600. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30601. * @returns true if fully ready
  30602. */
  30603. isReady(): boolean;
  30604. private _cachedSize;
  30605. /**
  30606. * Get the size of the texture.
  30607. * @returns the texture size.
  30608. */
  30609. getSize(): ISize;
  30610. /**
  30611. * Get the base size of the texture.
  30612. * It can be different from the size if the texture has been resized for POT for instance
  30613. * @returns the base size
  30614. */
  30615. getBaseSize(): ISize;
  30616. /**
  30617. * Update the sampling mode of the texture.
  30618. * Default is Trilinear mode.
  30619. *
  30620. * | Value | Type | Description |
  30621. * | ----- | ------------------ | ----------- |
  30622. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30623. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30624. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30625. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30626. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30627. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30628. * | 7 | NEAREST_LINEAR | |
  30629. * | 8 | NEAREST_NEAREST | |
  30630. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30631. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30632. * | 11 | LINEAR_LINEAR | |
  30633. * | 12 | LINEAR_NEAREST | |
  30634. *
  30635. * > _mag_: magnification filter (close to the viewer)
  30636. * > _min_: minification filter (far from the viewer)
  30637. * > _mip_: filter used between mip map levels
  30638. *@param samplingMode Define the new sampling mode of the texture
  30639. */
  30640. updateSamplingMode(samplingMode: number): void;
  30641. /**
  30642. * Scales the texture if is `canRescale()`
  30643. * @param ratio the resize factor we want to use to rescale
  30644. */
  30645. scale(ratio: number): void;
  30646. /**
  30647. * Get if the texture can rescale.
  30648. */
  30649. get canRescale(): boolean;
  30650. /** @hidden */
  30651. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30652. /** @hidden */
  30653. _rebuild(): void;
  30654. /**
  30655. * Triggers the load sequence in delayed load mode.
  30656. */
  30657. delayLoad(): void;
  30658. /**
  30659. * Clones the texture.
  30660. * @returns the cloned texture
  30661. */
  30662. clone(): Nullable<BaseTexture>;
  30663. /**
  30664. * Get the texture underlying type (INT, FLOAT...)
  30665. */
  30666. get textureType(): number;
  30667. /**
  30668. * Get the texture underlying format (RGB, RGBA...)
  30669. */
  30670. get textureFormat(): number;
  30671. /**
  30672. * Indicates that textures need to be re-calculated for all materials
  30673. */
  30674. protected _markAllSubMeshesAsTexturesDirty(): void;
  30675. /**
  30676. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30677. * This will returns an RGBA array buffer containing either in values (0-255) or
  30678. * float values (0-1) depending of the underlying buffer type.
  30679. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30680. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30681. * @param buffer defines a user defined buffer to fill with data (can be null)
  30682. * @returns The Array buffer containing the pixels data.
  30683. */
  30684. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30685. /**
  30686. * Release and destroy the underlying lower level texture aka internalTexture.
  30687. */
  30688. releaseInternalTexture(): void;
  30689. /** @hidden */
  30690. get _lodTextureHigh(): Nullable<BaseTexture>;
  30691. /** @hidden */
  30692. get _lodTextureMid(): Nullable<BaseTexture>;
  30693. /** @hidden */
  30694. get _lodTextureLow(): Nullable<BaseTexture>;
  30695. /**
  30696. * Dispose the texture and release its associated resources.
  30697. */
  30698. dispose(): void;
  30699. /**
  30700. * Serialize the texture into a JSON representation that can be parsed later on.
  30701. * @returns the JSON representation of the texture
  30702. */
  30703. serialize(): any;
  30704. /**
  30705. * Helper function to be called back once a list of texture contains only ready textures.
  30706. * @param textures Define the list of textures to wait for
  30707. * @param callback Define the callback triggered once the entire list will be ready
  30708. */
  30709. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30710. }
  30711. }
  30712. declare module "babylonjs/Materials/effect" {
  30713. import { Observable } from "babylonjs/Misc/observable";
  30714. import { Nullable } from "babylonjs/types";
  30715. import { IDisposable } from "babylonjs/scene";
  30716. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30717. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30718. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30719. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30720. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30721. import { Engine } from "babylonjs/Engines/engine";
  30722. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30724. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30725. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30726. /**
  30727. * Options to be used when creating an effect.
  30728. */
  30729. export interface IEffectCreationOptions {
  30730. /**
  30731. * Atrributes that will be used in the shader.
  30732. */
  30733. attributes: string[];
  30734. /**
  30735. * Uniform varible names that will be set in the shader.
  30736. */
  30737. uniformsNames: string[];
  30738. /**
  30739. * Uniform buffer variable names that will be set in the shader.
  30740. */
  30741. uniformBuffersNames: string[];
  30742. /**
  30743. * Sampler texture variable names that will be set in the shader.
  30744. */
  30745. samplers: string[];
  30746. /**
  30747. * Define statements that will be set in the shader.
  30748. */
  30749. defines: any;
  30750. /**
  30751. * Possible fallbacks for this effect to improve performance when needed.
  30752. */
  30753. fallbacks: Nullable<IEffectFallbacks>;
  30754. /**
  30755. * Callback that will be called when the shader is compiled.
  30756. */
  30757. onCompiled: Nullable<(effect: Effect) => void>;
  30758. /**
  30759. * Callback that will be called if an error occurs during shader compilation.
  30760. */
  30761. onError: Nullable<(effect: Effect, errors: string) => void>;
  30762. /**
  30763. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30764. */
  30765. indexParameters?: any;
  30766. /**
  30767. * Max number of lights that can be used in the shader.
  30768. */
  30769. maxSimultaneousLights?: number;
  30770. /**
  30771. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30772. */
  30773. transformFeedbackVaryings?: Nullable<string[]>;
  30774. }
  30775. /**
  30776. * Effect containing vertex and fragment shader that can be executed on an object.
  30777. */
  30778. export class Effect implements IDisposable {
  30779. /**
  30780. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30781. */
  30782. static ShadersRepository: string;
  30783. /**
  30784. * Name of the effect.
  30785. */
  30786. name: any;
  30787. /**
  30788. * String container all the define statements that should be set on the shader.
  30789. */
  30790. defines: string;
  30791. /**
  30792. * Callback that will be called when the shader is compiled.
  30793. */
  30794. onCompiled: Nullable<(effect: Effect) => void>;
  30795. /**
  30796. * Callback that will be called if an error occurs during shader compilation.
  30797. */
  30798. onError: Nullable<(effect: Effect, errors: string) => void>;
  30799. /**
  30800. * Callback that will be called when effect is bound.
  30801. */
  30802. onBind: Nullable<(effect: Effect) => void>;
  30803. /**
  30804. * Unique ID of the effect.
  30805. */
  30806. uniqueId: number;
  30807. /**
  30808. * Observable that will be called when the shader is compiled.
  30809. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30810. */
  30811. onCompileObservable: Observable<Effect>;
  30812. /**
  30813. * Observable that will be called if an error occurs during shader compilation.
  30814. */
  30815. onErrorObservable: Observable<Effect>;
  30816. /** @hidden */
  30817. _onBindObservable: Nullable<Observable<Effect>>;
  30818. /**
  30819. * @hidden
  30820. * Specifies if the effect was previously ready
  30821. */
  30822. _wasPreviouslyReady: boolean;
  30823. /**
  30824. * Observable that will be called when effect is bound.
  30825. */
  30826. get onBindObservable(): Observable<Effect>;
  30827. /** @hidden */
  30828. _bonesComputationForcedToCPU: boolean;
  30829. private static _uniqueIdSeed;
  30830. private _engine;
  30831. private _uniformBuffersNames;
  30832. private _uniformsNames;
  30833. private _samplerList;
  30834. private _samplers;
  30835. private _isReady;
  30836. private _compilationError;
  30837. private _allFallbacksProcessed;
  30838. private _attributesNames;
  30839. private _attributes;
  30840. private _attributeLocationByName;
  30841. private _uniforms;
  30842. /**
  30843. * Key for the effect.
  30844. * @hidden
  30845. */
  30846. _key: string;
  30847. private _indexParameters;
  30848. private _fallbacks;
  30849. private _vertexSourceCode;
  30850. private _fragmentSourceCode;
  30851. private _vertexSourceCodeOverride;
  30852. private _fragmentSourceCodeOverride;
  30853. private _transformFeedbackVaryings;
  30854. /**
  30855. * Compiled shader to webGL program.
  30856. * @hidden
  30857. */
  30858. _pipelineContext: Nullable<IPipelineContext>;
  30859. private _valueCache;
  30860. private static _baseCache;
  30861. /**
  30862. * Instantiates an effect.
  30863. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30864. * @param baseName Name of the effect.
  30865. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30866. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30867. * @param samplers List of sampler variables that will be passed to the shader.
  30868. * @param engine Engine to be used to render the effect
  30869. * @param defines Define statements to be added to the shader.
  30870. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30871. * @param onCompiled Callback that will be called when the shader is compiled.
  30872. * @param onError Callback that will be called if an error occurs during shader compilation.
  30873. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30874. */
  30875. 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);
  30876. private _useFinalCode;
  30877. /**
  30878. * Unique key for this effect
  30879. */
  30880. get key(): string;
  30881. /**
  30882. * If the effect has been compiled and prepared.
  30883. * @returns if the effect is compiled and prepared.
  30884. */
  30885. isReady(): boolean;
  30886. private _isReadyInternal;
  30887. /**
  30888. * The engine the effect was initialized with.
  30889. * @returns the engine.
  30890. */
  30891. getEngine(): Engine;
  30892. /**
  30893. * The pipeline context for this effect
  30894. * @returns the associated pipeline context
  30895. */
  30896. getPipelineContext(): Nullable<IPipelineContext>;
  30897. /**
  30898. * The set of names of attribute variables for the shader.
  30899. * @returns An array of attribute names.
  30900. */
  30901. getAttributesNames(): string[];
  30902. /**
  30903. * Returns the attribute at the given index.
  30904. * @param index The index of the attribute.
  30905. * @returns The location of the attribute.
  30906. */
  30907. getAttributeLocation(index: number): number;
  30908. /**
  30909. * Returns the attribute based on the name of the variable.
  30910. * @param name of the attribute to look up.
  30911. * @returns the attribute location.
  30912. */
  30913. getAttributeLocationByName(name: string): number;
  30914. /**
  30915. * The number of attributes.
  30916. * @returns the numnber of attributes.
  30917. */
  30918. getAttributesCount(): number;
  30919. /**
  30920. * Gets the index of a uniform variable.
  30921. * @param uniformName of the uniform to look up.
  30922. * @returns the index.
  30923. */
  30924. getUniformIndex(uniformName: string): number;
  30925. /**
  30926. * Returns the attribute based on the name of the variable.
  30927. * @param uniformName of the uniform to look up.
  30928. * @returns the location of the uniform.
  30929. */
  30930. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30931. /**
  30932. * Returns an array of sampler variable names
  30933. * @returns The array of sampler variable neames.
  30934. */
  30935. getSamplers(): string[];
  30936. /**
  30937. * The error from the last compilation.
  30938. * @returns the error string.
  30939. */
  30940. getCompilationError(): string;
  30941. /**
  30942. * Gets a boolean indicating that all fallbacks were used during compilation
  30943. * @returns true if all fallbacks were used
  30944. */
  30945. allFallbacksProcessed(): boolean;
  30946. /**
  30947. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30948. * @param func The callback to be used.
  30949. */
  30950. executeWhenCompiled(func: (effect: Effect) => void): void;
  30951. private _checkIsReady;
  30952. private _loadShader;
  30953. /**
  30954. * Recompiles the webGL program
  30955. * @param vertexSourceCode The source code for the vertex shader.
  30956. * @param fragmentSourceCode The source code for the fragment shader.
  30957. * @param onCompiled Callback called when completed.
  30958. * @param onError Callback called on error.
  30959. * @hidden
  30960. */
  30961. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30962. /**
  30963. * Prepares the effect
  30964. * @hidden
  30965. */
  30966. _prepareEffect(): void;
  30967. private _processCompilationErrors;
  30968. /**
  30969. * Checks if the effect is supported. (Must be called after compilation)
  30970. */
  30971. get isSupported(): boolean;
  30972. /**
  30973. * Binds a texture to the engine to be used as output of the shader.
  30974. * @param channel Name of the output variable.
  30975. * @param texture Texture to bind.
  30976. * @hidden
  30977. */
  30978. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30979. /**
  30980. * Sets a texture on the engine to be used in the shader.
  30981. * @param channel Name of the sampler variable.
  30982. * @param texture Texture to set.
  30983. */
  30984. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30985. /**
  30986. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30987. * @param channel Name of the sampler variable.
  30988. * @param texture Texture to set.
  30989. */
  30990. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30991. /**
  30992. * Sets an array of textures on the engine to be used in the shader.
  30993. * @param channel Name of the variable.
  30994. * @param textures Textures to set.
  30995. */
  30996. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30997. /**
  30998. * 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)
  30999. * @param channel Name of the sampler variable.
  31000. * @param postProcess Post process to get the input texture from.
  31001. */
  31002. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31003. /**
  31004. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31005. * 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)
  31006. * @param channel Name of the sampler variable.
  31007. * @param postProcess Post process to get the output texture from.
  31008. */
  31009. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31010. /** @hidden */
  31011. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31012. /** @hidden */
  31013. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31014. /** @hidden */
  31015. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31016. /** @hidden */
  31017. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31018. /**
  31019. * Binds a buffer to a uniform.
  31020. * @param buffer Buffer to bind.
  31021. * @param name Name of the uniform variable to bind to.
  31022. */
  31023. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31024. /**
  31025. * Binds block to a uniform.
  31026. * @param blockName Name of the block to bind.
  31027. * @param index Index to bind.
  31028. */
  31029. bindUniformBlock(blockName: string, index: number): void;
  31030. /**
  31031. * Sets an interger value on a uniform variable.
  31032. * @param uniformName Name of the variable.
  31033. * @param value Value to be set.
  31034. * @returns this effect.
  31035. */
  31036. setInt(uniformName: string, value: number): Effect;
  31037. /**
  31038. * Sets an int array on a uniform variable.
  31039. * @param uniformName Name of the variable.
  31040. * @param array array to be set.
  31041. * @returns this effect.
  31042. */
  31043. setIntArray(uniformName: string, array: Int32Array): Effect;
  31044. /**
  31045. * 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)
  31046. * @param uniformName Name of the variable.
  31047. * @param array array to be set.
  31048. * @returns this effect.
  31049. */
  31050. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31051. /**
  31052. * 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)
  31053. * @param uniformName Name of the variable.
  31054. * @param array array to be set.
  31055. * @returns this effect.
  31056. */
  31057. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31058. /**
  31059. * 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)
  31060. * @param uniformName Name of the variable.
  31061. * @param array array to be set.
  31062. * @returns this effect.
  31063. */
  31064. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31065. /**
  31066. * Sets an float array on a uniform variable.
  31067. * @param uniformName Name of the variable.
  31068. * @param array array to be set.
  31069. * @returns this effect.
  31070. */
  31071. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31072. /**
  31073. * 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)
  31074. * @param uniformName Name of the variable.
  31075. * @param array array to be set.
  31076. * @returns this effect.
  31077. */
  31078. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31079. /**
  31080. * 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)
  31081. * @param uniformName Name of the variable.
  31082. * @param array array to be set.
  31083. * @returns this effect.
  31084. */
  31085. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31086. /**
  31087. * 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)
  31088. * @param uniformName Name of the variable.
  31089. * @param array array to be set.
  31090. * @returns this effect.
  31091. */
  31092. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31093. /**
  31094. * Sets an array on a uniform variable.
  31095. * @param uniformName Name of the variable.
  31096. * @param array array to be set.
  31097. * @returns this effect.
  31098. */
  31099. setArray(uniformName: string, array: number[]): Effect;
  31100. /**
  31101. * 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)
  31102. * @param uniformName Name of the variable.
  31103. * @param array array to be set.
  31104. * @returns this effect.
  31105. */
  31106. setArray2(uniformName: string, array: number[]): Effect;
  31107. /**
  31108. * 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)
  31109. * @param uniformName Name of the variable.
  31110. * @param array array to be set.
  31111. * @returns this effect.
  31112. */
  31113. setArray3(uniformName: string, array: number[]): Effect;
  31114. /**
  31115. * 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)
  31116. * @param uniformName Name of the variable.
  31117. * @param array array to be set.
  31118. * @returns this effect.
  31119. */
  31120. setArray4(uniformName: string, array: number[]): Effect;
  31121. /**
  31122. * Sets matrices on a uniform variable.
  31123. * @param uniformName Name of the variable.
  31124. * @param matrices matrices to be set.
  31125. * @returns this effect.
  31126. */
  31127. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31128. /**
  31129. * Sets matrix on a uniform variable.
  31130. * @param uniformName Name of the variable.
  31131. * @param matrix matrix to be set.
  31132. * @returns this effect.
  31133. */
  31134. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31135. /**
  31136. * 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)
  31137. * @param uniformName Name of the variable.
  31138. * @param matrix matrix to be set.
  31139. * @returns this effect.
  31140. */
  31141. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31142. /**
  31143. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31144. * @param uniformName Name of the variable.
  31145. * @param matrix matrix to be set.
  31146. * @returns this effect.
  31147. */
  31148. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31149. /**
  31150. * Sets a float on a uniform variable.
  31151. * @param uniformName Name of the variable.
  31152. * @param value value to be set.
  31153. * @returns this effect.
  31154. */
  31155. setFloat(uniformName: string, value: number): Effect;
  31156. /**
  31157. * Sets a boolean on a uniform variable.
  31158. * @param uniformName Name of the variable.
  31159. * @param bool value to be set.
  31160. * @returns this effect.
  31161. */
  31162. setBool(uniformName: string, bool: boolean): Effect;
  31163. /**
  31164. * Sets a Vector2 on a uniform variable.
  31165. * @param uniformName Name of the variable.
  31166. * @param vector2 vector2 to be set.
  31167. * @returns this effect.
  31168. */
  31169. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31170. /**
  31171. * Sets a float2 on a uniform variable.
  31172. * @param uniformName Name of the variable.
  31173. * @param x First float in float2.
  31174. * @param y Second float in float2.
  31175. * @returns this effect.
  31176. */
  31177. setFloat2(uniformName: string, x: number, y: number): Effect;
  31178. /**
  31179. * Sets a Vector3 on a uniform variable.
  31180. * @param uniformName Name of the variable.
  31181. * @param vector3 Value to be set.
  31182. * @returns this effect.
  31183. */
  31184. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31185. /**
  31186. * Sets a float3 on a uniform variable.
  31187. * @param uniformName Name of the variable.
  31188. * @param x First float in float3.
  31189. * @param y Second float in float3.
  31190. * @param z Third float in float3.
  31191. * @returns this effect.
  31192. */
  31193. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31194. /**
  31195. * Sets a Vector4 on a uniform variable.
  31196. * @param uniformName Name of the variable.
  31197. * @param vector4 Value to be set.
  31198. * @returns this effect.
  31199. */
  31200. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31201. /**
  31202. * Sets a float4 on a uniform variable.
  31203. * @param uniformName Name of the variable.
  31204. * @param x First float in float4.
  31205. * @param y Second float in float4.
  31206. * @param z Third float in float4.
  31207. * @param w Fourth float in float4.
  31208. * @returns this effect.
  31209. */
  31210. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31211. /**
  31212. * Sets a Color3 on a uniform variable.
  31213. * @param uniformName Name of the variable.
  31214. * @param color3 Value to be set.
  31215. * @returns this effect.
  31216. */
  31217. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31218. /**
  31219. * Sets a Color4 on a uniform variable.
  31220. * @param uniformName Name of the variable.
  31221. * @param color3 Value to be set.
  31222. * @param alpha Alpha value to be set.
  31223. * @returns this effect.
  31224. */
  31225. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31226. /**
  31227. * Sets a Color4 on a uniform variable
  31228. * @param uniformName defines the name of the variable
  31229. * @param color4 defines the value to be set
  31230. * @returns this effect.
  31231. */
  31232. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31233. /** Release all associated resources */
  31234. dispose(): void;
  31235. /**
  31236. * This function will add a new shader to the shader store
  31237. * @param name the name of the shader
  31238. * @param pixelShader optional pixel shader content
  31239. * @param vertexShader optional vertex shader content
  31240. */
  31241. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31242. /**
  31243. * Store of each shader (The can be looked up using effect.key)
  31244. */
  31245. static ShadersStore: {
  31246. [key: string]: string;
  31247. };
  31248. /**
  31249. * Store of each included file for a shader (The can be looked up using effect.key)
  31250. */
  31251. static IncludesShadersStore: {
  31252. [key: string]: string;
  31253. };
  31254. /**
  31255. * Resets the cache of effects.
  31256. */
  31257. static ResetCache(): void;
  31258. }
  31259. }
  31260. declare module "babylonjs/Engines/engineCapabilities" {
  31261. /**
  31262. * Interface used to describe the capabilities of the engine relatively to the current browser
  31263. */
  31264. export interface EngineCapabilities {
  31265. /** Maximum textures units per fragment shader */
  31266. maxTexturesImageUnits: number;
  31267. /** Maximum texture units per vertex shader */
  31268. maxVertexTextureImageUnits: number;
  31269. /** Maximum textures units in the entire pipeline */
  31270. maxCombinedTexturesImageUnits: number;
  31271. /** Maximum texture size */
  31272. maxTextureSize: number;
  31273. /** Maximum texture samples */
  31274. maxSamples?: number;
  31275. /** Maximum cube texture size */
  31276. maxCubemapTextureSize: number;
  31277. /** Maximum render texture size */
  31278. maxRenderTextureSize: number;
  31279. /** Maximum number of vertex attributes */
  31280. maxVertexAttribs: number;
  31281. /** Maximum number of varyings */
  31282. maxVaryingVectors: number;
  31283. /** Maximum number of uniforms per vertex shader */
  31284. maxVertexUniformVectors: number;
  31285. /** Maximum number of uniforms per fragment shader */
  31286. maxFragmentUniformVectors: number;
  31287. /** Defines if standard derivates (dx/dy) are supported */
  31288. standardDerivatives: boolean;
  31289. /** Defines if s3tc texture compression is supported */
  31290. s3tc?: WEBGL_compressed_texture_s3tc;
  31291. /** Defines if pvrtc texture compression is supported */
  31292. pvrtc: any;
  31293. /** Defines if etc1 texture compression is supported */
  31294. etc1: any;
  31295. /** Defines if etc2 texture compression is supported */
  31296. etc2: any;
  31297. /** Defines if astc texture compression is supported */
  31298. astc: any;
  31299. /** Defines if float textures are supported */
  31300. textureFloat: boolean;
  31301. /** Defines if vertex array objects are supported */
  31302. vertexArrayObject: boolean;
  31303. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31304. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31305. /** Gets the maximum level of anisotropy supported */
  31306. maxAnisotropy: number;
  31307. /** Defines if instancing is supported */
  31308. instancedArrays: boolean;
  31309. /** Defines if 32 bits indices are supported */
  31310. uintIndices: boolean;
  31311. /** Defines if high precision shaders are supported */
  31312. highPrecisionShaderSupported: boolean;
  31313. /** Defines if depth reading in the fragment shader is supported */
  31314. fragmentDepthSupported: boolean;
  31315. /** Defines if float texture linear filtering is supported*/
  31316. textureFloatLinearFiltering: boolean;
  31317. /** Defines if rendering to float textures is supported */
  31318. textureFloatRender: boolean;
  31319. /** Defines if half float textures are supported*/
  31320. textureHalfFloat: boolean;
  31321. /** Defines if half float texture linear filtering is supported*/
  31322. textureHalfFloatLinearFiltering: boolean;
  31323. /** Defines if rendering to half float textures is supported */
  31324. textureHalfFloatRender: boolean;
  31325. /** Defines if textureLOD shader command is supported */
  31326. textureLOD: boolean;
  31327. /** Defines if draw buffers extension is supported */
  31328. drawBuffersExtension: boolean;
  31329. /** Defines if depth textures are supported */
  31330. depthTextureExtension: boolean;
  31331. /** Defines if float color buffer are supported */
  31332. colorBufferFloat: boolean;
  31333. /** Gets disjoint timer query extension (null if not supported) */
  31334. timerQuery?: EXT_disjoint_timer_query;
  31335. /** Defines if timestamp can be used with timer query */
  31336. canUseTimestampForTimerQuery: boolean;
  31337. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31338. multiview?: any;
  31339. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31340. oculusMultiview?: any;
  31341. /** Function used to let the system compiles shaders in background */
  31342. parallelShaderCompile?: {
  31343. COMPLETION_STATUS_KHR: number;
  31344. };
  31345. /** Max number of texture samples for MSAA */
  31346. maxMSAASamples: number;
  31347. /** Defines if the blend min max extension is supported */
  31348. blendMinMax: boolean;
  31349. }
  31350. }
  31351. declare module "babylonjs/States/depthCullingState" {
  31352. import { Nullable } from "babylonjs/types";
  31353. /**
  31354. * @hidden
  31355. **/
  31356. export class DepthCullingState {
  31357. private _isDepthTestDirty;
  31358. private _isDepthMaskDirty;
  31359. private _isDepthFuncDirty;
  31360. private _isCullFaceDirty;
  31361. private _isCullDirty;
  31362. private _isZOffsetDirty;
  31363. private _isFrontFaceDirty;
  31364. private _depthTest;
  31365. private _depthMask;
  31366. private _depthFunc;
  31367. private _cull;
  31368. private _cullFace;
  31369. private _zOffset;
  31370. private _frontFace;
  31371. /**
  31372. * Initializes the state.
  31373. */
  31374. constructor();
  31375. get isDirty(): boolean;
  31376. get zOffset(): number;
  31377. set zOffset(value: number);
  31378. get cullFace(): Nullable<number>;
  31379. set cullFace(value: Nullable<number>);
  31380. get cull(): Nullable<boolean>;
  31381. set cull(value: Nullable<boolean>);
  31382. get depthFunc(): Nullable<number>;
  31383. set depthFunc(value: Nullable<number>);
  31384. get depthMask(): boolean;
  31385. set depthMask(value: boolean);
  31386. get depthTest(): boolean;
  31387. set depthTest(value: boolean);
  31388. get frontFace(): Nullable<number>;
  31389. set frontFace(value: Nullable<number>);
  31390. reset(): void;
  31391. apply(gl: WebGLRenderingContext): void;
  31392. }
  31393. }
  31394. declare module "babylonjs/States/stencilState" {
  31395. /**
  31396. * @hidden
  31397. **/
  31398. export class StencilState {
  31399. /** 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 */
  31400. static readonly ALWAYS: number;
  31401. /** Passed to stencilOperation to specify that stencil value must be kept */
  31402. static readonly KEEP: number;
  31403. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31404. static readonly REPLACE: number;
  31405. private _isStencilTestDirty;
  31406. private _isStencilMaskDirty;
  31407. private _isStencilFuncDirty;
  31408. private _isStencilOpDirty;
  31409. private _stencilTest;
  31410. private _stencilMask;
  31411. private _stencilFunc;
  31412. private _stencilFuncRef;
  31413. private _stencilFuncMask;
  31414. private _stencilOpStencilFail;
  31415. private _stencilOpDepthFail;
  31416. private _stencilOpStencilDepthPass;
  31417. get isDirty(): boolean;
  31418. get stencilFunc(): number;
  31419. set stencilFunc(value: number);
  31420. get stencilFuncRef(): number;
  31421. set stencilFuncRef(value: number);
  31422. get stencilFuncMask(): number;
  31423. set stencilFuncMask(value: number);
  31424. get stencilOpStencilFail(): number;
  31425. set stencilOpStencilFail(value: number);
  31426. get stencilOpDepthFail(): number;
  31427. set stencilOpDepthFail(value: number);
  31428. get stencilOpStencilDepthPass(): number;
  31429. set stencilOpStencilDepthPass(value: number);
  31430. get stencilMask(): number;
  31431. set stencilMask(value: number);
  31432. get stencilTest(): boolean;
  31433. set stencilTest(value: boolean);
  31434. constructor();
  31435. reset(): void;
  31436. apply(gl: WebGLRenderingContext): void;
  31437. }
  31438. }
  31439. declare module "babylonjs/States/alphaCullingState" {
  31440. /**
  31441. * @hidden
  31442. **/
  31443. export class AlphaState {
  31444. private _isAlphaBlendDirty;
  31445. private _isBlendFunctionParametersDirty;
  31446. private _isBlendEquationParametersDirty;
  31447. private _isBlendConstantsDirty;
  31448. private _alphaBlend;
  31449. private _blendFunctionParameters;
  31450. private _blendEquationParameters;
  31451. private _blendConstants;
  31452. /**
  31453. * Initializes the state.
  31454. */
  31455. constructor();
  31456. get isDirty(): boolean;
  31457. get alphaBlend(): boolean;
  31458. set alphaBlend(value: boolean);
  31459. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31460. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31461. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31462. reset(): void;
  31463. apply(gl: WebGLRenderingContext): void;
  31464. }
  31465. }
  31466. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31467. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31468. /** @hidden */
  31469. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31470. attributeProcessor(attribute: string): string;
  31471. varyingProcessor(varying: string, isFragment: boolean): string;
  31472. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31473. }
  31474. }
  31475. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31476. /**
  31477. * Interface for attribute information associated with buffer instanciation
  31478. */
  31479. export interface InstancingAttributeInfo {
  31480. /**
  31481. * Name of the GLSL attribute
  31482. * if attribute index is not specified, this is used to retrieve the index from the effect
  31483. */
  31484. attributeName: string;
  31485. /**
  31486. * Index/offset of the attribute in the vertex shader
  31487. * if not specified, this will be computes from the name.
  31488. */
  31489. index?: number;
  31490. /**
  31491. * size of the attribute, 1, 2, 3 or 4
  31492. */
  31493. attributeSize: number;
  31494. /**
  31495. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31496. */
  31497. offset: number;
  31498. /**
  31499. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31500. * default to 1
  31501. */
  31502. divisor?: number;
  31503. /**
  31504. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31505. * default is FLOAT
  31506. */
  31507. attributeType?: number;
  31508. /**
  31509. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31510. */
  31511. normalized?: boolean;
  31512. }
  31513. }
  31514. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31515. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31516. import { Nullable } from "babylonjs/types";
  31517. module "babylonjs/Engines/thinEngine" {
  31518. interface ThinEngine {
  31519. /**
  31520. * Update a video texture
  31521. * @param texture defines the texture to update
  31522. * @param video defines the video element to use
  31523. * @param invertY defines if data must be stored with Y axis inverted
  31524. */
  31525. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31526. }
  31527. }
  31528. }
  31529. declare module "babylonjs/Materials/Textures/videoTexture" {
  31530. import { Observable } from "babylonjs/Misc/observable";
  31531. import { Nullable } from "babylonjs/types";
  31532. import { Scene } from "babylonjs/scene";
  31533. import { Texture } from "babylonjs/Materials/Textures/texture";
  31534. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31535. /**
  31536. * Settings for finer control over video usage
  31537. */
  31538. export interface VideoTextureSettings {
  31539. /**
  31540. * Applies `autoplay` to video, if specified
  31541. */
  31542. autoPlay?: boolean;
  31543. /**
  31544. * Applies `loop` to video, if specified
  31545. */
  31546. loop?: boolean;
  31547. /**
  31548. * Automatically updates internal texture from video at every frame in the render loop
  31549. */
  31550. autoUpdateTexture: boolean;
  31551. /**
  31552. * Image src displayed during the video loading or until the user interacts with the video.
  31553. */
  31554. poster?: string;
  31555. }
  31556. /**
  31557. * If you want to display a video in your scene, this is the special texture for that.
  31558. * This special texture works similar to other textures, with the exception of a few parameters.
  31559. * @see https://doc.babylonjs.com/how_to/video_texture
  31560. */
  31561. export class VideoTexture extends Texture {
  31562. /**
  31563. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31564. */
  31565. readonly autoUpdateTexture: boolean;
  31566. /**
  31567. * The video instance used by the texture internally
  31568. */
  31569. readonly video: HTMLVideoElement;
  31570. private _onUserActionRequestedObservable;
  31571. /**
  31572. * Event triggerd when a dom action is required by the user to play the video.
  31573. * This happens due to recent changes in browser policies preventing video to auto start.
  31574. */
  31575. get onUserActionRequestedObservable(): Observable<Texture>;
  31576. private _generateMipMaps;
  31577. private _engine;
  31578. private _stillImageCaptured;
  31579. private _displayingPosterTexture;
  31580. private _settings;
  31581. private _createInternalTextureOnEvent;
  31582. private _frameId;
  31583. private _currentSrc;
  31584. /**
  31585. * Creates a video texture.
  31586. * If you want to display a video in your scene, this is the special texture for that.
  31587. * This special texture works similar to other textures, with the exception of a few parameters.
  31588. * @see https://doc.babylonjs.com/how_to/video_texture
  31589. * @param name optional name, will detect from video source, if not defined
  31590. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31591. * @param scene is obviously the current scene.
  31592. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31593. * @param invertY is false by default but can be used to invert video on Y axis
  31594. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31595. * @param settings allows finer control over video usage
  31596. */
  31597. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31598. private _getName;
  31599. private _getVideo;
  31600. private _createInternalTexture;
  31601. private reset;
  31602. /**
  31603. * @hidden Internal method to initiate `update`.
  31604. */
  31605. _rebuild(): void;
  31606. /**
  31607. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31608. */
  31609. update(): void;
  31610. /**
  31611. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31612. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31613. */
  31614. updateTexture(isVisible: boolean): void;
  31615. protected _updateInternalTexture: () => void;
  31616. /**
  31617. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31618. * @param url New url.
  31619. */
  31620. updateURL(url: string): void;
  31621. /**
  31622. * Clones the texture.
  31623. * @returns the cloned texture
  31624. */
  31625. clone(): VideoTexture;
  31626. /**
  31627. * Dispose the texture and release its associated resources.
  31628. */
  31629. dispose(): void;
  31630. /**
  31631. * Creates a video texture straight from a stream.
  31632. * @param scene Define the scene the texture should be created in
  31633. * @param stream Define the stream the texture should be created from
  31634. * @returns The created video texture as a promise
  31635. */
  31636. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): 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 constraints Define the constraints to use to create the web cam feed from WebRTC
  31641. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31642. * @returns The created video texture as a promise
  31643. */
  31644. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31645. minWidth: number;
  31646. maxWidth: number;
  31647. minHeight: number;
  31648. maxHeight: number;
  31649. deviceId: string;
  31650. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31651. /**
  31652. * Creates a video texture straight from your WebCam video feed.
  31653. * @param scene Define the scene the texture should be created in
  31654. * @param onReady Define a callback to triggered once the texture will be ready
  31655. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31656. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31657. */
  31658. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31659. minWidth: number;
  31660. maxWidth: number;
  31661. minHeight: number;
  31662. maxHeight: number;
  31663. deviceId: string;
  31664. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31665. }
  31666. }
  31667. declare module "babylonjs/Engines/thinEngine" {
  31668. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31669. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31670. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31671. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31672. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31673. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31674. import { Observable } from "babylonjs/Misc/observable";
  31675. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31676. import { StencilState } from "babylonjs/States/stencilState";
  31677. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31678. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31679. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31680. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31681. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31682. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31683. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31684. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31685. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31687. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31688. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31689. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31690. import { WebRequest } from "babylonjs/Misc/webRequest";
  31691. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31692. /**
  31693. * Defines the interface used by objects working like Scene
  31694. * @hidden
  31695. */
  31696. interface ISceneLike {
  31697. _addPendingData(data: any): void;
  31698. _removePendingData(data: any): void;
  31699. offlineProvider: IOfflineProvider;
  31700. }
  31701. /** Interface defining initialization parameters for Engine class */
  31702. export interface EngineOptions extends WebGLContextAttributes {
  31703. /**
  31704. * Defines if the engine should no exceed a specified device ratio
  31705. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31706. */
  31707. limitDeviceRatio?: number;
  31708. /**
  31709. * Defines if webvr should be enabled automatically
  31710. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31711. */
  31712. autoEnableWebVR?: boolean;
  31713. /**
  31714. * Defines if webgl2 should be turned off even if supported
  31715. * @see http://doc.babylonjs.com/features/webgl2
  31716. */
  31717. disableWebGL2Support?: boolean;
  31718. /**
  31719. * Defines if webaudio should be initialized as well
  31720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31721. */
  31722. audioEngine?: boolean;
  31723. /**
  31724. * Defines if animations should run using a deterministic lock step
  31725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31726. */
  31727. deterministicLockstep?: boolean;
  31728. /** Defines the maximum steps to use with deterministic lock step mode */
  31729. lockstepMaxSteps?: number;
  31730. /** Defines the seconds between each deterministic lock step */
  31731. timeStep?: number;
  31732. /**
  31733. * Defines that engine should ignore context lost events
  31734. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31735. */
  31736. doNotHandleContextLost?: boolean;
  31737. /**
  31738. * Defines that engine should ignore modifying touch action attribute and style
  31739. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31740. */
  31741. doNotHandleTouchAction?: boolean;
  31742. /**
  31743. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31744. */
  31745. useHighPrecisionFloats?: boolean;
  31746. }
  31747. /**
  31748. * The base engine class (root of all engines)
  31749. */
  31750. export class ThinEngine {
  31751. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31752. static ExceptionList: ({
  31753. key: string;
  31754. capture: string;
  31755. captureConstraint: number;
  31756. targets: string[];
  31757. } | {
  31758. key: string;
  31759. capture: null;
  31760. captureConstraint: null;
  31761. targets: string[];
  31762. })[];
  31763. /** @hidden */
  31764. static _TextureLoaders: IInternalTextureLoader[];
  31765. /**
  31766. * Returns the current npm package of the sdk
  31767. */
  31768. static get NpmPackage(): string;
  31769. /**
  31770. * Returns the current version of the framework
  31771. */
  31772. static get Version(): string;
  31773. /**
  31774. * Returns a string describing the current engine
  31775. */
  31776. get description(): string;
  31777. /**
  31778. * Gets or sets the epsilon value used by collision engine
  31779. */
  31780. static CollisionsEpsilon: number;
  31781. /**
  31782. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31783. */
  31784. static get ShadersRepository(): string;
  31785. static set ShadersRepository(value: string);
  31786. /**
  31787. * Gets or sets the textures that the engine should not attempt to load as compressed
  31788. */
  31789. protected _excludedCompressedTextures: string[];
  31790. /**
  31791. * Filters the compressed texture formats to only include
  31792. * files that are not included in the skippable list
  31793. *
  31794. * @param url the current extension
  31795. * @param textureFormatInUse the current compressed texture format
  31796. * @returns "format" string
  31797. */
  31798. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31799. /** @hidden */
  31800. _shaderProcessor: IShaderProcessor;
  31801. /**
  31802. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31803. */
  31804. forcePOTTextures: boolean;
  31805. /**
  31806. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31807. */
  31808. isFullscreen: boolean;
  31809. /**
  31810. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31811. */
  31812. cullBackFaces: boolean;
  31813. /**
  31814. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31815. */
  31816. renderEvenInBackground: boolean;
  31817. /**
  31818. * Gets or sets a boolean indicating that cache can be kept between frames
  31819. */
  31820. preventCacheWipeBetweenFrames: boolean;
  31821. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31822. validateShaderPrograms: boolean;
  31823. /**
  31824. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31825. * This can provide greater z depth for distant objects.
  31826. */
  31827. useReverseDepthBuffer: boolean;
  31828. /**
  31829. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31830. */
  31831. disableUniformBuffers: boolean;
  31832. /** @hidden */
  31833. _uniformBuffers: UniformBuffer[];
  31834. /**
  31835. * Gets a boolean indicating that the engine supports uniform buffers
  31836. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31837. */
  31838. get supportsUniformBuffers(): boolean;
  31839. /** @hidden */
  31840. _gl: WebGLRenderingContext;
  31841. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31842. protected _windowIsBackground: boolean;
  31843. protected _webGLVersion: number;
  31844. protected _creationOptions: EngineOptions;
  31845. protected _highPrecisionShadersAllowed: boolean;
  31846. /** @hidden */
  31847. get _shouldUseHighPrecisionShader(): boolean;
  31848. /**
  31849. * Gets a boolean indicating that only power of 2 textures are supported
  31850. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31851. */
  31852. get needPOTTextures(): boolean;
  31853. /** @hidden */
  31854. _badOS: boolean;
  31855. /** @hidden */
  31856. _badDesktopOS: boolean;
  31857. private _hardwareScalingLevel;
  31858. /** @hidden */
  31859. _caps: EngineCapabilities;
  31860. private _isStencilEnable;
  31861. private _glVersion;
  31862. private _glRenderer;
  31863. private _glVendor;
  31864. /** @hidden */
  31865. _videoTextureSupported: boolean;
  31866. protected _renderingQueueLaunched: boolean;
  31867. protected _activeRenderLoops: (() => void)[];
  31868. /**
  31869. * Observable signaled when a context lost event is raised
  31870. */
  31871. onContextLostObservable: Observable<ThinEngine>;
  31872. /**
  31873. * Observable signaled when a context restored event is raised
  31874. */
  31875. onContextRestoredObservable: Observable<ThinEngine>;
  31876. private _onContextLost;
  31877. private _onContextRestored;
  31878. protected _contextWasLost: boolean;
  31879. /** @hidden */
  31880. _doNotHandleContextLost: boolean;
  31881. /**
  31882. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31884. */
  31885. get doNotHandleContextLost(): boolean;
  31886. set doNotHandleContextLost(value: boolean);
  31887. /**
  31888. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31889. */
  31890. disableVertexArrayObjects: boolean;
  31891. /** @hidden */
  31892. protected _colorWrite: boolean;
  31893. /** @hidden */
  31894. protected _colorWriteChanged: boolean;
  31895. /** @hidden */
  31896. protected _depthCullingState: DepthCullingState;
  31897. /** @hidden */
  31898. protected _stencilState: StencilState;
  31899. /** @hidden */
  31900. _alphaState: AlphaState;
  31901. /** @hidden */
  31902. _alphaMode: number;
  31903. /** @hidden */
  31904. _alphaEquation: number;
  31905. /** @hidden */
  31906. _internalTexturesCache: InternalTexture[];
  31907. /** @hidden */
  31908. protected _activeChannel: number;
  31909. private _currentTextureChannel;
  31910. /** @hidden */
  31911. protected _boundTexturesCache: {
  31912. [key: string]: Nullable<InternalTexture>;
  31913. };
  31914. /** @hidden */
  31915. protected _currentEffect: Nullable<Effect>;
  31916. /** @hidden */
  31917. protected _currentProgram: Nullable<WebGLProgram>;
  31918. private _compiledEffects;
  31919. private _vertexAttribArraysEnabled;
  31920. /** @hidden */
  31921. protected _cachedViewport: Nullable<IViewportLike>;
  31922. private _cachedVertexArrayObject;
  31923. /** @hidden */
  31924. protected _cachedVertexBuffers: any;
  31925. /** @hidden */
  31926. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31927. /** @hidden */
  31928. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31929. /** @hidden */
  31930. _currentRenderTarget: Nullable<InternalTexture>;
  31931. private _uintIndicesCurrentlySet;
  31932. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31933. /** @hidden */
  31934. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31935. private _currentBufferPointers;
  31936. private _currentInstanceLocations;
  31937. private _currentInstanceBuffers;
  31938. private _textureUnits;
  31939. /** @hidden */
  31940. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31941. /** @hidden */
  31942. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31943. /** @hidden */
  31944. _boundRenderFunction: any;
  31945. private _vaoRecordInProgress;
  31946. private _mustWipeVertexAttributes;
  31947. private _emptyTexture;
  31948. private _emptyCubeTexture;
  31949. private _emptyTexture3D;
  31950. private _emptyTexture2DArray;
  31951. /** @hidden */
  31952. _frameHandler: number;
  31953. private _nextFreeTextureSlots;
  31954. private _maxSimultaneousTextures;
  31955. private _activeRequests;
  31956. protected _texturesSupported: string[];
  31957. /** @hidden */
  31958. _textureFormatInUse: Nullable<string>;
  31959. protected get _supportsHardwareTextureRescaling(): boolean;
  31960. /**
  31961. * Gets the list of texture formats supported
  31962. */
  31963. get texturesSupported(): Array<string>;
  31964. /**
  31965. * Gets the list of texture formats in use
  31966. */
  31967. get textureFormatInUse(): Nullable<string>;
  31968. /**
  31969. * Gets the current viewport
  31970. */
  31971. get currentViewport(): Nullable<IViewportLike>;
  31972. /**
  31973. * Gets the default empty texture
  31974. */
  31975. get emptyTexture(): InternalTexture;
  31976. /**
  31977. * Gets the default empty 3D texture
  31978. */
  31979. get emptyTexture3D(): InternalTexture;
  31980. /**
  31981. * Gets the default empty 2D array texture
  31982. */
  31983. get emptyTexture2DArray(): InternalTexture;
  31984. /**
  31985. * Gets the default empty cube texture
  31986. */
  31987. get emptyCubeTexture(): InternalTexture;
  31988. /**
  31989. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31990. */
  31991. readonly premultipliedAlpha: boolean;
  31992. /**
  31993. * Observable event triggered before each texture is initialized
  31994. */
  31995. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31996. /**
  31997. * Creates a new engine
  31998. * @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
  31999. * @param antialias defines enable antialiasing (default: false)
  32000. * @param options defines further options to be sent to the getContext() function
  32001. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32002. */
  32003. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32004. private _rebuildInternalTextures;
  32005. private _rebuildEffects;
  32006. /**
  32007. * Gets a boolean indicating if all created effects are ready
  32008. * @returns true if all effects are ready
  32009. */
  32010. areAllEffectsReady(): boolean;
  32011. protected _rebuildBuffers(): void;
  32012. private _initGLContext;
  32013. /**
  32014. * Gets version of the current webGL context
  32015. */
  32016. get webGLVersion(): number;
  32017. /**
  32018. * Gets a string idenfifying the name of the class
  32019. * @returns "Engine" string
  32020. */
  32021. getClassName(): string;
  32022. /**
  32023. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32024. */
  32025. get isStencilEnable(): boolean;
  32026. /** @hidden */
  32027. _prepareWorkingCanvas(): void;
  32028. /**
  32029. * Reset the texture cache to empty state
  32030. */
  32031. resetTextureCache(): void;
  32032. /**
  32033. * Gets an object containing information about the current webGL context
  32034. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32035. */
  32036. getGlInfo(): {
  32037. vendor: string;
  32038. renderer: string;
  32039. version: string;
  32040. };
  32041. /**
  32042. * Defines the hardware scaling level.
  32043. * By default the hardware scaling level is computed from the window device ratio.
  32044. * 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.
  32045. * @param level defines the level to use
  32046. */
  32047. setHardwareScalingLevel(level: number): void;
  32048. /**
  32049. * Gets the current hardware scaling level.
  32050. * By default the hardware scaling level is computed from the window device ratio.
  32051. * 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.
  32052. * @returns a number indicating the current hardware scaling level
  32053. */
  32054. getHardwareScalingLevel(): number;
  32055. /**
  32056. * Gets the list of loaded textures
  32057. * @returns an array containing all loaded textures
  32058. */
  32059. getLoadedTexturesCache(): InternalTexture[];
  32060. /**
  32061. * Gets the object containing all engine capabilities
  32062. * @returns the EngineCapabilities object
  32063. */
  32064. getCaps(): EngineCapabilities;
  32065. /**
  32066. * stop executing a render loop function and remove it from the execution array
  32067. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32068. */
  32069. stopRenderLoop(renderFunction?: () => void): void;
  32070. /** @hidden */
  32071. _renderLoop(): void;
  32072. /**
  32073. * Gets the HTML canvas attached with the current webGL context
  32074. * @returns a HTML canvas
  32075. */
  32076. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32077. /**
  32078. * Gets host window
  32079. * @returns the host window object
  32080. */
  32081. getHostWindow(): Nullable<Window>;
  32082. /**
  32083. * Gets the current render width
  32084. * @param useScreen defines if screen size must be used (or the current render target if any)
  32085. * @returns a number defining the current render width
  32086. */
  32087. getRenderWidth(useScreen?: boolean): number;
  32088. /**
  32089. * Gets the current render height
  32090. * @param useScreen defines if screen size must be used (or the current render target if any)
  32091. * @returns a number defining the current render height
  32092. */
  32093. getRenderHeight(useScreen?: boolean): number;
  32094. /**
  32095. * Can be used to override the current requestAnimationFrame requester.
  32096. * @hidden
  32097. */
  32098. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32099. /**
  32100. * Register and execute a render loop. The engine can have more than one render function
  32101. * @param renderFunction defines the function to continuously execute
  32102. */
  32103. runRenderLoop(renderFunction: () => void): void;
  32104. /**
  32105. * Clear the current render buffer or the current render target (if any is set up)
  32106. * @param color defines the color to use
  32107. * @param backBuffer defines if the back buffer must be cleared
  32108. * @param depth defines if the depth buffer must be cleared
  32109. * @param stencil defines if the stencil buffer must be cleared
  32110. */
  32111. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32112. private _viewportCached;
  32113. /** @hidden */
  32114. _viewport(x: number, y: number, width: number, height: number): void;
  32115. /**
  32116. * Set the WebGL's viewport
  32117. * @param viewport defines the viewport element to be used
  32118. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32119. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32120. */
  32121. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32122. /**
  32123. * Begin a new frame
  32124. */
  32125. beginFrame(): void;
  32126. /**
  32127. * Enf the current frame
  32128. */
  32129. endFrame(): void;
  32130. /**
  32131. * Resize the view according to the canvas' size
  32132. */
  32133. resize(): void;
  32134. /**
  32135. * Force a specific size of the canvas
  32136. * @param width defines the new canvas' width
  32137. * @param height defines the new canvas' height
  32138. */
  32139. setSize(width: number, height: number): void;
  32140. /**
  32141. * Binds the frame buffer to the specified texture.
  32142. * @param texture The texture to render to or null for the default canvas
  32143. * @param faceIndex The face of the texture to render to in case of cube texture
  32144. * @param requiredWidth The width of the target to render to
  32145. * @param requiredHeight The height of the target to render to
  32146. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32147. * @param lodLevel defines the lod level to bind to the frame buffer
  32148. * @param layer defines the 2d array index to bind to frame buffer to
  32149. */
  32150. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32151. /** @hidden */
  32152. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32153. /**
  32154. * Unbind the current render target texture from the webGL context
  32155. * @param texture defines the render target texture to unbind
  32156. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32157. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32158. */
  32159. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32160. /**
  32161. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32162. */
  32163. flushFramebuffer(): void;
  32164. /**
  32165. * Unbind the current render target and bind the default framebuffer
  32166. */
  32167. restoreDefaultFramebuffer(): void;
  32168. /** @hidden */
  32169. protected _resetVertexBufferBinding(): void;
  32170. /**
  32171. * Creates a vertex buffer
  32172. * @param data the data for the vertex buffer
  32173. * @returns the new WebGL static buffer
  32174. */
  32175. createVertexBuffer(data: DataArray): DataBuffer;
  32176. private _createVertexBuffer;
  32177. /**
  32178. * Creates a dynamic vertex buffer
  32179. * @param data the data for the dynamic vertex buffer
  32180. * @returns the new WebGL dynamic buffer
  32181. */
  32182. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32183. protected _resetIndexBufferBinding(): void;
  32184. /**
  32185. * Creates a new index buffer
  32186. * @param indices defines the content of the index buffer
  32187. * @param updatable defines if the index buffer must be updatable
  32188. * @returns a new webGL buffer
  32189. */
  32190. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32191. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32192. /**
  32193. * Bind a webGL buffer to the webGL context
  32194. * @param buffer defines the buffer to bind
  32195. */
  32196. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32197. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32198. private bindBuffer;
  32199. /**
  32200. * update the bound buffer with the given data
  32201. * @param data defines the data to update
  32202. */
  32203. updateArrayBuffer(data: Float32Array): void;
  32204. private _vertexAttribPointer;
  32205. private _bindIndexBufferWithCache;
  32206. private _bindVertexBuffersAttributes;
  32207. /**
  32208. * Records a vertex array object
  32209. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32210. * @param vertexBuffers defines the list of vertex buffers to store
  32211. * @param indexBuffer defines the index buffer to store
  32212. * @param effect defines the effect to store
  32213. * @returns the new vertex array object
  32214. */
  32215. recordVertexArrayObject(vertexBuffers: {
  32216. [key: string]: VertexBuffer;
  32217. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32218. /**
  32219. * Bind a specific vertex array object
  32220. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32221. * @param vertexArrayObject defines the vertex array object to bind
  32222. * @param indexBuffer defines the index buffer to bind
  32223. */
  32224. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32225. /**
  32226. * Bind webGl buffers directly to the webGL context
  32227. * @param vertexBuffer defines the vertex buffer to bind
  32228. * @param indexBuffer defines the index buffer to bind
  32229. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32230. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32231. * @param effect defines the effect associated with the vertex buffer
  32232. */
  32233. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32234. private _unbindVertexArrayObject;
  32235. /**
  32236. * Bind a list of vertex buffers to the webGL context
  32237. * @param vertexBuffers defines the list of vertex buffers to bind
  32238. * @param indexBuffer defines the index buffer to bind
  32239. * @param effect defines the effect associated with the vertex buffers
  32240. */
  32241. bindBuffers(vertexBuffers: {
  32242. [key: string]: Nullable<VertexBuffer>;
  32243. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32244. /**
  32245. * Unbind all instance attributes
  32246. */
  32247. unbindInstanceAttributes(): void;
  32248. /**
  32249. * Release and free the memory of a vertex array object
  32250. * @param vao defines the vertex array object to delete
  32251. */
  32252. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32253. /** @hidden */
  32254. _releaseBuffer(buffer: DataBuffer): boolean;
  32255. protected _deleteBuffer(buffer: DataBuffer): void;
  32256. /**
  32257. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32258. * @param instancesBuffer defines the webGL buffer to update and bind
  32259. * @param data defines the data to store in the buffer
  32260. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32261. */
  32262. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32263. /**
  32264. * Bind the content of a webGL buffer used with instanciation
  32265. * @param instancesBuffer defines the webGL buffer to bind
  32266. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32267. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32268. */
  32269. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32270. /**
  32271. * Disable the instance attribute corresponding to the name in parameter
  32272. * @param name defines the name of the attribute to disable
  32273. */
  32274. disableInstanceAttributeByName(name: string): void;
  32275. /**
  32276. * Disable the instance attribute corresponding to the location in parameter
  32277. * @param attributeLocation defines the attribute location of the attribute to disable
  32278. */
  32279. disableInstanceAttribute(attributeLocation: number): void;
  32280. /**
  32281. * Disable the attribute corresponding to the location in parameter
  32282. * @param attributeLocation defines the attribute location of the attribute to disable
  32283. */
  32284. disableAttributeByIndex(attributeLocation: number): void;
  32285. /**
  32286. * Send a draw order
  32287. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32288. * @param indexStart defines the starting index
  32289. * @param indexCount defines the number of index to draw
  32290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32291. */
  32292. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32293. /**
  32294. * Draw a list of points
  32295. * @param verticesStart defines the index of first vertex to draw
  32296. * @param verticesCount defines the count of vertices to draw
  32297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32298. */
  32299. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32300. /**
  32301. * Draw a list of unindexed primitives
  32302. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32303. * @param verticesStart defines the index of first vertex to draw
  32304. * @param verticesCount defines the count of vertices to draw
  32305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32306. */
  32307. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32308. /**
  32309. * Draw a list of indexed primitives
  32310. * @param fillMode defines the primitive to use
  32311. * @param indexStart defines the starting index
  32312. * @param indexCount defines the number of index to draw
  32313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32314. */
  32315. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32316. /**
  32317. * Draw a list of unindexed primitives
  32318. * @param fillMode defines the primitive to use
  32319. * @param verticesStart defines the index of first vertex to draw
  32320. * @param verticesCount defines the count of vertices to draw
  32321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32322. */
  32323. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32324. private _drawMode;
  32325. /** @hidden */
  32326. protected _reportDrawCall(): void;
  32327. /** @hidden */
  32328. _releaseEffect(effect: Effect): void;
  32329. /** @hidden */
  32330. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32331. /**
  32332. * Create a new effect (used to store vertex/fragment shaders)
  32333. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32334. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32335. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32336. * @param samplers defines an array of string used to represent textures
  32337. * @param defines defines the string containing the defines to use to compile the shaders
  32338. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32339. * @param onCompiled defines a function to call when the effect creation is successful
  32340. * @param onError defines a function to call when the effect creation has failed
  32341. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32342. * @returns the new Effect
  32343. */
  32344. 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;
  32345. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32346. private _compileShader;
  32347. private _compileRawShader;
  32348. /**
  32349. * Directly creates a webGL program
  32350. * @param pipelineContext defines the pipeline context to attach to
  32351. * @param vertexCode defines the vertex shader code to use
  32352. * @param fragmentCode defines the fragment shader code to use
  32353. * @param context defines the webGL context to use (if not set, the current one will be used)
  32354. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32355. * @returns the new webGL program
  32356. */
  32357. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32358. /**
  32359. * Creates a webGL program
  32360. * @param pipelineContext defines the pipeline context to attach to
  32361. * @param vertexCode defines the vertex shader code to use
  32362. * @param fragmentCode defines the fragment shader code to use
  32363. * @param defines defines the string containing the defines to use to compile the shaders
  32364. * @param context defines the webGL context to use (if not set, the current one will be used)
  32365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32366. * @returns the new webGL program
  32367. */
  32368. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32369. /**
  32370. * Creates a new pipeline context
  32371. * @returns the new pipeline
  32372. */
  32373. createPipelineContext(): IPipelineContext;
  32374. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32375. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32376. /** @hidden */
  32377. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32378. /** @hidden */
  32379. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32380. /** @hidden */
  32381. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32382. /**
  32383. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32384. * @param pipelineContext defines the pipeline context to use
  32385. * @param uniformsNames defines the list of uniform names
  32386. * @returns an array of webGL uniform locations
  32387. */
  32388. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32389. /**
  32390. * Gets the lsit of active attributes for a given webGL program
  32391. * @param pipelineContext defines the pipeline context to use
  32392. * @param attributesNames defines the list of attribute names to get
  32393. * @returns an array of indices indicating the offset of each attribute
  32394. */
  32395. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32396. /**
  32397. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32398. * @param effect defines the effect to activate
  32399. */
  32400. enableEffect(effect: Nullable<Effect>): void;
  32401. /**
  32402. * Set the value of an uniform to a number (int)
  32403. * @param uniform defines the webGL uniform location where to store the value
  32404. * @param value defines the int number to store
  32405. */
  32406. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32407. /**
  32408. * Set the value of an uniform to an array of int32
  32409. * @param uniform defines the webGL uniform location where to store the value
  32410. * @param array defines the array of int32 to store
  32411. */
  32412. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32413. /**
  32414. * Set the value of an uniform to an array of int32 (stored as vec2)
  32415. * @param uniform defines the webGL uniform location where to store the value
  32416. * @param array defines the array of int32 to store
  32417. */
  32418. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32419. /**
  32420. * Set the value of an uniform to an array of int32 (stored as vec3)
  32421. * @param uniform defines the webGL uniform location where to store the value
  32422. * @param array defines the array of int32 to store
  32423. */
  32424. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32425. /**
  32426. * Set the value of an uniform to an array of int32 (stored as vec4)
  32427. * @param uniform defines the webGL uniform location where to store the value
  32428. * @param array defines the array of int32 to store
  32429. */
  32430. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32431. /**
  32432. * Set the value of an uniform to an array of number
  32433. * @param uniform defines the webGL uniform location where to store the value
  32434. * @param array defines the array of number to store
  32435. */
  32436. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32437. /**
  32438. * Set the value of an uniform to an array of number (stored as vec2)
  32439. * @param uniform defines the webGL uniform location where to store the value
  32440. * @param array defines the array of number to store
  32441. */
  32442. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32443. /**
  32444. * Set the value of an uniform to an array of number (stored as vec3)
  32445. * @param uniform defines the webGL uniform location where to store the value
  32446. * @param array defines the array of number to store
  32447. */
  32448. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32449. /**
  32450. * Set the value of an uniform to an array of number (stored as vec4)
  32451. * @param uniform defines the webGL uniform location where to store the value
  32452. * @param array defines the array of number to store
  32453. */
  32454. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32455. /**
  32456. * Set the value of an uniform to an array of float32 (stored as matrices)
  32457. * @param uniform defines the webGL uniform location where to store the value
  32458. * @param matrices defines the array of float32 to store
  32459. */
  32460. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32461. /**
  32462. * Set the value of an uniform to a matrix (3x3)
  32463. * @param uniform defines the webGL uniform location where to store the value
  32464. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32465. */
  32466. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32467. /**
  32468. * Set the value of an uniform to a matrix (2x2)
  32469. * @param uniform defines the webGL uniform location where to store the value
  32470. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32471. */
  32472. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32473. /**
  32474. * Set the value of an uniform to a number (float)
  32475. * @param uniform defines the webGL uniform location where to store the value
  32476. * @param value defines the float number to store
  32477. */
  32478. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32479. /**
  32480. * Set the value of an uniform to a vec2
  32481. * @param uniform defines the webGL uniform location where to store the value
  32482. * @param x defines the 1st component of the value
  32483. * @param y defines the 2nd component of the value
  32484. */
  32485. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32486. /**
  32487. * Set the value of an uniform to a vec3
  32488. * @param uniform defines the webGL uniform location where to store the value
  32489. * @param x defines the 1st component of the value
  32490. * @param y defines the 2nd component of the value
  32491. * @param z defines the 3rd component of the value
  32492. */
  32493. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32494. /**
  32495. * Set the value of an uniform to a vec4
  32496. * @param uniform defines the webGL uniform location where to store the value
  32497. * @param x defines the 1st component of the value
  32498. * @param y defines the 2nd component of the value
  32499. * @param z defines the 3rd component of the value
  32500. * @param w defines the 4th component of the value
  32501. */
  32502. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32503. /**
  32504. * Apply all cached states (depth, culling, stencil and alpha)
  32505. */
  32506. applyStates(): void;
  32507. /**
  32508. * Enable or disable color writing
  32509. * @param enable defines the state to set
  32510. */
  32511. setColorWrite(enable: boolean): void;
  32512. /**
  32513. * Gets a boolean indicating if color writing is enabled
  32514. * @returns the current color writing state
  32515. */
  32516. getColorWrite(): boolean;
  32517. /**
  32518. * Gets the depth culling state manager
  32519. */
  32520. get depthCullingState(): DepthCullingState;
  32521. /**
  32522. * Gets the alpha state manager
  32523. */
  32524. get alphaState(): AlphaState;
  32525. /**
  32526. * Gets the stencil state manager
  32527. */
  32528. get stencilState(): StencilState;
  32529. /**
  32530. * Clears the list of texture accessible through engine.
  32531. * This can help preventing texture load conflict due to name collision.
  32532. */
  32533. clearInternalTexturesCache(): void;
  32534. /**
  32535. * Force the entire cache to be cleared
  32536. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32537. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32538. */
  32539. wipeCaches(bruteForce?: boolean): void;
  32540. /** @hidden */
  32541. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32542. min: number;
  32543. mag: number;
  32544. };
  32545. /** @hidden */
  32546. _createTexture(): WebGLTexture;
  32547. /**
  32548. * Usually called from Texture.ts.
  32549. * Passed information to create a WebGLTexture
  32550. * @param urlArg defines a value which contains one of the following:
  32551. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32552. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32553. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32554. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32555. * @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)
  32556. * @param scene needed for loading to the correct scene
  32557. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32558. * @param onLoad optional callback to be called upon successful completion
  32559. * @param onError optional callback to be called upon failure
  32560. * @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
  32561. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32562. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32563. * @param forcedExtension defines the extension to use to pick the right loader
  32564. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32565. * @param mimeType defines an optional mime type
  32566. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32567. */
  32568. 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;
  32569. /**
  32570. * Loads an image as an HTMLImageElement.
  32571. * @param input url string, ArrayBuffer, or Blob to load
  32572. * @param onLoad callback called when the image successfully loads
  32573. * @param onError callback called when the image fails to load
  32574. * @param offlineProvider offline provider for caching
  32575. * @param mimeType optional mime type
  32576. * @returns the HTMLImageElement of the loaded image
  32577. * @hidden
  32578. */
  32579. 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>;
  32580. /**
  32581. * @hidden
  32582. */
  32583. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32584. /**
  32585. * Creates a raw texture
  32586. * @param data defines the data to store in the texture
  32587. * @param width defines the width of the texture
  32588. * @param height defines the height of the texture
  32589. * @param format defines the format of the data
  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 (Texture.NEAREST_SAMPLINGMODE by default)
  32593. * @param compression defines the compression used (null by default)
  32594. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32595. * @returns the raw texture inside an InternalTexture
  32596. */
  32597. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32598. /**
  32599. * Creates a new raw cube texture
  32600. * @param data defines the array of data to use to create each face
  32601. * @param size defines the size of the textures
  32602. * @param format defines the format of the data
  32603. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32604. * @param generateMipMaps defines if the engine should generate the 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 compression used (null by default)
  32608. * @returns the cube texture as an InternalTexture
  32609. */
  32610. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32611. /**
  32612. * Creates a new raw 3D texture
  32613. * @param data defines the data used to create the texture
  32614. * @param width defines the width of the texture
  32615. * @param height defines the height of the texture
  32616. * @param depth defines the depth of the texture
  32617. * @param format defines the format of the texture
  32618. * @param generateMipMaps defines if the engine must generate mip levels
  32619. * @param invertY defines if data must be stored with Y axis inverted
  32620. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32621. * @param compression defines the compressed used (can be null)
  32622. * @param textureType defines the compressed used (can be null)
  32623. * @returns a new raw 3D texture (stored in an InternalTexture)
  32624. */
  32625. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32626. /**
  32627. * Creates a new raw 2D array texture
  32628. * @param data defines the data used to create the texture
  32629. * @param width defines the width of the texture
  32630. * @param height defines the height of the texture
  32631. * @param depth defines the number of layers of the texture
  32632. * @param format defines the format of the texture
  32633. * @param generateMipMaps defines if the engine must generate mip levels
  32634. * @param invertY defines if data must be stored with Y axis inverted
  32635. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32636. * @param compression defines the compressed used (can be null)
  32637. * @param textureType defines the compressed used (can be null)
  32638. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32639. */
  32640. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32641. private _unpackFlipYCached;
  32642. /**
  32643. * In case you are sharing the context with other applications, it might
  32644. * be interested to not cache the unpack flip y state to ensure a consistent
  32645. * value would be set.
  32646. */
  32647. enableUnpackFlipYCached: boolean;
  32648. /** @hidden */
  32649. _unpackFlipY(value: boolean): void;
  32650. /** @hidden */
  32651. _getUnpackAlignement(): number;
  32652. private _getTextureTarget;
  32653. /**
  32654. * Update the sampling mode of a given texture
  32655. * @param samplingMode defines the required sampling mode
  32656. * @param texture defines the texture to update
  32657. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32658. */
  32659. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32660. /**
  32661. * Update the sampling mode of a given texture
  32662. * @param texture defines the texture to update
  32663. * @param wrapU defines the texture wrap mode of the u coordinates
  32664. * @param wrapV defines the texture wrap mode of the v coordinates
  32665. * @param wrapR defines the texture wrap mode of the r coordinates
  32666. */
  32667. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32668. /** @hidden */
  32669. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32670. width: number;
  32671. height: number;
  32672. layers?: number;
  32673. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32674. /** @hidden */
  32675. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32676. /** @hidden */
  32677. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32678. /**
  32679. * Update a portion of an internal texture
  32680. * @param texture defines the texture to update
  32681. * @param imageData defines the data to store into the texture
  32682. * @param xOffset defines the x coordinates of the update rectangle
  32683. * @param yOffset defines the y coordinates of the update rectangle
  32684. * @param width defines the width of the update rectangle
  32685. * @param height defines the height of the update rectangle
  32686. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32687. * @param lod defines the lod level to update (0 by default)
  32688. */
  32689. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32690. /** @hidden */
  32691. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32692. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32693. private _prepareWebGLTexture;
  32694. /** @hidden */
  32695. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32696. private _getDepthStencilBuffer;
  32697. /** @hidden */
  32698. _releaseFramebufferObjects(texture: InternalTexture): void;
  32699. /** @hidden */
  32700. _releaseTexture(texture: InternalTexture): void;
  32701. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32702. protected _setProgram(program: WebGLProgram): void;
  32703. protected _boundUniforms: {
  32704. [key: number]: WebGLUniformLocation;
  32705. };
  32706. /**
  32707. * Binds an effect to the webGL context
  32708. * @param effect defines the effect to bind
  32709. */
  32710. bindSamplers(effect: Effect): void;
  32711. private _activateCurrentTexture;
  32712. /** @hidden */
  32713. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32714. /** @hidden */
  32715. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32716. /**
  32717. * Unbind all textures from the webGL context
  32718. */
  32719. unbindAllTextures(): void;
  32720. /**
  32721. * Sets a texture to the according uniform.
  32722. * @param channel The texture channel
  32723. * @param uniform The uniform to set
  32724. * @param texture The texture to apply
  32725. */
  32726. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32727. private _bindSamplerUniformToChannel;
  32728. private _getTextureWrapMode;
  32729. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32730. /**
  32731. * Sets an array of texture to the webGL context
  32732. * @param channel defines the channel where the texture array must be set
  32733. * @param uniform defines the associated uniform location
  32734. * @param textures defines the array of textures to bind
  32735. */
  32736. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32737. /** @hidden */
  32738. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32739. private _setTextureParameterFloat;
  32740. private _setTextureParameterInteger;
  32741. /**
  32742. * Unbind all vertex attributes from the webGL context
  32743. */
  32744. unbindAllAttributes(): void;
  32745. /**
  32746. * 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
  32747. */
  32748. releaseEffects(): void;
  32749. /**
  32750. * Dispose and release all associated resources
  32751. */
  32752. dispose(): void;
  32753. /**
  32754. * Attach a new callback raised when context lost event is fired
  32755. * @param callback defines the callback to call
  32756. */
  32757. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32758. /**
  32759. * Attach a new callback raised when context restored event is fired
  32760. * @param callback defines the callback to call
  32761. */
  32762. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32763. /**
  32764. * Get the current error code of the webGL context
  32765. * @returns the error code
  32766. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32767. */
  32768. getError(): number;
  32769. private _canRenderToFloatFramebuffer;
  32770. private _canRenderToHalfFloatFramebuffer;
  32771. private _canRenderToFramebuffer;
  32772. /** @hidden */
  32773. _getWebGLTextureType(type: number): number;
  32774. /** @hidden */
  32775. _getInternalFormat(format: number): number;
  32776. /** @hidden */
  32777. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32778. /** @hidden */
  32779. _getRGBAMultiSampleBufferFormat(type: number): number;
  32780. /** @hidden */
  32781. _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;
  32782. /**
  32783. * Loads a file from a url
  32784. * @param url url to load
  32785. * @param onSuccess callback called when the file successfully loads
  32786. * @param onProgress callback called while file is loading (if the server supports this mode)
  32787. * @param offlineProvider defines the offline provider for caching
  32788. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32789. * @param onError callback called when the file fails to load
  32790. * @returns a file request object
  32791. * @hidden
  32792. */
  32793. 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;
  32794. /**
  32795. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32796. * @param x defines the x coordinate of the rectangle where pixels must be read
  32797. * @param y defines the y coordinate of the rectangle where pixels must be read
  32798. * @param width defines the width of the rectangle where pixels must be read
  32799. * @param height defines the height of the rectangle where pixels must be read
  32800. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32801. * @returns a Uint8Array containing RGBA colors
  32802. */
  32803. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32804. private static _isSupported;
  32805. /**
  32806. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32807. * @returns true if the engine can be created
  32808. * @ignorenaming
  32809. */
  32810. static isSupported(): boolean;
  32811. /**
  32812. * Find the next highest power of two.
  32813. * @param x Number to start search from.
  32814. * @return Next highest power of two.
  32815. */
  32816. static CeilingPOT(x: number): number;
  32817. /**
  32818. * Find the next lowest power of two.
  32819. * @param x Number to start search from.
  32820. * @return Next lowest power of two.
  32821. */
  32822. static FloorPOT(x: number): number;
  32823. /**
  32824. * Find the nearest power of two.
  32825. * @param x Number to start search from.
  32826. * @return Next nearest power of two.
  32827. */
  32828. static NearestPOT(x: number): number;
  32829. /**
  32830. * Get the closest exponent of two
  32831. * @param value defines the value to approximate
  32832. * @param max defines the maximum value to return
  32833. * @param mode defines how to define the closest value
  32834. * @returns closest exponent of two of the given value
  32835. */
  32836. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32837. /**
  32838. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32839. * @param func - the function to be called
  32840. * @param requester - the object that will request the next frame. Falls back to window.
  32841. * @returns frame number
  32842. */
  32843. static QueueNewFrame(func: () => void, requester?: any): number;
  32844. /**
  32845. * Gets host document
  32846. * @returns the host document object
  32847. */
  32848. getHostDocument(): Nullable<Document>;
  32849. }
  32850. }
  32851. declare module "babylonjs/Maths/sphericalPolynomial" {
  32852. import { Vector3 } from "babylonjs/Maths/math.vector";
  32853. import { Color3 } from "babylonjs/Maths/math.color";
  32854. /**
  32855. * Class representing spherical harmonics coefficients to the 3rd degree
  32856. */
  32857. export class SphericalHarmonics {
  32858. /**
  32859. * Defines whether or not the harmonics have been prescaled for rendering.
  32860. */
  32861. preScaled: boolean;
  32862. /**
  32863. * The l0,0 coefficients of the spherical harmonics
  32864. */
  32865. l00: Vector3;
  32866. /**
  32867. * The l1,-1 coefficients of the spherical harmonics
  32868. */
  32869. l1_1: Vector3;
  32870. /**
  32871. * The l1,0 coefficients of the spherical harmonics
  32872. */
  32873. l10: Vector3;
  32874. /**
  32875. * The l1,1 coefficients of the spherical harmonics
  32876. */
  32877. l11: Vector3;
  32878. /**
  32879. * The l2,-2 coefficients of the spherical harmonics
  32880. */
  32881. l2_2: Vector3;
  32882. /**
  32883. * The l2,-1 coefficients of the spherical harmonics
  32884. */
  32885. l2_1: Vector3;
  32886. /**
  32887. * The l2,0 coefficients of the spherical harmonics
  32888. */
  32889. l20: Vector3;
  32890. /**
  32891. * The l2,1 coefficients of the spherical harmonics
  32892. */
  32893. l21: Vector3;
  32894. /**
  32895. * The l2,2 coefficients of the spherical harmonics
  32896. */
  32897. l22: Vector3;
  32898. /**
  32899. * Adds a light to the spherical harmonics
  32900. * @param direction the direction of the light
  32901. * @param color the color of the light
  32902. * @param deltaSolidAngle the delta solid angle of the light
  32903. */
  32904. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32905. /**
  32906. * Scales the spherical harmonics by the given amount
  32907. * @param scale the amount to scale
  32908. */
  32909. scaleInPlace(scale: number): void;
  32910. /**
  32911. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32912. *
  32913. * ```
  32914. * E_lm = A_l * L_lm
  32915. * ```
  32916. *
  32917. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32918. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32919. * the scaling factors are given in equation 9.
  32920. */
  32921. convertIncidentRadianceToIrradiance(): void;
  32922. /**
  32923. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32924. *
  32925. * ```
  32926. * L = (1/pi) * E * rho
  32927. * ```
  32928. *
  32929. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32930. */
  32931. convertIrradianceToLambertianRadiance(): void;
  32932. /**
  32933. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32934. * required operations at run time.
  32935. *
  32936. * This is simply done by scaling back the SH with Ylm constants parameter.
  32937. * The trigonometric part being applied by the shader at run time.
  32938. */
  32939. preScaleForRendering(): void;
  32940. /**
  32941. * Constructs a spherical harmonics from an array.
  32942. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32943. * @returns the spherical harmonics
  32944. */
  32945. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32946. /**
  32947. * Gets the spherical harmonics from polynomial
  32948. * @param polynomial the spherical polynomial
  32949. * @returns the spherical harmonics
  32950. */
  32951. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32952. }
  32953. /**
  32954. * Class representing spherical polynomial coefficients to the 3rd degree
  32955. */
  32956. export class SphericalPolynomial {
  32957. private _harmonics;
  32958. /**
  32959. * The spherical harmonics used to create the polynomials.
  32960. */
  32961. get preScaledHarmonics(): SphericalHarmonics;
  32962. /**
  32963. * The x coefficients of the spherical polynomial
  32964. */
  32965. x: Vector3;
  32966. /**
  32967. * The y coefficients of the spherical polynomial
  32968. */
  32969. y: Vector3;
  32970. /**
  32971. * The z coefficients of the spherical polynomial
  32972. */
  32973. z: Vector3;
  32974. /**
  32975. * The xx coefficients of the spherical polynomial
  32976. */
  32977. xx: Vector3;
  32978. /**
  32979. * The yy coefficients of the spherical polynomial
  32980. */
  32981. yy: Vector3;
  32982. /**
  32983. * The zz coefficients of the spherical polynomial
  32984. */
  32985. zz: Vector3;
  32986. /**
  32987. * The xy coefficients of the spherical polynomial
  32988. */
  32989. xy: Vector3;
  32990. /**
  32991. * The yz coefficients of the spherical polynomial
  32992. */
  32993. yz: Vector3;
  32994. /**
  32995. * The zx coefficients of the spherical polynomial
  32996. */
  32997. zx: Vector3;
  32998. /**
  32999. * Adds an ambient color to the spherical polynomial
  33000. * @param color the color to add
  33001. */
  33002. addAmbient(color: Color3): void;
  33003. /**
  33004. * Scales the spherical polynomial by the given amount
  33005. * @param scale the amount to scale
  33006. */
  33007. scaleInPlace(scale: number): void;
  33008. /**
  33009. * Gets the spherical polynomial from harmonics
  33010. * @param harmonics the spherical harmonics
  33011. * @returns the spherical polynomial
  33012. */
  33013. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33014. /**
  33015. * Constructs a spherical polynomial from an array.
  33016. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33017. * @returns the spherical polynomial
  33018. */
  33019. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33020. }
  33021. }
  33022. declare module "babylonjs/Materials/Textures/internalTexture" {
  33023. import { Observable } from "babylonjs/Misc/observable";
  33024. import { Nullable, int } from "babylonjs/types";
  33025. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33027. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33028. /**
  33029. * Defines the source of the internal texture
  33030. */
  33031. export enum InternalTextureSource {
  33032. /**
  33033. * The source of the texture data is unknown
  33034. */
  33035. Unknown = 0,
  33036. /**
  33037. * Texture data comes from an URL
  33038. */
  33039. Url = 1,
  33040. /**
  33041. * Texture data is only used for temporary storage
  33042. */
  33043. Temp = 2,
  33044. /**
  33045. * Texture data comes from raw data (ArrayBuffer)
  33046. */
  33047. Raw = 3,
  33048. /**
  33049. * Texture content is dynamic (video or dynamic texture)
  33050. */
  33051. Dynamic = 4,
  33052. /**
  33053. * Texture content is generated by rendering to it
  33054. */
  33055. RenderTarget = 5,
  33056. /**
  33057. * Texture content is part of a multi render target process
  33058. */
  33059. MultiRenderTarget = 6,
  33060. /**
  33061. * Texture data comes from a cube data file
  33062. */
  33063. Cube = 7,
  33064. /**
  33065. * Texture data comes from a raw cube data
  33066. */
  33067. CubeRaw = 8,
  33068. /**
  33069. * Texture data come from a prefiltered cube data file
  33070. */
  33071. CubePrefiltered = 9,
  33072. /**
  33073. * Texture content is raw 3D data
  33074. */
  33075. Raw3D = 10,
  33076. /**
  33077. * Texture content is raw 2D array data
  33078. */
  33079. Raw2DArray = 11,
  33080. /**
  33081. * Texture content is a depth texture
  33082. */
  33083. Depth = 12,
  33084. /**
  33085. * Texture data comes from a raw cube data encoded with RGBD
  33086. */
  33087. CubeRawRGBD = 13
  33088. }
  33089. /**
  33090. * Class used to store data associated with WebGL texture data for the engine
  33091. * This class should not be used directly
  33092. */
  33093. export class InternalTexture {
  33094. /** @hidden */
  33095. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33096. /**
  33097. * Defines if the texture is ready
  33098. */
  33099. isReady: boolean;
  33100. /**
  33101. * Defines if the texture is a cube texture
  33102. */
  33103. isCube: boolean;
  33104. /**
  33105. * Defines if the texture contains 3D data
  33106. */
  33107. is3D: boolean;
  33108. /**
  33109. * Defines if the texture contains 2D array data
  33110. */
  33111. is2DArray: boolean;
  33112. /**
  33113. * Defines if the texture contains multiview data
  33114. */
  33115. isMultiview: boolean;
  33116. /**
  33117. * Gets the URL used to load this texture
  33118. */
  33119. url: string;
  33120. /**
  33121. * Gets the sampling mode of the texture
  33122. */
  33123. samplingMode: number;
  33124. /**
  33125. * Gets a boolean indicating if the texture needs mipmaps generation
  33126. */
  33127. generateMipMaps: boolean;
  33128. /**
  33129. * Gets the number of samples used by the texture (WebGL2+ only)
  33130. */
  33131. samples: number;
  33132. /**
  33133. * Gets the type of the texture (int, float...)
  33134. */
  33135. type: number;
  33136. /**
  33137. * Gets the format of the texture (RGB, RGBA...)
  33138. */
  33139. format: number;
  33140. /**
  33141. * Observable called when the texture is loaded
  33142. */
  33143. onLoadedObservable: Observable<InternalTexture>;
  33144. /**
  33145. * Gets the width of the texture
  33146. */
  33147. width: number;
  33148. /**
  33149. * Gets the height of the texture
  33150. */
  33151. height: number;
  33152. /**
  33153. * Gets the depth of the texture
  33154. */
  33155. depth: number;
  33156. /**
  33157. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33158. */
  33159. baseWidth: number;
  33160. /**
  33161. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33162. */
  33163. baseHeight: number;
  33164. /**
  33165. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33166. */
  33167. baseDepth: number;
  33168. /**
  33169. * Gets a boolean indicating if the texture is inverted on Y axis
  33170. */
  33171. invertY: boolean;
  33172. /** @hidden */
  33173. _invertVScale: boolean;
  33174. /** @hidden */
  33175. _associatedChannel: number;
  33176. /** @hidden */
  33177. _source: InternalTextureSource;
  33178. /** @hidden */
  33179. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33180. /** @hidden */
  33181. _bufferView: Nullable<ArrayBufferView>;
  33182. /** @hidden */
  33183. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33184. /** @hidden */
  33185. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33186. /** @hidden */
  33187. _size: number;
  33188. /** @hidden */
  33189. _extension: string;
  33190. /** @hidden */
  33191. _files: Nullable<string[]>;
  33192. /** @hidden */
  33193. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33194. /** @hidden */
  33195. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33196. /** @hidden */
  33197. _framebuffer: Nullable<WebGLFramebuffer>;
  33198. /** @hidden */
  33199. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33200. /** @hidden */
  33201. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33202. /** @hidden */
  33203. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33204. /** @hidden */
  33205. _attachments: Nullable<number[]>;
  33206. /** @hidden */
  33207. _cachedCoordinatesMode: Nullable<number>;
  33208. /** @hidden */
  33209. _cachedWrapU: Nullable<number>;
  33210. /** @hidden */
  33211. _cachedWrapV: Nullable<number>;
  33212. /** @hidden */
  33213. _cachedWrapR: Nullable<number>;
  33214. /** @hidden */
  33215. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33216. /** @hidden */
  33217. _isDisabled: boolean;
  33218. /** @hidden */
  33219. _compression: Nullable<string>;
  33220. /** @hidden */
  33221. _generateStencilBuffer: boolean;
  33222. /** @hidden */
  33223. _generateDepthBuffer: boolean;
  33224. /** @hidden */
  33225. _comparisonFunction: number;
  33226. /** @hidden */
  33227. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33228. /** @hidden */
  33229. _lodGenerationScale: number;
  33230. /** @hidden */
  33231. _lodGenerationOffset: number;
  33232. /** @hidden */
  33233. _depthStencilTexture: Nullable<InternalTexture>;
  33234. /** @hidden */
  33235. _colorTextureArray: Nullable<WebGLTexture>;
  33236. /** @hidden */
  33237. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33238. /** @hidden */
  33239. _lodTextureHigh: Nullable<BaseTexture>;
  33240. /** @hidden */
  33241. _lodTextureMid: Nullable<BaseTexture>;
  33242. /** @hidden */
  33243. _lodTextureLow: Nullable<BaseTexture>;
  33244. /** @hidden */
  33245. _isRGBD: boolean;
  33246. /** @hidden */
  33247. _linearSpecularLOD: boolean;
  33248. /** @hidden */
  33249. _irradianceTexture: Nullable<BaseTexture>;
  33250. /** @hidden */
  33251. _webGLTexture: Nullable<WebGLTexture>;
  33252. /** @hidden */
  33253. _references: number;
  33254. private _engine;
  33255. /**
  33256. * Gets the Engine the texture belongs to.
  33257. * @returns The babylon engine
  33258. */
  33259. getEngine(): ThinEngine;
  33260. /**
  33261. * Gets the data source type of the texture
  33262. */
  33263. get source(): InternalTextureSource;
  33264. /**
  33265. * Creates a new InternalTexture
  33266. * @param engine defines the engine to use
  33267. * @param source defines the type of data that will be used
  33268. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33269. */
  33270. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33271. /**
  33272. * Increments the number of references (ie. the number of Texture that point to it)
  33273. */
  33274. incrementReferences(): void;
  33275. /**
  33276. * Change the size of the texture (not the size of the content)
  33277. * @param width defines the new width
  33278. * @param height defines the new height
  33279. * @param depth defines the new depth (1 by default)
  33280. */
  33281. updateSize(width: int, height: int, depth?: int): void;
  33282. /** @hidden */
  33283. _rebuild(): void;
  33284. /** @hidden */
  33285. _swapAndDie(target: InternalTexture): void;
  33286. /**
  33287. * Dispose the current allocated resources
  33288. */
  33289. dispose(): void;
  33290. }
  33291. }
  33292. declare module "babylonjs/Audio/analyser" {
  33293. import { Scene } from "babylonjs/scene";
  33294. /**
  33295. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33297. */
  33298. export class Analyser {
  33299. /**
  33300. * Gets or sets the smoothing
  33301. * @ignorenaming
  33302. */
  33303. SMOOTHING: number;
  33304. /**
  33305. * Gets or sets the FFT table size
  33306. * @ignorenaming
  33307. */
  33308. FFT_SIZE: number;
  33309. /**
  33310. * Gets or sets the bar graph amplitude
  33311. * @ignorenaming
  33312. */
  33313. BARGRAPHAMPLITUDE: number;
  33314. /**
  33315. * Gets or sets the position of the debug canvas
  33316. * @ignorenaming
  33317. */
  33318. DEBUGCANVASPOS: {
  33319. x: number;
  33320. y: number;
  33321. };
  33322. /**
  33323. * Gets or sets the debug canvas size
  33324. * @ignorenaming
  33325. */
  33326. DEBUGCANVASSIZE: {
  33327. width: number;
  33328. height: number;
  33329. };
  33330. private _byteFreqs;
  33331. private _byteTime;
  33332. private _floatFreqs;
  33333. private _webAudioAnalyser;
  33334. private _debugCanvas;
  33335. private _debugCanvasContext;
  33336. private _scene;
  33337. private _registerFunc;
  33338. private _audioEngine;
  33339. /**
  33340. * Creates a new analyser
  33341. * @param scene defines hosting scene
  33342. */
  33343. constructor(scene: Scene);
  33344. /**
  33345. * Get the number of data values you will have to play with for the visualization
  33346. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33347. * @returns a number
  33348. */
  33349. getFrequencyBinCount(): number;
  33350. /**
  33351. * Gets the current frequency data as a byte array
  33352. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33353. * @returns a Uint8Array
  33354. */
  33355. getByteFrequencyData(): Uint8Array;
  33356. /**
  33357. * Gets the current waveform as a byte array
  33358. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33359. * @returns a Uint8Array
  33360. */
  33361. getByteTimeDomainData(): Uint8Array;
  33362. /**
  33363. * Gets the current frequency data as a float array
  33364. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33365. * @returns a Float32Array
  33366. */
  33367. getFloatFrequencyData(): Float32Array;
  33368. /**
  33369. * Renders the debug canvas
  33370. */
  33371. drawDebugCanvas(): void;
  33372. /**
  33373. * Stops rendering the debug canvas and removes it
  33374. */
  33375. stopDebugCanvas(): void;
  33376. /**
  33377. * Connects two audio nodes
  33378. * @param inputAudioNode defines first node to connect
  33379. * @param outputAudioNode defines second node to connect
  33380. */
  33381. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33382. /**
  33383. * Releases all associated resources
  33384. */
  33385. dispose(): void;
  33386. }
  33387. }
  33388. declare module "babylonjs/Audio/audioEngine" {
  33389. import { IDisposable } from "babylonjs/scene";
  33390. import { Analyser } from "babylonjs/Audio/analyser";
  33391. import { Nullable } from "babylonjs/types";
  33392. import { Observable } from "babylonjs/Misc/observable";
  33393. /**
  33394. * This represents an audio engine and it is responsible
  33395. * to play, synchronize and analyse sounds throughout the application.
  33396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33397. */
  33398. export interface IAudioEngine extends IDisposable {
  33399. /**
  33400. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33401. */
  33402. readonly canUseWebAudio: boolean;
  33403. /**
  33404. * Gets the current AudioContext if available.
  33405. */
  33406. readonly audioContext: Nullable<AudioContext>;
  33407. /**
  33408. * The master gain node defines the global audio volume of your audio engine.
  33409. */
  33410. readonly masterGain: GainNode;
  33411. /**
  33412. * Gets whether or not mp3 are supported by your browser.
  33413. */
  33414. readonly isMP3supported: boolean;
  33415. /**
  33416. * Gets whether or not ogg are supported by your browser.
  33417. */
  33418. readonly isOGGsupported: boolean;
  33419. /**
  33420. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33421. * @ignoreNaming
  33422. */
  33423. WarnedWebAudioUnsupported: boolean;
  33424. /**
  33425. * Defines if the audio engine relies on a custom unlocked button.
  33426. * In this case, the embedded button will not be displayed.
  33427. */
  33428. useCustomUnlockedButton: boolean;
  33429. /**
  33430. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33431. */
  33432. readonly unlocked: boolean;
  33433. /**
  33434. * Event raised when audio has been unlocked on the browser.
  33435. */
  33436. onAudioUnlockedObservable: Observable<AudioEngine>;
  33437. /**
  33438. * Event raised when audio has been locked on the browser.
  33439. */
  33440. onAudioLockedObservable: Observable<AudioEngine>;
  33441. /**
  33442. * Flags the audio engine in Locked state.
  33443. * This happens due to new browser policies preventing audio to autoplay.
  33444. */
  33445. lock(): void;
  33446. /**
  33447. * Unlocks the audio engine once a user action has been done on the dom.
  33448. * This is helpful to resume play once browser policies have been satisfied.
  33449. */
  33450. unlock(): void;
  33451. }
  33452. /**
  33453. * This represents the default audio engine used in babylon.
  33454. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33456. */
  33457. export class AudioEngine implements IAudioEngine {
  33458. private _audioContext;
  33459. private _audioContextInitialized;
  33460. private _muteButton;
  33461. private _hostElement;
  33462. /**
  33463. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33464. */
  33465. canUseWebAudio: boolean;
  33466. /**
  33467. * The master gain node defines the global audio volume of your audio engine.
  33468. */
  33469. masterGain: GainNode;
  33470. /**
  33471. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33472. * @ignoreNaming
  33473. */
  33474. WarnedWebAudioUnsupported: boolean;
  33475. /**
  33476. * Gets whether or not mp3 are supported by your browser.
  33477. */
  33478. isMP3supported: boolean;
  33479. /**
  33480. * Gets whether or not ogg are supported by your browser.
  33481. */
  33482. isOGGsupported: boolean;
  33483. /**
  33484. * Gets whether audio has been unlocked on the device.
  33485. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33486. * a user interaction has happened.
  33487. */
  33488. unlocked: boolean;
  33489. /**
  33490. * Defines if the audio engine relies on a custom unlocked button.
  33491. * In this case, the embedded button will not be displayed.
  33492. */
  33493. useCustomUnlockedButton: boolean;
  33494. /**
  33495. * Event raised when audio has been unlocked on the browser.
  33496. */
  33497. onAudioUnlockedObservable: Observable<AudioEngine>;
  33498. /**
  33499. * Event raised when audio has been locked on the browser.
  33500. */
  33501. onAudioLockedObservable: Observable<AudioEngine>;
  33502. /**
  33503. * Gets the current AudioContext if available.
  33504. */
  33505. get audioContext(): Nullable<AudioContext>;
  33506. private _connectedAnalyser;
  33507. /**
  33508. * Instantiates a new audio engine.
  33509. *
  33510. * There should be only one per page as some browsers restrict the number
  33511. * of audio contexts you can create.
  33512. * @param hostElement defines the host element where to display the mute icon if necessary
  33513. */
  33514. constructor(hostElement?: Nullable<HTMLElement>);
  33515. /**
  33516. * Flags the audio engine in Locked state.
  33517. * This happens due to new browser policies preventing audio to autoplay.
  33518. */
  33519. lock(): void;
  33520. /**
  33521. * Unlocks the audio engine once a user action has been done on the dom.
  33522. * This is helpful to resume play once browser policies have been satisfied.
  33523. */
  33524. unlock(): void;
  33525. private _resumeAudioContext;
  33526. private _initializeAudioContext;
  33527. private _tryToRun;
  33528. private _triggerRunningState;
  33529. private _triggerSuspendedState;
  33530. private _displayMuteButton;
  33531. private _moveButtonToTopLeft;
  33532. private _onResize;
  33533. private _hideMuteButton;
  33534. /**
  33535. * Destroy and release the resources associated with the audio ccontext.
  33536. */
  33537. dispose(): void;
  33538. /**
  33539. * Gets the global volume sets on the master gain.
  33540. * @returns the global volume if set or -1 otherwise
  33541. */
  33542. getGlobalVolume(): number;
  33543. /**
  33544. * Sets the global volume of your experience (sets on the master gain).
  33545. * @param newVolume Defines the new global volume of the application
  33546. */
  33547. setGlobalVolume(newVolume: number): void;
  33548. /**
  33549. * Connect the audio engine to an audio analyser allowing some amazing
  33550. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33552. * @param analyser The analyser to connect to the engine
  33553. */
  33554. connectToAnalyser(analyser: Analyser): void;
  33555. }
  33556. }
  33557. declare module "babylonjs/Loading/loadingScreen" {
  33558. /**
  33559. * Interface used to present a loading screen while loading a scene
  33560. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33561. */
  33562. export interface ILoadingScreen {
  33563. /**
  33564. * Function called to display the loading screen
  33565. */
  33566. displayLoadingUI: () => void;
  33567. /**
  33568. * Function called to hide the loading screen
  33569. */
  33570. hideLoadingUI: () => void;
  33571. /**
  33572. * Gets or sets the color to use for the background
  33573. */
  33574. loadingUIBackgroundColor: string;
  33575. /**
  33576. * Gets or sets the text to display while loading
  33577. */
  33578. loadingUIText: string;
  33579. }
  33580. /**
  33581. * Class used for the default loading screen
  33582. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33583. */
  33584. export class DefaultLoadingScreen implements ILoadingScreen {
  33585. private _renderingCanvas;
  33586. private _loadingText;
  33587. private _loadingDivBackgroundColor;
  33588. private _loadingDiv;
  33589. private _loadingTextDiv;
  33590. /** Gets or sets the logo url to use for the default loading screen */
  33591. static DefaultLogoUrl: string;
  33592. /** Gets or sets the spinner url to use for the default loading screen */
  33593. static DefaultSpinnerUrl: string;
  33594. /**
  33595. * Creates a new default loading screen
  33596. * @param _renderingCanvas defines the canvas used to render the scene
  33597. * @param _loadingText defines the default text to display
  33598. * @param _loadingDivBackgroundColor defines the default background color
  33599. */
  33600. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33601. /**
  33602. * Function called to display the loading screen
  33603. */
  33604. displayLoadingUI(): void;
  33605. /**
  33606. * Function called to hide the loading screen
  33607. */
  33608. hideLoadingUI(): void;
  33609. /**
  33610. * Gets or sets the text to display while loading
  33611. */
  33612. set loadingUIText(text: string);
  33613. get loadingUIText(): string;
  33614. /**
  33615. * Gets or sets the color to use for the background
  33616. */
  33617. get loadingUIBackgroundColor(): string;
  33618. set loadingUIBackgroundColor(color: string);
  33619. private _resizeLoadingUI;
  33620. }
  33621. }
  33622. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33623. /**
  33624. * Interface for any object that can request an animation frame
  33625. */
  33626. export interface ICustomAnimationFrameRequester {
  33627. /**
  33628. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33629. */
  33630. renderFunction?: Function;
  33631. /**
  33632. * Called to request the next frame to render to
  33633. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33634. */
  33635. requestAnimationFrame: Function;
  33636. /**
  33637. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33638. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33639. */
  33640. requestID?: number;
  33641. }
  33642. }
  33643. declare module "babylonjs/Misc/performanceMonitor" {
  33644. /**
  33645. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33646. */
  33647. export class PerformanceMonitor {
  33648. private _enabled;
  33649. private _rollingFrameTime;
  33650. private _lastFrameTimeMs;
  33651. /**
  33652. * constructor
  33653. * @param frameSampleSize The number of samples required to saturate the sliding window
  33654. */
  33655. constructor(frameSampleSize?: number);
  33656. /**
  33657. * Samples current frame
  33658. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33659. */
  33660. sampleFrame(timeMs?: number): void;
  33661. /**
  33662. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33663. */
  33664. get averageFrameTime(): number;
  33665. /**
  33666. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33667. */
  33668. get averageFrameTimeVariance(): number;
  33669. /**
  33670. * Returns the frame time of the most recent frame
  33671. */
  33672. get instantaneousFrameTime(): number;
  33673. /**
  33674. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33675. */
  33676. get averageFPS(): number;
  33677. /**
  33678. * Returns the average framerate in frames per second using the most recent frame time
  33679. */
  33680. get instantaneousFPS(): number;
  33681. /**
  33682. * Returns true if enough samples have been taken to completely fill the sliding window
  33683. */
  33684. get isSaturated(): boolean;
  33685. /**
  33686. * Enables contributions to the sliding window sample set
  33687. */
  33688. enable(): void;
  33689. /**
  33690. * Disables contributions to the sliding window sample set
  33691. * Samples will not be interpolated over the disabled period
  33692. */
  33693. disable(): void;
  33694. /**
  33695. * Returns true if sampling is enabled
  33696. */
  33697. get isEnabled(): boolean;
  33698. /**
  33699. * Resets performance monitor
  33700. */
  33701. reset(): void;
  33702. }
  33703. /**
  33704. * RollingAverage
  33705. *
  33706. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33707. */
  33708. export class RollingAverage {
  33709. /**
  33710. * Current average
  33711. */
  33712. average: number;
  33713. /**
  33714. * Current variance
  33715. */
  33716. variance: number;
  33717. protected _samples: Array<number>;
  33718. protected _sampleCount: number;
  33719. protected _pos: number;
  33720. protected _m2: number;
  33721. /**
  33722. * constructor
  33723. * @param length The number of samples required to saturate the sliding window
  33724. */
  33725. constructor(length: number);
  33726. /**
  33727. * Adds a sample to the sample set
  33728. * @param v The sample value
  33729. */
  33730. add(v: number): void;
  33731. /**
  33732. * Returns previously added values or null if outside of history or outside the sliding window domain
  33733. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33734. * @return Value previously recorded with add() or null if outside of range
  33735. */
  33736. history(i: number): number;
  33737. /**
  33738. * Returns true if enough samples have been taken to completely fill the sliding window
  33739. * @return true if sample-set saturated
  33740. */
  33741. isSaturated(): boolean;
  33742. /**
  33743. * Resets the rolling average (equivalent to 0 samples taken so far)
  33744. */
  33745. reset(): void;
  33746. /**
  33747. * Wraps a value around the sample range boundaries
  33748. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33749. * @return Wrapped position in sample range
  33750. */
  33751. protected _wrapPosition(i: number): number;
  33752. }
  33753. }
  33754. declare module "babylonjs/Misc/perfCounter" {
  33755. /**
  33756. * This class is used to track a performance counter which is number based.
  33757. * The user has access to many properties which give statistics of different nature.
  33758. *
  33759. * The implementer can track two kinds of Performance Counter: time and count.
  33760. * 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.
  33761. * 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.
  33762. */
  33763. export class PerfCounter {
  33764. /**
  33765. * Gets or sets a global boolean to turn on and off all the counters
  33766. */
  33767. static Enabled: boolean;
  33768. /**
  33769. * Returns the smallest value ever
  33770. */
  33771. get min(): number;
  33772. /**
  33773. * Returns the biggest value ever
  33774. */
  33775. get max(): number;
  33776. /**
  33777. * Returns the average value since the performance counter is running
  33778. */
  33779. get average(): number;
  33780. /**
  33781. * Returns the average value of the last second the counter was monitored
  33782. */
  33783. get lastSecAverage(): number;
  33784. /**
  33785. * Returns the current value
  33786. */
  33787. get current(): number;
  33788. /**
  33789. * Gets the accumulated total
  33790. */
  33791. get total(): number;
  33792. /**
  33793. * Gets the total value count
  33794. */
  33795. get count(): number;
  33796. /**
  33797. * Creates a new counter
  33798. */
  33799. constructor();
  33800. /**
  33801. * Call this method to start monitoring a new frame.
  33802. * 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.
  33803. */
  33804. fetchNewFrame(): void;
  33805. /**
  33806. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33807. * @param newCount the count value to add to the monitored count
  33808. * @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.
  33809. */
  33810. addCount(newCount: number, fetchResult: boolean): void;
  33811. /**
  33812. * Start monitoring this performance counter
  33813. */
  33814. beginMonitoring(): void;
  33815. /**
  33816. * Compute the time lapsed since the previous beginMonitoring() call.
  33817. * @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
  33818. */
  33819. endMonitoring(newFrame?: boolean): void;
  33820. private _fetchResult;
  33821. private _startMonitoringTime;
  33822. private _min;
  33823. private _max;
  33824. private _average;
  33825. private _current;
  33826. private _totalValueCount;
  33827. private _totalAccumulated;
  33828. private _lastSecAverage;
  33829. private _lastSecAccumulated;
  33830. private _lastSecTime;
  33831. private _lastSecValueCount;
  33832. }
  33833. }
  33834. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33835. module "babylonjs/Engines/thinEngine" {
  33836. interface ThinEngine {
  33837. /**
  33838. * Sets alpha constants used by some alpha blending modes
  33839. * @param r defines the red component
  33840. * @param g defines the green component
  33841. * @param b defines the blue component
  33842. * @param a defines the alpha component
  33843. */
  33844. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33845. /**
  33846. * Sets the current alpha mode
  33847. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33848. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33849. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33850. */
  33851. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33852. /**
  33853. * Gets the current alpha mode
  33854. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33855. * @returns the current alpha mode
  33856. */
  33857. getAlphaMode(): number;
  33858. /**
  33859. * Sets the current alpha equation
  33860. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33861. */
  33862. setAlphaEquation(equation: number): void;
  33863. /**
  33864. * Gets the current alpha equation.
  33865. * @returns the current alpha equation
  33866. */
  33867. getAlphaEquation(): number;
  33868. }
  33869. }
  33870. }
  33871. declare module "babylonjs/Engines/engine" {
  33872. import { Observable } from "babylonjs/Misc/observable";
  33873. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33874. import { Scene } from "babylonjs/scene";
  33875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33876. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33877. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33878. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33879. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33880. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33881. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33882. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33883. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33884. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33885. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33886. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33887. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33888. import "babylonjs/Engines/Extensions/engine.alpha";
  33889. import { Material } from "babylonjs/Materials/material";
  33890. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33891. /**
  33892. * Defines the interface used by display changed events
  33893. */
  33894. export interface IDisplayChangedEventArgs {
  33895. /** Gets the vrDisplay object (if any) */
  33896. vrDisplay: Nullable<any>;
  33897. /** Gets a boolean indicating if webVR is supported */
  33898. vrSupported: boolean;
  33899. }
  33900. /**
  33901. * Defines the interface used by objects containing a viewport (like a camera)
  33902. */
  33903. interface IViewportOwnerLike {
  33904. /**
  33905. * Gets or sets the viewport
  33906. */
  33907. viewport: IViewportLike;
  33908. }
  33909. /**
  33910. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33911. */
  33912. export class Engine extends ThinEngine {
  33913. /** Defines that alpha blending is disabled */
  33914. static readonly ALPHA_DISABLE: number;
  33915. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33916. static readonly ALPHA_ADD: number;
  33917. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33918. static readonly ALPHA_COMBINE: number;
  33919. /** Defines that alpha blending to DEST - SRC * DEST */
  33920. static readonly ALPHA_SUBTRACT: number;
  33921. /** Defines that alpha blending to SRC * DEST */
  33922. static readonly ALPHA_MULTIPLY: number;
  33923. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33924. static readonly ALPHA_MAXIMIZED: number;
  33925. /** Defines that alpha blending to SRC + DEST */
  33926. static readonly ALPHA_ONEONE: number;
  33927. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33928. static readonly ALPHA_PREMULTIPLIED: number;
  33929. /**
  33930. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33931. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33932. */
  33933. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33934. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33935. static readonly ALPHA_INTERPOLATE: number;
  33936. /**
  33937. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33938. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33939. */
  33940. static readonly ALPHA_SCREENMODE: number;
  33941. /** Defines that the ressource is not delayed*/
  33942. static readonly DELAYLOADSTATE_NONE: number;
  33943. /** Defines that the ressource was successfully delay loaded */
  33944. static readonly DELAYLOADSTATE_LOADED: number;
  33945. /** Defines that the ressource is currently delay loading */
  33946. static readonly DELAYLOADSTATE_LOADING: number;
  33947. /** Defines that the ressource is delayed and has not started loading */
  33948. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33950. static readonly NEVER: number;
  33951. /** 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 */
  33952. static readonly ALWAYS: number;
  33953. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33954. static readonly LESS: number;
  33955. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33956. static readonly EQUAL: number;
  33957. /** 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 */
  33958. static readonly LEQUAL: number;
  33959. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33960. static readonly GREATER: number;
  33961. /** 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 */
  33962. static readonly GEQUAL: number;
  33963. /** 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 */
  33964. static readonly NOTEQUAL: number;
  33965. /** Passed to stencilOperation to specify that stencil value must be kept */
  33966. static readonly KEEP: number;
  33967. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33968. static readonly REPLACE: number;
  33969. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33970. static readonly INCR: number;
  33971. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33972. static readonly DECR: number;
  33973. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33974. static readonly INVERT: number;
  33975. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33976. static readonly INCR_WRAP: number;
  33977. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33978. static readonly DECR_WRAP: number;
  33979. /** Texture is not repeating outside of 0..1 UVs */
  33980. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33981. /** Texture is repeating outside of 0..1 UVs */
  33982. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33983. /** Texture is repeating and mirrored */
  33984. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33985. /** ALPHA */
  33986. static readonly TEXTUREFORMAT_ALPHA: number;
  33987. /** LUMINANCE */
  33988. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33989. /** LUMINANCE_ALPHA */
  33990. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33991. /** RGB */
  33992. static readonly TEXTUREFORMAT_RGB: number;
  33993. /** RGBA */
  33994. static readonly TEXTUREFORMAT_RGBA: number;
  33995. /** RED */
  33996. static readonly TEXTUREFORMAT_RED: number;
  33997. /** RED (2nd reference) */
  33998. static readonly TEXTUREFORMAT_R: number;
  33999. /** RG */
  34000. static readonly TEXTUREFORMAT_RG: number;
  34001. /** RED_INTEGER */
  34002. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34003. /** RED_INTEGER (2nd reference) */
  34004. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34005. /** RG_INTEGER */
  34006. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34007. /** RGB_INTEGER */
  34008. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34009. /** RGBA_INTEGER */
  34010. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34011. /** UNSIGNED_BYTE */
  34012. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34013. /** UNSIGNED_BYTE (2nd reference) */
  34014. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34015. /** FLOAT */
  34016. static readonly TEXTURETYPE_FLOAT: number;
  34017. /** HALF_FLOAT */
  34018. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34019. /** BYTE */
  34020. static readonly TEXTURETYPE_BYTE: number;
  34021. /** SHORT */
  34022. static readonly TEXTURETYPE_SHORT: number;
  34023. /** UNSIGNED_SHORT */
  34024. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34025. /** INT */
  34026. static readonly TEXTURETYPE_INT: number;
  34027. /** UNSIGNED_INT */
  34028. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34029. /** UNSIGNED_SHORT_4_4_4_4 */
  34030. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34031. /** UNSIGNED_SHORT_5_5_5_1 */
  34032. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34033. /** UNSIGNED_SHORT_5_6_5 */
  34034. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34035. /** UNSIGNED_INT_2_10_10_10_REV */
  34036. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34037. /** UNSIGNED_INT_24_8 */
  34038. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34039. /** UNSIGNED_INT_10F_11F_11F_REV */
  34040. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34041. /** UNSIGNED_INT_5_9_9_9_REV */
  34042. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34043. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34044. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34045. /** nearest is mag = nearest and min = nearest and mip = linear */
  34046. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34047. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34048. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34049. /** Trilinear is mag = linear and min = linear and mip = linear */
  34050. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34051. /** nearest is mag = nearest and min = nearest and mip = linear */
  34052. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34053. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34054. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34055. /** Trilinear is mag = linear and min = linear and mip = linear */
  34056. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34057. /** mag = nearest and min = nearest and mip = nearest */
  34058. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34059. /** mag = nearest and min = linear and mip = nearest */
  34060. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34061. /** mag = nearest and min = linear and mip = linear */
  34062. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34063. /** mag = nearest and min = linear and mip = none */
  34064. static readonly TEXTURE_NEAREST_LINEAR: number;
  34065. /** mag = nearest and min = nearest and mip = none */
  34066. static readonly TEXTURE_NEAREST_NEAREST: number;
  34067. /** mag = linear and min = nearest and mip = nearest */
  34068. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34069. /** mag = linear and min = nearest and mip = linear */
  34070. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34071. /** mag = linear and min = linear and mip = none */
  34072. static readonly TEXTURE_LINEAR_LINEAR: number;
  34073. /** mag = linear and min = nearest and mip = none */
  34074. static readonly TEXTURE_LINEAR_NEAREST: number;
  34075. /** Explicit coordinates mode */
  34076. static readonly TEXTURE_EXPLICIT_MODE: number;
  34077. /** Spherical coordinates mode */
  34078. static readonly TEXTURE_SPHERICAL_MODE: number;
  34079. /** Planar coordinates mode */
  34080. static readonly TEXTURE_PLANAR_MODE: number;
  34081. /** Cubic coordinates mode */
  34082. static readonly TEXTURE_CUBIC_MODE: number;
  34083. /** Projection coordinates mode */
  34084. static readonly TEXTURE_PROJECTION_MODE: number;
  34085. /** Skybox coordinates mode */
  34086. static readonly TEXTURE_SKYBOX_MODE: number;
  34087. /** Inverse Cubic coordinates mode */
  34088. static readonly TEXTURE_INVCUBIC_MODE: number;
  34089. /** Equirectangular coordinates mode */
  34090. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34091. /** Equirectangular Fixed coordinates mode */
  34092. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34093. /** Equirectangular Fixed Mirrored coordinates mode */
  34094. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34095. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34096. static readonly SCALEMODE_FLOOR: number;
  34097. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34098. static readonly SCALEMODE_NEAREST: number;
  34099. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34100. static readonly SCALEMODE_CEILING: number;
  34101. /**
  34102. * Returns the current npm package of the sdk
  34103. */
  34104. static get NpmPackage(): string;
  34105. /**
  34106. * Returns the current version of the framework
  34107. */
  34108. static get Version(): string;
  34109. /** Gets the list of created engines */
  34110. static get Instances(): Engine[];
  34111. /**
  34112. * Gets the latest created engine
  34113. */
  34114. static get LastCreatedEngine(): Nullable<Engine>;
  34115. /**
  34116. * Gets the latest created scene
  34117. */
  34118. static get LastCreatedScene(): Nullable<Scene>;
  34119. /**
  34120. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34121. * @param flag defines which part of the materials must be marked as dirty
  34122. * @param predicate defines a predicate used to filter which materials should be affected
  34123. */
  34124. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34125. /**
  34126. * Method called to create the default loading screen.
  34127. * This can be overriden in your own app.
  34128. * @param canvas The rendering canvas element
  34129. * @returns The loading screen
  34130. */
  34131. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34132. /**
  34133. * Method called to create the default rescale post process on each engine.
  34134. */
  34135. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34136. /**
  34137. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34138. **/
  34139. enableOfflineSupport: boolean;
  34140. /**
  34141. * 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)
  34142. **/
  34143. disableManifestCheck: boolean;
  34144. /**
  34145. * Gets the list of created scenes
  34146. */
  34147. scenes: Scene[];
  34148. /**
  34149. * Event raised when a new scene is created
  34150. */
  34151. onNewSceneAddedObservable: Observable<Scene>;
  34152. /**
  34153. * Gets the list of created postprocesses
  34154. */
  34155. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34156. /**
  34157. * Gets a boolean indicating if the pointer is currently locked
  34158. */
  34159. isPointerLock: boolean;
  34160. /**
  34161. * Observable event triggered each time the rendering canvas is resized
  34162. */
  34163. onResizeObservable: Observable<Engine>;
  34164. /**
  34165. * Observable event triggered each time the canvas loses focus
  34166. */
  34167. onCanvasBlurObservable: Observable<Engine>;
  34168. /**
  34169. * Observable event triggered each time the canvas gains focus
  34170. */
  34171. onCanvasFocusObservable: Observable<Engine>;
  34172. /**
  34173. * Observable event triggered each time the canvas receives pointerout event
  34174. */
  34175. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34176. /**
  34177. * Observable raised when the engine begins a new frame
  34178. */
  34179. onBeginFrameObservable: Observable<Engine>;
  34180. /**
  34181. * If set, will be used to request the next animation frame for the render loop
  34182. */
  34183. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34184. /**
  34185. * Observable raised when the engine ends the current frame
  34186. */
  34187. onEndFrameObservable: Observable<Engine>;
  34188. /**
  34189. * Observable raised when the engine is about to compile a shader
  34190. */
  34191. onBeforeShaderCompilationObservable: Observable<Engine>;
  34192. /**
  34193. * Observable raised when the engine has jsut compiled a shader
  34194. */
  34195. onAfterShaderCompilationObservable: Observable<Engine>;
  34196. /**
  34197. * Gets the audio engine
  34198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34199. * @ignorenaming
  34200. */
  34201. static audioEngine: IAudioEngine;
  34202. /**
  34203. * Default AudioEngine factory responsible of creating the Audio Engine.
  34204. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34205. */
  34206. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34207. /**
  34208. * Default offline support factory responsible of creating a tool used to store data locally.
  34209. * By default, this will create a Database object if the workload has been embedded.
  34210. */
  34211. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34212. private _loadingScreen;
  34213. private _pointerLockRequested;
  34214. private _dummyFramebuffer;
  34215. private _rescalePostProcess;
  34216. private _deterministicLockstep;
  34217. private _lockstepMaxSteps;
  34218. private _timeStep;
  34219. protected get _supportsHardwareTextureRescaling(): boolean;
  34220. private _fps;
  34221. private _deltaTime;
  34222. /** @hidden */
  34223. _drawCalls: PerfCounter;
  34224. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34225. canvasTabIndex: number;
  34226. /**
  34227. * Turn this value on if you want to pause FPS computation when in background
  34228. */
  34229. disablePerformanceMonitorInBackground: boolean;
  34230. private _performanceMonitor;
  34231. /**
  34232. * Gets the performance monitor attached to this engine
  34233. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34234. */
  34235. get performanceMonitor(): PerformanceMonitor;
  34236. private _onFocus;
  34237. private _onBlur;
  34238. private _onCanvasPointerOut;
  34239. private _onCanvasBlur;
  34240. private _onCanvasFocus;
  34241. private _onFullscreenChange;
  34242. private _onPointerLockChange;
  34243. /**
  34244. * Gets the HTML element used to attach event listeners
  34245. * @returns a HTML element
  34246. */
  34247. getInputElement(): Nullable<HTMLElement>;
  34248. /**
  34249. * Creates a new engine
  34250. * @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
  34251. * @param antialias defines enable antialiasing (default: false)
  34252. * @param options defines further options to be sent to the getContext() function
  34253. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34254. */
  34255. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34256. /**
  34257. * Gets current aspect ratio
  34258. * @param viewportOwner defines the camera to use to get the aspect ratio
  34259. * @param useScreen defines if screen size must be used (or the current render target if any)
  34260. * @returns a number defining the aspect ratio
  34261. */
  34262. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34263. /**
  34264. * Gets current screen aspect ratio
  34265. * @returns a number defining the aspect ratio
  34266. */
  34267. getScreenAspectRatio(): number;
  34268. /**
  34269. * Gets the client rect of the HTML canvas attached with the current webGL context
  34270. * @returns a client rectanglee
  34271. */
  34272. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34273. /**
  34274. * Gets the client rect of the HTML element used for events
  34275. * @returns a client rectanglee
  34276. */
  34277. getInputElementClientRect(): Nullable<ClientRect>;
  34278. /**
  34279. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34280. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34281. * @returns true if engine is in deterministic lock step mode
  34282. */
  34283. isDeterministicLockStep(): boolean;
  34284. /**
  34285. * Gets the max steps when engine is running in deterministic lock step
  34286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34287. * @returns the max steps
  34288. */
  34289. getLockstepMaxSteps(): number;
  34290. /**
  34291. * Returns the time in ms between steps when using deterministic lock step.
  34292. * @returns time step in (ms)
  34293. */
  34294. getTimeStep(): number;
  34295. /**
  34296. * Force the mipmap generation for the given render target texture
  34297. * @param texture defines the render target texture to use
  34298. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34299. */
  34300. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34301. /** States */
  34302. /**
  34303. * Set various states to the webGL context
  34304. * @param culling defines backface culling state
  34305. * @param zOffset defines the value to apply to zOffset (0 by default)
  34306. * @param force defines if states must be applied even if cache is up to date
  34307. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34308. */
  34309. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34310. /**
  34311. * Set the z offset to apply to current rendering
  34312. * @param value defines the offset to apply
  34313. */
  34314. setZOffset(value: number): void;
  34315. /**
  34316. * Gets the current value of the zOffset
  34317. * @returns the current zOffset state
  34318. */
  34319. getZOffset(): number;
  34320. /**
  34321. * Enable or disable depth buffering
  34322. * @param enable defines the state to set
  34323. */
  34324. setDepthBuffer(enable: boolean): void;
  34325. /**
  34326. * Gets a boolean indicating if depth writing is enabled
  34327. * @returns the current depth writing state
  34328. */
  34329. getDepthWrite(): boolean;
  34330. /**
  34331. * Enable or disable depth writing
  34332. * @param enable defines the state to set
  34333. */
  34334. setDepthWrite(enable: boolean): void;
  34335. /**
  34336. * Gets a boolean indicating if stencil buffer is enabled
  34337. * @returns the current stencil buffer state
  34338. */
  34339. getStencilBuffer(): boolean;
  34340. /**
  34341. * Enable or disable the stencil buffer
  34342. * @param enable defines if the stencil buffer must be enabled or disabled
  34343. */
  34344. setStencilBuffer(enable: boolean): void;
  34345. /**
  34346. * Gets the current stencil mask
  34347. * @returns a number defining the new stencil mask to use
  34348. */
  34349. getStencilMask(): number;
  34350. /**
  34351. * Sets the current stencil mask
  34352. * @param mask defines the new stencil mask to use
  34353. */
  34354. setStencilMask(mask: number): void;
  34355. /**
  34356. * Gets the current stencil function
  34357. * @returns a number defining the stencil function to use
  34358. */
  34359. getStencilFunction(): number;
  34360. /**
  34361. * Gets the current stencil reference value
  34362. * @returns a number defining the stencil reference value to use
  34363. */
  34364. getStencilFunctionReference(): number;
  34365. /**
  34366. * Gets the current stencil mask
  34367. * @returns a number defining the stencil mask to use
  34368. */
  34369. getStencilFunctionMask(): number;
  34370. /**
  34371. * Sets the current stencil function
  34372. * @param stencilFunc defines the new stencil function to use
  34373. */
  34374. setStencilFunction(stencilFunc: number): void;
  34375. /**
  34376. * Sets the current stencil reference
  34377. * @param reference defines the new stencil reference to use
  34378. */
  34379. setStencilFunctionReference(reference: number): void;
  34380. /**
  34381. * Sets the current stencil mask
  34382. * @param mask defines the new stencil mask to use
  34383. */
  34384. setStencilFunctionMask(mask: number): void;
  34385. /**
  34386. * Gets the current stencil operation when stencil fails
  34387. * @returns a number defining stencil operation to use when stencil fails
  34388. */
  34389. getStencilOperationFail(): number;
  34390. /**
  34391. * Gets the current stencil operation when depth fails
  34392. * @returns a number defining stencil operation to use when depth fails
  34393. */
  34394. getStencilOperationDepthFail(): number;
  34395. /**
  34396. * Gets the current stencil operation when stencil passes
  34397. * @returns a number defining stencil operation to use when stencil passes
  34398. */
  34399. getStencilOperationPass(): number;
  34400. /**
  34401. * Sets the stencil operation to use when stencil fails
  34402. * @param operation defines the stencil operation to use when stencil fails
  34403. */
  34404. setStencilOperationFail(operation: number): void;
  34405. /**
  34406. * Sets the stencil operation to use when depth fails
  34407. * @param operation defines the stencil operation to use when depth fails
  34408. */
  34409. setStencilOperationDepthFail(operation: number): void;
  34410. /**
  34411. * Sets the stencil operation to use when stencil passes
  34412. * @param operation defines the stencil operation to use when stencil passes
  34413. */
  34414. setStencilOperationPass(operation: number): void;
  34415. /**
  34416. * Sets a boolean indicating if the dithering state is enabled or disabled
  34417. * @param value defines the dithering state
  34418. */
  34419. setDitheringState(value: boolean): void;
  34420. /**
  34421. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34422. * @param value defines the rasterizer state
  34423. */
  34424. setRasterizerState(value: boolean): void;
  34425. /**
  34426. * Gets the current depth function
  34427. * @returns a number defining the depth function
  34428. */
  34429. getDepthFunction(): Nullable<number>;
  34430. /**
  34431. * Sets the current depth function
  34432. * @param depthFunc defines the function to use
  34433. */
  34434. setDepthFunction(depthFunc: number): void;
  34435. /**
  34436. * Sets the current depth function to GREATER
  34437. */
  34438. setDepthFunctionToGreater(): void;
  34439. /**
  34440. * Sets the current depth function to GEQUAL
  34441. */
  34442. setDepthFunctionToGreaterOrEqual(): void;
  34443. /**
  34444. * Sets the current depth function to LESS
  34445. */
  34446. setDepthFunctionToLess(): void;
  34447. /**
  34448. * Sets the current depth function to LEQUAL
  34449. */
  34450. setDepthFunctionToLessOrEqual(): void;
  34451. private _cachedStencilBuffer;
  34452. private _cachedStencilFunction;
  34453. private _cachedStencilMask;
  34454. private _cachedStencilOperationPass;
  34455. private _cachedStencilOperationFail;
  34456. private _cachedStencilOperationDepthFail;
  34457. private _cachedStencilReference;
  34458. /**
  34459. * Caches the the state of the stencil buffer
  34460. */
  34461. cacheStencilState(): void;
  34462. /**
  34463. * Restores the state of the stencil buffer
  34464. */
  34465. restoreStencilState(): void;
  34466. /**
  34467. * Directly set the WebGL Viewport
  34468. * @param x defines the x coordinate of the viewport (in screen space)
  34469. * @param y defines the y coordinate of the viewport (in screen space)
  34470. * @param width defines the width of the viewport (in screen space)
  34471. * @param height defines the height of the viewport (in screen space)
  34472. * @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
  34473. */
  34474. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34475. /**
  34476. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34477. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34478. * @param y defines the y-coordinate of the corner of the clear rectangle
  34479. * @param width defines the width of the clear rectangle
  34480. * @param height defines the height of the clear rectangle
  34481. * @param clearColor defines the clear color
  34482. */
  34483. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34484. /**
  34485. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34486. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34487. * @param y defines the y-coordinate of the corner of the clear rectangle
  34488. * @param width defines the width of the clear rectangle
  34489. * @param height defines the height of the clear rectangle
  34490. */
  34491. enableScissor(x: number, y: number, width: number, height: number): void;
  34492. /**
  34493. * Disable previously set scissor test rectangle
  34494. */
  34495. disableScissor(): void;
  34496. protected _reportDrawCall(): void;
  34497. /**
  34498. * Initializes a webVR display and starts listening to display change events
  34499. * The onVRDisplayChangedObservable will be notified upon these changes
  34500. * @returns The onVRDisplayChangedObservable
  34501. */
  34502. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34503. /** @hidden */
  34504. _prepareVRComponent(): void;
  34505. /** @hidden */
  34506. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34507. /** @hidden */
  34508. _submitVRFrame(): void;
  34509. /**
  34510. * Call this function to leave webVR mode
  34511. * Will do nothing if webVR is not supported or if there is no webVR device
  34512. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34513. */
  34514. disableVR(): void;
  34515. /**
  34516. * Gets a boolean indicating that the system is in VR mode and is presenting
  34517. * @returns true if VR mode is engaged
  34518. */
  34519. isVRPresenting(): boolean;
  34520. /** @hidden */
  34521. _requestVRFrame(): void;
  34522. /** @hidden */
  34523. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34524. /**
  34525. * Gets the source code of the vertex shader associated with a specific webGL program
  34526. * @param program defines the program to use
  34527. * @returns a string containing the source code of the vertex shader associated with the program
  34528. */
  34529. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34530. /**
  34531. * Gets the source code of the fragment shader associated with a specific webGL program
  34532. * @param program defines the program to use
  34533. * @returns a string containing the source code of the fragment shader associated with the program
  34534. */
  34535. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34536. /**
  34537. * Sets a depth stencil texture from a render target to the according uniform.
  34538. * @param channel The texture channel
  34539. * @param uniform The uniform to set
  34540. * @param texture The render target texture containing the depth stencil texture to apply
  34541. */
  34542. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34543. /**
  34544. * Sets a texture to the webGL context from a postprocess
  34545. * @param channel defines the channel to use
  34546. * @param postProcess defines the source postprocess
  34547. */
  34548. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34549. /**
  34550. * Binds the output of the passed in post process to the texture channel specified
  34551. * @param channel The channel the texture should be bound to
  34552. * @param postProcess The post process which's output should be bound
  34553. */
  34554. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34555. /** @hidden */
  34556. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34557. protected _rebuildBuffers(): void;
  34558. /** @hidden */
  34559. _renderFrame(): void;
  34560. _renderLoop(): void;
  34561. /** @hidden */
  34562. _renderViews(): boolean;
  34563. /**
  34564. * Toggle full screen mode
  34565. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34566. */
  34567. switchFullscreen(requestPointerLock: boolean): void;
  34568. /**
  34569. * Enters full screen mode
  34570. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34571. */
  34572. enterFullscreen(requestPointerLock: boolean): void;
  34573. /**
  34574. * Exits full screen mode
  34575. */
  34576. exitFullscreen(): void;
  34577. /**
  34578. * Enters Pointerlock mode
  34579. */
  34580. enterPointerlock(): void;
  34581. /**
  34582. * Exits Pointerlock mode
  34583. */
  34584. exitPointerlock(): void;
  34585. /**
  34586. * Begin a new frame
  34587. */
  34588. beginFrame(): void;
  34589. /**
  34590. * Enf the current frame
  34591. */
  34592. endFrame(): void;
  34593. resize(): void;
  34594. /**
  34595. * Set the compressed texture format to use, based on the formats you have, and the formats
  34596. * supported by the hardware / browser.
  34597. *
  34598. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34599. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34600. * to API arguments needed to compressed textures. This puts the burden on the container
  34601. * generator to house the arcane code for determining these for current & future formats.
  34602. *
  34603. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34604. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34605. *
  34606. * Note: The result of this call is not taken into account when a texture is base64.
  34607. *
  34608. * @param formatsAvailable defines the list of those format families you have created
  34609. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34610. *
  34611. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34612. * @returns The extension selected.
  34613. */
  34614. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34615. /**
  34616. * Set the compressed texture extensions or file names to skip.
  34617. *
  34618. * @param skippedFiles defines the list of those texture files you want to skip
  34619. * Example: [".dds", ".env", "myfile.png"]
  34620. */
  34621. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34622. /**
  34623. * Force a specific size of the canvas
  34624. * @param width defines the new canvas' width
  34625. * @param height defines the new canvas' height
  34626. */
  34627. setSize(width: number, height: number): void;
  34628. /**
  34629. * Updates a dynamic vertex buffer.
  34630. * @param vertexBuffer the vertex buffer to update
  34631. * @param data the data used to update the vertex buffer
  34632. * @param byteOffset the byte offset of the data
  34633. * @param byteLength the byte length of the data
  34634. */
  34635. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34636. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34637. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34638. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34639. _releaseTexture(texture: InternalTexture): void;
  34640. /**
  34641. * @hidden
  34642. * Rescales a texture
  34643. * @param source input texutre
  34644. * @param destination destination texture
  34645. * @param scene scene to use to render the resize
  34646. * @param internalFormat format to use when resizing
  34647. * @param onComplete callback to be called when resize has completed
  34648. */
  34649. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34650. /**
  34651. * Gets the current framerate
  34652. * @returns a number representing the framerate
  34653. */
  34654. getFps(): number;
  34655. /**
  34656. * Gets the time spent between current and previous frame
  34657. * @returns a number representing the delta time in ms
  34658. */
  34659. getDeltaTime(): number;
  34660. private _measureFps;
  34661. /** @hidden */
  34662. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34663. /**
  34664. * Update a dynamic index buffer
  34665. * @param indexBuffer defines the target index buffer
  34666. * @param indices defines the data to update
  34667. * @param offset defines the offset in the target index buffer where update should start
  34668. */
  34669. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34670. /**
  34671. * Updates the sample count of a render target texture
  34672. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34673. * @param texture defines the texture to update
  34674. * @param samples defines the sample count to set
  34675. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34676. */
  34677. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34678. /**
  34679. * Updates a depth texture Comparison Mode and Function.
  34680. * If the comparison Function is equal to 0, the mode will be set to none.
  34681. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34682. * @param texture The texture to set the comparison function for
  34683. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34684. */
  34685. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34686. /**
  34687. * Creates a webGL buffer to use with instanciation
  34688. * @param capacity defines the size of the buffer
  34689. * @returns the webGL buffer
  34690. */
  34691. createInstancesBuffer(capacity: number): DataBuffer;
  34692. /**
  34693. * Delete a webGL buffer used with instanciation
  34694. * @param buffer defines the webGL buffer to delete
  34695. */
  34696. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34697. /** @hidden */
  34698. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34699. dispose(): void;
  34700. private _disableTouchAction;
  34701. /**
  34702. * Display the loading screen
  34703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34704. */
  34705. displayLoadingUI(): void;
  34706. /**
  34707. * Hide the loading screen
  34708. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34709. */
  34710. hideLoadingUI(): void;
  34711. /**
  34712. * Gets the current loading screen object
  34713. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34714. */
  34715. get loadingScreen(): ILoadingScreen;
  34716. /**
  34717. * Sets the current loading screen object
  34718. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34719. */
  34720. set loadingScreen(loadingScreen: ILoadingScreen);
  34721. /**
  34722. * Sets the current loading screen text
  34723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34724. */
  34725. set loadingUIText(text: string);
  34726. /**
  34727. * Sets the current loading screen background color
  34728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34729. */
  34730. set loadingUIBackgroundColor(color: string);
  34731. /** Pointerlock and fullscreen */
  34732. /**
  34733. * Ask the browser to promote the current element to pointerlock mode
  34734. * @param element defines the DOM element to promote
  34735. */
  34736. static _RequestPointerlock(element: HTMLElement): void;
  34737. /**
  34738. * Asks the browser to exit pointerlock mode
  34739. */
  34740. static _ExitPointerlock(): void;
  34741. /**
  34742. * Ask the browser to promote the current element to fullscreen rendering mode
  34743. * @param element defines the DOM element to promote
  34744. */
  34745. static _RequestFullscreen(element: HTMLElement): void;
  34746. /**
  34747. * Asks the browser to exit fullscreen mode
  34748. */
  34749. static _ExitFullscreen(): void;
  34750. }
  34751. }
  34752. declare module "babylonjs/Engines/engineStore" {
  34753. import { Nullable } from "babylonjs/types";
  34754. import { Engine } from "babylonjs/Engines/engine";
  34755. import { Scene } from "babylonjs/scene";
  34756. /**
  34757. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34758. * during the life time of the application.
  34759. */
  34760. export class EngineStore {
  34761. /** Gets the list of created engines */
  34762. static Instances: import("babylonjs/Engines/engine").Engine[];
  34763. /** @hidden */
  34764. static _LastCreatedScene: Nullable<Scene>;
  34765. /**
  34766. * Gets the latest created engine
  34767. */
  34768. static get LastCreatedEngine(): Nullable<Engine>;
  34769. /**
  34770. * Gets the latest created scene
  34771. */
  34772. static get LastCreatedScene(): Nullable<Scene>;
  34773. /**
  34774. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34775. * @ignorenaming
  34776. */
  34777. static UseFallbackTexture: boolean;
  34778. /**
  34779. * Texture content used if a texture cannot loaded
  34780. * @ignorenaming
  34781. */
  34782. static FallbackTexture: string;
  34783. }
  34784. }
  34785. declare module "babylonjs/Misc/promise" {
  34786. /**
  34787. * Helper class that provides a small promise polyfill
  34788. */
  34789. export class PromisePolyfill {
  34790. /**
  34791. * Static function used to check if the polyfill is required
  34792. * If this is the case then the function will inject the polyfill to window.Promise
  34793. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34794. */
  34795. static Apply(force?: boolean): void;
  34796. }
  34797. }
  34798. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34799. /**
  34800. * Interface for screenshot methods with describe argument called `size` as object with options
  34801. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34802. */
  34803. export interface IScreenshotSize {
  34804. /**
  34805. * number in pixels for canvas height
  34806. */
  34807. height?: number;
  34808. /**
  34809. * multiplier allowing render at a higher or lower resolution
  34810. * If value is defined then height and width will be ignored and taken from camera
  34811. */
  34812. precision?: number;
  34813. /**
  34814. * number in pixels for canvas width
  34815. */
  34816. width?: number;
  34817. }
  34818. }
  34819. declare module "babylonjs/Misc/tools" {
  34820. import { Nullable, float } from "babylonjs/types";
  34821. import { DomManagement } from "babylonjs/Misc/domManagement";
  34822. import { WebRequest } from "babylonjs/Misc/webRequest";
  34823. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34824. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34825. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34826. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34827. import { Camera } from "babylonjs/Cameras/camera";
  34828. import { Engine } from "babylonjs/Engines/engine";
  34829. interface IColor4Like {
  34830. r: float;
  34831. g: float;
  34832. b: float;
  34833. a: float;
  34834. }
  34835. /**
  34836. * Class containing a set of static utilities functions
  34837. */
  34838. export class Tools {
  34839. /**
  34840. * Gets or sets the base URL to use to load assets
  34841. */
  34842. static get BaseUrl(): string;
  34843. static set BaseUrl(value: string);
  34844. /**
  34845. * Enable/Disable Custom HTTP Request Headers globally.
  34846. * default = false
  34847. * @see CustomRequestHeaders
  34848. */
  34849. static UseCustomRequestHeaders: boolean;
  34850. /**
  34851. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34852. * i.e. when loading files, where the server/service expects an Authorization header
  34853. */
  34854. static CustomRequestHeaders: {
  34855. [key: string]: string;
  34856. };
  34857. /**
  34858. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34859. */
  34860. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34861. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34862. /**
  34863. * Default behaviour for cors in the application.
  34864. * It can be a string if the expected behavior is identical in the entire app.
  34865. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34866. */
  34867. static CorsBehavior: string | ((url: string | string[]) => string);
  34868. /**
  34869. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34870. * @ignorenaming
  34871. */
  34872. static get UseFallbackTexture(): boolean;
  34873. static set UseFallbackTexture(value: boolean);
  34874. /**
  34875. * Use this object to register external classes like custom textures or material
  34876. * to allow the laoders to instantiate them
  34877. */
  34878. static get RegisteredExternalClasses(): {
  34879. [key: string]: Object;
  34880. };
  34881. static set RegisteredExternalClasses(classes: {
  34882. [key: string]: Object;
  34883. });
  34884. /**
  34885. * Texture content used if a texture cannot loaded
  34886. * @ignorenaming
  34887. */
  34888. static get fallbackTexture(): string;
  34889. static set fallbackTexture(value: string);
  34890. /**
  34891. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34892. * @param u defines the coordinate on X axis
  34893. * @param v defines the coordinate on Y axis
  34894. * @param width defines the width of the source data
  34895. * @param height defines the height of the source data
  34896. * @param pixels defines the source byte array
  34897. * @param color defines the output color
  34898. */
  34899. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34900. /**
  34901. * Interpolates between a and b via alpha
  34902. * @param a The lower value (returned when alpha = 0)
  34903. * @param b The upper value (returned when alpha = 1)
  34904. * @param alpha The interpolation-factor
  34905. * @return The mixed value
  34906. */
  34907. static Mix(a: number, b: number, alpha: number): number;
  34908. /**
  34909. * Tries to instantiate a new object from a given class name
  34910. * @param className defines the class name to instantiate
  34911. * @returns the new object or null if the system was not able to do the instantiation
  34912. */
  34913. static Instantiate(className: string): any;
  34914. /**
  34915. * Provides a slice function that will work even on IE
  34916. * @param data defines the array to slice
  34917. * @param start defines the start of the data (optional)
  34918. * @param end defines the end of the data (optional)
  34919. * @returns the new sliced array
  34920. */
  34921. static Slice<T>(data: T, start?: number, end?: number): T;
  34922. /**
  34923. * Polyfill for setImmediate
  34924. * @param action defines the action to execute after the current execution block
  34925. */
  34926. static SetImmediate(action: () => void): void;
  34927. /**
  34928. * Function indicating if a number is an exponent of 2
  34929. * @param value defines the value to test
  34930. * @returns true if the value is an exponent of 2
  34931. */
  34932. static IsExponentOfTwo(value: number): boolean;
  34933. private static _tmpFloatArray;
  34934. /**
  34935. * Returns the nearest 32-bit single precision float representation of a Number
  34936. * @param value A Number. If the parameter is of a different type, it will get converted
  34937. * to a number or to NaN if it cannot be converted
  34938. * @returns number
  34939. */
  34940. static FloatRound(value: number): number;
  34941. /**
  34942. * Extracts the filename from a path
  34943. * @param path defines the path to use
  34944. * @returns the filename
  34945. */
  34946. static GetFilename(path: string): string;
  34947. /**
  34948. * Extracts the "folder" part of a path (everything before the filename).
  34949. * @param uri The URI to extract the info from
  34950. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34951. * @returns The "folder" part of the path
  34952. */
  34953. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34954. /**
  34955. * Extracts text content from a DOM element hierarchy
  34956. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34957. */
  34958. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34959. /**
  34960. * Convert an angle in radians to degrees
  34961. * @param angle defines the angle to convert
  34962. * @returns the angle in degrees
  34963. */
  34964. static ToDegrees(angle: number): number;
  34965. /**
  34966. * Convert an angle in degrees to radians
  34967. * @param angle defines the angle to convert
  34968. * @returns the angle in radians
  34969. */
  34970. static ToRadians(angle: number): number;
  34971. /**
  34972. * Returns an array if obj is not an array
  34973. * @param obj defines the object to evaluate as an array
  34974. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34975. * @returns either obj directly if obj is an array or a new array containing obj
  34976. */
  34977. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34978. /**
  34979. * Gets the pointer prefix to use
  34980. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34981. */
  34982. static GetPointerPrefix(): string;
  34983. /**
  34984. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34985. * @param url define the url we are trying
  34986. * @param element define the dom element where to configure the cors policy
  34987. */
  34988. static SetCorsBehavior(url: string | string[], element: {
  34989. crossOrigin: string | null;
  34990. }): void;
  34991. /**
  34992. * Removes unwanted characters from an url
  34993. * @param url defines the url to clean
  34994. * @returns the cleaned url
  34995. */
  34996. static CleanUrl(url: string): string;
  34997. /**
  34998. * Gets or sets a function used to pre-process url before using them to load assets
  34999. */
  35000. static get PreprocessUrl(): (url: string) => string;
  35001. static set PreprocessUrl(processor: (url: string) => string);
  35002. /**
  35003. * Loads an image as an HTMLImageElement.
  35004. * @param input url string, ArrayBuffer, or Blob to load
  35005. * @param onLoad callback called when the image successfully loads
  35006. * @param onError callback called when the image fails to load
  35007. * @param offlineProvider offline provider for caching
  35008. * @param mimeType optional mime type
  35009. * @returns the HTMLImageElement of the loaded image
  35010. */
  35011. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35012. /**
  35013. * Loads a file from a url
  35014. * @param url url string, ArrayBuffer, or Blob to load
  35015. * @param onSuccess callback called when the file successfully loads
  35016. * @param onProgress callback called while file is loading (if the server supports this mode)
  35017. * @param offlineProvider defines the offline provider for caching
  35018. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35019. * @param onError callback called when the file fails to load
  35020. * @returns a file request object
  35021. */
  35022. 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;
  35023. /**
  35024. * Loads a file from a url
  35025. * @param url the file url to load
  35026. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  35027. */
  35028. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  35029. /**
  35030. * Load a script (identified by an url). When the url returns, the
  35031. * content of this file is added into a new script element, attached to the DOM (body element)
  35032. * @param scriptUrl defines the url of the script to laod
  35033. * @param onSuccess defines the callback called when the script is loaded
  35034. * @param onError defines the callback to call if an error occurs
  35035. * @param scriptId defines the id of the script element
  35036. */
  35037. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35038. /**
  35039. * Load an asynchronous script (identified by an url). When the url returns, the
  35040. * content of this file is added into a new script element, attached to the DOM (body element)
  35041. * @param scriptUrl defines the url of the script to laod
  35042. * @param scriptId defines the id of the script element
  35043. * @returns a promise request object
  35044. */
  35045. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35046. /**
  35047. * Loads a file from a blob
  35048. * @param fileToLoad defines the blob to use
  35049. * @param callback defines the callback to call when data is loaded
  35050. * @param progressCallback defines the callback to call during loading process
  35051. * @returns a file request object
  35052. */
  35053. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35054. /**
  35055. * Reads a file from a File object
  35056. * @param file defines the file to load
  35057. * @param onSuccess defines the callback to call when data is loaded
  35058. * @param onProgress defines the callback to call during loading process
  35059. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35060. * @param onError defines the callback to call when an error occurs
  35061. * @returns a file request object
  35062. */
  35063. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35064. /**
  35065. * Creates a data url from a given string content
  35066. * @param content defines the content to convert
  35067. * @returns the new data url link
  35068. */
  35069. static FileAsURL(content: string): string;
  35070. /**
  35071. * Format the given number to a specific decimal format
  35072. * @param value defines the number to format
  35073. * @param decimals defines the number of decimals to use
  35074. * @returns the formatted string
  35075. */
  35076. static Format(value: number, decimals?: number): string;
  35077. /**
  35078. * Tries to copy an object by duplicating every property
  35079. * @param source defines the source object
  35080. * @param destination defines the target object
  35081. * @param doNotCopyList defines a list of properties to avoid
  35082. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35083. */
  35084. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35085. /**
  35086. * Gets a boolean indicating if the given object has no own property
  35087. * @param obj defines the object to test
  35088. * @returns true if object has no own property
  35089. */
  35090. static IsEmpty(obj: any): boolean;
  35091. /**
  35092. * Function used to register events at window level
  35093. * @param windowElement defines the Window object to use
  35094. * @param events defines the events to register
  35095. */
  35096. static RegisterTopRootEvents(windowElement: Window, events: {
  35097. name: string;
  35098. handler: Nullable<(e: FocusEvent) => any>;
  35099. }[]): void;
  35100. /**
  35101. * Function used to unregister events from window level
  35102. * @param windowElement defines the Window object to use
  35103. * @param events defines the events to unregister
  35104. */
  35105. static UnregisterTopRootEvents(windowElement: Window, events: {
  35106. name: string;
  35107. handler: Nullable<(e: FocusEvent) => any>;
  35108. }[]): void;
  35109. /**
  35110. * @ignore
  35111. */
  35112. static _ScreenshotCanvas: HTMLCanvasElement;
  35113. /**
  35114. * Dumps the current bound framebuffer
  35115. * @param width defines the rendering width
  35116. * @param height defines the rendering height
  35117. * @param engine defines the hosting engine
  35118. * @param successCallback defines the callback triggered once the data are available
  35119. * @param mimeType defines the mime type of the result
  35120. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35121. */
  35122. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35123. /**
  35124. * Converts the canvas data to blob.
  35125. * This acts as a polyfill for browsers not supporting the to blob function.
  35126. * @param canvas Defines the canvas to extract the data from
  35127. * @param successCallback Defines the callback triggered once the data are available
  35128. * @param mimeType Defines the mime type of the result
  35129. */
  35130. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35131. /**
  35132. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35133. * @param successCallback defines the callback triggered once the data are available
  35134. * @param mimeType defines the mime type of the result
  35135. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35136. */
  35137. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35138. /**
  35139. * Downloads a blob in the browser
  35140. * @param blob defines the blob to download
  35141. * @param fileName defines the name of the downloaded file
  35142. */
  35143. static Download(blob: Blob, fileName: string): void;
  35144. /**
  35145. * Captures a screenshot of the current rendering
  35146. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35147. * @param engine defines the rendering engine
  35148. * @param camera defines the source camera
  35149. * @param size This parameter can be set to a single number or to an object with the
  35150. * following (optional) properties: precision, width, height. If a single number is passed,
  35151. * it will be used for both width and height. If an object is passed, the screenshot size
  35152. * will be derived from the parameters. The precision property is a multiplier allowing
  35153. * rendering at a higher or lower resolution
  35154. * @param successCallback defines the callback receives a single parameter which contains the
  35155. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35156. * src parameter of an <img> to display it
  35157. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35158. * Check your browser for supported MIME types
  35159. */
  35160. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35161. /**
  35162. * Captures a screenshot of the current rendering
  35163. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35164. * @param engine defines the rendering engine
  35165. * @param camera defines the source camera
  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 mimeType defines the MIME type of the screenshot image (default: image/png).
  35172. * Check your browser for supported MIME types
  35173. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35174. * to the src parameter of an <img> to display it
  35175. */
  35176. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35177. /**
  35178. * Generates an image screenshot from the specified camera.
  35179. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35180. * @param engine The engine to use for rendering
  35181. * @param camera The camera to use for rendering
  35182. * @param size This parameter can be set to a single number or to an object with the
  35183. * following (optional) properties: precision, width, height. If a single number is passed,
  35184. * it will be used for both width and height. If an object is passed, the screenshot size
  35185. * will be derived from the parameters. The precision property is a multiplier allowing
  35186. * rendering at a higher or lower resolution
  35187. * @param successCallback The callback receives a single parameter which contains the
  35188. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35189. * src parameter of an <img> to display it
  35190. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35191. * Check your browser for supported MIME types
  35192. * @param samples Texture samples (default: 1)
  35193. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35194. * @param fileName A name for for the downloaded file.
  35195. */
  35196. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35197. /**
  35198. * Generates an image screenshot from the specified camera.
  35199. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35200. * @param engine The engine to use for rendering
  35201. * @param camera The camera to use for rendering
  35202. * @param size This parameter can be set to a single number or to an object with the
  35203. * following (optional) properties: precision, width, height. If a single number is passed,
  35204. * it will be used for both width and height. If an object is passed, the screenshot size
  35205. * will be derived from the parameters. The precision property is a multiplier allowing
  35206. * rendering at a higher or lower resolution
  35207. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35208. * Check your browser for supported MIME types
  35209. * @param samples Texture samples (default: 1)
  35210. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35211. * @param fileName A name for for the downloaded file.
  35212. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35213. * to the src parameter of an <img> to display it
  35214. */
  35215. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35216. /**
  35217. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35218. * Be aware Math.random() could cause collisions, but:
  35219. * "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"
  35220. * @returns a pseudo random id
  35221. */
  35222. static RandomId(): string;
  35223. /**
  35224. * Test if the given uri is a base64 string
  35225. * @param uri The uri to test
  35226. * @return True if the uri is a base64 string or false otherwise
  35227. */
  35228. static IsBase64(uri: string): boolean;
  35229. /**
  35230. * Decode the given base64 uri.
  35231. * @param uri The uri to decode
  35232. * @return The decoded base64 data.
  35233. */
  35234. static DecodeBase64(uri: string): ArrayBuffer;
  35235. /**
  35236. * Gets the absolute url.
  35237. * @param url the input url
  35238. * @return the absolute url
  35239. */
  35240. static GetAbsoluteUrl(url: string): string;
  35241. /**
  35242. * No log
  35243. */
  35244. static readonly NoneLogLevel: number;
  35245. /**
  35246. * Only message logs
  35247. */
  35248. static readonly MessageLogLevel: number;
  35249. /**
  35250. * Only warning logs
  35251. */
  35252. static readonly WarningLogLevel: number;
  35253. /**
  35254. * Only error logs
  35255. */
  35256. static readonly ErrorLogLevel: number;
  35257. /**
  35258. * All logs
  35259. */
  35260. static readonly AllLogLevel: number;
  35261. /**
  35262. * Gets a value indicating the number of loading errors
  35263. * @ignorenaming
  35264. */
  35265. static get errorsCount(): number;
  35266. /**
  35267. * Callback called when a new log is added
  35268. */
  35269. static OnNewCacheEntry: (entry: string) => void;
  35270. /**
  35271. * Log a message to the console
  35272. * @param message defines the message to log
  35273. */
  35274. static Log(message: string): void;
  35275. /**
  35276. * Write a warning message to the console
  35277. * @param message defines the message to log
  35278. */
  35279. static Warn(message: string): void;
  35280. /**
  35281. * Write an error message to the console
  35282. * @param message defines the message to log
  35283. */
  35284. static Error(message: string): void;
  35285. /**
  35286. * Gets current log cache (list of logs)
  35287. */
  35288. static get LogCache(): string;
  35289. /**
  35290. * Clears the log cache
  35291. */
  35292. static ClearLogCache(): void;
  35293. /**
  35294. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35295. */
  35296. static set LogLevels(level: number);
  35297. /**
  35298. * Checks if the window object exists
  35299. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35300. */
  35301. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35302. /**
  35303. * No performance log
  35304. */
  35305. static readonly PerformanceNoneLogLevel: number;
  35306. /**
  35307. * Use user marks to log performance
  35308. */
  35309. static readonly PerformanceUserMarkLogLevel: number;
  35310. /**
  35311. * Log performance to the console
  35312. */
  35313. static readonly PerformanceConsoleLogLevel: number;
  35314. private static _performance;
  35315. /**
  35316. * Sets the current performance log level
  35317. */
  35318. static set PerformanceLogLevel(level: number);
  35319. private static _StartPerformanceCounterDisabled;
  35320. private static _EndPerformanceCounterDisabled;
  35321. private static _StartUserMark;
  35322. private static _EndUserMark;
  35323. private static _StartPerformanceConsole;
  35324. private static _EndPerformanceConsole;
  35325. /**
  35326. * Starts a performance counter
  35327. */
  35328. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35329. /**
  35330. * Ends a specific performance coutner
  35331. */
  35332. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35333. /**
  35334. * Gets either window.performance.now() if supported or Date.now() else
  35335. */
  35336. static get Now(): number;
  35337. /**
  35338. * This method will return the name of the class used to create the instance of the given object.
  35339. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35340. * @param object the object to get the class name from
  35341. * @param isType defines if the object is actually a type
  35342. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35343. */
  35344. static GetClassName(object: any, isType?: boolean): string;
  35345. /**
  35346. * Gets the first element of an array satisfying a given predicate
  35347. * @param array defines the array to browse
  35348. * @param predicate defines the predicate to use
  35349. * @returns null if not found or the element
  35350. */
  35351. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35352. /**
  35353. * This method will return the name of the full name of the class, including its owning module (if any).
  35354. * 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).
  35355. * @param object the object to get the class name from
  35356. * @param isType defines if the object is actually a type
  35357. * @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.
  35358. * @ignorenaming
  35359. */
  35360. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35361. /**
  35362. * Returns a promise that resolves after the given amount of time.
  35363. * @param delay Number of milliseconds to delay
  35364. * @returns Promise that resolves after the given amount of time
  35365. */
  35366. static DelayAsync(delay: number): Promise<void>;
  35367. /**
  35368. * Utility function to detect if the current user agent is Safari
  35369. * @returns whether or not the current user agent is safari
  35370. */
  35371. static IsSafari(): boolean;
  35372. }
  35373. /**
  35374. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35375. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35376. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35377. * @param name The name of the class, case should be preserved
  35378. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35379. */
  35380. export function className(name: string, module?: string): (target: Object) => void;
  35381. /**
  35382. * An implementation of a loop for asynchronous functions.
  35383. */
  35384. export class AsyncLoop {
  35385. /**
  35386. * Defines the number of iterations for the loop
  35387. */
  35388. iterations: number;
  35389. /**
  35390. * Defines the current index of the loop.
  35391. */
  35392. index: number;
  35393. private _done;
  35394. private _fn;
  35395. private _successCallback;
  35396. /**
  35397. * Constructor.
  35398. * @param iterations the number of iterations.
  35399. * @param func the function to run each iteration
  35400. * @param successCallback the callback that will be called upon succesful execution
  35401. * @param offset starting offset.
  35402. */
  35403. constructor(
  35404. /**
  35405. * Defines the number of iterations for the loop
  35406. */
  35407. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35408. /**
  35409. * Execute the next iteration. Must be called after the last iteration was finished.
  35410. */
  35411. executeNext(): void;
  35412. /**
  35413. * Break the loop and run the success callback.
  35414. */
  35415. breakLoop(): void;
  35416. /**
  35417. * Create and run an async loop.
  35418. * @param iterations the number of iterations.
  35419. * @param fn the function to run each iteration
  35420. * @param successCallback the callback that will be called upon succesful execution
  35421. * @param offset starting offset.
  35422. * @returns the created async loop object
  35423. */
  35424. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35425. /**
  35426. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35427. * @param iterations total number of iterations
  35428. * @param syncedIterations number of synchronous iterations in each async iteration.
  35429. * @param fn the function to call each iteration.
  35430. * @param callback a success call back that will be called when iterating stops.
  35431. * @param breakFunction a break condition (optional)
  35432. * @param timeout timeout settings for the setTimeout function. default - 0.
  35433. * @returns the created async loop object
  35434. */
  35435. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35436. }
  35437. }
  35438. declare module "babylonjs/Misc/stringDictionary" {
  35439. import { Nullable } from "babylonjs/types";
  35440. /**
  35441. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35442. * The underlying implementation relies on an associative array to ensure the best performances.
  35443. * The value can be anything including 'null' but except 'undefined'
  35444. */
  35445. export class StringDictionary<T> {
  35446. /**
  35447. * This will clear this dictionary and copy the content from the 'source' one.
  35448. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35449. * @param source the dictionary to take the content from and copy to this dictionary
  35450. */
  35451. copyFrom(source: StringDictionary<T>): void;
  35452. /**
  35453. * Get a value based from its key
  35454. * @param key the given key to get the matching value from
  35455. * @return the value if found, otherwise undefined is returned
  35456. */
  35457. get(key: string): T | undefined;
  35458. /**
  35459. * Get a value from its key or add it if it doesn't exist.
  35460. * This method will ensure you that a given key/data will be present in the dictionary.
  35461. * @param key the given key to get the matching value from
  35462. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35463. * The factory will only be invoked if there's no data for the given key.
  35464. * @return the value corresponding to the key.
  35465. */
  35466. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35467. /**
  35468. * Get a value from its key if present in the dictionary otherwise add it
  35469. * @param key the key to get the value from
  35470. * @param val if there's no such key/value pair in the dictionary add it with this value
  35471. * @return the value corresponding to the key
  35472. */
  35473. getOrAdd(key: string, val: T): T;
  35474. /**
  35475. * Check if there's a given key in the dictionary
  35476. * @param key the key to check for
  35477. * @return true if the key is present, false otherwise
  35478. */
  35479. contains(key: string): boolean;
  35480. /**
  35481. * Add a new key and its corresponding value
  35482. * @param key the key to add
  35483. * @param value the value corresponding to the key
  35484. * @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
  35485. */
  35486. add(key: string, value: T): boolean;
  35487. /**
  35488. * Update a specific value associated to a key
  35489. * @param key defines the key to use
  35490. * @param value defines the value to store
  35491. * @returns true if the value was updated (or false if the key was not found)
  35492. */
  35493. set(key: string, value: T): boolean;
  35494. /**
  35495. * Get the element of the given key and remove it from the dictionary
  35496. * @param key defines the key to search
  35497. * @returns the value associated with the key or null if not found
  35498. */
  35499. getAndRemove(key: string): Nullable<T>;
  35500. /**
  35501. * Remove a key/value from the dictionary.
  35502. * @param key the key to remove
  35503. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35504. */
  35505. remove(key: string): boolean;
  35506. /**
  35507. * Clear the whole content of the dictionary
  35508. */
  35509. clear(): void;
  35510. /**
  35511. * Gets the current count
  35512. */
  35513. get count(): number;
  35514. /**
  35515. * Execute a callback on each key/val of the dictionary.
  35516. * Note that you can remove any element in this dictionary in the callback implementation
  35517. * @param callback the callback to execute on a given key/value pair
  35518. */
  35519. forEach(callback: (key: string, val: T) => void): void;
  35520. /**
  35521. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35522. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35523. * Note that you can remove any element in this dictionary in the callback implementation
  35524. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35525. * @returns the first item
  35526. */
  35527. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35528. private _count;
  35529. private _data;
  35530. }
  35531. }
  35532. declare module "babylonjs/Collisions/collisionCoordinator" {
  35533. import { Nullable } from "babylonjs/types";
  35534. import { Scene } from "babylonjs/scene";
  35535. import { Vector3 } from "babylonjs/Maths/math.vector";
  35536. import { Collider } from "babylonjs/Collisions/collider";
  35537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35538. /** @hidden */
  35539. export interface ICollisionCoordinator {
  35540. createCollider(): Collider;
  35541. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35542. init(scene: Scene): void;
  35543. }
  35544. /** @hidden */
  35545. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35546. private _scene;
  35547. private _scaledPosition;
  35548. private _scaledVelocity;
  35549. private _finalPosition;
  35550. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35551. createCollider(): Collider;
  35552. init(scene: Scene): void;
  35553. private _collideWithWorld;
  35554. }
  35555. }
  35556. declare module "babylonjs/Inputs/scene.inputManager" {
  35557. import { Nullable } from "babylonjs/types";
  35558. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35559. import { Vector2 } from "babylonjs/Maths/math.vector";
  35560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35561. import { Scene } from "babylonjs/scene";
  35562. /**
  35563. * Class used to manage all inputs for the scene.
  35564. */
  35565. export class InputManager {
  35566. /** The distance in pixel that you have to move to prevent some events */
  35567. static DragMovementThreshold: number;
  35568. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35569. static LongPressDelay: number;
  35570. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35571. static DoubleClickDelay: number;
  35572. /** If you need to check double click without raising a single click at first click, enable this flag */
  35573. static ExclusiveDoubleClickMode: boolean;
  35574. private _wheelEventName;
  35575. private _onPointerMove;
  35576. private _onPointerDown;
  35577. private _onPointerUp;
  35578. private _initClickEvent;
  35579. private _initActionManager;
  35580. private _delayedSimpleClick;
  35581. private _delayedSimpleClickTimeout;
  35582. private _previousDelayedSimpleClickTimeout;
  35583. private _meshPickProceed;
  35584. private _previousButtonPressed;
  35585. private _currentPickResult;
  35586. private _previousPickResult;
  35587. private _totalPointersPressed;
  35588. private _doubleClickOccured;
  35589. private _pointerOverMesh;
  35590. private _pickedDownMesh;
  35591. private _pickedUpMesh;
  35592. private _pointerX;
  35593. private _pointerY;
  35594. private _unTranslatedPointerX;
  35595. private _unTranslatedPointerY;
  35596. private _startingPointerPosition;
  35597. private _previousStartingPointerPosition;
  35598. private _startingPointerTime;
  35599. private _previousStartingPointerTime;
  35600. private _pointerCaptures;
  35601. private _onKeyDown;
  35602. private _onKeyUp;
  35603. private _onCanvasFocusObserver;
  35604. private _onCanvasBlurObserver;
  35605. private _scene;
  35606. /**
  35607. * Creates a new InputManager
  35608. * @param scene defines the hosting scene
  35609. */
  35610. constructor(scene: Scene);
  35611. /**
  35612. * Gets the mesh that is currently under the pointer
  35613. */
  35614. get meshUnderPointer(): Nullable<AbstractMesh>;
  35615. /**
  35616. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35617. */
  35618. get unTranslatedPointer(): Vector2;
  35619. /**
  35620. * Gets or sets the current on-screen X position of the pointer
  35621. */
  35622. get pointerX(): number;
  35623. set pointerX(value: number);
  35624. /**
  35625. * Gets or sets the current on-screen Y position of the pointer
  35626. */
  35627. get pointerY(): number;
  35628. set pointerY(value: number);
  35629. private _updatePointerPosition;
  35630. private _processPointerMove;
  35631. private _setRayOnPointerInfo;
  35632. private _checkPrePointerObservable;
  35633. /**
  35634. * Use this method to simulate a pointer move on a mesh
  35635. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35636. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35637. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35638. */
  35639. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35640. /**
  35641. * Use this method to simulate a pointer down on a mesh
  35642. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35643. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35644. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35645. */
  35646. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35647. private _processPointerDown;
  35648. /** @hidden */
  35649. _isPointerSwiping(): boolean;
  35650. /**
  35651. * Use this method to simulate a pointer up on a mesh
  35652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35655. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35656. */
  35657. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35658. private _processPointerUp;
  35659. /**
  35660. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35661. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35662. * @returns true if the pointer was captured
  35663. */
  35664. isPointerCaptured(pointerId?: number): boolean;
  35665. /**
  35666. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35667. * @param attachUp defines if you want to attach events to pointerup
  35668. * @param attachDown defines if you want to attach events to pointerdown
  35669. * @param attachMove defines if you want to attach events to pointermove
  35670. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35671. */
  35672. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35673. /**
  35674. * Detaches all event handlers
  35675. */
  35676. detachControl(): void;
  35677. /**
  35678. * Force the value of meshUnderPointer
  35679. * @param mesh defines the mesh to use
  35680. */
  35681. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35682. /**
  35683. * Gets the mesh under the pointer
  35684. * @returns a Mesh or null if no mesh is under the pointer
  35685. */
  35686. getPointerOverMesh(): Nullable<AbstractMesh>;
  35687. }
  35688. }
  35689. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35690. /**
  35691. * Helper class used to generate session unique ID
  35692. */
  35693. export class UniqueIdGenerator {
  35694. private static _UniqueIdCounter;
  35695. /**
  35696. * Gets an unique (relatively to the current scene) Id
  35697. */
  35698. static get UniqueId(): number;
  35699. }
  35700. }
  35701. declare module "babylonjs/Animations/animationGroup" {
  35702. import { Animatable } from "babylonjs/Animations/animatable";
  35703. import { Animation } from "babylonjs/Animations/animation";
  35704. import { Scene, IDisposable } from "babylonjs/scene";
  35705. import { Observable } from "babylonjs/Misc/observable";
  35706. import { Nullable } from "babylonjs/types";
  35707. import "babylonjs/Animations/animatable";
  35708. /**
  35709. * This class defines the direct association between an animation and a target
  35710. */
  35711. export class TargetedAnimation {
  35712. /**
  35713. * Animation to perform
  35714. */
  35715. animation: Animation;
  35716. /**
  35717. * Target to animate
  35718. */
  35719. target: any;
  35720. /**
  35721. * Serialize the object
  35722. * @returns the JSON object representing the current entity
  35723. */
  35724. serialize(): any;
  35725. }
  35726. /**
  35727. * Use this class to create coordinated animations on multiple targets
  35728. */
  35729. export class AnimationGroup implements IDisposable {
  35730. /** The name of the animation group */
  35731. name: string;
  35732. private _scene;
  35733. private _targetedAnimations;
  35734. private _animatables;
  35735. private _from;
  35736. private _to;
  35737. private _isStarted;
  35738. private _isPaused;
  35739. private _speedRatio;
  35740. private _loopAnimation;
  35741. /**
  35742. * Gets or sets the unique id of the node
  35743. */
  35744. uniqueId: number;
  35745. /**
  35746. * This observable will notify when one animation have ended
  35747. */
  35748. onAnimationEndObservable: Observable<TargetedAnimation>;
  35749. /**
  35750. * Observer raised when one animation loops
  35751. */
  35752. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35753. /**
  35754. * Observer raised when all animations have looped
  35755. */
  35756. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35757. /**
  35758. * This observable will notify when all animations have ended.
  35759. */
  35760. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35761. /**
  35762. * This observable will notify when all animations have paused.
  35763. */
  35764. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35765. /**
  35766. * This observable will notify when all animations are playing.
  35767. */
  35768. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35769. /**
  35770. * Gets the first frame
  35771. */
  35772. get from(): number;
  35773. /**
  35774. * Gets the last frame
  35775. */
  35776. get to(): number;
  35777. /**
  35778. * Define if the animations are started
  35779. */
  35780. get isStarted(): boolean;
  35781. /**
  35782. * Gets a value indicating that the current group is playing
  35783. */
  35784. get isPlaying(): boolean;
  35785. /**
  35786. * Gets or sets the speed ratio to use for all animations
  35787. */
  35788. get speedRatio(): number;
  35789. /**
  35790. * Gets or sets the speed ratio to use for all animations
  35791. */
  35792. set speedRatio(value: number);
  35793. /**
  35794. * Gets or sets if all animations should loop or not
  35795. */
  35796. get loopAnimation(): boolean;
  35797. set loopAnimation(value: boolean);
  35798. /**
  35799. * Gets the targeted animations for this animation group
  35800. */
  35801. get targetedAnimations(): Array<TargetedAnimation>;
  35802. /**
  35803. * returning the list of animatables controlled by this animation group.
  35804. */
  35805. get animatables(): Array<Animatable>;
  35806. /**
  35807. * Instantiates a new Animation Group.
  35808. * This helps managing several animations at once.
  35809. * @see http://doc.babylonjs.com/how_to/group
  35810. * @param name Defines the name of the group
  35811. * @param scene Defines the scene the group belongs to
  35812. */
  35813. constructor(
  35814. /** The name of the animation group */
  35815. name: string, scene?: Nullable<Scene>);
  35816. /**
  35817. * Add an animation (with its target) in the group
  35818. * @param animation defines the animation we want to add
  35819. * @param target defines the target of the animation
  35820. * @returns the TargetedAnimation object
  35821. */
  35822. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35823. /**
  35824. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35825. * It can add constant keys at begin or end
  35826. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35827. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35828. * @returns the animation group
  35829. */
  35830. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35831. private _animationLoopCount;
  35832. private _animationLoopFlags;
  35833. private _processLoop;
  35834. /**
  35835. * Start all animations on given targets
  35836. * @param loop defines if animations must loop
  35837. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35838. * @param from defines the from key (optional)
  35839. * @param to defines the to key (optional)
  35840. * @returns the current animation group
  35841. */
  35842. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35843. /**
  35844. * Pause all animations
  35845. * @returns the animation group
  35846. */
  35847. pause(): AnimationGroup;
  35848. /**
  35849. * Play all animations to initial state
  35850. * This function will start() the animations if they were not started or will restart() them if they were paused
  35851. * @param loop defines if animations must loop
  35852. * @returns the animation group
  35853. */
  35854. play(loop?: boolean): AnimationGroup;
  35855. /**
  35856. * Reset all animations to initial state
  35857. * @returns the animation group
  35858. */
  35859. reset(): AnimationGroup;
  35860. /**
  35861. * Restart animations from key 0
  35862. * @returns the animation group
  35863. */
  35864. restart(): AnimationGroup;
  35865. /**
  35866. * Stop all animations
  35867. * @returns the animation group
  35868. */
  35869. stop(): AnimationGroup;
  35870. /**
  35871. * Set animation weight for all animatables
  35872. * @param weight defines the weight to use
  35873. * @return the animationGroup
  35874. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35875. */
  35876. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35877. /**
  35878. * Synchronize and normalize all animatables with a source animatable
  35879. * @param root defines the root animatable to synchronize with
  35880. * @return the animationGroup
  35881. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35882. */
  35883. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35884. /**
  35885. * Goes to a specific frame in this animation group
  35886. * @param frame the frame number to go to
  35887. * @return the animationGroup
  35888. */
  35889. goToFrame(frame: number): AnimationGroup;
  35890. /**
  35891. * Dispose all associated resources
  35892. */
  35893. dispose(): void;
  35894. private _checkAnimationGroupEnded;
  35895. /**
  35896. * Clone the current animation group and returns a copy
  35897. * @param newName defines the name of the new group
  35898. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35899. * @returns the new aniamtion group
  35900. */
  35901. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35902. /**
  35903. * Serializes the animationGroup to an object
  35904. * @returns Serialized object
  35905. */
  35906. serialize(): any;
  35907. /**
  35908. * Returns a new AnimationGroup object parsed from the source provided.
  35909. * @param parsedAnimationGroup defines the source
  35910. * @param scene defines the scene that will receive the animationGroup
  35911. * @returns a new AnimationGroup
  35912. */
  35913. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35914. /**
  35915. * Returns the string "AnimationGroup"
  35916. * @returns "AnimationGroup"
  35917. */
  35918. getClassName(): string;
  35919. /**
  35920. * Creates a detailled string about the object
  35921. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35922. * @returns a string representing the object
  35923. */
  35924. toString(fullDetails?: boolean): string;
  35925. }
  35926. }
  35927. declare module "babylonjs/scene" {
  35928. import { Nullable } from "babylonjs/types";
  35929. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35930. import { Observable } from "babylonjs/Misc/observable";
  35931. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35932. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35933. import { Geometry } from "babylonjs/Meshes/geometry";
  35934. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35937. import { Mesh } from "babylonjs/Meshes/mesh";
  35938. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35939. import { Bone } from "babylonjs/Bones/bone";
  35940. import { Skeleton } from "babylonjs/Bones/skeleton";
  35941. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35942. import { Camera } from "babylonjs/Cameras/camera";
  35943. import { AbstractScene } from "babylonjs/abstractScene";
  35944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35945. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35946. import { Material } from "babylonjs/Materials/material";
  35947. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35948. import { Effect } from "babylonjs/Materials/effect";
  35949. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35950. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35951. import { Light } from "babylonjs/Lights/light";
  35952. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35953. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35954. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35955. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35956. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35957. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35958. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35959. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35960. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35961. import { Engine } from "babylonjs/Engines/engine";
  35962. import { Node } from "babylonjs/node";
  35963. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35964. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35965. import { WebRequest } from "babylonjs/Misc/webRequest";
  35966. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35967. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35968. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35969. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35970. import { Plane } from "babylonjs/Maths/math.plane";
  35971. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35972. import { Ray } from "babylonjs/Culling/ray";
  35973. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35974. import { Animation } from "babylonjs/Animations/animation";
  35975. import { Animatable } from "babylonjs/Animations/animatable";
  35976. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35977. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35978. import { Collider } from "babylonjs/Collisions/collider";
  35979. /**
  35980. * Define an interface for all classes that will hold resources
  35981. */
  35982. export interface IDisposable {
  35983. /**
  35984. * Releases all held resources
  35985. */
  35986. dispose(): void;
  35987. }
  35988. /** Interface defining initialization parameters for Scene class */
  35989. export interface SceneOptions {
  35990. /**
  35991. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35992. * It will improve performance when the number of geometries becomes important.
  35993. */
  35994. useGeometryUniqueIdsMap?: boolean;
  35995. /**
  35996. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35997. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35998. */
  35999. useMaterialMeshMap?: boolean;
  36000. /**
  36001. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36002. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36003. */
  36004. useClonedMeshMap?: boolean;
  36005. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36006. virtual?: boolean;
  36007. }
  36008. /**
  36009. * Represents a scene to be rendered by the engine.
  36010. * @see http://doc.babylonjs.com/features/scene
  36011. */
  36012. export class Scene extends AbstractScene implements IAnimatable {
  36013. /** The fog is deactivated */
  36014. static readonly FOGMODE_NONE: number;
  36015. /** The fog density is following an exponential function */
  36016. static readonly FOGMODE_EXP: number;
  36017. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36018. static readonly FOGMODE_EXP2: number;
  36019. /** The fog density is following a linear function. */
  36020. static readonly FOGMODE_LINEAR: number;
  36021. /**
  36022. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36023. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36024. */
  36025. static MinDeltaTime: number;
  36026. /**
  36027. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36028. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36029. */
  36030. static MaxDeltaTime: number;
  36031. /**
  36032. * Factory used to create the default material.
  36033. * @param name The name of the material to create
  36034. * @param scene The scene to create the material for
  36035. * @returns The default material
  36036. */
  36037. static DefaultMaterialFactory(scene: Scene): Material;
  36038. /**
  36039. * Factory used to create the a collision coordinator.
  36040. * @returns The collision coordinator
  36041. */
  36042. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36043. /** @hidden */
  36044. _inputManager: InputManager;
  36045. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36046. cameraToUseForPointers: Nullable<Camera>;
  36047. /** @hidden */
  36048. readonly _isScene: boolean;
  36049. /**
  36050. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36051. */
  36052. autoClear: boolean;
  36053. /**
  36054. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36055. */
  36056. autoClearDepthAndStencil: boolean;
  36057. /**
  36058. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36059. */
  36060. clearColor: Color4;
  36061. /**
  36062. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36063. */
  36064. ambientColor: Color3;
  36065. /**
  36066. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36067. * It should only be one of the following (if not the default embedded one):
  36068. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36069. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36070. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36071. * The material properties need to be setup according to the type of texture in use.
  36072. */
  36073. environmentBRDFTexture: BaseTexture;
  36074. /** @hidden */
  36075. protected _environmentTexture: Nullable<BaseTexture>;
  36076. /**
  36077. * Texture used in all pbr material as the reflection texture.
  36078. * As in the majority of the scene they are the same (exception for multi room and so on),
  36079. * this is easier to reference from here than from all the materials.
  36080. */
  36081. get environmentTexture(): Nullable<BaseTexture>;
  36082. /**
  36083. * Texture used in all pbr material as the reflection texture.
  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 environmentTexture(value: Nullable<BaseTexture>);
  36088. /** @hidden */
  36089. protected _environmentIntensity: number;
  36090. /**
  36091. * Intensity of the environment in all pbr material.
  36092. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36093. * As in the majority of the scene they are the same (exception for multi room and so on),
  36094. * this is easier to reference from here than from all the materials.
  36095. */
  36096. get environmentIntensity(): number;
  36097. /**
  36098. * Intensity of the environment in all pbr material.
  36099. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36100. * As in the majority of the scene they are the same (exception for multi room and so on),
  36101. * this is easier to set here than in all the materials.
  36102. */
  36103. set environmentIntensity(value: number);
  36104. /** @hidden */
  36105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36106. /**
  36107. * Default image processing configuration used either in the rendering
  36108. * Forward main pass or through the imageProcessingPostProcess if present.
  36109. * As in the majority of the scene they are the same (exception for multi camera),
  36110. * this is easier to reference from here than from all the materials and post process.
  36111. *
  36112. * No setter as we it is a shared configuration, you can set the values instead.
  36113. */
  36114. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36115. private _forceWireframe;
  36116. /**
  36117. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36118. */
  36119. set forceWireframe(value: boolean);
  36120. get forceWireframe(): boolean;
  36121. private _skipFrustumClipping;
  36122. /**
  36123. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36124. */
  36125. set skipFrustumClipping(value: boolean);
  36126. get skipFrustumClipping(): boolean;
  36127. private _forcePointsCloud;
  36128. /**
  36129. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36130. */
  36131. set forcePointsCloud(value: boolean);
  36132. get forcePointsCloud(): boolean;
  36133. /**
  36134. * Gets or sets the active clipplane 1
  36135. */
  36136. clipPlane: Nullable<Plane>;
  36137. /**
  36138. * Gets or sets the active clipplane 2
  36139. */
  36140. clipPlane2: Nullable<Plane>;
  36141. /**
  36142. * Gets or sets the active clipplane 3
  36143. */
  36144. clipPlane3: Nullable<Plane>;
  36145. /**
  36146. * Gets or sets the active clipplane 4
  36147. */
  36148. clipPlane4: Nullable<Plane>;
  36149. /**
  36150. * Gets or sets the active clipplane 5
  36151. */
  36152. clipPlane5: Nullable<Plane>;
  36153. /**
  36154. * Gets or sets the active clipplane 6
  36155. */
  36156. clipPlane6: Nullable<Plane>;
  36157. /**
  36158. * Gets or sets a boolean indicating if animations are enabled
  36159. */
  36160. animationsEnabled: boolean;
  36161. private _animationPropertiesOverride;
  36162. /**
  36163. * Gets or sets the animation properties override
  36164. */
  36165. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36166. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36167. /**
  36168. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36169. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36170. */
  36171. useConstantAnimationDeltaTime: boolean;
  36172. /**
  36173. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36174. * Please note that it requires to run a ray cast through the scene on every frame
  36175. */
  36176. constantlyUpdateMeshUnderPointer: boolean;
  36177. /**
  36178. * Defines the HTML cursor to use when hovering over interactive elements
  36179. */
  36180. hoverCursor: string;
  36181. /**
  36182. * Defines the HTML default cursor to use (empty by default)
  36183. */
  36184. defaultCursor: string;
  36185. /**
  36186. * Defines wether cursors are handled by the scene.
  36187. */
  36188. doNotHandleCursors: boolean;
  36189. /**
  36190. * This is used to call preventDefault() on pointer down
  36191. * in order to block unwanted artifacts like system double clicks
  36192. */
  36193. preventDefaultOnPointerDown: boolean;
  36194. /**
  36195. * This is used to call preventDefault() on pointer up
  36196. * in order to block unwanted artifacts like system double clicks
  36197. */
  36198. preventDefaultOnPointerUp: boolean;
  36199. /**
  36200. * Gets or sets user defined metadata
  36201. */
  36202. metadata: any;
  36203. /**
  36204. * For internal use only. Please do not use.
  36205. */
  36206. reservedDataStore: any;
  36207. /**
  36208. * Gets the name of the plugin used to load this scene (null by default)
  36209. */
  36210. loadingPluginName: string;
  36211. /**
  36212. * Use this array to add regular expressions used to disable offline support for specific urls
  36213. */
  36214. disableOfflineSupportExceptionRules: RegExp[];
  36215. /**
  36216. * An event triggered when the scene is disposed.
  36217. */
  36218. onDisposeObservable: Observable<Scene>;
  36219. private _onDisposeObserver;
  36220. /** Sets a function to be executed when this scene is disposed. */
  36221. set onDispose(callback: () => void);
  36222. /**
  36223. * An event triggered before rendering the scene (right after animations and physics)
  36224. */
  36225. onBeforeRenderObservable: Observable<Scene>;
  36226. private _onBeforeRenderObserver;
  36227. /** Sets a function to be executed before rendering this scene */
  36228. set beforeRender(callback: Nullable<() => void>);
  36229. /**
  36230. * An event triggered after rendering the scene
  36231. */
  36232. onAfterRenderObservable: Observable<Scene>;
  36233. /**
  36234. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36235. */
  36236. onAfterRenderCameraObservable: Observable<Camera>;
  36237. private _onAfterRenderObserver;
  36238. /** Sets a function to be executed after rendering this scene */
  36239. set afterRender(callback: Nullable<() => void>);
  36240. /**
  36241. * An event triggered before animating the scene
  36242. */
  36243. onBeforeAnimationsObservable: Observable<Scene>;
  36244. /**
  36245. * An event triggered after animations processing
  36246. */
  36247. onAfterAnimationsObservable: Observable<Scene>;
  36248. /**
  36249. * An event triggered before draw calls are ready to be sent
  36250. */
  36251. onBeforeDrawPhaseObservable: Observable<Scene>;
  36252. /**
  36253. * An event triggered after draw calls have been sent
  36254. */
  36255. onAfterDrawPhaseObservable: Observable<Scene>;
  36256. /**
  36257. * An event triggered when the scene is ready
  36258. */
  36259. onReadyObservable: Observable<Scene>;
  36260. /**
  36261. * An event triggered before rendering a camera
  36262. */
  36263. onBeforeCameraRenderObservable: Observable<Camera>;
  36264. private _onBeforeCameraRenderObserver;
  36265. /** Sets a function to be executed before rendering a camera*/
  36266. set beforeCameraRender(callback: () => void);
  36267. /**
  36268. * An event triggered after rendering a camera
  36269. */
  36270. onAfterCameraRenderObservable: Observable<Camera>;
  36271. private _onAfterCameraRenderObserver;
  36272. /** Sets a function to be executed after rendering a camera*/
  36273. set afterCameraRender(callback: () => void);
  36274. /**
  36275. * An event triggered when active meshes evaluation is about to start
  36276. */
  36277. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36278. /**
  36279. * An event triggered when active meshes evaluation is done
  36280. */
  36281. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36282. /**
  36283. * An event triggered when particles rendering is about to start
  36284. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36285. */
  36286. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36287. /**
  36288. * An event triggered when particles rendering is done
  36289. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36290. */
  36291. onAfterParticlesRenderingObservable: Observable<Scene>;
  36292. /**
  36293. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36294. */
  36295. onDataLoadedObservable: Observable<Scene>;
  36296. /**
  36297. * An event triggered when a camera is created
  36298. */
  36299. onNewCameraAddedObservable: Observable<Camera>;
  36300. /**
  36301. * An event triggered when a camera is removed
  36302. */
  36303. onCameraRemovedObservable: Observable<Camera>;
  36304. /**
  36305. * An event triggered when a light is created
  36306. */
  36307. onNewLightAddedObservable: Observable<Light>;
  36308. /**
  36309. * An event triggered when a light is removed
  36310. */
  36311. onLightRemovedObservable: Observable<Light>;
  36312. /**
  36313. * An event triggered when a geometry is created
  36314. */
  36315. onNewGeometryAddedObservable: Observable<Geometry>;
  36316. /**
  36317. * An event triggered when a geometry is removed
  36318. */
  36319. onGeometryRemovedObservable: Observable<Geometry>;
  36320. /**
  36321. * An event triggered when a transform node is created
  36322. */
  36323. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36324. /**
  36325. * An event triggered when a transform node is removed
  36326. */
  36327. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36328. /**
  36329. * An event triggered when a mesh is created
  36330. */
  36331. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36332. /**
  36333. * An event triggered when a mesh is removed
  36334. */
  36335. onMeshRemovedObservable: Observable<AbstractMesh>;
  36336. /**
  36337. * An event triggered when a skeleton is created
  36338. */
  36339. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36340. /**
  36341. * An event triggered when a skeleton is removed
  36342. */
  36343. onSkeletonRemovedObservable: Observable<Skeleton>;
  36344. /**
  36345. * An event triggered when a material is created
  36346. */
  36347. onNewMaterialAddedObservable: Observable<Material>;
  36348. /**
  36349. * An event triggered when a material is removed
  36350. */
  36351. onMaterialRemovedObservable: Observable<Material>;
  36352. /**
  36353. * An event triggered when a texture is created
  36354. */
  36355. onNewTextureAddedObservable: Observable<BaseTexture>;
  36356. /**
  36357. * An event triggered when a texture is removed
  36358. */
  36359. onTextureRemovedObservable: Observable<BaseTexture>;
  36360. /**
  36361. * An event triggered when render targets are about to be rendered
  36362. * Can happen multiple times per frame.
  36363. */
  36364. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36365. /**
  36366. * An event triggered when render targets were rendered.
  36367. * Can happen multiple times per frame.
  36368. */
  36369. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36370. /**
  36371. * An event triggered before calculating deterministic simulation step
  36372. */
  36373. onBeforeStepObservable: Observable<Scene>;
  36374. /**
  36375. * An event triggered after calculating deterministic simulation step
  36376. */
  36377. onAfterStepObservable: Observable<Scene>;
  36378. /**
  36379. * An event triggered when the activeCamera property is updated
  36380. */
  36381. onActiveCameraChanged: Observable<Scene>;
  36382. /**
  36383. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36384. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36385. * 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)
  36386. */
  36387. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36388. /**
  36389. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36390. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36391. * 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)
  36392. */
  36393. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36394. /**
  36395. * This Observable will when a mesh has been imported into the scene.
  36396. */
  36397. onMeshImportedObservable: Observable<AbstractMesh>;
  36398. /**
  36399. * This Observable will when an animation file has been imported into the scene.
  36400. */
  36401. onAnimationFileImportedObservable: Observable<Scene>;
  36402. /**
  36403. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36404. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36405. */
  36406. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36407. /** @hidden */
  36408. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36409. /**
  36410. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36411. */
  36412. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36413. /**
  36414. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36415. */
  36416. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36417. /**
  36418. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36419. */
  36420. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36421. /** Callback called when a pointer move is detected */
  36422. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36423. /** Callback called when a pointer down is detected */
  36424. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36425. /** Callback called when a pointer up is detected */
  36426. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36427. /** Callback called when a pointer pick is detected */
  36428. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36429. /**
  36430. * 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).
  36431. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36432. */
  36433. onPrePointerObservable: Observable<PointerInfoPre>;
  36434. /**
  36435. * Observable event triggered each time an input event is received from the rendering canvas
  36436. */
  36437. onPointerObservable: Observable<PointerInfo>;
  36438. /**
  36439. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36440. */
  36441. get unTranslatedPointer(): Vector2;
  36442. /**
  36443. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36444. */
  36445. static get DragMovementThreshold(): number;
  36446. static set DragMovementThreshold(value: number);
  36447. /**
  36448. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36449. */
  36450. static get LongPressDelay(): number;
  36451. static set LongPressDelay(value: number);
  36452. /**
  36453. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36454. */
  36455. static get DoubleClickDelay(): number;
  36456. static set DoubleClickDelay(value: number);
  36457. /** If you need to check double click without raising a single click at first click, enable this flag */
  36458. static get ExclusiveDoubleClickMode(): boolean;
  36459. static set ExclusiveDoubleClickMode(value: boolean);
  36460. /** @hidden */
  36461. _mirroredCameraPosition: Nullable<Vector3>;
  36462. /**
  36463. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36464. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36465. */
  36466. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36467. /**
  36468. * Observable event triggered each time an keyboard event is received from the hosting window
  36469. */
  36470. onKeyboardObservable: Observable<KeyboardInfo>;
  36471. private _useRightHandedSystem;
  36472. /**
  36473. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36474. */
  36475. set useRightHandedSystem(value: boolean);
  36476. get useRightHandedSystem(): boolean;
  36477. private _timeAccumulator;
  36478. private _currentStepId;
  36479. private _currentInternalStep;
  36480. /**
  36481. * Sets the step Id used by deterministic lock step
  36482. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36483. * @param newStepId defines the step Id
  36484. */
  36485. setStepId(newStepId: number): void;
  36486. /**
  36487. * Gets the step Id used by deterministic lock step
  36488. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36489. * @returns the step Id
  36490. */
  36491. getStepId(): number;
  36492. /**
  36493. * Gets the internal step used by deterministic lock step
  36494. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36495. * @returns the internal step
  36496. */
  36497. getInternalStep(): number;
  36498. private _fogEnabled;
  36499. /**
  36500. * Gets or sets a boolean indicating if fog is enabled on this scene
  36501. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36502. * (Default is true)
  36503. */
  36504. set fogEnabled(value: boolean);
  36505. get fogEnabled(): boolean;
  36506. private _fogMode;
  36507. /**
  36508. * Gets or sets the fog mode to use
  36509. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36510. * | mode | value |
  36511. * | --- | --- |
  36512. * | FOGMODE_NONE | 0 |
  36513. * | FOGMODE_EXP | 1 |
  36514. * | FOGMODE_EXP2 | 2 |
  36515. * | FOGMODE_LINEAR | 3 |
  36516. */
  36517. set fogMode(value: number);
  36518. get fogMode(): number;
  36519. /**
  36520. * Gets or sets the fog color to use
  36521. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36522. * (Default is Color3(0.2, 0.2, 0.3))
  36523. */
  36524. fogColor: Color3;
  36525. /**
  36526. * Gets or sets the fog density to use
  36527. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36528. * (Default is 0.1)
  36529. */
  36530. fogDensity: number;
  36531. /**
  36532. * Gets or sets the fog start distance to use
  36533. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36534. * (Default is 0)
  36535. */
  36536. fogStart: number;
  36537. /**
  36538. * Gets or sets the fog end distance to use
  36539. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36540. * (Default is 1000)
  36541. */
  36542. fogEnd: number;
  36543. private _shadowsEnabled;
  36544. /**
  36545. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36546. */
  36547. set shadowsEnabled(value: boolean);
  36548. get shadowsEnabled(): boolean;
  36549. private _lightsEnabled;
  36550. /**
  36551. * Gets or sets a boolean indicating if lights are enabled on this scene
  36552. */
  36553. set lightsEnabled(value: boolean);
  36554. get lightsEnabled(): boolean;
  36555. /** All of the active cameras added to this scene. */
  36556. activeCameras: Camera[];
  36557. /** @hidden */
  36558. _activeCamera: Nullable<Camera>;
  36559. /** Gets or sets the current active camera */
  36560. get activeCamera(): Nullable<Camera>;
  36561. set activeCamera(value: Nullable<Camera>);
  36562. private _defaultMaterial;
  36563. /** The default material used on meshes when no material is affected */
  36564. get defaultMaterial(): Material;
  36565. /** The default material used on meshes when no material is affected */
  36566. set defaultMaterial(value: Material);
  36567. private _texturesEnabled;
  36568. /**
  36569. * Gets or sets a boolean indicating if textures are enabled on this scene
  36570. */
  36571. set texturesEnabled(value: boolean);
  36572. get texturesEnabled(): boolean;
  36573. /**
  36574. * Gets or sets a boolean indicating if particles are enabled on this scene
  36575. */
  36576. particlesEnabled: boolean;
  36577. /**
  36578. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36579. */
  36580. spritesEnabled: boolean;
  36581. private _skeletonsEnabled;
  36582. /**
  36583. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36584. */
  36585. set skeletonsEnabled(value: boolean);
  36586. get skeletonsEnabled(): boolean;
  36587. /**
  36588. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36589. */
  36590. lensFlaresEnabled: boolean;
  36591. /**
  36592. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36594. */
  36595. collisionsEnabled: boolean;
  36596. private _collisionCoordinator;
  36597. /** @hidden */
  36598. get collisionCoordinator(): ICollisionCoordinator;
  36599. /**
  36600. * Defines the gravity applied to this scene (used only for collisions)
  36601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36602. */
  36603. gravity: Vector3;
  36604. /**
  36605. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36606. */
  36607. postProcessesEnabled: boolean;
  36608. /**
  36609. * The list of postprocesses added to the scene
  36610. */
  36611. postProcesses: PostProcess[];
  36612. /**
  36613. * Gets the current postprocess manager
  36614. */
  36615. postProcessManager: PostProcessManager;
  36616. /**
  36617. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36618. */
  36619. renderTargetsEnabled: boolean;
  36620. /**
  36621. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36622. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36623. */
  36624. dumpNextRenderTargets: boolean;
  36625. /**
  36626. * The list of user defined render targets added to the scene
  36627. */
  36628. customRenderTargets: RenderTargetTexture[];
  36629. /**
  36630. * Defines if texture loading must be delayed
  36631. * If true, textures will only be loaded when they need to be rendered
  36632. */
  36633. useDelayedTextureLoading: boolean;
  36634. /**
  36635. * Gets the list of meshes imported to the scene through SceneLoader
  36636. */
  36637. importedMeshesFiles: String[];
  36638. /**
  36639. * Gets or sets a boolean indicating if probes are enabled on this scene
  36640. */
  36641. probesEnabled: boolean;
  36642. /**
  36643. * Gets or sets the current offline provider to use to store scene data
  36644. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36645. */
  36646. offlineProvider: IOfflineProvider;
  36647. /**
  36648. * Gets or sets the action manager associated with the scene
  36649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36650. */
  36651. actionManager: AbstractActionManager;
  36652. private _meshesForIntersections;
  36653. /**
  36654. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36655. */
  36656. proceduralTexturesEnabled: boolean;
  36657. private _engine;
  36658. private _totalVertices;
  36659. /** @hidden */
  36660. _activeIndices: PerfCounter;
  36661. /** @hidden */
  36662. _activeParticles: PerfCounter;
  36663. /** @hidden */
  36664. _activeBones: PerfCounter;
  36665. private _animationRatio;
  36666. /** @hidden */
  36667. _animationTimeLast: number;
  36668. /** @hidden */
  36669. _animationTime: number;
  36670. /**
  36671. * Gets or sets a general scale for animation speed
  36672. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36673. */
  36674. animationTimeScale: number;
  36675. /** @hidden */
  36676. _cachedMaterial: Nullable<Material>;
  36677. /** @hidden */
  36678. _cachedEffect: Nullable<Effect>;
  36679. /** @hidden */
  36680. _cachedVisibility: Nullable<number>;
  36681. private _renderId;
  36682. private _frameId;
  36683. private _executeWhenReadyTimeoutId;
  36684. private _intermediateRendering;
  36685. private _viewUpdateFlag;
  36686. private _projectionUpdateFlag;
  36687. /** @hidden */
  36688. _toBeDisposed: Nullable<IDisposable>[];
  36689. private _activeRequests;
  36690. /** @hidden */
  36691. _pendingData: any[];
  36692. private _isDisposed;
  36693. /**
  36694. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36695. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36696. */
  36697. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36698. private _activeMeshes;
  36699. private _processedMaterials;
  36700. private _renderTargets;
  36701. /** @hidden */
  36702. _activeParticleSystems: SmartArray<IParticleSystem>;
  36703. private _activeSkeletons;
  36704. private _softwareSkinnedMeshes;
  36705. private _renderingManager;
  36706. /** @hidden */
  36707. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36708. private _transformMatrix;
  36709. private _sceneUbo;
  36710. /** @hidden */
  36711. _viewMatrix: Matrix;
  36712. private _projectionMatrix;
  36713. /** @hidden */
  36714. _forcedViewPosition: Nullable<Vector3>;
  36715. /** @hidden */
  36716. _frustumPlanes: Plane[];
  36717. /**
  36718. * Gets the list of frustum planes (built from the active camera)
  36719. */
  36720. get frustumPlanes(): Plane[];
  36721. /**
  36722. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36723. * This is useful if there are more lights that the maximum simulteanous authorized
  36724. */
  36725. requireLightSorting: boolean;
  36726. /** @hidden */
  36727. readonly useMaterialMeshMap: boolean;
  36728. /** @hidden */
  36729. readonly useClonedMeshMap: boolean;
  36730. private _externalData;
  36731. private _uid;
  36732. /**
  36733. * @hidden
  36734. * Backing store of defined scene components.
  36735. */
  36736. _components: ISceneComponent[];
  36737. /**
  36738. * @hidden
  36739. * Backing store of defined scene components.
  36740. */
  36741. _serializableComponents: ISceneSerializableComponent[];
  36742. /**
  36743. * List of components to register on the next registration step.
  36744. */
  36745. private _transientComponents;
  36746. /**
  36747. * Registers the transient components if needed.
  36748. */
  36749. private _registerTransientComponents;
  36750. /**
  36751. * @hidden
  36752. * Add a component to the scene.
  36753. * Note that the ccomponent could be registered on th next frame if this is called after
  36754. * the register component stage.
  36755. * @param component Defines the component to add to the scene
  36756. */
  36757. _addComponent(component: ISceneComponent): void;
  36758. /**
  36759. * @hidden
  36760. * Gets a component from the scene.
  36761. * @param name defines the name of the component to retrieve
  36762. * @returns the component or null if not present
  36763. */
  36764. _getComponent(name: string): Nullable<ISceneComponent>;
  36765. /**
  36766. * @hidden
  36767. * Defines the actions happening before camera updates.
  36768. */
  36769. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36770. /**
  36771. * @hidden
  36772. * Defines the actions happening before clear the canvas.
  36773. */
  36774. _beforeClearStage: Stage<SimpleStageAction>;
  36775. /**
  36776. * @hidden
  36777. * Defines the actions when collecting render targets for the frame.
  36778. */
  36779. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36780. /**
  36781. * @hidden
  36782. * Defines the actions happening for one camera in the frame.
  36783. */
  36784. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36785. /**
  36786. * @hidden
  36787. * Defines the actions happening during the per mesh ready checks.
  36788. */
  36789. _isReadyForMeshStage: Stage<MeshStageAction>;
  36790. /**
  36791. * @hidden
  36792. * Defines the actions happening before evaluate active mesh checks.
  36793. */
  36794. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36795. /**
  36796. * @hidden
  36797. * Defines the actions happening during the evaluate sub mesh checks.
  36798. */
  36799. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36800. /**
  36801. * @hidden
  36802. * Defines the actions happening during the active mesh stage.
  36803. */
  36804. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36805. /**
  36806. * @hidden
  36807. * Defines the actions happening during the per camera render target step.
  36808. */
  36809. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36810. /**
  36811. * @hidden
  36812. * Defines the actions happening just before the active camera is drawing.
  36813. */
  36814. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36815. /**
  36816. * @hidden
  36817. * Defines the actions happening just before a render target is drawing.
  36818. */
  36819. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36820. /**
  36821. * @hidden
  36822. * Defines the actions happening just before a rendering group is drawing.
  36823. */
  36824. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36825. /**
  36826. * @hidden
  36827. * Defines the actions happening just before a mesh is drawing.
  36828. */
  36829. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36830. /**
  36831. * @hidden
  36832. * Defines the actions happening just after a mesh has been drawn.
  36833. */
  36834. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36835. /**
  36836. * @hidden
  36837. * Defines the actions happening just after a rendering group has been drawn.
  36838. */
  36839. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36840. /**
  36841. * @hidden
  36842. * Defines the actions happening just after the active camera has been drawn.
  36843. */
  36844. _afterCameraDrawStage: Stage<CameraStageAction>;
  36845. /**
  36846. * @hidden
  36847. * Defines the actions happening just after a render target has been drawn.
  36848. */
  36849. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36850. /**
  36851. * @hidden
  36852. * Defines the actions happening just after rendering all cameras and computing intersections.
  36853. */
  36854. _afterRenderStage: Stage<SimpleStageAction>;
  36855. /**
  36856. * @hidden
  36857. * Defines the actions happening when a pointer move event happens.
  36858. */
  36859. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36860. /**
  36861. * @hidden
  36862. * Defines the actions happening when a pointer down event happens.
  36863. */
  36864. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36865. /**
  36866. * @hidden
  36867. * Defines the actions happening when a pointer up event happens.
  36868. */
  36869. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36870. /**
  36871. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36872. */
  36873. private geometriesByUniqueId;
  36874. /**
  36875. * Creates a new Scene
  36876. * @param engine defines the engine to use to render this scene
  36877. * @param options defines the scene options
  36878. */
  36879. constructor(engine: Engine, options?: SceneOptions);
  36880. /**
  36881. * Gets a string idenfifying the name of the class
  36882. * @returns "Scene" string
  36883. */
  36884. getClassName(): string;
  36885. private _defaultMeshCandidates;
  36886. /**
  36887. * @hidden
  36888. */
  36889. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36890. private _defaultSubMeshCandidates;
  36891. /**
  36892. * @hidden
  36893. */
  36894. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36895. /**
  36896. * Sets the default candidate providers for the scene.
  36897. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36898. * and getCollidingSubMeshCandidates to their default function
  36899. */
  36900. setDefaultCandidateProviders(): void;
  36901. /**
  36902. * Gets the mesh that is currently under the pointer
  36903. */
  36904. get meshUnderPointer(): Nullable<AbstractMesh>;
  36905. /**
  36906. * Gets or sets the current on-screen X position of the pointer
  36907. */
  36908. get pointerX(): number;
  36909. set pointerX(value: number);
  36910. /**
  36911. * Gets or sets the current on-screen Y position of the pointer
  36912. */
  36913. get pointerY(): number;
  36914. set pointerY(value: number);
  36915. /**
  36916. * Gets the cached material (ie. the latest rendered one)
  36917. * @returns the cached material
  36918. */
  36919. getCachedMaterial(): Nullable<Material>;
  36920. /**
  36921. * Gets the cached effect (ie. the latest rendered one)
  36922. * @returns the cached effect
  36923. */
  36924. getCachedEffect(): Nullable<Effect>;
  36925. /**
  36926. * Gets the cached visibility state (ie. the latest rendered one)
  36927. * @returns the cached visibility state
  36928. */
  36929. getCachedVisibility(): Nullable<number>;
  36930. /**
  36931. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36932. * @param material defines the current material
  36933. * @param effect defines the current effect
  36934. * @param visibility defines the current visibility state
  36935. * @returns true if one parameter is not cached
  36936. */
  36937. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36938. /**
  36939. * Gets the engine associated with the scene
  36940. * @returns an Engine
  36941. */
  36942. getEngine(): Engine;
  36943. /**
  36944. * Gets the total number of vertices rendered per frame
  36945. * @returns the total number of vertices rendered per frame
  36946. */
  36947. getTotalVertices(): number;
  36948. /**
  36949. * Gets the performance counter for total vertices
  36950. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36951. */
  36952. get totalVerticesPerfCounter(): PerfCounter;
  36953. /**
  36954. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36955. * @returns the total number of active indices rendered per frame
  36956. */
  36957. getActiveIndices(): number;
  36958. /**
  36959. * Gets the performance counter for active indices
  36960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36961. */
  36962. get totalActiveIndicesPerfCounter(): PerfCounter;
  36963. /**
  36964. * Gets the total number of active particles rendered per frame
  36965. * @returns the total number of active particles rendered per frame
  36966. */
  36967. getActiveParticles(): number;
  36968. /**
  36969. * Gets the performance counter for active particles
  36970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36971. */
  36972. get activeParticlesPerfCounter(): PerfCounter;
  36973. /**
  36974. * Gets the total number of active bones rendered per frame
  36975. * @returns the total number of active bones rendered per frame
  36976. */
  36977. getActiveBones(): number;
  36978. /**
  36979. * Gets the performance counter for active bones
  36980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36981. */
  36982. get activeBonesPerfCounter(): PerfCounter;
  36983. /**
  36984. * Gets the array of active meshes
  36985. * @returns an array of AbstractMesh
  36986. */
  36987. getActiveMeshes(): SmartArray<AbstractMesh>;
  36988. /**
  36989. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36990. * @returns a number
  36991. */
  36992. getAnimationRatio(): number;
  36993. /**
  36994. * Gets an unique Id for the current render phase
  36995. * @returns a number
  36996. */
  36997. getRenderId(): number;
  36998. /**
  36999. * Gets an unique Id for the current frame
  37000. * @returns a number
  37001. */
  37002. getFrameId(): number;
  37003. /** Call this function if you want to manually increment the render Id*/
  37004. incrementRenderId(): void;
  37005. private _createUbo;
  37006. /**
  37007. * Use this method to simulate a pointer move 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. * @returns the current scene
  37012. */
  37013. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37014. /**
  37015. * Use this method to simulate a pointer down on a mesh
  37016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37019. * @returns the current scene
  37020. */
  37021. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37022. /**
  37023. * Use this method to simulate a pointer up on a mesh
  37024. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37025. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37026. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37027. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37028. * @returns the current scene
  37029. */
  37030. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37031. /**
  37032. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37033. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37034. * @returns true if the pointer was captured
  37035. */
  37036. isPointerCaptured(pointerId?: number): boolean;
  37037. /**
  37038. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37039. * @param attachUp defines if you want to attach events to pointerup
  37040. * @param attachDown defines if you want to attach events to pointerdown
  37041. * @param attachMove defines if you want to attach events to pointermove
  37042. */
  37043. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37044. /** Detaches all event handlers*/
  37045. detachControl(): void;
  37046. /**
  37047. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37048. * Delay loaded resources are not taking in account
  37049. * @return true if all required resources are ready
  37050. */
  37051. isReady(): boolean;
  37052. /** Resets all cached information relative to material (including effect and visibility) */
  37053. resetCachedMaterial(): void;
  37054. /**
  37055. * Registers a function to be called before every frame render
  37056. * @param func defines the function to register
  37057. */
  37058. registerBeforeRender(func: () => void): void;
  37059. /**
  37060. * Unregisters a function called before every frame render
  37061. * @param func defines the function to unregister
  37062. */
  37063. unregisterBeforeRender(func: () => void): void;
  37064. /**
  37065. * Registers a function to be called after every frame render
  37066. * @param func defines the function to register
  37067. */
  37068. registerAfterRender(func: () => void): void;
  37069. /**
  37070. * Unregisters a function called after every frame render
  37071. * @param func defines the function to unregister
  37072. */
  37073. unregisterAfterRender(func: () => void): void;
  37074. private _executeOnceBeforeRender;
  37075. /**
  37076. * The provided function will run before render once and will be disposed afterwards.
  37077. * A timeout delay can be provided so that the function will be executed in N ms.
  37078. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37079. * @param func The function to be executed.
  37080. * @param timeout optional delay in ms
  37081. */
  37082. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37083. /** @hidden */
  37084. _addPendingData(data: any): void;
  37085. /** @hidden */
  37086. _removePendingData(data: any): void;
  37087. /**
  37088. * Returns the number of items waiting to be loaded
  37089. * @returns the number of items waiting to be loaded
  37090. */
  37091. getWaitingItemsCount(): number;
  37092. /**
  37093. * Returns a boolean indicating if the scene is still loading data
  37094. */
  37095. get isLoading(): boolean;
  37096. /**
  37097. * Registers a function to be executed when the scene is ready
  37098. * @param {Function} func - the function to be executed
  37099. */
  37100. executeWhenReady(func: () => void): void;
  37101. /**
  37102. * Returns a promise that resolves when the scene is ready
  37103. * @returns A promise that resolves when the scene is ready
  37104. */
  37105. whenReadyAsync(): Promise<void>;
  37106. /** @hidden */
  37107. _checkIsReady(): void;
  37108. /**
  37109. * Gets all animatable attached to the scene
  37110. */
  37111. get animatables(): Animatable[];
  37112. /**
  37113. * Resets the last animation time frame.
  37114. * Useful to override when animations start running when loading a scene for the first time.
  37115. */
  37116. resetLastAnimationTimeFrame(): void;
  37117. /**
  37118. * Gets the current view matrix
  37119. * @returns a Matrix
  37120. */
  37121. getViewMatrix(): Matrix;
  37122. /**
  37123. * Gets the current projection matrix
  37124. * @returns a Matrix
  37125. */
  37126. getProjectionMatrix(): Matrix;
  37127. /**
  37128. * Gets the current transform matrix
  37129. * @returns a Matrix made of View * Projection
  37130. */
  37131. getTransformMatrix(): Matrix;
  37132. /**
  37133. * Sets the current transform matrix
  37134. * @param viewL defines the View matrix to use
  37135. * @param projectionL defines the Projection matrix to use
  37136. * @param viewR defines the right View matrix to use (if provided)
  37137. * @param projectionR defines the right Projection matrix to use (if provided)
  37138. */
  37139. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37140. /**
  37141. * Gets the uniform buffer used to store scene data
  37142. * @returns a UniformBuffer
  37143. */
  37144. getSceneUniformBuffer(): UniformBuffer;
  37145. /**
  37146. * Gets an unique (relatively to the current scene) Id
  37147. * @returns an unique number for the scene
  37148. */
  37149. getUniqueId(): number;
  37150. /**
  37151. * Add a mesh to the list of scene's meshes
  37152. * @param newMesh defines the mesh to add
  37153. * @param recursive if all child meshes should also be added to the scene
  37154. */
  37155. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37156. /**
  37157. * Remove a mesh for the list of scene's meshes
  37158. * @param toRemove defines the mesh to remove
  37159. * @param recursive if all child meshes should also be removed from the scene
  37160. * @returns the index where the mesh was in the mesh list
  37161. */
  37162. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37163. /**
  37164. * Add a transform node to the list of scene's transform nodes
  37165. * @param newTransformNode defines the transform node to add
  37166. */
  37167. addTransformNode(newTransformNode: TransformNode): void;
  37168. /**
  37169. * Remove a transform node for the list of scene's transform nodes
  37170. * @param toRemove defines the transform node to remove
  37171. * @returns the index where the transform node was in the transform node list
  37172. */
  37173. removeTransformNode(toRemove: TransformNode): number;
  37174. /**
  37175. * Remove a skeleton for the list of scene's skeletons
  37176. * @param toRemove defines the skeleton to remove
  37177. * @returns the index where the skeleton was in the skeleton list
  37178. */
  37179. removeSkeleton(toRemove: Skeleton): number;
  37180. /**
  37181. * Remove a morph target for the list of scene's morph targets
  37182. * @param toRemove defines the morph target to remove
  37183. * @returns the index where the morph target was in the morph target list
  37184. */
  37185. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37186. /**
  37187. * Remove a light for the list of scene's lights
  37188. * @param toRemove defines the light to remove
  37189. * @returns the index where the light was in the light list
  37190. */
  37191. removeLight(toRemove: Light): number;
  37192. /**
  37193. * Remove a camera for the list of scene's cameras
  37194. * @param toRemove defines the camera to remove
  37195. * @returns the index where the camera was in the camera list
  37196. */
  37197. removeCamera(toRemove: Camera): number;
  37198. /**
  37199. * Remove a particle system for the list of scene's particle systems
  37200. * @param toRemove defines the particle system to remove
  37201. * @returns the index where the particle system was in the particle system list
  37202. */
  37203. removeParticleSystem(toRemove: IParticleSystem): number;
  37204. /**
  37205. * Remove a animation for the list of scene's animations
  37206. * @param toRemove defines the animation to remove
  37207. * @returns the index where the animation was in the animation list
  37208. */
  37209. removeAnimation(toRemove: Animation): number;
  37210. /**
  37211. * Will stop the animation of the given target
  37212. * @param target - the target
  37213. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37214. * @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)
  37215. */
  37216. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37217. /**
  37218. * Removes the given animation group from this scene.
  37219. * @param toRemove The animation group to remove
  37220. * @returns The index of the removed animation group
  37221. */
  37222. removeAnimationGroup(toRemove: AnimationGroup): number;
  37223. /**
  37224. * Removes the given multi-material from this scene.
  37225. * @param toRemove The multi-material to remove
  37226. * @returns The index of the removed multi-material
  37227. */
  37228. removeMultiMaterial(toRemove: MultiMaterial): number;
  37229. /**
  37230. * Removes the given material from this scene.
  37231. * @param toRemove The material to remove
  37232. * @returns The index of the removed material
  37233. */
  37234. removeMaterial(toRemove: Material): number;
  37235. /**
  37236. * Removes the given action manager from this scene.
  37237. * @param toRemove The action manager to remove
  37238. * @returns The index of the removed action manager
  37239. */
  37240. removeActionManager(toRemove: AbstractActionManager): number;
  37241. /**
  37242. * Removes the given texture from this scene.
  37243. * @param toRemove The texture to remove
  37244. * @returns The index of the removed texture
  37245. */
  37246. removeTexture(toRemove: BaseTexture): number;
  37247. /**
  37248. * Adds the given light to this scene
  37249. * @param newLight The light to add
  37250. */
  37251. addLight(newLight: Light): void;
  37252. /**
  37253. * Sorts the list list based on light priorities
  37254. */
  37255. sortLightsByPriority(): void;
  37256. /**
  37257. * Adds the given camera to this scene
  37258. * @param newCamera The camera to add
  37259. */
  37260. addCamera(newCamera: Camera): void;
  37261. /**
  37262. * Adds the given skeleton to this scene
  37263. * @param newSkeleton The skeleton to add
  37264. */
  37265. addSkeleton(newSkeleton: Skeleton): void;
  37266. /**
  37267. * Adds the given particle system to this scene
  37268. * @param newParticleSystem The particle system to add
  37269. */
  37270. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37271. /**
  37272. * Adds the given animation to this scene
  37273. * @param newAnimation The animation to add
  37274. */
  37275. addAnimation(newAnimation: Animation): void;
  37276. /**
  37277. * Adds the given animation group to this scene.
  37278. * @param newAnimationGroup The animation group to add
  37279. */
  37280. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37281. /**
  37282. * Adds the given multi-material to this scene
  37283. * @param newMultiMaterial The multi-material to add
  37284. */
  37285. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37286. /**
  37287. * Adds the given material to this scene
  37288. * @param newMaterial The material to add
  37289. */
  37290. addMaterial(newMaterial: Material): void;
  37291. /**
  37292. * Adds the given morph target to this scene
  37293. * @param newMorphTargetManager The morph target to add
  37294. */
  37295. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37296. /**
  37297. * Adds the given geometry to this scene
  37298. * @param newGeometry The geometry to add
  37299. */
  37300. addGeometry(newGeometry: Geometry): void;
  37301. /**
  37302. * Adds the given action manager to this scene
  37303. * @param newActionManager The action manager to add
  37304. */
  37305. addActionManager(newActionManager: AbstractActionManager): void;
  37306. /**
  37307. * Adds the given texture to this scene.
  37308. * @param newTexture The texture to add
  37309. */
  37310. addTexture(newTexture: BaseTexture): void;
  37311. /**
  37312. * Switch active camera
  37313. * @param newCamera defines the new active camera
  37314. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37315. */
  37316. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37317. /**
  37318. * sets the active camera of the scene using its ID
  37319. * @param id defines the camera's ID
  37320. * @return the new active camera or null if none found.
  37321. */
  37322. setActiveCameraByID(id: string): Nullable<Camera>;
  37323. /**
  37324. * sets the active camera of the scene using its name
  37325. * @param name defines the camera's name
  37326. * @returns the new active camera or null if none found.
  37327. */
  37328. setActiveCameraByName(name: string): Nullable<Camera>;
  37329. /**
  37330. * get an animation group using its name
  37331. * @param name defines the material's name
  37332. * @return the animation group or null if none found.
  37333. */
  37334. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37335. /**
  37336. * Get a material using its unique id
  37337. * @param uniqueId defines the material's unique id
  37338. * @return the material or null if none found.
  37339. */
  37340. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37341. /**
  37342. * get a material using its id
  37343. * @param id defines the material's ID
  37344. * @return the material or null if none found.
  37345. */
  37346. getMaterialByID(id: string): Nullable<Material>;
  37347. /**
  37348. * Gets a the last added material using a given id
  37349. * @param id defines the material's ID
  37350. * @return the last material with the given id or null if none found.
  37351. */
  37352. getLastMaterialByID(id: string): Nullable<Material>;
  37353. /**
  37354. * Gets a material using its name
  37355. * @param name defines the material's name
  37356. * @return the material or null if none found.
  37357. */
  37358. getMaterialByName(name: string): Nullable<Material>;
  37359. /**
  37360. * Get a texture using its unique id
  37361. * @param uniqueId defines the texture's unique id
  37362. * @return the texture or null if none found.
  37363. */
  37364. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37365. /**
  37366. * Gets a camera using its id
  37367. * @param id defines the id to look for
  37368. * @returns the camera or null if not found
  37369. */
  37370. getCameraByID(id: string): Nullable<Camera>;
  37371. /**
  37372. * Gets a camera using its unique id
  37373. * @param uniqueId defines the unique id to look for
  37374. * @returns the camera or null if not found
  37375. */
  37376. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37377. /**
  37378. * Gets a camera using its name
  37379. * @param name defines the camera's name
  37380. * @return the camera or null if none found.
  37381. */
  37382. getCameraByName(name: string): Nullable<Camera>;
  37383. /**
  37384. * Gets a bone using its id
  37385. * @param id defines the bone's id
  37386. * @return the bone or null if not found
  37387. */
  37388. getBoneByID(id: string): Nullable<Bone>;
  37389. /**
  37390. * Gets a bone using its id
  37391. * @param name defines the bone's name
  37392. * @return the bone or null if not found
  37393. */
  37394. getBoneByName(name: string): Nullable<Bone>;
  37395. /**
  37396. * Gets a light node using its name
  37397. * @param name defines the the light's name
  37398. * @return the light or null if none found.
  37399. */
  37400. getLightByName(name: string): Nullable<Light>;
  37401. /**
  37402. * Gets a light node using its id
  37403. * @param id defines the light's id
  37404. * @return the light or null if none found.
  37405. */
  37406. getLightByID(id: string): Nullable<Light>;
  37407. /**
  37408. * Gets a light node using its scene-generated unique ID
  37409. * @param uniqueId defines the light's unique id
  37410. * @return the light or null if none found.
  37411. */
  37412. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37413. /**
  37414. * Gets a particle system by id
  37415. * @param id defines the particle system id
  37416. * @return the corresponding system or null if none found
  37417. */
  37418. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37419. /**
  37420. * Gets a geometry using its ID
  37421. * @param id defines the geometry's id
  37422. * @return the geometry or null if none found.
  37423. */
  37424. getGeometryByID(id: string): Nullable<Geometry>;
  37425. private _getGeometryByUniqueID;
  37426. /**
  37427. * Add a new geometry to this scene
  37428. * @param geometry defines the geometry to be added to the scene.
  37429. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37430. * @return a boolean defining if the geometry was added or not
  37431. */
  37432. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37433. /**
  37434. * Removes an existing geometry
  37435. * @param geometry defines the geometry to be removed from the scene
  37436. * @return a boolean defining if the geometry was removed or not
  37437. */
  37438. removeGeometry(geometry: Geometry): boolean;
  37439. /**
  37440. * Gets the list of geometries attached to the scene
  37441. * @returns an array of Geometry
  37442. */
  37443. getGeometries(): Geometry[];
  37444. /**
  37445. * Gets the first added mesh found of a given ID
  37446. * @param id defines the id to search for
  37447. * @return the mesh found or null if not found at all
  37448. */
  37449. getMeshByID(id: string): Nullable<AbstractMesh>;
  37450. /**
  37451. * Gets a list of meshes using their id
  37452. * @param id defines the id to search for
  37453. * @returns a list of meshes
  37454. */
  37455. getMeshesByID(id: string): Array<AbstractMesh>;
  37456. /**
  37457. * Gets the first added transform node found of a given ID
  37458. * @param id defines the id to search for
  37459. * @return the found transform node or null if not found at all.
  37460. */
  37461. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37462. /**
  37463. * Gets a transform node with its auto-generated unique id
  37464. * @param uniqueId efines the unique id to search for
  37465. * @return the found transform node or null if not found at all.
  37466. */
  37467. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37468. /**
  37469. * Gets a list of transform nodes using their id
  37470. * @param id defines the id to search for
  37471. * @returns a list of transform nodes
  37472. */
  37473. getTransformNodesByID(id: string): Array<TransformNode>;
  37474. /**
  37475. * Gets a mesh with its auto-generated unique id
  37476. * @param uniqueId defines the unique id to search for
  37477. * @return the found mesh or null if not found at all.
  37478. */
  37479. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37480. /**
  37481. * Gets a the last added mesh using a given id
  37482. * @param id defines the id to search for
  37483. * @return the found mesh or null if not found at all.
  37484. */
  37485. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37486. /**
  37487. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37488. * @param id defines the id to search for
  37489. * @return the found node or null if not found at all
  37490. */
  37491. getLastEntryByID(id: string): Nullable<Node>;
  37492. /**
  37493. * Gets a node (Mesh, Camera, Light) using a given id
  37494. * @param id defines the id to search for
  37495. * @return the found node or null if not found at all
  37496. */
  37497. getNodeByID(id: string): Nullable<Node>;
  37498. /**
  37499. * Gets a node (Mesh, Camera, Light) using a given name
  37500. * @param name defines the name to search for
  37501. * @return the found node or null if not found at all.
  37502. */
  37503. getNodeByName(name: string): Nullable<Node>;
  37504. /**
  37505. * Gets a mesh using a given name
  37506. * @param name defines the name to search for
  37507. * @return the found mesh or null if not found at all.
  37508. */
  37509. getMeshByName(name: string): Nullable<AbstractMesh>;
  37510. /**
  37511. * Gets a transform node using a given name
  37512. * @param name defines the name to search for
  37513. * @return the found transform node or null if not found at all.
  37514. */
  37515. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37516. /**
  37517. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37518. * @param id defines the id to search for
  37519. * @return the found skeleton or null if not found at all.
  37520. */
  37521. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37522. /**
  37523. * Gets a skeleton using a given auto generated unique id
  37524. * @param uniqueId defines the unique id to search for
  37525. * @return the found skeleton or null if not found at all.
  37526. */
  37527. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37528. /**
  37529. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37530. * @param id defines the id to search for
  37531. * @return the found skeleton or null if not found at all.
  37532. */
  37533. getSkeletonById(id: string): Nullable<Skeleton>;
  37534. /**
  37535. * Gets a skeleton using a given name
  37536. * @param name defines the name to search for
  37537. * @return the found skeleton or null if not found at all.
  37538. */
  37539. getSkeletonByName(name: string): Nullable<Skeleton>;
  37540. /**
  37541. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37542. * @param id defines the id to search for
  37543. * @return the found morph target manager or null if not found at all.
  37544. */
  37545. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37546. /**
  37547. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37548. * @param id defines the id to search for
  37549. * @return the found morph target or null if not found at all.
  37550. */
  37551. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37552. /**
  37553. * Gets a boolean indicating if the given mesh is active
  37554. * @param mesh defines the mesh to look for
  37555. * @returns true if the mesh is in the active list
  37556. */
  37557. isActiveMesh(mesh: AbstractMesh): boolean;
  37558. /**
  37559. * Return a unique id as a string which can serve as an identifier for the scene
  37560. */
  37561. get uid(): string;
  37562. /**
  37563. * Add an externaly attached data from its key.
  37564. * This method call will fail and return false, if such key already exists.
  37565. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37566. * @param key the unique key that identifies the data
  37567. * @param data the data object to associate to the key for this Engine instance
  37568. * @return true if no such key were already present and the data was added successfully, false otherwise
  37569. */
  37570. addExternalData<T>(key: string, data: T): boolean;
  37571. /**
  37572. * Get an externaly attached data from its key
  37573. * @param key the unique key that identifies the data
  37574. * @return the associated data, if present (can be null), or undefined if not present
  37575. */
  37576. getExternalData<T>(key: string): Nullable<T>;
  37577. /**
  37578. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37579. * @param key the unique key that identifies the data
  37580. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37581. * @return the associated data, can be null if the factory returned null.
  37582. */
  37583. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37584. /**
  37585. * Remove an externaly attached data from the Engine instance
  37586. * @param key the unique key that identifies the data
  37587. * @return true if the data was successfully removed, false if it doesn't exist
  37588. */
  37589. removeExternalData(key: string): boolean;
  37590. private _evaluateSubMesh;
  37591. /**
  37592. * Clear the processed materials smart array preventing retention point in material dispose.
  37593. */
  37594. freeProcessedMaterials(): void;
  37595. private _preventFreeActiveMeshesAndRenderingGroups;
  37596. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37597. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37598. * when disposing several meshes in a row or a hierarchy of meshes.
  37599. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37600. */
  37601. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37602. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37603. /**
  37604. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37605. */
  37606. freeActiveMeshes(): void;
  37607. /**
  37608. * Clear the info related to rendering groups preventing retention points during dispose.
  37609. */
  37610. freeRenderingGroups(): void;
  37611. /** @hidden */
  37612. _isInIntermediateRendering(): boolean;
  37613. /**
  37614. * Lambda returning the list of potentially active meshes.
  37615. */
  37616. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37617. /**
  37618. * Lambda returning the list of potentially active sub meshes.
  37619. */
  37620. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37621. /**
  37622. * Lambda returning the list of potentially intersecting sub meshes.
  37623. */
  37624. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37625. /**
  37626. * Lambda returning the list of potentially colliding sub meshes.
  37627. */
  37628. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37629. private _activeMeshesFrozen;
  37630. private _skipEvaluateActiveMeshesCompletely;
  37631. /**
  37632. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37633. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37634. * @returns the current scene
  37635. */
  37636. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37637. /**
  37638. * Use this function to restart evaluating active meshes on every frame
  37639. * @returns the current scene
  37640. */
  37641. unfreezeActiveMeshes(): Scene;
  37642. private _evaluateActiveMeshes;
  37643. private _activeMesh;
  37644. /**
  37645. * Update the transform matrix to update from the current active camera
  37646. * @param force defines a boolean used to force the update even if cache is up to date
  37647. */
  37648. updateTransformMatrix(force?: boolean): void;
  37649. private _bindFrameBuffer;
  37650. /** @hidden */
  37651. _allowPostProcessClearColor: boolean;
  37652. /** @hidden */
  37653. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37654. private _processSubCameras;
  37655. private _checkIntersections;
  37656. /** @hidden */
  37657. _advancePhysicsEngineStep(step: number): void;
  37658. /**
  37659. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37660. */
  37661. getDeterministicFrameTime: () => number;
  37662. /** @hidden */
  37663. _animate(): void;
  37664. /** Execute all animations (for a frame) */
  37665. animate(): void;
  37666. /**
  37667. * Render the scene
  37668. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37669. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37670. */
  37671. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37672. /**
  37673. * Freeze all materials
  37674. * A frozen material will not be updatable but should be faster to render
  37675. */
  37676. freezeMaterials(): void;
  37677. /**
  37678. * Unfreeze all materials
  37679. * A frozen material will not be updatable but should be faster to render
  37680. */
  37681. unfreezeMaterials(): void;
  37682. /**
  37683. * Releases all held ressources
  37684. */
  37685. dispose(): void;
  37686. /**
  37687. * Gets if the scene is already disposed
  37688. */
  37689. get isDisposed(): boolean;
  37690. /**
  37691. * Call this function to reduce memory footprint of the scene.
  37692. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37693. */
  37694. clearCachedVertexData(): void;
  37695. /**
  37696. * This function will remove the local cached buffer data from texture.
  37697. * It will save memory but will prevent the texture from being rebuilt
  37698. */
  37699. cleanCachedTextureBuffer(): void;
  37700. /**
  37701. * Get the world extend vectors with an optional filter
  37702. *
  37703. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37704. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37705. */
  37706. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37707. min: Vector3;
  37708. max: Vector3;
  37709. };
  37710. /**
  37711. * Creates a ray that can be used to pick in the scene
  37712. * @param x defines the x coordinate of the origin (on-screen)
  37713. * @param y defines the y coordinate of the origin (on-screen)
  37714. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37715. * @param camera defines the camera to use for the picking
  37716. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37717. * @returns a Ray
  37718. */
  37719. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37720. /**
  37721. * Creates a ray that can be used to pick in the scene
  37722. * @param x defines the x coordinate of the origin (on-screen)
  37723. * @param y defines the y coordinate of the origin (on-screen)
  37724. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37725. * @param result defines the ray where to store the picking ray
  37726. * @param camera defines the camera to use for the picking
  37727. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37728. * @returns the current scene
  37729. */
  37730. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37731. /**
  37732. * Creates a ray that can be used to pick in the scene
  37733. * @param x defines the x coordinate of the origin (on-screen)
  37734. * @param y defines the y coordinate of the origin (on-screen)
  37735. * @param camera defines the camera to use for the picking
  37736. * @returns a Ray
  37737. */
  37738. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37739. /**
  37740. * Creates a ray that can be used to pick in the scene
  37741. * @param x defines the x coordinate of the origin (on-screen)
  37742. * @param y defines the y coordinate of the origin (on-screen)
  37743. * @param result defines the ray where to store the picking ray
  37744. * @param camera defines the camera to use for the picking
  37745. * @returns the current scene
  37746. */
  37747. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37748. /** Launch a ray to try to pick a mesh in the scene
  37749. * @param x position on screen
  37750. * @param y position on screen
  37751. * @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
  37752. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37753. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37754. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37755. * @returns a PickingInfo
  37756. */
  37757. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37758. /** Use the given ray to pick a mesh in the scene
  37759. * @param ray The ray to use to pick meshes
  37760. * @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
  37761. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37762. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37763. * @returns a PickingInfo
  37764. */
  37765. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37766. /**
  37767. * Launch a ray to try to pick a mesh in the scene
  37768. * @param x X position on screen
  37769. * @param y Y position on screen
  37770. * @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
  37771. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37772. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37773. * @returns an array of PickingInfo
  37774. */
  37775. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37776. /**
  37777. * Launch a ray to try to pick a mesh in the scene
  37778. * @param ray Ray to use
  37779. * @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
  37780. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37781. * @returns an array of PickingInfo
  37782. */
  37783. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37784. /**
  37785. * Force the value of meshUnderPointer
  37786. * @param mesh defines the mesh to use
  37787. */
  37788. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37789. /**
  37790. * Gets the mesh under the pointer
  37791. * @returns a Mesh or null if no mesh is under the pointer
  37792. */
  37793. getPointerOverMesh(): Nullable<AbstractMesh>;
  37794. /** @hidden */
  37795. _rebuildGeometries(): void;
  37796. /** @hidden */
  37797. _rebuildTextures(): void;
  37798. private _getByTags;
  37799. /**
  37800. * Get a list of meshes by tags
  37801. * @param tagsQuery defines the tags query to use
  37802. * @param forEach defines a predicate used to filter results
  37803. * @returns an array of Mesh
  37804. */
  37805. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37806. /**
  37807. * Get a list of cameras by tags
  37808. * @param tagsQuery defines the tags query to use
  37809. * @param forEach defines a predicate used to filter results
  37810. * @returns an array of Camera
  37811. */
  37812. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37813. /**
  37814. * Get a list of lights by tags
  37815. * @param tagsQuery defines the tags query to use
  37816. * @param forEach defines a predicate used to filter results
  37817. * @returns an array of Light
  37818. */
  37819. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37820. /**
  37821. * Get a list of materials by tags
  37822. * @param tagsQuery defines the tags query to use
  37823. * @param forEach defines a predicate used to filter results
  37824. * @returns an array of Material
  37825. */
  37826. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37827. /**
  37828. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37829. * This allowed control for front to back rendering or reversly depending of the special needs.
  37830. *
  37831. * @param renderingGroupId The rendering group id corresponding to its index
  37832. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37833. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37834. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37835. */
  37836. 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;
  37837. /**
  37838. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37839. *
  37840. * @param renderingGroupId The rendering group id corresponding to its index
  37841. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37842. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37843. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37844. */
  37845. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37846. /**
  37847. * Gets the current auto clear configuration for one rendering group of the rendering
  37848. * manager.
  37849. * @param index the rendering group index to get the information for
  37850. * @returns The auto clear setup for the requested rendering group
  37851. */
  37852. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37853. private _blockMaterialDirtyMechanism;
  37854. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37855. get blockMaterialDirtyMechanism(): boolean;
  37856. set blockMaterialDirtyMechanism(value: boolean);
  37857. /**
  37858. * Will flag all materials as dirty to trigger new shader compilation
  37859. * @param flag defines the flag used to specify which material part must be marked as dirty
  37860. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37861. */
  37862. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37863. /** @hidden */
  37864. _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;
  37865. /** @hidden */
  37866. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37867. /** @hidden */
  37868. _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;
  37869. /** @hidden */
  37870. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37871. /** @hidden */
  37872. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37873. /** @hidden */
  37874. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37875. }
  37876. }
  37877. declare module "babylonjs/assetContainer" {
  37878. import { AbstractScene } from "babylonjs/abstractScene";
  37879. import { Scene } from "babylonjs/scene";
  37880. import { Mesh } from "babylonjs/Meshes/mesh";
  37881. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37882. import { Skeleton } from "babylonjs/Bones/skeleton";
  37883. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37884. import { Animatable } from "babylonjs/Animations/animatable";
  37885. import { Nullable } from "babylonjs/types";
  37886. import { Node } from "babylonjs/node";
  37887. /**
  37888. * Set of assets to keep when moving a scene into an asset container.
  37889. */
  37890. export class KeepAssets extends AbstractScene {
  37891. }
  37892. /**
  37893. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37894. */
  37895. export class InstantiatedEntries {
  37896. /**
  37897. * List of new root nodes (eg. nodes with no parent)
  37898. */
  37899. rootNodes: TransformNode[];
  37900. /**
  37901. * List of new skeletons
  37902. */
  37903. skeletons: Skeleton[];
  37904. /**
  37905. * List of new animation groups
  37906. */
  37907. animationGroups: AnimationGroup[];
  37908. }
  37909. /**
  37910. * Container with a set of assets that can be added or removed from a scene.
  37911. */
  37912. export class AssetContainer extends AbstractScene {
  37913. /**
  37914. * The scene the AssetContainer belongs to.
  37915. */
  37916. scene: Scene;
  37917. /**
  37918. * Instantiates an AssetContainer.
  37919. * @param scene The scene the AssetContainer belongs to.
  37920. */
  37921. constructor(scene: Scene);
  37922. /**
  37923. * Instantiate or clone all meshes and add the new ones to the scene.
  37924. * Skeletons and animation groups will all be cloned
  37925. * @param nameFunction defines an optional function used to get new names for clones
  37926. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37927. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37928. */
  37929. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37930. /**
  37931. * Adds all the assets from the container to the scene.
  37932. */
  37933. addAllToScene(): void;
  37934. /**
  37935. * Removes all the assets in the container from the scene
  37936. */
  37937. removeAllFromScene(): void;
  37938. /**
  37939. * Disposes all the assets in the container
  37940. */
  37941. dispose(): void;
  37942. private _moveAssets;
  37943. /**
  37944. * Removes all the assets contained in the scene and adds them to the container.
  37945. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37946. */
  37947. moveAllFromScene(keepAssets?: KeepAssets): void;
  37948. /**
  37949. * 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.
  37950. * @returns the root mesh
  37951. */
  37952. createRootMesh(): Mesh;
  37953. /**
  37954. * Merge animations from this asset container into a scene
  37955. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37956. * @param animatables set of animatables to retarget to a node from the scene
  37957. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37958. */
  37959. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37960. }
  37961. }
  37962. declare module "babylonjs/abstractScene" {
  37963. import { Scene } from "babylonjs/scene";
  37964. import { Nullable } from "babylonjs/types";
  37965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37966. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37967. import { Geometry } from "babylonjs/Meshes/geometry";
  37968. import { Skeleton } from "babylonjs/Bones/skeleton";
  37969. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37970. import { AssetContainer } from "babylonjs/assetContainer";
  37971. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37972. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37974. import { Material } from "babylonjs/Materials/material";
  37975. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37976. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37977. import { Camera } from "babylonjs/Cameras/camera";
  37978. import { Light } from "babylonjs/Lights/light";
  37979. import { Node } from "babylonjs/node";
  37980. import { Animation } from "babylonjs/Animations/animation";
  37981. /**
  37982. * Defines how the parser contract is defined.
  37983. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37984. */
  37985. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37986. /**
  37987. * Defines how the individual parser contract is defined.
  37988. * These parser can parse an individual asset
  37989. */
  37990. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37991. /**
  37992. * Base class of the scene acting as a container for the different elements composing a scene.
  37993. * This class is dynamically extended by the different components of the scene increasing
  37994. * flexibility and reducing coupling
  37995. */
  37996. export abstract class AbstractScene {
  37997. /**
  37998. * Stores the list of available parsers in the application.
  37999. */
  38000. private static _BabylonFileParsers;
  38001. /**
  38002. * Stores the list of available individual parsers in the application.
  38003. */
  38004. private static _IndividualBabylonFileParsers;
  38005. /**
  38006. * Adds a parser in the list of available ones
  38007. * @param name Defines the name of the parser
  38008. * @param parser Defines the parser to add
  38009. */
  38010. static AddParser(name: string, parser: BabylonFileParser): void;
  38011. /**
  38012. * Gets a general parser from the list of avaialble ones
  38013. * @param name Defines the name of the parser
  38014. * @returns the requested parser or null
  38015. */
  38016. static GetParser(name: string): Nullable<BabylonFileParser>;
  38017. /**
  38018. * Adds n individual parser in the list of available ones
  38019. * @param name Defines the name of the parser
  38020. * @param parser Defines the parser to add
  38021. */
  38022. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38023. /**
  38024. * Gets an individual parser from the list of avaialble ones
  38025. * @param name Defines the name of the parser
  38026. * @returns the requested parser or null
  38027. */
  38028. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38029. /**
  38030. * Parser json data and populate both a scene and its associated container object
  38031. * @param jsonData Defines the data to parse
  38032. * @param scene Defines the scene to parse the data for
  38033. * @param container Defines the container attached to the parsing sequence
  38034. * @param rootUrl Defines the root url of the data
  38035. */
  38036. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38037. /**
  38038. * Gets the list of root nodes (ie. nodes with no parent)
  38039. */
  38040. rootNodes: Node[];
  38041. /** All of the cameras added to this scene
  38042. * @see http://doc.babylonjs.com/babylon101/cameras
  38043. */
  38044. cameras: Camera[];
  38045. /**
  38046. * All of the lights added to this scene
  38047. * @see http://doc.babylonjs.com/babylon101/lights
  38048. */
  38049. lights: Light[];
  38050. /**
  38051. * All of the (abstract) meshes added to this scene
  38052. */
  38053. meshes: AbstractMesh[];
  38054. /**
  38055. * The list of skeletons added to the scene
  38056. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38057. */
  38058. skeletons: Skeleton[];
  38059. /**
  38060. * All of the particle systems added to this scene
  38061. * @see http://doc.babylonjs.com/babylon101/particles
  38062. */
  38063. particleSystems: IParticleSystem[];
  38064. /**
  38065. * Gets a list of Animations associated with the scene
  38066. */
  38067. animations: Animation[];
  38068. /**
  38069. * All of the animation groups added to this scene
  38070. * @see http://doc.babylonjs.com/how_to/group
  38071. */
  38072. animationGroups: AnimationGroup[];
  38073. /**
  38074. * All of the multi-materials added to this scene
  38075. * @see http://doc.babylonjs.com/how_to/multi_materials
  38076. */
  38077. multiMaterials: MultiMaterial[];
  38078. /**
  38079. * All of the materials added to this scene
  38080. * In the context of a Scene, it is not supposed to be modified manually.
  38081. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38082. * Note also that the order of the Material within the array is not significant and might change.
  38083. * @see http://doc.babylonjs.com/babylon101/materials
  38084. */
  38085. materials: Material[];
  38086. /**
  38087. * The list of morph target managers added to the scene
  38088. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38089. */
  38090. morphTargetManagers: MorphTargetManager[];
  38091. /**
  38092. * The list of geometries used in the scene.
  38093. */
  38094. geometries: Geometry[];
  38095. /**
  38096. * All of the tranform nodes added to this scene
  38097. * In the context of a Scene, it is not supposed to be modified manually.
  38098. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38099. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38100. * @see http://doc.babylonjs.com/how_to/transformnode
  38101. */
  38102. transformNodes: TransformNode[];
  38103. /**
  38104. * ActionManagers available on the scene.
  38105. */
  38106. actionManagers: AbstractActionManager[];
  38107. /**
  38108. * Textures to keep.
  38109. */
  38110. textures: BaseTexture[];
  38111. /**
  38112. * Environment texture for the scene
  38113. */
  38114. environmentTexture: Nullable<BaseTexture>;
  38115. /**
  38116. * @returns all meshes, lights, cameras, transformNodes and bones
  38117. */
  38118. getNodes(): Array<Node>;
  38119. }
  38120. }
  38121. declare module "babylonjs/Audio/sound" {
  38122. import { Observable } from "babylonjs/Misc/observable";
  38123. import { Vector3 } from "babylonjs/Maths/math.vector";
  38124. import { Nullable } from "babylonjs/types";
  38125. import { Scene } from "babylonjs/scene";
  38126. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38127. /**
  38128. * Interface used to define options for Sound class
  38129. */
  38130. export interface ISoundOptions {
  38131. /**
  38132. * Does the sound autoplay once loaded.
  38133. */
  38134. autoplay?: boolean;
  38135. /**
  38136. * Does the sound loop after it finishes playing once.
  38137. */
  38138. loop?: boolean;
  38139. /**
  38140. * Sound's volume
  38141. */
  38142. volume?: number;
  38143. /**
  38144. * Is it a spatial sound?
  38145. */
  38146. spatialSound?: boolean;
  38147. /**
  38148. * Maximum distance to hear that sound
  38149. */
  38150. maxDistance?: number;
  38151. /**
  38152. * Uses user defined attenuation function
  38153. */
  38154. useCustomAttenuation?: boolean;
  38155. /**
  38156. * Define the roll off factor of spatial sounds.
  38157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38158. */
  38159. rolloffFactor?: number;
  38160. /**
  38161. * Define the reference distance the sound should be heard perfectly.
  38162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38163. */
  38164. refDistance?: number;
  38165. /**
  38166. * Define the distance attenuation model the sound will follow.
  38167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38168. */
  38169. distanceModel?: string;
  38170. /**
  38171. * Defines the playback speed (1 by default)
  38172. */
  38173. playbackRate?: number;
  38174. /**
  38175. * Defines if the sound is from a streaming source
  38176. */
  38177. streaming?: boolean;
  38178. /**
  38179. * Defines an optional length (in seconds) inside the sound file
  38180. */
  38181. length?: number;
  38182. /**
  38183. * Defines an optional offset (in seconds) inside the sound file
  38184. */
  38185. offset?: number;
  38186. /**
  38187. * If true, URLs will not be required to state the audio file codec to use.
  38188. */
  38189. skipCodecCheck?: boolean;
  38190. }
  38191. /**
  38192. * Defines a sound that can be played in the application.
  38193. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38195. */
  38196. export class Sound {
  38197. /**
  38198. * The name of the sound in the scene.
  38199. */
  38200. name: string;
  38201. /**
  38202. * Does the sound autoplay once loaded.
  38203. */
  38204. autoplay: boolean;
  38205. /**
  38206. * Does the sound loop after it finishes playing once.
  38207. */
  38208. loop: boolean;
  38209. /**
  38210. * Does the sound use a custom attenuation curve to simulate the falloff
  38211. * happening when the source gets further away from the camera.
  38212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38213. */
  38214. useCustomAttenuation: boolean;
  38215. /**
  38216. * The sound track id this sound belongs to.
  38217. */
  38218. soundTrackId: number;
  38219. /**
  38220. * Is this sound currently played.
  38221. */
  38222. isPlaying: boolean;
  38223. /**
  38224. * Is this sound currently paused.
  38225. */
  38226. isPaused: boolean;
  38227. /**
  38228. * Does this sound enables spatial sound.
  38229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38230. */
  38231. spatialSound: boolean;
  38232. /**
  38233. * Define the reference distance the sound should be heard perfectly.
  38234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38235. */
  38236. refDistance: number;
  38237. /**
  38238. * Define the roll off factor of spatial sounds.
  38239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38240. */
  38241. rolloffFactor: number;
  38242. /**
  38243. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38245. */
  38246. maxDistance: number;
  38247. /**
  38248. * Define the distance attenuation model the sound will follow.
  38249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38250. */
  38251. distanceModel: string;
  38252. /**
  38253. * @hidden
  38254. * Back Compat
  38255. **/
  38256. onended: () => any;
  38257. /**
  38258. * Observable event when the current playing sound finishes.
  38259. */
  38260. onEndedObservable: Observable<Sound>;
  38261. private _panningModel;
  38262. private _playbackRate;
  38263. private _streaming;
  38264. private _startTime;
  38265. private _startOffset;
  38266. private _position;
  38267. /** @hidden */
  38268. _positionInEmitterSpace: boolean;
  38269. private _localDirection;
  38270. private _volume;
  38271. private _isReadyToPlay;
  38272. private _isDirectional;
  38273. private _readyToPlayCallback;
  38274. private _audioBuffer;
  38275. private _soundSource;
  38276. private _streamingSource;
  38277. private _soundPanner;
  38278. private _soundGain;
  38279. private _inputAudioNode;
  38280. private _outputAudioNode;
  38281. private _coneInnerAngle;
  38282. private _coneOuterAngle;
  38283. private _coneOuterGain;
  38284. private _scene;
  38285. private _connectedTransformNode;
  38286. private _customAttenuationFunction;
  38287. private _registerFunc;
  38288. private _isOutputConnected;
  38289. private _htmlAudioElement;
  38290. private _urlType;
  38291. private _length?;
  38292. private _offset?;
  38293. /** @hidden */
  38294. static _SceneComponentInitialization: (scene: Scene) => void;
  38295. /**
  38296. * Create a sound and attach it to a scene
  38297. * @param name Name of your sound
  38298. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38299. * @param scene defines the scene the sound belongs to
  38300. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38301. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38302. */
  38303. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38304. /**
  38305. * Release the sound and its associated resources
  38306. */
  38307. dispose(): void;
  38308. /**
  38309. * Gets if the sounds is ready to be played or not.
  38310. * @returns true if ready, otherwise false
  38311. */
  38312. isReady(): boolean;
  38313. private _soundLoaded;
  38314. /**
  38315. * Sets the data of the sound from an audiobuffer
  38316. * @param audioBuffer The audioBuffer containing the data
  38317. */
  38318. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38319. /**
  38320. * Updates the current sounds options such as maxdistance, loop...
  38321. * @param options A JSON object containing values named as the object properties
  38322. */
  38323. updateOptions(options: ISoundOptions): void;
  38324. private _createSpatialParameters;
  38325. private _updateSpatialParameters;
  38326. /**
  38327. * Switch the panning model to HRTF:
  38328. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38330. */
  38331. switchPanningModelToHRTF(): void;
  38332. /**
  38333. * Switch the panning model to Equal Power:
  38334. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38336. */
  38337. switchPanningModelToEqualPower(): void;
  38338. private _switchPanningModel;
  38339. /**
  38340. * Connect this sound to a sound track audio node like gain...
  38341. * @param soundTrackAudioNode the sound track audio node to connect to
  38342. */
  38343. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38344. /**
  38345. * Transform this sound into a directional source
  38346. * @param coneInnerAngle Size of the inner cone in degree
  38347. * @param coneOuterAngle Size of the outer cone in degree
  38348. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38349. */
  38350. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38351. /**
  38352. * Gets or sets the inner angle for the directional cone.
  38353. */
  38354. get directionalConeInnerAngle(): number;
  38355. /**
  38356. * Gets or sets the inner angle for the directional cone.
  38357. */
  38358. set directionalConeInnerAngle(value: number);
  38359. /**
  38360. * Gets or sets the outer angle for the directional cone.
  38361. */
  38362. get directionalConeOuterAngle(): number;
  38363. /**
  38364. * Gets or sets the outer angle for the directional cone.
  38365. */
  38366. set directionalConeOuterAngle(value: number);
  38367. /**
  38368. * Sets the position of the emitter if spatial sound is enabled
  38369. * @param newPosition Defines the new posisiton
  38370. */
  38371. setPosition(newPosition: Vector3): void;
  38372. /**
  38373. * Sets the local direction of the emitter if spatial sound is enabled
  38374. * @param newLocalDirection Defines the new local direction
  38375. */
  38376. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38377. private _updateDirection;
  38378. /** @hidden */
  38379. updateDistanceFromListener(): void;
  38380. /**
  38381. * Sets a new custom attenuation function for the sound.
  38382. * @param callback Defines the function used for the attenuation
  38383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38384. */
  38385. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38386. /**
  38387. * Play the sound
  38388. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38389. * @param offset (optional) Start the sound at a specific time in seconds
  38390. * @param length (optional) Sound duration (in seconds)
  38391. */
  38392. play(time?: number, offset?: number, length?: number): void;
  38393. private _onended;
  38394. /**
  38395. * Stop the sound
  38396. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38397. */
  38398. stop(time?: number): void;
  38399. /**
  38400. * Put the sound in pause
  38401. */
  38402. pause(): void;
  38403. /**
  38404. * Sets a dedicated volume for this sounds
  38405. * @param newVolume Define the new volume of the sound
  38406. * @param time Define time for gradual change to new volume
  38407. */
  38408. setVolume(newVolume: number, time?: number): void;
  38409. /**
  38410. * Set the sound play back rate
  38411. * @param newPlaybackRate Define the playback rate the sound should be played at
  38412. */
  38413. setPlaybackRate(newPlaybackRate: number): void;
  38414. /**
  38415. * Gets the volume of the sound.
  38416. * @returns the volume of the sound
  38417. */
  38418. getVolume(): number;
  38419. /**
  38420. * Attach the sound to a dedicated mesh
  38421. * @param transformNode The transform node to connect the sound with
  38422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38423. */
  38424. attachToMesh(transformNode: TransformNode): void;
  38425. /**
  38426. * Detach the sound from the previously attached mesh
  38427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38428. */
  38429. detachFromMesh(): void;
  38430. private _onRegisterAfterWorldMatrixUpdate;
  38431. /**
  38432. * Clone the current sound in the scene.
  38433. * @returns the new sound clone
  38434. */
  38435. clone(): Nullable<Sound>;
  38436. /**
  38437. * Gets the current underlying audio buffer containing the data
  38438. * @returns the audio buffer
  38439. */
  38440. getAudioBuffer(): Nullable<AudioBuffer>;
  38441. /**
  38442. * Serializes the Sound in a JSON representation
  38443. * @returns the JSON representation of the sound
  38444. */
  38445. serialize(): any;
  38446. /**
  38447. * Parse a JSON representation of a sound to innstantiate in a given scene
  38448. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38449. * @param scene Define the scene the new parsed sound should be created in
  38450. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38451. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38452. * @returns the newly parsed sound
  38453. */
  38454. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38455. }
  38456. }
  38457. declare module "babylonjs/Actions/directAudioActions" {
  38458. import { Action } from "babylonjs/Actions/action";
  38459. import { Condition } from "babylonjs/Actions/condition";
  38460. import { Sound } from "babylonjs/Audio/sound";
  38461. /**
  38462. * This defines an action helpful to play a defined sound on a triggered action.
  38463. */
  38464. export class PlaySoundAction extends Action {
  38465. private _sound;
  38466. /**
  38467. * Instantiate the action
  38468. * @param triggerOptions defines the trigger options
  38469. * @param sound defines the sound to play
  38470. * @param condition defines the trigger related conditions
  38471. */
  38472. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38473. /** @hidden */
  38474. _prepare(): void;
  38475. /**
  38476. * Execute the action and play the sound.
  38477. */
  38478. execute(): void;
  38479. /**
  38480. * Serializes the actions and its related information.
  38481. * @param parent defines the object to serialize in
  38482. * @returns the serialized object
  38483. */
  38484. serialize(parent: any): any;
  38485. }
  38486. /**
  38487. * This defines an action helpful to stop a defined sound on a triggered action.
  38488. */
  38489. export class StopSoundAction extends Action {
  38490. private _sound;
  38491. /**
  38492. * Instantiate the action
  38493. * @param triggerOptions defines the trigger options
  38494. * @param sound defines the sound to stop
  38495. * @param condition defines the trigger related conditions
  38496. */
  38497. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38498. /** @hidden */
  38499. _prepare(): void;
  38500. /**
  38501. * Execute the action and stop the sound.
  38502. */
  38503. execute(): void;
  38504. /**
  38505. * Serializes the actions and its related information.
  38506. * @param parent defines the object to serialize in
  38507. * @returns the serialized object
  38508. */
  38509. serialize(parent: any): any;
  38510. }
  38511. }
  38512. declare module "babylonjs/Actions/interpolateValueAction" {
  38513. import { Action } from "babylonjs/Actions/action";
  38514. import { Condition } from "babylonjs/Actions/condition";
  38515. import { Observable } from "babylonjs/Misc/observable";
  38516. /**
  38517. * This defines an action responsible to change the value of a property
  38518. * by interpolating between its current value and the newly set one once triggered.
  38519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38520. */
  38521. export class InterpolateValueAction extends Action {
  38522. /**
  38523. * Defines the path of the property where the value should be interpolated
  38524. */
  38525. propertyPath: string;
  38526. /**
  38527. * Defines the target value at the end of the interpolation.
  38528. */
  38529. value: any;
  38530. /**
  38531. * Defines the time it will take for the property to interpolate to the value.
  38532. */
  38533. duration: number;
  38534. /**
  38535. * Defines if the other scene animations should be stopped when the action has been triggered
  38536. */
  38537. stopOtherAnimations?: boolean;
  38538. /**
  38539. * Defines a callback raised once the interpolation animation has been done.
  38540. */
  38541. onInterpolationDone?: () => void;
  38542. /**
  38543. * Observable triggered once the interpolation animation has been done.
  38544. */
  38545. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38546. private _target;
  38547. private _effectiveTarget;
  38548. private _property;
  38549. /**
  38550. * Instantiate the action
  38551. * @param triggerOptions defines the trigger options
  38552. * @param target defines the object containing the value to interpolate
  38553. * @param propertyPath defines the path to the property in the target object
  38554. * @param value defines the target value at the end of the interpolation
  38555. * @param duration deines the time it will take for the property to interpolate to the value.
  38556. * @param condition defines the trigger related conditions
  38557. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38558. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38559. */
  38560. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38561. /** @hidden */
  38562. _prepare(): void;
  38563. /**
  38564. * Execute the action starts the value interpolation.
  38565. */
  38566. execute(): void;
  38567. /**
  38568. * Serializes the actions and its related information.
  38569. * @param parent defines the object to serialize in
  38570. * @returns the serialized object
  38571. */
  38572. serialize(parent: any): any;
  38573. }
  38574. }
  38575. declare module "babylonjs/Actions/index" {
  38576. export * from "babylonjs/Actions/abstractActionManager";
  38577. export * from "babylonjs/Actions/action";
  38578. export * from "babylonjs/Actions/actionEvent";
  38579. export * from "babylonjs/Actions/actionManager";
  38580. export * from "babylonjs/Actions/condition";
  38581. export * from "babylonjs/Actions/directActions";
  38582. export * from "babylonjs/Actions/directAudioActions";
  38583. export * from "babylonjs/Actions/interpolateValueAction";
  38584. }
  38585. declare module "babylonjs/Animations/index" {
  38586. export * from "babylonjs/Animations/animatable";
  38587. export * from "babylonjs/Animations/animation";
  38588. export * from "babylonjs/Animations/animationGroup";
  38589. export * from "babylonjs/Animations/animationPropertiesOverride";
  38590. export * from "babylonjs/Animations/easing";
  38591. export * from "babylonjs/Animations/runtimeAnimation";
  38592. export * from "babylonjs/Animations/animationEvent";
  38593. export * from "babylonjs/Animations/animationGroup";
  38594. export * from "babylonjs/Animations/animationKey";
  38595. export * from "babylonjs/Animations/animationRange";
  38596. export * from "babylonjs/Animations/animatable.interface";
  38597. }
  38598. declare module "babylonjs/Audio/soundTrack" {
  38599. import { Sound } from "babylonjs/Audio/sound";
  38600. import { Analyser } from "babylonjs/Audio/analyser";
  38601. import { Scene } from "babylonjs/scene";
  38602. /**
  38603. * Options allowed during the creation of a sound track.
  38604. */
  38605. export interface ISoundTrackOptions {
  38606. /**
  38607. * The volume the sound track should take during creation
  38608. */
  38609. volume?: number;
  38610. /**
  38611. * Define if the sound track is the main sound track of the scene
  38612. */
  38613. mainTrack?: boolean;
  38614. }
  38615. /**
  38616. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38617. * It will be also used in a future release to apply effects on a specific track.
  38618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38619. */
  38620. export class SoundTrack {
  38621. /**
  38622. * The unique identifier of the sound track in the scene.
  38623. */
  38624. id: number;
  38625. /**
  38626. * The list of sounds included in the sound track.
  38627. */
  38628. soundCollection: Array<Sound>;
  38629. private _outputAudioNode;
  38630. private _scene;
  38631. private _connectedAnalyser;
  38632. private _options;
  38633. private _isInitialized;
  38634. /**
  38635. * Creates a new sound track.
  38636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38637. * @param scene Define the scene the sound track belongs to
  38638. * @param options
  38639. */
  38640. constructor(scene: Scene, options?: ISoundTrackOptions);
  38641. private _initializeSoundTrackAudioGraph;
  38642. /**
  38643. * Release the sound track and its associated resources
  38644. */
  38645. dispose(): void;
  38646. /**
  38647. * Adds a sound to this sound track
  38648. * @param sound define the cound to add
  38649. * @ignoreNaming
  38650. */
  38651. AddSound(sound: Sound): void;
  38652. /**
  38653. * Removes a sound to this sound track
  38654. * @param sound define the cound to remove
  38655. * @ignoreNaming
  38656. */
  38657. RemoveSound(sound: Sound): void;
  38658. /**
  38659. * Set a global volume for the full sound track.
  38660. * @param newVolume Define the new volume of the sound track
  38661. */
  38662. setVolume(newVolume: number): void;
  38663. /**
  38664. * Switch the panning model to HRTF:
  38665. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38667. */
  38668. switchPanningModelToHRTF(): void;
  38669. /**
  38670. * Switch the panning model to Equal Power:
  38671. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38673. */
  38674. switchPanningModelToEqualPower(): void;
  38675. /**
  38676. * Connect the sound track to an audio analyser allowing some amazing
  38677. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38679. * @param analyser The analyser to connect to the engine
  38680. */
  38681. connectToAnalyser(analyser: Analyser): void;
  38682. }
  38683. }
  38684. declare module "babylonjs/Audio/audioSceneComponent" {
  38685. import { Sound } from "babylonjs/Audio/sound";
  38686. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38687. import { Nullable } from "babylonjs/types";
  38688. import { Vector3 } from "babylonjs/Maths/math.vector";
  38689. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38690. import { Scene } from "babylonjs/scene";
  38691. import { AbstractScene } from "babylonjs/abstractScene";
  38692. import "babylonjs/Audio/audioEngine";
  38693. module "babylonjs/abstractScene" {
  38694. interface AbstractScene {
  38695. /**
  38696. * The list of sounds used in the scene.
  38697. */
  38698. sounds: Nullable<Array<Sound>>;
  38699. }
  38700. }
  38701. module "babylonjs/scene" {
  38702. interface Scene {
  38703. /**
  38704. * @hidden
  38705. * Backing field
  38706. */
  38707. _mainSoundTrack: SoundTrack;
  38708. /**
  38709. * The main sound track played by the scene.
  38710. * It cotains your primary collection of sounds.
  38711. */
  38712. mainSoundTrack: SoundTrack;
  38713. /**
  38714. * The list of sound tracks added to the scene
  38715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38716. */
  38717. soundTracks: Nullable<Array<SoundTrack>>;
  38718. /**
  38719. * Gets a sound using a given name
  38720. * @param name defines the name to search for
  38721. * @return the found sound or null if not found at all.
  38722. */
  38723. getSoundByName(name: string): Nullable<Sound>;
  38724. /**
  38725. * Gets or sets if audio support is enabled
  38726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38727. */
  38728. audioEnabled: boolean;
  38729. /**
  38730. * Gets or sets if audio will be output to headphones
  38731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38732. */
  38733. headphone: boolean;
  38734. /**
  38735. * Gets or sets custom audio listener position provider
  38736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38737. */
  38738. audioListenerPositionProvider: Nullable<() => Vector3>;
  38739. /**
  38740. * Gets or sets a refresh rate when using 3D audio positioning
  38741. */
  38742. audioPositioningRefreshRate: number;
  38743. }
  38744. }
  38745. /**
  38746. * Defines the sound scene component responsible to manage any sounds
  38747. * in a given scene.
  38748. */
  38749. export class AudioSceneComponent implements ISceneSerializableComponent {
  38750. /**
  38751. * The component name helpfull to identify the component in the list of scene components.
  38752. */
  38753. readonly name: string;
  38754. /**
  38755. * The scene the component belongs to.
  38756. */
  38757. scene: Scene;
  38758. private _audioEnabled;
  38759. /**
  38760. * Gets whether audio is enabled or not.
  38761. * Please use related enable/disable method to switch state.
  38762. */
  38763. get audioEnabled(): boolean;
  38764. private _headphone;
  38765. /**
  38766. * Gets whether audio is outputing to headphone or not.
  38767. * Please use the according Switch methods to change output.
  38768. */
  38769. get headphone(): boolean;
  38770. /**
  38771. * Gets or sets a refresh rate when using 3D audio positioning
  38772. */
  38773. audioPositioningRefreshRate: number;
  38774. private _audioListenerPositionProvider;
  38775. /**
  38776. * Gets the current audio listener position provider
  38777. */
  38778. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38779. /**
  38780. * Sets a custom listener position for all sounds in the scene
  38781. * By default, this is the position of the first active camera
  38782. */
  38783. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38784. /**
  38785. * Creates a new instance of the component for the given scene
  38786. * @param scene Defines the scene to register the component in
  38787. */
  38788. constructor(scene: Scene);
  38789. /**
  38790. * Registers the component in a given scene
  38791. */
  38792. register(): void;
  38793. /**
  38794. * Rebuilds the elements related to this component in case of
  38795. * context lost for instance.
  38796. */
  38797. rebuild(): void;
  38798. /**
  38799. * Serializes the component data to the specified json object
  38800. * @param serializationObject The object to serialize to
  38801. */
  38802. serialize(serializationObject: any): void;
  38803. /**
  38804. * Adds all the elements from the container to the scene
  38805. * @param container the container holding the elements
  38806. */
  38807. addFromContainer(container: AbstractScene): void;
  38808. /**
  38809. * Removes all the elements in the container from the scene
  38810. * @param container contains the elements to remove
  38811. * @param dispose if the removed element should be disposed (default: false)
  38812. */
  38813. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38814. /**
  38815. * Disposes the component and the associated ressources.
  38816. */
  38817. dispose(): void;
  38818. /**
  38819. * Disables audio in the associated scene.
  38820. */
  38821. disableAudio(): void;
  38822. /**
  38823. * Enables audio in the associated scene.
  38824. */
  38825. enableAudio(): void;
  38826. /**
  38827. * Switch audio to headphone output.
  38828. */
  38829. switchAudioModeForHeadphones(): void;
  38830. /**
  38831. * Switch audio to normal speakers.
  38832. */
  38833. switchAudioModeForNormalSpeakers(): void;
  38834. private _cachedCameraDirection;
  38835. private _cachedCameraPosition;
  38836. private _lastCheck;
  38837. private _afterRender;
  38838. }
  38839. }
  38840. declare module "babylonjs/Audio/weightedsound" {
  38841. import { Sound } from "babylonjs/Audio/sound";
  38842. /**
  38843. * Wraps one or more Sound objects and selects one with random weight for playback.
  38844. */
  38845. export class WeightedSound {
  38846. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38847. loop: boolean;
  38848. private _coneInnerAngle;
  38849. private _coneOuterAngle;
  38850. private _volume;
  38851. /** A Sound is currently playing. */
  38852. isPlaying: boolean;
  38853. /** A Sound is currently paused. */
  38854. isPaused: boolean;
  38855. private _sounds;
  38856. private _weights;
  38857. private _currentIndex?;
  38858. /**
  38859. * Creates a new WeightedSound from the list of sounds given.
  38860. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38861. * @param sounds Array of Sounds that will be selected from.
  38862. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38863. */
  38864. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38865. /**
  38866. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38867. */
  38868. get directionalConeInnerAngle(): number;
  38869. /**
  38870. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38871. */
  38872. set directionalConeInnerAngle(value: number);
  38873. /**
  38874. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38875. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38876. */
  38877. get directionalConeOuterAngle(): number;
  38878. /**
  38879. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38880. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38881. */
  38882. set directionalConeOuterAngle(value: number);
  38883. /**
  38884. * Playback volume.
  38885. */
  38886. get volume(): number;
  38887. /**
  38888. * Playback volume.
  38889. */
  38890. set volume(value: number);
  38891. private _onended;
  38892. /**
  38893. * Suspend playback
  38894. */
  38895. pause(): void;
  38896. /**
  38897. * Stop playback
  38898. */
  38899. stop(): void;
  38900. /**
  38901. * Start playback.
  38902. * @param startOffset Position the clip head at a specific time in seconds.
  38903. */
  38904. play(startOffset?: number): void;
  38905. }
  38906. }
  38907. declare module "babylonjs/Audio/index" {
  38908. export * from "babylonjs/Audio/analyser";
  38909. export * from "babylonjs/Audio/audioEngine";
  38910. export * from "babylonjs/Audio/audioSceneComponent";
  38911. export * from "babylonjs/Audio/sound";
  38912. export * from "babylonjs/Audio/soundTrack";
  38913. export * from "babylonjs/Audio/weightedsound";
  38914. }
  38915. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38916. import { Behavior } from "babylonjs/Behaviors/behavior";
  38917. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38918. import { BackEase } from "babylonjs/Animations/easing";
  38919. /**
  38920. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38922. */
  38923. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38924. /**
  38925. * Gets the name of the behavior.
  38926. */
  38927. get name(): string;
  38928. /**
  38929. * The easing function used by animations
  38930. */
  38931. static EasingFunction: BackEase;
  38932. /**
  38933. * The easing mode used by animations
  38934. */
  38935. static EasingMode: number;
  38936. /**
  38937. * The duration of the animation, in milliseconds
  38938. */
  38939. transitionDuration: number;
  38940. /**
  38941. * Length of the distance animated by the transition when lower radius is reached
  38942. */
  38943. lowerRadiusTransitionRange: number;
  38944. /**
  38945. * Length of the distance animated by the transition when upper radius is reached
  38946. */
  38947. upperRadiusTransitionRange: number;
  38948. private _autoTransitionRange;
  38949. /**
  38950. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38951. */
  38952. get autoTransitionRange(): boolean;
  38953. /**
  38954. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38955. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38956. */
  38957. set autoTransitionRange(value: boolean);
  38958. private _attachedCamera;
  38959. private _onAfterCheckInputsObserver;
  38960. private _onMeshTargetChangedObserver;
  38961. /**
  38962. * Initializes the behavior.
  38963. */
  38964. init(): void;
  38965. /**
  38966. * Attaches the behavior to its arc rotate camera.
  38967. * @param camera Defines the camera to attach the behavior to
  38968. */
  38969. attach(camera: ArcRotateCamera): void;
  38970. /**
  38971. * Detaches the behavior from its current arc rotate camera.
  38972. */
  38973. detach(): void;
  38974. private _radiusIsAnimating;
  38975. private _radiusBounceTransition;
  38976. private _animatables;
  38977. private _cachedWheelPrecision;
  38978. /**
  38979. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38980. * @param radiusLimit The limit to check against.
  38981. * @return Bool to indicate if at limit.
  38982. */
  38983. private _isRadiusAtLimit;
  38984. /**
  38985. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38986. * @param radiusDelta The delta by which to animate to. Can be negative.
  38987. */
  38988. private _applyBoundRadiusAnimation;
  38989. /**
  38990. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38991. */
  38992. protected _clearAnimationLocks(): void;
  38993. /**
  38994. * Stops and removes all animations that have been applied to the camera
  38995. */
  38996. stopAllAnimations(): void;
  38997. }
  38998. }
  38999. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39000. import { Behavior } from "babylonjs/Behaviors/behavior";
  39001. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39002. import { ExponentialEase } from "babylonjs/Animations/easing";
  39003. import { Nullable } from "babylonjs/types";
  39004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39005. import { Vector3 } from "babylonjs/Maths/math.vector";
  39006. /**
  39007. * 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.
  39008. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39009. */
  39010. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39011. /**
  39012. * Gets the name of the behavior.
  39013. */
  39014. get name(): string;
  39015. private _mode;
  39016. private _radiusScale;
  39017. private _positionScale;
  39018. private _defaultElevation;
  39019. private _elevationReturnTime;
  39020. private _elevationReturnWaitTime;
  39021. private _zoomStopsAnimation;
  39022. private _framingTime;
  39023. /**
  39024. * The easing function used by animations
  39025. */
  39026. static EasingFunction: ExponentialEase;
  39027. /**
  39028. * The easing mode used by animations
  39029. */
  39030. static EasingMode: number;
  39031. /**
  39032. * Sets the current mode used by the behavior
  39033. */
  39034. set mode(mode: number);
  39035. /**
  39036. * Gets current mode used by the behavior.
  39037. */
  39038. get mode(): number;
  39039. /**
  39040. * Sets the scale applied to the radius (1 by default)
  39041. */
  39042. set radiusScale(radius: number);
  39043. /**
  39044. * Gets the scale applied to the radius
  39045. */
  39046. get radiusScale(): number;
  39047. /**
  39048. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39049. */
  39050. set positionScale(scale: number);
  39051. /**
  39052. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39053. */
  39054. get positionScale(): number;
  39055. /**
  39056. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39057. * behaviour is triggered, in radians.
  39058. */
  39059. set defaultElevation(elevation: number);
  39060. /**
  39061. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39062. * behaviour is triggered, in radians.
  39063. */
  39064. get defaultElevation(): number;
  39065. /**
  39066. * Sets the time (in milliseconds) taken to return to the default beta position.
  39067. * Negative value indicates camera should not return to default.
  39068. */
  39069. set elevationReturnTime(speed: number);
  39070. /**
  39071. * Gets the time (in milliseconds) taken to return to the default beta position.
  39072. * Negative value indicates camera should not return to default.
  39073. */
  39074. get elevationReturnTime(): number;
  39075. /**
  39076. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39077. */
  39078. set elevationReturnWaitTime(time: number);
  39079. /**
  39080. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39081. */
  39082. get elevationReturnWaitTime(): number;
  39083. /**
  39084. * Sets the flag that indicates if user zooming should stop animation.
  39085. */
  39086. set zoomStopsAnimation(flag: boolean);
  39087. /**
  39088. * Gets the flag that indicates if user zooming should stop animation.
  39089. */
  39090. get zoomStopsAnimation(): boolean;
  39091. /**
  39092. * Sets the transition time when framing the mesh, in milliseconds
  39093. */
  39094. set framingTime(time: number);
  39095. /**
  39096. * Gets the transition time when framing the mesh, in milliseconds
  39097. */
  39098. get framingTime(): number;
  39099. /**
  39100. * Define if the behavior should automatically change the configured
  39101. * camera limits and sensibilities.
  39102. */
  39103. autoCorrectCameraLimitsAndSensibility: boolean;
  39104. private _onPrePointerObservableObserver;
  39105. private _onAfterCheckInputsObserver;
  39106. private _onMeshTargetChangedObserver;
  39107. private _attachedCamera;
  39108. private _isPointerDown;
  39109. private _lastInteractionTime;
  39110. /**
  39111. * Initializes the behavior.
  39112. */
  39113. init(): void;
  39114. /**
  39115. * Attaches the behavior to its arc rotate camera.
  39116. * @param camera Defines the camera to attach the behavior to
  39117. */
  39118. attach(camera: ArcRotateCamera): void;
  39119. /**
  39120. * Detaches the behavior from its current arc rotate camera.
  39121. */
  39122. detach(): void;
  39123. private _animatables;
  39124. private _betaIsAnimating;
  39125. private _betaTransition;
  39126. private _radiusTransition;
  39127. private _vectorTransition;
  39128. /**
  39129. * Targets the given mesh and updates zoom level accordingly.
  39130. * @param mesh The mesh to target.
  39131. * @param radius Optional. If a cached radius position already exists, overrides default.
  39132. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39133. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39134. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39135. */
  39136. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39137. /**
  39138. * Targets the given mesh with its children and updates zoom level accordingly.
  39139. * @param mesh The mesh to target.
  39140. * @param radius Optional. If a cached radius position already exists, overrides default.
  39141. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39142. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39143. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39144. */
  39145. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39146. /**
  39147. * Targets the given meshes with their children and updates zoom level accordingly.
  39148. * @param meshes The mesh to target.
  39149. * @param radius Optional. If a cached radius position already exists, overrides default.
  39150. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39151. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39152. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39153. */
  39154. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39155. /**
  39156. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39157. * @param minimumWorld Determines the smaller position of the bounding box extend
  39158. * @param maximumWorld Determines the bigger position of the bounding box extend
  39159. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39160. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39161. */
  39162. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39163. /**
  39164. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39165. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39166. * frustum width.
  39167. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39168. * to fully enclose the mesh in the viewing frustum.
  39169. */
  39170. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39171. /**
  39172. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39173. * is automatically returned to its default position (expected to be above ground plane).
  39174. */
  39175. private _maintainCameraAboveGround;
  39176. /**
  39177. * Returns the frustum slope based on the canvas ratio and camera FOV
  39178. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39179. */
  39180. private _getFrustumSlope;
  39181. /**
  39182. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39183. */
  39184. private _clearAnimationLocks;
  39185. /**
  39186. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39187. */
  39188. private _applyUserInteraction;
  39189. /**
  39190. * Stops and removes all animations that have been applied to the camera
  39191. */
  39192. stopAllAnimations(): void;
  39193. /**
  39194. * Gets a value indicating if the user is moving the camera
  39195. */
  39196. get isUserIsMoving(): boolean;
  39197. /**
  39198. * The camera can move all the way towards the mesh.
  39199. */
  39200. static IgnoreBoundsSizeMode: number;
  39201. /**
  39202. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39203. */
  39204. static FitFrustumSidesMode: number;
  39205. }
  39206. }
  39207. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39208. import { Nullable } from "babylonjs/types";
  39209. import { Camera } from "babylonjs/Cameras/camera";
  39210. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39211. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39212. /**
  39213. * Base class for Camera Pointer Inputs.
  39214. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39215. * for example usage.
  39216. */
  39217. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39218. /**
  39219. * Defines the camera the input is attached to.
  39220. */
  39221. abstract camera: Camera;
  39222. /**
  39223. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39224. */
  39225. protected _altKey: boolean;
  39226. protected _ctrlKey: boolean;
  39227. protected _metaKey: boolean;
  39228. protected _shiftKey: boolean;
  39229. /**
  39230. * Which mouse buttons were pressed at time of last mouse event.
  39231. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39232. */
  39233. protected _buttonsPressed: number;
  39234. /**
  39235. * Defines the buttons associated with the input to handle camera move.
  39236. */
  39237. buttons: number[];
  39238. /**
  39239. * Attach the input controls to a specific dom element to get the input from.
  39240. * @param element Defines the element the controls should be listened from
  39241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39242. */
  39243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39244. /**
  39245. * Detach the current controls from the specified dom element.
  39246. * @param element Defines the element to stop listening the inputs from
  39247. */
  39248. detachControl(element: Nullable<HTMLElement>): void;
  39249. /**
  39250. * Gets the class name of the current input.
  39251. * @returns the class name
  39252. */
  39253. getClassName(): string;
  39254. /**
  39255. * Get the friendly name associated with the input class.
  39256. * @returns the input friendly name
  39257. */
  39258. getSimpleName(): string;
  39259. /**
  39260. * Called on pointer POINTERDOUBLETAP event.
  39261. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39262. */
  39263. protected onDoubleTap(type: string): void;
  39264. /**
  39265. * Called on pointer POINTERMOVE event if only a single touch is active.
  39266. * Override this method to provide functionality.
  39267. */
  39268. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39269. /**
  39270. * Called on pointer POINTERMOVE event if multiple touches are active.
  39271. * Override this method to provide functionality.
  39272. */
  39273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39274. /**
  39275. * Called on JS contextmenu event.
  39276. * Override this method to provide functionality.
  39277. */
  39278. protected onContextMenu(evt: PointerEvent): void;
  39279. /**
  39280. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39281. * press.
  39282. * Override this method to provide functionality.
  39283. */
  39284. protected onButtonDown(evt: PointerEvent): void;
  39285. /**
  39286. * Called each time a new POINTERUP event occurs. Ie, for each button
  39287. * release.
  39288. * Override this method to provide functionality.
  39289. */
  39290. protected onButtonUp(evt: PointerEvent): void;
  39291. /**
  39292. * Called when window becomes inactive.
  39293. * Override this method to provide functionality.
  39294. */
  39295. protected onLostFocus(): void;
  39296. private _pointerInput;
  39297. private _observer;
  39298. private _onLostFocus;
  39299. private pointA;
  39300. private pointB;
  39301. }
  39302. }
  39303. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39304. import { Nullable } from "babylonjs/types";
  39305. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39306. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39307. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39308. /**
  39309. * Manage the pointers inputs to control an arc rotate camera.
  39310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39311. */
  39312. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39313. /**
  39314. * Defines the camera the input is attached to.
  39315. */
  39316. camera: ArcRotateCamera;
  39317. /**
  39318. * Gets the class name of the current input.
  39319. * @returns the class name
  39320. */
  39321. getClassName(): string;
  39322. /**
  39323. * Defines the buttons associated with the input to handle camera move.
  39324. */
  39325. buttons: number[];
  39326. /**
  39327. * Defines the pointer angular sensibility along the X axis or how fast is
  39328. * the camera rotating.
  39329. */
  39330. angularSensibilityX: number;
  39331. /**
  39332. * Defines the pointer angular sensibility along the Y axis or how fast is
  39333. * the camera rotating.
  39334. */
  39335. angularSensibilityY: number;
  39336. /**
  39337. * Defines the pointer pinch precision or how fast is the camera zooming.
  39338. */
  39339. pinchPrecision: number;
  39340. /**
  39341. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39342. * from 0.
  39343. * It defines the percentage of current camera.radius to use as delta when
  39344. * pinch zoom is used.
  39345. */
  39346. pinchDeltaPercentage: number;
  39347. /**
  39348. * Defines the pointer panning sensibility or how fast is the camera moving.
  39349. */
  39350. panningSensibility: number;
  39351. /**
  39352. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39353. */
  39354. multiTouchPanning: boolean;
  39355. /**
  39356. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39357. * zoom (pinch) through multitouch.
  39358. */
  39359. multiTouchPanAndZoom: boolean;
  39360. /**
  39361. * Revers pinch action direction.
  39362. */
  39363. pinchInwards: boolean;
  39364. private _isPanClick;
  39365. private _twoFingerActivityCount;
  39366. private _isPinching;
  39367. /**
  39368. * Called on pointer POINTERMOVE event if only a single touch is active.
  39369. */
  39370. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39371. /**
  39372. * Called on pointer POINTERDOUBLETAP event.
  39373. */
  39374. protected onDoubleTap(type: string): void;
  39375. /**
  39376. * Called on pointer POINTERMOVE event if multiple touches are active.
  39377. */
  39378. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39379. /**
  39380. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39381. * press.
  39382. */
  39383. protected onButtonDown(evt: PointerEvent): void;
  39384. /**
  39385. * Called each time a new POINTERUP event occurs. Ie, for each button
  39386. * release.
  39387. */
  39388. protected onButtonUp(evt: PointerEvent): void;
  39389. /**
  39390. * Called when window becomes inactive.
  39391. */
  39392. protected onLostFocus(): void;
  39393. }
  39394. }
  39395. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39396. import { Nullable } from "babylonjs/types";
  39397. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39398. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39399. /**
  39400. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39402. */
  39403. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39404. /**
  39405. * Defines the camera the input is attached to.
  39406. */
  39407. camera: ArcRotateCamera;
  39408. /**
  39409. * Defines the list of key codes associated with the up action (increase alpha)
  39410. */
  39411. keysUp: number[];
  39412. /**
  39413. * Defines the list of key codes associated with the down action (decrease alpha)
  39414. */
  39415. keysDown: number[];
  39416. /**
  39417. * Defines the list of key codes associated with the left action (increase beta)
  39418. */
  39419. keysLeft: number[];
  39420. /**
  39421. * Defines the list of key codes associated with the right action (decrease beta)
  39422. */
  39423. keysRight: number[];
  39424. /**
  39425. * Defines the list of key codes associated with the reset action.
  39426. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39427. */
  39428. keysReset: number[];
  39429. /**
  39430. * Defines the panning sensibility of the inputs.
  39431. * (How fast is the camera paning)
  39432. */
  39433. panningSensibility: number;
  39434. /**
  39435. * Defines the zooming sensibility of the inputs.
  39436. * (How fast is the camera zooming)
  39437. */
  39438. zoomingSensibility: number;
  39439. /**
  39440. * Defines wether maintaining the alt key down switch the movement mode from
  39441. * orientation to zoom.
  39442. */
  39443. useAltToZoom: boolean;
  39444. /**
  39445. * Rotation speed of the camera
  39446. */
  39447. angularSpeed: number;
  39448. private _keys;
  39449. private _ctrlPressed;
  39450. private _altPressed;
  39451. private _onCanvasBlurObserver;
  39452. private _onKeyboardObserver;
  39453. private _engine;
  39454. private _scene;
  39455. /**
  39456. * Attach the input controls to a specific dom element to get the input from.
  39457. * @param element Defines the element the controls should be listened from
  39458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39459. */
  39460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39461. /**
  39462. * Detach the current controls from the specified dom element.
  39463. * @param element Defines the element to stop listening the inputs from
  39464. */
  39465. detachControl(element: Nullable<HTMLElement>): void;
  39466. /**
  39467. * Update the current camera state depending on the inputs that have been used this frame.
  39468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39469. */
  39470. checkInputs(): void;
  39471. /**
  39472. * Gets the class name of the current intput.
  39473. * @returns the class name
  39474. */
  39475. getClassName(): string;
  39476. /**
  39477. * Get the friendly name associated with the input class.
  39478. * @returns the input friendly name
  39479. */
  39480. getSimpleName(): string;
  39481. }
  39482. }
  39483. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39484. import { Nullable } from "babylonjs/types";
  39485. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39486. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39487. /**
  39488. * Manage the mouse wheel inputs to control an arc rotate camera.
  39489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39490. */
  39491. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39492. /**
  39493. * Defines the camera the input is attached to.
  39494. */
  39495. camera: ArcRotateCamera;
  39496. /**
  39497. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39498. */
  39499. wheelPrecision: number;
  39500. /**
  39501. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39502. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39503. */
  39504. wheelDeltaPercentage: number;
  39505. private _wheel;
  39506. private _observer;
  39507. private computeDeltaFromMouseWheelLegacyEvent;
  39508. /**
  39509. * Attach the input controls to a specific dom element to get the input from.
  39510. * @param element Defines the element the controls should be listened from
  39511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39512. */
  39513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39514. /**
  39515. * Detach the current controls from the specified dom element.
  39516. * @param element Defines the element to stop listening the inputs from
  39517. */
  39518. detachControl(element: Nullable<HTMLElement>): void;
  39519. /**
  39520. * Gets the class name of the current intput.
  39521. * @returns the class name
  39522. */
  39523. getClassName(): string;
  39524. /**
  39525. * Get the friendly name associated with the input class.
  39526. * @returns the input friendly name
  39527. */
  39528. getSimpleName(): string;
  39529. }
  39530. }
  39531. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39532. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39533. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39534. /**
  39535. * Default Inputs manager for the ArcRotateCamera.
  39536. * It groups all the default supported inputs for ease of use.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39540. /**
  39541. * Instantiates a new ArcRotateCameraInputsManager.
  39542. * @param camera Defines the camera the inputs belong to
  39543. */
  39544. constructor(camera: ArcRotateCamera);
  39545. /**
  39546. * Add mouse wheel input support to the input manager.
  39547. * @returns the current input manager
  39548. */
  39549. addMouseWheel(): ArcRotateCameraInputsManager;
  39550. /**
  39551. * Add pointers input support to the input manager.
  39552. * @returns the current input manager
  39553. */
  39554. addPointers(): ArcRotateCameraInputsManager;
  39555. /**
  39556. * Add keyboard input support to the input manager.
  39557. * @returns the current input manager
  39558. */
  39559. addKeyboard(): ArcRotateCameraInputsManager;
  39560. }
  39561. }
  39562. declare module "babylonjs/Cameras/arcRotateCamera" {
  39563. import { Observable } from "babylonjs/Misc/observable";
  39564. import { Nullable } from "babylonjs/types";
  39565. import { Scene } from "babylonjs/scene";
  39566. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39568. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39569. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39570. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39571. import { Camera } from "babylonjs/Cameras/camera";
  39572. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39573. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39574. import { Collider } from "babylonjs/Collisions/collider";
  39575. /**
  39576. * This represents an orbital type of camera.
  39577. *
  39578. * 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.
  39579. * 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.
  39580. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39581. */
  39582. export class ArcRotateCamera extends TargetCamera {
  39583. /**
  39584. * Defines the rotation angle of the camera along the longitudinal axis.
  39585. */
  39586. alpha: number;
  39587. /**
  39588. * Defines the rotation angle of the camera along the latitudinal axis.
  39589. */
  39590. beta: number;
  39591. /**
  39592. * Defines the radius of the camera from it s target point.
  39593. */
  39594. radius: number;
  39595. protected _target: Vector3;
  39596. protected _targetHost: Nullable<AbstractMesh>;
  39597. /**
  39598. * Defines the target point of the camera.
  39599. * The camera looks towards it form the radius distance.
  39600. */
  39601. get target(): Vector3;
  39602. set target(value: Vector3);
  39603. /**
  39604. * Define the current local position of the camera in the scene
  39605. */
  39606. get position(): Vector3;
  39607. set position(newPosition: Vector3);
  39608. protected _upVector: Vector3;
  39609. protected _upToYMatrix: Matrix;
  39610. protected _YToUpMatrix: Matrix;
  39611. /**
  39612. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39613. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39614. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39615. */
  39616. set upVector(vec: Vector3);
  39617. get upVector(): Vector3;
  39618. /**
  39619. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39620. */
  39621. setMatUp(): void;
  39622. /**
  39623. * Current inertia value on the longitudinal axis.
  39624. * The bigger this number the longer it will take for the camera to stop.
  39625. */
  39626. inertialAlphaOffset: number;
  39627. /**
  39628. * Current inertia value on the latitudinal axis.
  39629. * The bigger this number the longer it will take for the camera to stop.
  39630. */
  39631. inertialBetaOffset: number;
  39632. /**
  39633. * Current inertia value on the radius axis.
  39634. * The bigger this number the longer it will take for the camera to stop.
  39635. */
  39636. inertialRadiusOffset: number;
  39637. /**
  39638. * Minimum allowed angle on the longitudinal axis.
  39639. * This can help limiting how the Camera is able to move in the scene.
  39640. */
  39641. lowerAlphaLimit: Nullable<number>;
  39642. /**
  39643. * Maximum allowed angle on the longitudinal axis.
  39644. * This can help limiting how the Camera is able to move in the scene.
  39645. */
  39646. upperAlphaLimit: Nullable<number>;
  39647. /**
  39648. * Minimum allowed angle on the latitudinal axis.
  39649. * This can help limiting how the Camera is able to move in the scene.
  39650. */
  39651. lowerBetaLimit: number;
  39652. /**
  39653. * Maximum allowed angle on the latitudinal axis.
  39654. * This can help limiting how the Camera is able to move in the scene.
  39655. */
  39656. upperBetaLimit: number;
  39657. /**
  39658. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39659. * This can help limiting how the Camera is able to move in the scene.
  39660. */
  39661. lowerRadiusLimit: Nullable<number>;
  39662. /**
  39663. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39664. * This can help limiting how the Camera is able to move in the scene.
  39665. */
  39666. upperRadiusLimit: Nullable<number>;
  39667. /**
  39668. * Defines the current inertia value used during panning of the camera along the X axis.
  39669. */
  39670. inertialPanningX: number;
  39671. /**
  39672. * Defines the current inertia value used during panning of the camera along the Y axis.
  39673. */
  39674. inertialPanningY: number;
  39675. /**
  39676. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39677. * Basically if your fingers moves away from more than this distance you will be considered
  39678. * in pinch mode.
  39679. */
  39680. pinchToPanMaxDistance: number;
  39681. /**
  39682. * Defines the maximum distance the camera can pan.
  39683. * This could help keeping the cammera always in your scene.
  39684. */
  39685. panningDistanceLimit: Nullable<number>;
  39686. /**
  39687. * Defines the target of the camera before paning.
  39688. */
  39689. panningOriginTarget: Vector3;
  39690. /**
  39691. * Defines the value of the inertia used during panning.
  39692. * 0 would mean stop inertia and one would mean no decelleration at all.
  39693. */
  39694. panningInertia: number;
  39695. /**
  39696. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39697. */
  39698. get angularSensibilityX(): number;
  39699. set angularSensibilityX(value: number);
  39700. /**
  39701. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39702. */
  39703. get angularSensibilityY(): number;
  39704. set angularSensibilityY(value: number);
  39705. /**
  39706. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39707. */
  39708. get pinchPrecision(): number;
  39709. set pinchPrecision(value: number);
  39710. /**
  39711. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39712. * It will be used instead of pinchDeltaPrecision if different from 0.
  39713. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39714. */
  39715. get pinchDeltaPercentage(): number;
  39716. set pinchDeltaPercentage(value: number);
  39717. /**
  39718. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39719. */
  39720. get panningSensibility(): number;
  39721. set panningSensibility(value: number);
  39722. /**
  39723. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39724. */
  39725. get keysUp(): number[];
  39726. set keysUp(value: number[]);
  39727. /**
  39728. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39729. */
  39730. get keysDown(): number[];
  39731. set keysDown(value: number[]);
  39732. /**
  39733. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39734. */
  39735. get keysLeft(): number[];
  39736. set keysLeft(value: number[]);
  39737. /**
  39738. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39739. */
  39740. get keysRight(): number[];
  39741. set keysRight(value: number[]);
  39742. /**
  39743. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39744. */
  39745. get wheelPrecision(): number;
  39746. set wheelPrecision(value: number);
  39747. /**
  39748. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39749. * It will be used instead of pinchDeltaPrecision if different from 0.
  39750. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39751. */
  39752. get wheelDeltaPercentage(): number;
  39753. set wheelDeltaPercentage(value: number);
  39754. /**
  39755. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39756. */
  39757. zoomOnFactor: number;
  39758. /**
  39759. * Defines a screen offset for the camera position.
  39760. */
  39761. targetScreenOffset: Vector2;
  39762. /**
  39763. * Allows the camera to be completely reversed.
  39764. * If false the camera can not arrive upside down.
  39765. */
  39766. allowUpsideDown: boolean;
  39767. /**
  39768. * Define if double tap/click is used to restore the previously saved state of the camera.
  39769. */
  39770. useInputToRestoreState: boolean;
  39771. /** @hidden */
  39772. _viewMatrix: Matrix;
  39773. /** @hidden */
  39774. _useCtrlForPanning: boolean;
  39775. /** @hidden */
  39776. _panningMouseButton: number;
  39777. /**
  39778. * Defines the input associated to the camera.
  39779. */
  39780. inputs: ArcRotateCameraInputsManager;
  39781. /** @hidden */
  39782. _reset: () => void;
  39783. /**
  39784. * Defines the allowed panning axis.
  39785. */
  39786. panningAxis: Vector3;
  39787. protected _localDirection: Vector3;
  39788. protected _transformedDirection: Vector3;
  39789. private _bouncingBehavior;
  39790. /**
  39791. * Gets the bouncing behavior of the camera if it has been enabled.
  39792. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39793. */
  39794. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39795. /**
  39796. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39797. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39798. */
  39799. get useBouncingBehavior(): boolean;
  39800. set useBouncingBehavior(value: boolean);
  39801. private _framingBehavior;
  39802. /**
  39803. * Gets the framing behavior of the camera if it has been enabled.
  39804. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39805. */
  39806. get framingBehavior(): Nullable<FramingBehavior>;
  39807. /**
  39808. * Defines if the framing behavior of the camera is enabled on the camera.
  39809. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39810. */
  39811. get useFramingBehavior(): boolean;
  39812. set useFramingBehavior(value: boolean);
  39813. private _autoRotationBehavior;
  39814. /**
  39815. * Gets the auto rotation behavior of the camera if it has been enabled.
  39816. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39817. */
  39818. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39819. /**
  39820. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39822. */
  39823. get useAutoRotationBehavior(): boolean;
  39824. set useAutoRotationBehavior(value: boolean);
  39825. /**
  39826. * Observable triggered when the mesh target has been changed on the camera.
  39827. */
  39828. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39829. /**
  39830. * Event raised when the camera is colliding with a mesh.
  39831. */
  39832. onCollide: (collidedMesh: AbstractMesh) => void;
  39833. /**
  39834. * Defines whether the camera should check collision with the objects oh the scene.
  39835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39836. */
  39837. checkCollisions: boolean;
  39838. /**
  39839. * Defines the collision radius of the camera.
  39840. * This simulates a sphere around the camera.
  39841. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39842. */
  39843. collisionRadius: Vector3;
  39844. protected _collider: Collider;
  39845. protected _previousPosition: Vector3;
  39846. protected _collisionVelocity: Vector3;
  39847. protected _newPosition: Vector3;
  39848. protected _previousAlpha: number;
  39849. protected _previousBeta: number;
  39850. protected _previousRadius: number;
  39851. protected _collisionTriggered: boolean;
  39852. protected _targetBoundingCenter: Nullable<Vector3>;
  39853. private _computationVector;
  39854. /**
  39855. * Instantiates a new ArcRotateCamera in a given scene
  39856. * @param name Defines the name of the camera
  39857. * @param alpha Defines the camera rotation along the logitudinal axis
  39858. * @param beta Defines the camera rotation along the latitudinal axis
  39859. * @param radius Defines the camera distance from its target
  39860. * @param target Defines the camera target
  39861. * @param scene Defines the scene the camera belongs to
  39862. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39863. */
  39864. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39865. /** @hidden */
  39866. _initCache(): void;
  39867. /** @hidden */
  39868. _updateCache(ignoreParentClass?: boolean): void;
  39869. protected _getTargetPosition(): Vector3;
  39870. private _storedAlpha;
  39871. private _storedBeta;
  39872. private _storedRadius;
  39873. private _storedTarget;
  39874. private _storedTargetScreenOffset;
  39875. /**
  39876. * Stores the current state of the camera (alpha, beta, radius and target)
  39877. * @returns the camera itself
  39878. */
  39879. storeState(): Camera;
  39880. /**
  39881. * @hidden
  39882. * Restored camera state. You must call storeState() first
  39883. */
  39884. _restoreStateValues(): boolean;
  39885. /** @hidden */
  39886. _isSynchronizedViewMatrix(): boolean;
  39887. /**
  39888. * Attached controls to the current camera.
  39889. * @param element Defines the element the controls should be listened from
  39890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39891. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39892. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39893. */
  39894. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39895. /**
  39896. * Detach the current controls from the camera.
  39897. * The camera will stop reacting to inputs.
  39898. * @param element Defines the element to stop listening the inputs from
  39899. */
  39900. detachControl(element: HTMLElement): void;
  39901. /** @hidden */
  39902. _checkInputs(): void;
  39903. protected _checkLimits(): void;
  39904. /**
  39905. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39906. */
  39907. rebuildAnglesAndRadius(): void;
  39908. /**
  39909. * Use a position to define the current camera related information like alpha, beta and radius
  39910. * @param position Defines the position to set the camera at
  39911. */
  39912. setPosition(position: Vector3): void;
  39913. /**
  39914. * Defines the target the camera should look at.
  39915. * This will automatically adapt alpha beta and radius to fit within the new target.
  39916. * @param target Defines the new target as a Vector or a mesh
  39917. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39918. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39919. */
  39920. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39921. /** @hidden */
  39922. _getViewMatrix(): Matrix;
  39923. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39924. /**
  39925. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39926. * @param meshes Defines the mesh to zoom on
  39927. * @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)
  39928. */
  39929. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39930. /**
  39931. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39932. * The target will be changed but the radius
  39933. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39934. * @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)
  39935. */
  39936. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39937. min: Vector3;
  39938. max: Vector3;
  39939. distance: number;
  39940. }, doNotUpdateMaxZ?: boolean): void;
  39941. /**
  39942. * @override
  39943. * Override Camera.createRigCamera
  39944. */
  39945. createRigCamera(name: string, cameraIndex: number): Camera;
  39946. /**
  39947. * @hidden
  39948. * @override
  39949. * Override Camera._updateRigCameras
  39950. */
  39951. _updateRigCameras(): void;
  39952. /**
  39953. * Destroy the camera and release the current resources hold by it.
  39954. */
  39955. dispose(): void;
  39956. /**
  39957. * Gets the current object class name.
  39958. * @return the class name
  39959. */
  39960. getClassName(): string;
  39961. }
  39962. }
  39963. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39964. import { Behavior } from "babylonjs/Behaviors/behavior";
  39965. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39966. /**
  39967. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39968. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39969. */
  39970. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39971. /**
  39972. * Gets the name of the behavior.
  39973. */
  39974. get name(): string;
  39975. private _zoomStopsAnimation;
  39976. private _idleRotationSpeed;
  39977. private _idleRotationWaitTime;
  39978. private _idleRotationSpinupTime;
  39979. /**
  39980. * Sets the flag that indicates if user zooming should stop animation.
  39981. */
  39982. set zoomStopsAnimation(flag: boolean);
  39983. /**
  39984. * Gets the flag that indicates if user zooming should stop animation.
  39985. */
  39986. get zoomStopsAnimation(): boolean;
  39987. /**
  39988. * Sets the default speed at which the camera rotates around the model.
  39989. */
  39990. set idleRotationSpeed(speed: number);
  39991. /**
  39992. * Gets the default speed at which the camera rotates around the model.
  39993. */
  39994. get idleRotationSpeed(): number;
  39995. /**
  39996. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39997. */
  39998. set idleRotationWaitTime(time: number);
  39999. /**
  40000. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40001. */
  40002. get idleRotationWaitTime(): number;
  40003. /**
  40004. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40005. */
  40006. set idleRotationSpinupTime(time: number);
  40007. /**
  40008. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40009. */
  40010. get idleRotationSpinupTime(): number;
  40011. /**
  40012. * Gets a value indicating if the camera is currently rotating because of this behavior
  40013. */
  40014. get rotationInProgress(): boolean;
  40015. private _onPrePointerObservableObserver;
  40016. private _onAfterCheckInputsObserver;
  40017. private _attachedCamera;
  40018. private _isPointerDown;
  40019. private _lastFrameTime;
  40020. private _lastInteractionTime;
  40021. private _cameraRotationSpeed;
  40022. /**
  40023. * Initializes the behavior.
  40024. */
  40025. init(): void;
  40026. /**
  40027. * Attaches the behavior to its arc rotate camera.
  40028. * @param camera Defines the camera to attach the behavior to
  40029. */
  40030. attach(camera: ArcRotateCamera): void;
  40031. /**
  40032. * Detaches the behavior from its current arc rotate camera.
  40033. */
  40034. detach(): void;
  40035. /**
  40036. * Returns true if user is scrolling.
  40037. * @return true if user is scrolling.
  40038. */
  40039. private _userIsZooming;
  40040. private _lastFrameRadius;
  40041. private _shouldAnimationStopForInteraction;
  40042. /**
  40043. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40044. */
  40045. private _applyUserInteraction;
  40046. private _userIsMoving;
  40047. }
  40048. }
  40049. declare module "babylonjs/Behaviors/Cameras/index" {
  40050. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40051. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40052. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40053. }
  40054. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40055. import { Mesh } from "babylonjs/Meshes/mesh";
  40056. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40057. import { Behavior } from "babylonjs/Behaviors/behavior";
  40058. /**
  40059. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40060. */
  40061. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40062. private ui;
  40063. /**
  40064. * The name of the behavior
  40065. */
  40066. name: string;
  40067. /**
  40068. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40069. */
  40070. distanceAwayFromFace: number;
  40071. /**
  40072. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40073. */
  40074. distanceAwayFromBottomOfFace: number;
  40075. private _faceVectors;
  40076. private _target;
  40077. private _scene;
  40078. private _onRenderObserver;
  40079. private _tmpMatrix;
  40080. private _tmpVector;
  40081. /**
  40082. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40083. * @param ui The transform node that should be attched to the mesh
  40084. */
  40085. constructor(ui: TransformNode);
  40086. /**
  40087. * Initializes the behavior
  40088. */
  40089. init(): void;
  40090. private _closestFace;
  40091. private _zeroVector;
  40092. private _lookAtTmpMatrix;
  40093. private _lookAtToRef;
  40094. /**
  40095. * Attaches the AttachToBoxBehavior to the passed in mesh
  40096. * @param target The mesh that the specified node will be attached to
  40097. */
  40098. attach(target: Mesh): void;
  40099. /**
  40100. * Detaches the behavior from the mesh
  40101. */
  40102. detach(): void;
  40103. }
  40104. }
  40105. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40106. import { Behavior } from "babylonjs/Behaviors/behavior";
  40107. import { Mesh } from "babylonjs/Meshes/mesh";
  40108. /**
  40109. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40110. */
  40111. export class FadeInOutBehavior implements Behavior<Mesh> {
  40112. /**
  40113. * Time in milliseconds to delay before fading in (Default: 0)
  40114. */
  40115. delay: number;
  40116. /**
  40117. * Time in milliseconds for the mesh to fade in (Default: 300)
  40118. */
  40119. fadeInTime: number;
  40120. private _millisecondsPerFrame;
  40121. private _hovered;
  40122. private _hoverValue;
  40123. private _ownerNode;
  40124. /**
  40125. * Instatiates the FadeInOutBehavior
  40126. */
  40127. constructor();
  40128. /**
  40129. * The name of the behavior
  40130. */
  40131. get name(): string;
  40132. /**
  40133. * Initializes the behavior
  40134. */
  40135. init(): void;
  40136. /**
  40137. * Attaches the fade behavior on the passed in mesh
  40138. * @param ownerNode The mesh that will be faded in/out once attached
  40139. */
  40140. attach(ownerNode: Mesh): void;
  40141. /**
  40142. * Detaches the behavior from the mesh
  40143. */
  40144. detach(): void;
  40145. /**
  40146. * Triggers the mesh to begin fading in or out
  40147. * @param value if the object should fade in or out (true to fade in)
  40148. */
  40149. fadeIn(value: boolean): void;
  40150. private _update;
  40151. private _setAllVisibility;
  40152. }
  40153. }
  40154. declare module "babylonjs/Misc/pivotTools" {
  40155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40156. /**
  40157. * Class containing a set of static utilities functions for managing Pivots
  40158. * @hidden
  40159. */
  40160. export class PivotTools {
  40161. private static _PivotCached;
  40162. private static _OldPivotPoint;
  40163. private static _PivotTranslation;
  40164. private static _PivotTmpVector;
  40165. /** @hidden */
  40166. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40167. /** @hidden */
  40168. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40169. }
  40170. }
  40171. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40172. import { Scene } from "babylonjs/scene";
  40173. import { Vector4 } from "babylonjs/Maths/math.vector";
  40174. import { Mesh } from "babylonjs/Meshes/mesh";
  40175. import { Nullable } from "babylonjs/types";
  40176. import { Plane } from "babylonjs/Maths/math.plane";
  40177. /**
  40178. * Class containing static functions to help procedurally build meshes
  40179. */
  40180. export class PlaneBuilder {
  40181. /**
  40182. * Creates a plane mesh
  40183. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40184. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40185. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40189. * @param name defines the name of the mesh
  40190. * @param options defines the options used to create the mesh
  40191. * @param scene defines the hosting scene
  40192. * @returns the plane mesh
  40193. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40194. */
  40195. static CreatePlane(name: string, options: {
  40196. size?: number;
  40197. width?: number;
  40198. height?: number;
  40199. sideOrientation?: number;
  40200. frontUVs?: Vector4;
  40201. backUVs?: Vector4;
  40202. updatable?: boolean;
  40203. sourcePlane?: Plane;
  40204. }, scene?: Nullable<Scene>): Mesh;
  40205. }
  40206. }
  40207. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40208. import { Behavior } from "babylonjs/Behaviors/behavior";
  40209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40210. import { Observable } from "babylonjs/Misc/observable";
  40211. import { Vector3 } from "babylonjs/Maths/math.vector";
  40212. import { Ray } from "babylonjs/Culling/ray";
  40213. import "babylonjs/Meshes/Builders/planeBuilder";
  40214. /**
  40215. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40216. */
  40217. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40218. private static _AnyMouseID;
  40219. /**
  40220. * Abstract mesh the behavior is set on
  40221. */
  40222. attachedNode: AbstractMesh;
  40223. private _dragPlane;
  40224. private _scene;
  40225. private _pointerObserver;
  40226. private _beforeRenderObserver;
  40227. private static _planeScene;
  40228. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40229. /**
  40230. * 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)
  40231. */
  40232. maxDragAngle: number;
  40233. /**
  40234. * @hidden
  40235. */
  40236. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40237. /**
  40238. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40239. */
  40240. currentDraggingPointerID: number;
  40241. /**
  40242. * The last position where the pointer hit the drag plane in world space
  40243. */
  40244. lastDragPosition: Vector3;
  40245. /**
  40246. * If the behavior is currently in a dragging state
  40247. */
  40248. dragging: boolean;
  40249. /**
  40250. * 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)
  40251. */
  40252. dragDeltaRatio: number;
  40253. /**
  40254. * If the drag plane orientation should be updated during the dragging (Default: true)
  40255. */
  40256. updateDragPlane: boolean;
  40257. private _debugMode;
  40258. private _moving;
  40259. /**
  40260. * Fires each time the attached mesh is dragged with the pointer
  40261. * * delta between last drag position and current drag position in world space
  40262. * * dragDistance along the drag axis
  40263. * * dragPlaneNormal normal of the current drag plane used during the drag
  40264. * * dragPlanePoint in world space where the drag intersects the drag plane
  40265. */
  40266. onDragObservable: Observable<{
  40267. delta: Vector3;
  40268. dragPlanePoint: Vector3;
  40269. dragPlaneNormal: Vector3;
  40270. dragDistance: number;
  40271. pointerId: number;
  40272. }>;
  40273. /**
  40274. * Fires each time a drag begins (eg. mouse down on mesh)
  40275. */
  40276. onDragStartObservable: Observable<{
  40277. dragPlanePoint: Vector3;
  40278. pointerId: number;
  40279. }>;
  40280. /**
  40281. * Fires each time a drag ends (eg. mouse release after drag)
  40282. */
  40283. onDragEndObservable: Observable<{
  40284. dragPlanePoint: Vector3;
  40285. pointerId: number;
  40286. }>;
  40287. /**
  40288. * If the attached mesh should be moved when dragged
  40289. */
  40290. moveAttached: boolean;
  40291. /**
  40292. * If the drag behavior will react to drag events (Default: true)
  40293. */
  40294. enabled: boolean;
  40295. /**
  40296. * If pointer events should start and release the drag (Default: true)
  40297. */
  40298. startAndReleaseDragOnPointerEvents: boolean;
  40299. /**
  40300. * If camera controls should be detached during the drag
  40301. */
  40302. detachCameraControls: boolean;
  40303. /**
  40304. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40305. */
  40306. useObjectOrientationForDragging: boolean;
  40307. private _options;
  40308. /**
  40309. * Gets the options used by the behavior
  40310. */
  40311. get options(): {
  40312. dragAxis?: Vector3;
  40313. dragPlaneNormal?: Vector3;
  40314. };
  40315. /**
  40316. * Sets the options used by the behavior
  40317. */
  40318. set options(options: {
  40319. dragAxis?: Vector3;
  40320. dragPlaneNormal?: Vector3;
  40321. });
  40322. /**
  40323. * Creates a pointer drag behavior that can be attached to a mesh
  40324. * @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)
  40325. */
  40326. constructor(options?: {
  40327. dragAxis?: Vector3;
  40328. dragPlaneNormal?: Vector3;
  40329. });
  40330. /**
  40331. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40332. */
  40333. validateDrag: (targetPosition: Vector3) => boolean;
  40334. /**
  40335. * The name of the behavior
  40336. */
  40337. get name(): string;
  40338. /**
  40339. * Initializes the behavior
  40340. */
  40341. init(): void;
  40342. private _tmpVector;
  40343. private _alternatePickedPoint;
  40344. private _worldDragAxis;
  40345. private _targetPosition;
  40346. private _attachedElement;
  40347. /**
  40348. * Attaches the drag behavior the passed in mesh
  40349. * @param ownerNode The mesh that will be dragged around once attached
  40350. * @param predicate Predicate to use for pick filtering
  40351. */
  40352. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40353. /**
  40354. * Force relase the drag action by code.
  40355. */
  40356. releaseDrag(): void;
  40357. private _startDragRay;
  40358. private _lastPointerRay;
  40359. /**
  40360. * Simulates the start of a pointer drag event on the behavior
  40361. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40362. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40363. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40364. */
  40365. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40366. private _startDrag;
  40367. private _dragDelta;
  40368. private _moveDrag;
  40369. private _pickWithRayOnDragPlane;
  40370. private _pointA;
  40371. private _pointB;
  40372. private _pointC;
  40373. private _lineA;
  40374. private _lineB;
  40375. private _localAxis;
  40376. private _lookAt;
  40377. private _updateDragPlanePosition;
  40378. /**
  40379. * Detaches the behavior from the mesh
  40380. */
  40381. detach(): void;
  40382. }
  40383. }
  40384. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40385. import { Mesh } from "babylonjs/Meshes/mesh";
  40386. import { Behavior } from "babylonjs/Behaviors/behavior";
  40387. /**
  40388. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40389. */
  40390. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40391. private _dragBehaviorA;
  40392. private _dragBehaviorB;
  40393. private _startDistance;
  40394. private _initialScale;
  40395. private _targetScale;
  40396. private _ownerNode;
  40397. private _sceneRenderObserver;
  40398. /**
  40399. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40400. */
  40401. constructor();
  40402. /**
  40403. * The name of the behavior
  40404. */
  40405. get name(): string;
  40406. /**
  40407. * Initializes the behavior
  40408. */
  40409. init(): void;
  40410. private _getCurrentDistance;
  40411. /**
  40412. * Attaches the scale behavior the passed in mesh
  40413. * @param ownerNode The mesh that will be scaled around once attached
  40414. */
  40415. attach(ownerNode: Mesh): void;
  40416. /**
  40417. * Detaches the behavior from the mesh
  40418. */
  40419. detach(): void;
  40420. }
  40421. }
  40422. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40423. import { Behavior } from "babylonjs/Behaviors/behavior";
  40424. import { Mesh } from "babylonjs/Meshes/mesh";
  40425. import { Observable } from "babylonjs/Misc/observable";
  40426. /**
  40427. * 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
  40428. */
  40429. export class SixDofDragBehavior implements Behavior<Mesh> {
  40430. private static _virtualScene;
  40431. private _ownerNode;
  40432. private _sceneRenderObserver;
  40433. private _scene;
  40434. private _targetPosition;
  40435. private _virtualOriginMesh;
  40436. private _virtualDragMesh;
  40437. private _pointerObserver;
  40438. private _moving;
  40439. private _startingOrientation;
  40440. /**
  40441. * 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)
  40442. */
  40443. private zDragFactor;
  40444. /**
  40445. * If the object should rotate to face the drag origin
  40446. */
  40447. rotateDraggedObject: boolean;
  40448. /**
  40449. * If the behavior is currently in a dragging state
  40450. */
  40451. dragging: boolean;
  40452. /**
  40453. * 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)
  40454. */
  40455. dragDeltaRatio: number;
  40456. /**
  40457. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40458. */
  40459. currentDraggingPointerID: number;
  40460. /**
  40461. * If camera controls should be detached during the drag
  40462. */
  40463. detachCameraControls: boolean;
  40464. /**
  40465. * Fires each time a drag starts
  40466. */
  40467. onDragStartObservable: Observable<{}>;
  40468. /**
  40469. * Fires each time a drag ends (eg. mouse release after drag)
  40470. */
  40471. onDragEndObservable: Observable<{}>;
  40472. /**
  40473. * 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
  40474. */
  40475. constructor();
  40476. /**
  40477. * The name of the behavior
  40478. */
  40479. get name(): string;
  40480. /**
  40481. * Initializes the behavior
  40482. */
  40483. init(): void;
  40484. /**
  40485. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40486. */
  40487. private get _pointerCamera();
  40488. /**
  40489. * Attaches the scale behavior the passed in mesh
  40490. * @param ownerNode The mesh that will be scaled around once attached
  40491. */
  40492. attach(ownerNode: Mesh): void;
  40493. /**
  40494. * Detaches the behavior from the mesh
  40495. */
  40496. detach(): void;
  40497. }
  40498. }
  40499. declare module "babylonjs/Behaviors/Meshes/index" {
  40500. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40501. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40502. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40503. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40504. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40505. }
  40506. declare module "babylonjs/Behaviors/index" {
  40507. export * from "babylonjs/Behaviors/behavior";
  40508. export * from "babylonjs/Behaviors/Cameras/index";
  40509. export * from "babylonjs/Behaviors/Meshes/index";
  40510. }
  40511. declare module "babylonjs/Bones/boneIKController" {
  40512. import { Bone } from "babylonjs/Bones/bone";
  40513. import { Vector3 } from "babylonjs/Maths/math.vector";
  40514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40515. import { Nullable } from "babylonjs/types";
  40516. /**
  40517. * Class used to apply inverse kinematics to bones
  40518. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40519. */
  40520. export class BoneIKController {
  40521. private static _tmpVecs;
  40522. private static _tmpQuat;
  40523. private static _tmpMats;
  40524. /**
  40525. * Gets or sets the target mesh
  40526. */
  40527. targetMesh: AbstractMesh;
  40528. /** Gets or sets the mesh used as pole */
  40529. poleTargetMesh: AbstractMesh;
  40530. /**
  40531. * Gets or sets the bone used as pole
  40532. */
  40533. poleTargetBone: Nullable<Bone>;
  40534. /**
  40535. * Gets or sets the target position
  40536. */
  40537. targetPosition: Vector3;
  40538. /**
  40539. * Gets or sets the pole target position
  40540. */
  40541. poleTargetPosition: Vector3;
  40542. /**
  40543. * Gets or sets the pole target local offset
  40544. */
  40545. poleTargetLocalOffset: Vector3;
  40546. /**
  40547. * Gets or sets the pole angle
  40548. */
  40549. poleAngle: number;
  40550. /**
  40551. * Gets or sets the mesh associated with the controller
  40552. */
  40553. mesh: AbstractMesh;
  40554. /**
  40555. * 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)
  40556. */
  40557. slerpAmount: number;
  40558. private _bone1Quat;
  40559. private _bone1Mat;
  40560. private _bone2Ang;
  40561. private _bone1;
  40562. private _bone2;
  40563. private _bone1Length;
  40564. private _bone2Length;
  40565. private _maxAngle;
  40566. private _maxReach;
  40567. private _rightHandedSystem;
  40568. private _bendAxis;
  40569. private _slerping;
  40570. private _adjustRoll;
  40571. /**
  40572. * Gets or sets maximum allowed angle
  40573. */
  40574. get maxAngle(): number;
  40575. set maxAngle(value: number);
  40576. /**
  40577. * Creates a new BoneIKController
  40578. * @param mesh defines the mesh to control
  40579. * @param bone defines the bone to control
  40580. * @param options defines options to set up the controller
  40581. */
  40582. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40583. targetMesh?: AbstractMesh;
  40584. poleTargetMesh?: AbstractMesh;
  40585. poleTargetBone?: Bone;
  40586. poleTargetLocalOffset?: Vector3;
  40587. poleAngle?: number;
  40588. bendAxis?: Vector3;
  40589. maxAngle?: number;
  40590. slerpAmount?: number;
  40591. });
  40592. private _setMaxAngle;
  40593. /**
  40594. * Force the controller to update the bones
  40595. */
  40596. update(): void;
  40597. }
  40598. }
  40599. declare module "babylonjs/Bones/boneLookController" {
  40600. import { Vector3 } from "babylonjs/Maths/math.vector";
  40601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40602. import { Bone } from "babylonjs/Bones/bone";
  40603. import { Space } from "babylonjs/Maths/math.axis";
  40604. /**
  40605. * Class used to make a bone look toward a point in space
  40606. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40607. */
  40608. export class BoneLookController {
  40609. private static _tmpVecs;
  40610. private static _tmpQuat;
  40611. private static _tmpMats;
  40612. /**
  40613. * The target Vector3 that the bone will look at
  40614. */
  40615. target: Vector3;
  40616. /**
  40617. * The mesh that the bone is attached to
  40618. */
  40619. mesh: AbstractMesh;
  40620. /**
  40621. * The bone that will be looking to the target
  40622. */
  40623. bone: Bone;
  40624. /**
  40625. * The up axis of the coordinate system that is used when the bone is rotated
  40626. */
  40627. upAxis: Vector3;
  40628. /**
  40629. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40630. */
  40631. upAxisSpace: Space;
  40632. /**
  40633. * Used to make an adjustment to the yaw of the bone
  40634. */
  40635. adjustYaw: number;
  40636. /**
  40637. * Used to make an adjustment to the pitch of the bone
  40638. */
  40639. adjustPitch: number;
  40640. /**
  40641. * Used to make an adjustment to the roll of the bone
  40642. */
  40643. adjustRoll: number;
  40644. /**
  40645. * 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)
  40646. */
  40647. slerpAmount: number;
  40648. private _minYaw;
  40649. private _maxYaw;
  40650. private _minPitch;
  40651. private _maxPitch;
  40652. private _minYawSin;
  40653. private _minYawCos;
  40654. private _maxYawSin;
  40655. private _maxYawCos;
  40656. private _midYawConstraint;
  40657. private _minPitchTan;
  40658. private _maxPitchTan;
  40659. private _boneQuat;
  40660. private _slerping;
  40661. private _transformYawPitch;
  40662. private _transformYawPitchInv;
  40663. private _firstFrameSkipped;
  40664. private _yawRange;
  40665. private _fowardAxis;
  40666. /**
  40667. * Gets or sets the minimum yaw angle that the bone can look to
  40668. */
  40669. get minYaw(): number;
  40670. set minYaw(value: number);
  40671. /**
  40672. * Gets or sets the maximum yaw angle that the bone can look to
  40673. */
  40674. get maxYaw(): number;
  40675. set maxYaw(value: number);
  40676. /**
  40677. * Gets or sets the minimum pitch angle that the bone can look to
  40678. */
  40679. get minPitch(): number;
  40680. set minPitch(value: number);
  40681. /**
  40682. * Gets or sets the maximum pitch angle that the bone can look to
  40683. */
  40684. get maxPitch(): number;
  40685. set maxPitch(value: number);
  40686. /**
  40687. * Create a BoneLookController
  40688. * @param mesh the mesh that the bone belongs to
  40689. * @param bone the bone that will be looking to the target
  40690. * @param target the target Vector3 to look at
  40691. * @param options optional settings:
  40692. * * maxYaw: the maximum angle the bone will yaw to
  40693. * * minYaw: the minimum angle the bone will yaw to
  40694. * * maxPitch: the maximum angle the bone will pitch to
  40695. * * minPitch: the minimum angle the bone will yaw to
  40696. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40697. * * upAxis: the up axis of the coordinate system
  40698. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40699. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40700. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40701. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40702. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40703. * * adjustRoll: used to make an adjustment to the roll of the bone
  40704. **/
  40705. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40706. maxYaw?: number;
  40707. minYaw?: number;
  40708. maxPitch?: number;
  40709. minPitch?: number;
  40710. slerpAmount?: number;
  40711. upAxis?: Vector3;
  40712. upAxisSpace?: Space;
  40713. yawAxis?: Vector3;
  40714. pitchAxis?: Vector3;
  40715. adjustYaw?: number;
  40716. adjustPitch?: number;
  40717. adjustRoll?: number;
  40718. });
  40719. /**
  40720. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40721. */
  40722. update(): void;
  40723. private _getAngleDiff;
  40724. private _getAngleBetween;
  40725. private _isAngleBetween;
  40726. }
  40727. }
  40728. declare module "babylonjs/Bones/index" {
  40729. export * from "babylonjs/Bones/bone";
  40730. export * from "babylonjs/Bones/boneIKController";
  40731. export * from "babylonjs/Bones/boneLookController";
  40732. export * from "babylonjs/Bones/skeleton";
  40733. }
  40734. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40735. import { Nullable } from "babylonjs/types";
  40736. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40737. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40738. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40739. /**
  40740. * Manage the gamepad inputs to control an arc rotate camera.
  40741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40742. */
  40743. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40744. /**
  40745. * Defines the camera the input is attached to.
  40746. */
  40747. camera: ArcRotateCamera;
  40748. /**
  40749. * Defines the gamepad the input is gathering event from.
  40750. */
  40751. gamepad: Nullable<Gamepad>;
  40752. /**
  40753. * Defines the gamepad rotation sensiblity.
  40754. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40755. */
  40756. gamepadRotationSensibility: number;
  40757. /**
  40758. * Defines the gamepad move sensiblity.
  40759. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40760. */
  40761. gamepadMoveSensibility: number;
  40762. private _yAxisScale;
  40763. /**
  40764. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40765. */
  40766. get invertYAxis(): boolean;
  40767. set invertYAxis(value: boolean);
  40768. private _onGamepadConnectedObserver;
  40769. private _onGamepadDisconnectedObserver;
  40770. /**
  40771. * Attach the input controls to a specific dom element to get the input from.
  40772. * @param element Defines the element the controls should be listened from
  40773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40774. */
  40775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40776. /**
  40777. * Detach the current controls from the specified dom element.
  40778. * @param element Defines the element to stop listening the inputs from
  40779. */
  40780. detachControl(element: Nullable<HTMLElement>): void;
  40781. /**
  40782. * Update the current camera state depending on the inputs that have been used this frame.
  40783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40784. */
  40785. checkInputs(): void;
  40786. /**
  40787. * Gets the class name of the current intput.
  40788. * @returns the class name
  40789. */
  40790. getClassName(): string;
  40791. /**
  40792. * Get the friendly name associated with the input class.
  40793. * @returns the input friendly name
  40794. */
  40795. getSimpleName(): string;
  40796. }
  40797. }
  40798. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40799. import { Nullable } from "babylonjs/types";
  40800. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40801. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40802. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40803. interface ArcRotateCameraInputsManager {
  40804. /**
  40805. * Add orientation input support to the input manager.
  40806. * @returns the current input manager
  40807. */
  40808. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40809. }
  40810. }
  40811. /**
  40812. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40814. */
  40815. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40816. /**
  40817. * Defines the camera the input is attached to.
  40818. */
  40819. camera: ArcRotateCamera;
  40820. /**
  40821. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40822. */
  40823. alphaCorrection: number;
  40824. /**
  40825. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40826. */
  40827. gammaCorrection: number;
  40828. private _alpha;
  40829. private _gamma;
  40830. private _dirty;
  40831. private _deviceOrientationHandler;
  40832. /**
  40833. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40834. */
  40835. constructor();
  40836. /**
  40837. * Attach the input controls to a specific dom element to get the input from.
  40838. * @param element Defines the element the controls should be listened from
  40839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40840. */
  40841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40842. /** @hidden */
  40843. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40844. /**
  40845. * Update the current camera state depending on the inputs that have been used this frame.
  40846. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40847. */
  40848. checkInputs(): void;
  40849. /**
  40850. * Detach the current controls from the specified dom element.
  40851. * @param element Defines the element to stop listening the inputs from
  40852. */
  40853. detachControl(element: Nullable<HTMLElement>): void;
  40854. /**
  40855. * Gets the class name of the current intput.
  40856. * @returns the class name
  40857. */
  40858. getClassName(): string;
  40859. /**
  40860. * Get the friendly name associated with the input class.
  40861. * @returns the input friendly name
  40862. */
  40863. getSimpleName(): string;
  40864. }
  40865. }
  40866. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40867. import { Nullable } from "babylonjs/types";
  40868. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40869. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40870. /**
  40871. * Listen to mouse events to control the camera.
  40872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40873. */
  40874. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40875. /**
  40876. * Defines the camera the input is attached to.
  40877. */
  40878. camera: FlyCamera;
  40879. /**
  40880. * Defines if touch is enabled. (Default is true.)
  40881. */
  40882. touchEnabled: boolean;
  40883. /**
  40884. * Defines the buttons associated with the input to handle camera rotation.
  40885. */
  40886. buttons: number[];
  40887. /**
  40888. * Assign buttons for Yaw control.
  40889. */
  40890. buttonsYaw: number[];
  40891. /**
  40892. * Assign buttons for Pitch control.
  40893. */
  40894. buttonsPitch: number[];
  40895. /**
  40896. * Assign buttons for Roll control.
  40897. */
  40898. buttonsRoll: number[];
  40899. /**
  40900. * Detect if any button is being pressed while mouse is moved.
  40901. * -1 = Mouse locked.
  40902. * 0 = Left button.
  40903. * 1 = Middle Button.
  40904. * 2 = Right Button.
  40905. */
  40906. activeButton: number;
  40907. /**
  40908. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40909. * Higher values reduce its sensitivity.
  40910. */
  40911. angularSensibility: number;
  40912. private _mousemoveCallback;
  40913. private _observer;
  40914. private _rollObserver;
  40915. private previousPosition;
  40916. private noPreventDefault;
  40917. private element;
  40918. /**
  40919. * Listen to mouse events to control the camera.
  40920. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40922. */
  40923. constructor(touchEnabled?: boolean);
  40924. /**
  40925. * Attach the mouse control to the HTML DOM element.
  40926. * @param element Defines the element that listens to the input events.
  40927. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40928. */
  40929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40930. /**
  40931. * Detach the current controls from the specified dom element.
  40932. * @param element Defines the element to stop listening the inputs from
  40933. */
  40934. detachControl(element: Nullable<HTMLElement>): void;
  40935. /**
  40936. * Gets the class name of the current input.
  40937. * @returns the class name.
  40938. */
  40939. getClassName(): string;
  40940. /**
  40941. * Get the friendly name associated with the input class.
  40942. * @returns the input's friendly name.
  40943. */
  40944. getSimpleName(): string;
  40945. private _pointerInput;
  40946. private _onMouseMove;
  40947. /**
  40948. * Rotate camera by mouse offset.
  40949. */
  40950. private rotateCamera;
  40951. }
  40952. }
  40953. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40954. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40955. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40956. /**
  40957. * Default Inputs manager for the FlyCamera.
  40958. * It groups all the default supported inputs for ease of use.
  40959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40960. */
  40961. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40962. /**
  40963. * Instantiates a new FlyCameraInputsManager.
  40964. * @param camera Defines the camera the inputs belong to.
  40965. */
  40966. constructor(camera: FlyCamera);
  40967. /**
  40968. * Add keyboard input support to the input manager.
  40969. * @returns the new FlyCameraKeyboardMoveInput().
  40970. */
  40971. addKeyboard(): FlyCameraInputsManager;
  40972. /**
  40973. * Add mouse input support to the input manager.
  40974. * @param touchEnabled Enable touch screen support.
  40975. * @returns the new FlyCameraMouseInput().
  40976. */
  40977. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40978. }
  40979. }
  40980. declare module "babylonjs/Cameras/flyCamera" {
  40981. import { Scene } from "babylonjs/scene";
  40982. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40984. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40985. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40986. /**
  40987. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40988. * such as in a 3D Space Shooter or a Flight Simulator.
  40989. */
  40990. export class FlyCamera extends TargetCamera {
  40991. /**
  40992. * Define the collision ellipsoid of the camera.
  40993. * This is helpful for simulating a camera body, like a player's body.
  40994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40995. */
  40996. ellipsoid: Vector3;
  40997. /**
  40998. * Define an offset for the position of the ellipsoid around the camera.
  40999. * This can be helpful if the camera is attached away from the player's body center,
  41000. * such as at its head.
  41001. */
  41002. ellipsoidOffset: Vector3;
  41003. /**
  41004. * Enable or disable collisions of the camera with the rest of the scene objects.
  41005. */
  41006. checkCollisions: boolean;
  41007. /**
  41008. * Enable or disable gravity on the camera.
  41009. */
  41010. applyGravity: boolean;
  41011. /**
  41012. * Define the current direction the camera is moving to.
  41013. */
  41014. cameraDirection: Vector3;
  41015. /**
  41016. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41017. * This overrides and empties cameraRotation.
  41018. */
  41019. rotationQuaternion: Quaternion;
  41020. /**
  41021. * Track Roll to maintain the wanted Rolling when looking around.
  41022. */
  41023. _trackRoll: number;
  41024. /**
  41025. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41026. */
  41027. rollCorrect: number;
  41028. /**
  41029. * Mimic a banked turn, Rolling the camera when Yawing.
  41030. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41031. */
  41032. bankedTurn: boolean;
  41033. /**
  41034. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41035. */
  41036. bankedTurnLimit: number;
  41037. /**
  41038. * Value of 0 disables the banked Roll.
  41039. * Value of 1 is equal to the Yaw angle in radians.
  41040. */
  41041. bankedTurnMultiplier: number;
  41042. /**
  41043. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41044. */
  41045. inputs: FlyCameraInputsManager;
  41046. /**
  41047. * Gets the input sensibility for mouse input.
  41048. * Higher values reduce sensitivity.
  41049. */
  41050. get angularSensibility(): number;
  41051. /**
  41052. * Sets the input sensibility for a mouse input.
  41053. * Higher values reduce sensitivity.
  41054. */
  41055. set angularSensibility(value: number);
  41056. /**
  41057. * Get the keys for camera movement forward.
  41058. */
  41059. get keysForward(): number[];
  41060. /**
  41061. * Set the keys for camera movement forward.
  41062. */
  41063. set keysForward(value: number[]);
  41064. /**
  41065. * Get the keys for camera movement backward.
  41066. */
  41067. get keysBackward(): number[];
  41068. set keysBackward(value: number[]);
  41069. /**
  41070. * Get the keys for camera movement up.
  41071. */
  41072. get keysUp(): number[];
  41073. /**
  41074. * Set the keys for camera movement up.
  41075. */
  41076. set keysUp(value: number[]);
  41077. /**
  41078. * Get the keys for camera movement down.
  41079. */
  41080. get keysDown(): number[];
  41081. /**
  41082. * Set the keys for camera movement down.
  41083. */
  41084. set keysDown(value: number[]);
  41085. /**
  41086. * Get the keys for camera movement left.
  41087. */
  41088. get keysLeft(): number[];
  41089. /**
  41090. * Set the keys for camera movement left.
  41091. */
  41092. set keysLeft(value: number[]);
  41093. /**
  41094. * Set the keys for camera movement right.
  41095. */
  41096. get keysRight(): number[];
  41097. /**
  41098. * Set the keys for camera movement right.
  41099. */
  41100. set keysRight(value: number[]);
  41101. /**
  41102. * Event raised when the camera collides with a mesh in the scene.
  41103. */
  41104. onCollide: (collidedMesh: AbstractMesh) => void;
  41105. private _collider;
  41106. private _needMoveForGravity;
  41107. private _oldPosition;
  41108. private _diffPosition;
  41109. private _newPosition;
  41110. /** @hidden */
  41111. _localDirection: Vector3;
  41112. /** @hidden */
  41113. _transformedDirection: Vector3;
  41114. /**
  41115. * Instantiates a FlyCamera.
  41116. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41117. * such as in a 3D Space Shooter or a Flight Simulator.
  41118. * @param name Define the name of the camera in the scene.
  41119. * @param position Define the starting position of the camera in the scene.
  41120. * @param scene Define the scene the camera belongs to.
  41121. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41122. */
  41123. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41124. /**
  41125. * Attach a control to the HTML DOM element.
  41126. * @param element Defines the element that listens to the input events.
  41127. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41128. */
  41129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41130. /**
  41131. * Detach a control from the HTML DOM element.
  41132. * The camera will stop reacting to that input.
  41133. * @param element Defines the element that listens to the input events.
  41134. */
  41135. detachControl(element: HTMLElement): void;
  41136. private _collisionMask;
  41137. /**
  41138. * Get the mask that the camera ignores in collision events.
  41139. */
  41140. get collisionMask(): number;
  41141. /**
  41142. * Set the mask that the camera ignores in collision events.
  41143. */
  41144. set collisionMask(mask: number);
  41145. /** @hidden */
  41146. _collideWithWorld(displacement: Vector3): void;
  41147. /** @hidden */
  41148. private _onCollisionPositionChange;
  41149. /** @hidden */
  41150. _checkInputs(): void;
  41151. /** @hidden */
  41152. _decideIfNeedsToMove(): boolean;
  41153. /** @hidden */
  41154. _updatePosition(): void;
  41155. /**
  41156. * Restore the Roll to its target value at the rate specified.
  41157. * @param rate - Higher means slower restoring.
  41158. * @hidden
  41159. */
  41160. restoreRoll(rate: number): void;
  41161. /**
  41162. * Destroy the camera and release the current resources held by it.
  41163. */
  41164. dispose(): void;
  41165. /**
  41166. * Get the current object class name.
  41167. * @returns the class name.
  41168. */
  41169. getClassName(): string;
  41170. }
  41171. }
  41172. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41173. import { Nullable } from "babylonjs/types";
  41174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41175. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41176. /**
  41177. * Listen to keyboard events to control the camera.
  41178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41179. */
  41180. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41181. /**
  41182. * Defines the camera the input is attached to.
  41183. */
  41184. camera: FlyCamera;
  41185. /**
  41186. * The list of keyboard keys used to control the forward move of the camera.
  41187. */
  41188. keysForward: number[];
  41189. /**
  41190. * The list of keyboard keys used to control the backward move of the camera.
  41191. */
  41192. keysBackward: number[];
  41193. /**
  41194. * The list of keyboard keys used to control the forward move of the camera.
  41195. */
  41196. keysUp: number[];
  41197. /**
  41198. * The list of keyboard keys used to control the backward move of the camera.
  41199. */
  41200. keysDown: number[];
  41201. /**
  41202. * The list of keyboard keys used to control the right strafe move of the camera.
  41203. */
  41204. keysRight: number[];
  41205. /**
  41206. * The list of keyboard keys used to control the left strafe move of the camera.
  41207. */
  41208. keysLeft: number[];
  41209. private _keys;
  41210. private _onCanvasBlurObserver;
  41211. private _onKeyboardObserver;
  41212. private _engine;
  41213. private _scene;
  41214. /**
  41215. * Attach the input controls to a specific dom element to get the input from.
  41216. * @param element Defines the element the controls should be listened from
  41217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41218. */
  41219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41220. /**
  41221. * Detach the current controls from the specified dom element.
  41222. * @param element Defines the element to stop listening the inputs from
  41223. */
  41224. detachControl(element: Nullable<HTMLElement>): void;
  41225. /**
  41226. * Gets the class name of the current intput.
  41227. * @returns the class name
  41228. */
  41229. getClassName(): string;
  41230. /** @hidden */
  41231. _onLostFocus(e: FocusEvent): void;
  41232. /**
  41233. * Get the friendly name associated with the input class.
  41234. * @returns the input friendly name
  41235. */
  41236. getSimpleName(): string;
  41237. /**
  41238. * Update the current camera state depending on the inputs that have been used this frame.
  41239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41240. */
  41241. checkInputs(): void;
  41242. }
  41243. }
  41244. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41245. import { Nullable } from "babylonjs/types";
  41246. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41247. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41248. /**
  41249. * Manage the mouse wheel inputs to control a follow camera.
  41250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41251. */
  41252. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41253. /**
  41254. * Defines the camera the input is attached to.
  41255. */
  41256. camera: FollowCamera;
  41257. /**
  41258. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41259. */
  41260. axisControlRadius: boolean;
  41261. /**
  41262. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41263. */
  41264. axisControlHeight: boolean;
  41265. /**
  41266. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41267. */
  41268. axisControlRotation: boolean;
  41269. /**
  41270. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41271. * relation to mouseWheel events.
  41272. */
  41273. wheelPrecision: number;
  41274. /**
  41275. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41276. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41277. */
  41278. wheelDeltaPercentage: number;
  41279. private _wheel;
  41280. private _observer;
  41281. /**
  41282. * Attach the input controls to a specific dom element to get the input from.
  41283. * @param element Defines the element the controls should be listened from
  41284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41285. */
  41286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41287. /**
  41288. * Detach the current controls from the specified dom element.
  41289. * @param element Defines the element to stop listening the inputs from
  41290. */
  41291. detachControl(element: Nullable<HTMLElement>): void;
  41292. /**
  41293. * Gets the class name of the current intput.
  41294. * @returns the class name
  41295. */
  41296. getClassName(): string;
  41297. /**
  41298. * Get the friendly name associated with the input class.
  41299. * @returns the input friendly name
  41300. */
  41301. getSimpleName(): string;
  41302. }
  41303. }
  41304. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41305. import { Nullable } from "babylonjs/types";
  41306. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41307. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41308. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41309. /**
  41310. * Manage the pointers inputs to control an follow camera.
  41311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41312. */
  41313. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41314. /**
  41315. * Defines the camera the input is attached to.
  41316. */
  41317. camera: FollowCamera;
  41318. /**
  41319. * Gets the class name of the current input.
  41320. * @returns the class name
  41321. */
  41322. getClassName(): string;
  41323. /**
  41324. * Defines the pointer angular sensibility along the X axis or how fast is
  41325. * the camera rotating.
  41326. * A negative number will reverse the axis direction.
  41327. */
  41328. angularSensibilityX: number;
  41329. /**
  41330. * Defines the pointer angular sensibility along the Y axis or how fast is
  41331. * the camera rotating.
  41332. * A negative number will reverse the axis direction.
  41333. */
  41334. angularSensibilityY: number;
  41335. /**
  41336. * Defines the pointer pinch precision or how fast is the camera zooming.
  41337. * A negative number will reverse the axis direction.
  41338. */
  41339. pinchPrecision: number;
  41340. /**
  41341. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41342. * from 0.
  41343. * It defines the percentage of current camera.radius to use as delta when
  41344. * pinch zoom is used.
  41345. */
  41346. pinchDeltaPercentage: number;
  41347. /**
  41348. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41349. */
  41350. axisXControlRadius: boolean;
  41351. /**
  41352. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41353. */
  41354. axisXControlHeight: boolean;
  41355. /**
  41356. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41357. */
  41358. axisXControlRotation: boolean;
  41359. /**
  41360. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41361. */
  41362. axisYControlRadius: boolean;
  41363. /**
  41364. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41365. */
  41366. axisYControlHeight: boolean;
  41367. /**
  41368. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41369. */
  41370. axisYControlRotation: boolean;
  41371. /**
  41372. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41373. */
  41374. axisPinchControlRadius: boolean;
  41375. /**
  41376. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41377. */
  41378. axisPinchControlHeight: boolean;
  41379. /**
  41380. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41381. */
  41382. axisPinchControlRotation: boolean;
  41383. /**
  41384. * Log error messages if basic misconfiguration has occurred.
  41385. */
  41386. warningEnable: boolean;
  41387. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41388. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41389. private _warningCounter;
  41390. private _warning;
  41391. }
  41392. }
  41393. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41394. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41395. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41396. /**
  41397. * Default Inputs manager for the FollowCamera.
  41398. * It groups all the default supported inputs for ease of use.
  41399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41400. */
  41401. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41402. /**
  41403. * Instantiates a new FollowCameraInputsManager.
  41404. * @param camera Defines the camera the inputs belong to
  41405. */
  41406. constructor(camera: FollowCamera);
  41407. /**
  41408. * Add keyboard input support to the input manager.
  41409. * @returns the current input manager
  41410. */
  41411. addKeyboard(): FollowCameraInputsManager;
  41412. /**
  41413. * Add mouse wheel input support to the input manager.
  41414. * @returns the current input manager
  41415. */
  41416. addMouseWheel(): FollowCameraInputsManager;
  41417. /**
  41418. * Add pointers input support to the input manager.
  41419. * @returns the current input manager
  41420. */
  41421. addPointers(): FollowCameraInputsManager;
  41422. /**
  41423. * Add orientation input support to the input manager.
  41424. * @returns the current input manager
  41425. */
  41426. addVRDeviceOrientation(): FollowCameraInputsManager;
  41427. }
  41428. }
  41429. declare module "babylonjs/Cameras/followCamera" {
  41430. import { Nullable } from "babylonjs/types";
  41431. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41432. import { Scene } from "babylonjs/scene";
  41433. import { Vector3 } from "babylonjs/Maths/math.vector";
  41434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41435. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41436. /**
  41437. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41438. * an arc rotate version arcFollowCamera are available.
  41439. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41440. */
  41441. export class FollowCamera extends TargetCamera {
  41442. /**
  41443. * Distance the follow camera should follow an object at
  41444. */
  41445. radius: number;
  41446. /**
  41447. * Minimum allowed distance of the camera to the axis of rotation
  41448. * (The camera can not get closer).
  41449. * This can help limiting how the Camera is able to move in the scene.
  41450. */
  41451. lowerRadiusLimit: Nullable<number>;
  41452. /**
  41453. * Maximum allowed distance of the camera to the axis of rotation
  41454. * (The camera can not get further).
  41455. * This can help limiting how the Camera is able to move in the scene.
  41456. */
  41457. upperRadiusLimit: Nullable<number>;
  41458. /**
  41459. * Define a rotation offset between the camera and the object it follows
  41460. */
  41461. rotationOffset: number;
  41462. /**
  41463. * Minimum allowed angle to camera position relative to target object.
  41464. * This can help limiting how the Camera is able to move in the scene.
  41465. */
  41466. lowerRotationOffsetLimit: Nullable<number>;
  41467. /**
  41468. * Maximum allowed angle to camera position relative to target object.
  41469. * This can help limiting how the Camera is able to move in the scene.
  41470. */
  41471. upperRotationOffsetLimit: Nullable<number>;
  41472. /**
  41473. * Define a height offset between the camera and the object it follows.
  41474. * It can help following an object from the top (like a car chaing a plane)
  41475. */
  41476. heightOffset: number;
  41477. /**
  41478. * Minimum allowed height of camera position relative to target object.
  41479. * This can help limiting how the Camera is able to move in the scene.
  41480. */
  41481. lowerHeightOffsetLimit: Nullable<number>;
  41482. /**
  41483. * Maximum allowed height of camera position relative to target object.
  41484. * This can help limiting how the Camera is able to move in the scene.
  41485. */
  41486. upperHeightOffsetLimit: Nullable<number>;
  41487. /**
  41488. * Define how fast the camera can accelerate to follow it s target.
  41489. */
  41490. cameraAcceleration: number;
  41491. /**
  41492. * Define the speed limit of the camera following an object.
  41493. */
  41494. maxCameraSpeed: number;
  41495. /**
  41496. * Define the target of the camera.
  41497. */
  41498. lockedTarget: Nullable<AbstractMesh>;
  41499. /**
  41500. * Defines the input associated with the camera.
  41501. */
  41502. inputs: FollowCameraInputsManager;
  41503. /**
  41504. * Instantiates the follow camera.
  41505. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41506. * @param name Define the name of the camera in the scene
  41507. * @param position Define the position of the camera
  41508. * @param scene Define the scene the camera belong to
  41509. * @param lockedTarget Define the target of the camera
  41510. */
  41511. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41512. private _follow;
  41513. /**
  41514. * Attached controls to the current camera.
  41515. * @param element Defines the element the controls should be listened from
  41516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41517. */
  41518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41519. /**
  41520. * Detach the current controls from the camera.
  41521. * The camera will stop reacting to inputs.
  41522. * @param element Defines the element to stop listening the inputs from
  41523. */
  41524. detachControl(element: HTMLElement): void;
  41525. /** @hidden */
  41526. _checkInputs(): void;
  41527. private _checkLimits;
  41528. /**
  41529. * Gets the camera class name.
  41530. * @returns the class name
  41531. */
  41532. getClassName(): string;
  41533. }
  41534. /**
  41535. * Arc Rotate version of the follow camera.
  41536. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41537. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41538. */
  41539. export class ArcFollowCamera extends TargetCamera {
  41540. /** The longitudinal angle of the camera */
  41541. alpha: number;
  41542. /** The latitudinal angle of the camera */
  41543. beta: number;
  41544. /** The radius of the camera from its target */
  41545. radius: number;
  41546. /** Define the camera target (the messh it should follow) */
  41547. target: Nullable<AbstractMesh>;
  41548. private _cartesianCoordinates;
  41549. /**
  41550. * Instantiates a new ArcFollowCamera
  41551. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41552. * @param name Define the name of the camera
  41553. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41554. * @param beta Define the rotation angle of the camera around the elevation axis
  41555. * @param radius Define the radius of the camera from its target point
  41556. * @param target Define the target of the camera
  41557. * @param scene Define the scene the camera belongs to
  41558. */
  41559. constructor(name: string,
  41560. /** The longitudinal angle of the camera */
  41561. alpha: number,
  41562. /** The latitudinal angle of the camera */
  41563. beta: number,
  41564. /** The radius of the camera from its target */
  41565. radius: number,
  41566. /** Define the camera target (the messh it should follow) */
  41567. target: Nullable<AbstractMesh>, scene: Scene);
  41568. private _follow;
  41569. /** @hidden */
  41570. _checkInputs(): void;
  41571. /**
  41572. * Returns the class name of the object.
  41573. * It is mostly used internally for serialization purposes.
  41574. */
  41575. getClassName(): string;
  41576. }
  41577. }
  41578. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41579. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41580. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41581. import { Nullable } from "babylonjs/types";
  41582. /**
  41583. * Manage the keyboard inputs to control the movement of a follow camera.
  41584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41585. */
  41586. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41587. /**
  41588. * Defines the camera the input is attached to.
  41589. */
  41590. camera: FollowCamera;
  41591. /**
  41592. * Defines the list of key codes associated with the up action (increase heightOffset)
  41593. */
  41594. keysHeightOffsetIncr: number[];
  41595. /**
  41596. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41597. */
  41598. keysHeightOffsetDecr: number[];
  41599. /**
  41600. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41601. */
  41602. keysHeightOffsetModifierAlt: boolean;
  41603. /**
  41604. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41605. */
  41606. keysHeightOffsetModifierCtrl: boolean;
  41607. /**
  41608. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41609. */
  41610. keysHeightOffsetModifierShift: boolean;
  41611. /**
  41612. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41613. */
  41614. keysRotationOffsetIncr: number[];
  41615. /**
  41616. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41617. */
  41618. keysRotationOffsetDecr: number[];
  41619. /**
  41620. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41621. */
  41622. keysRotationOffsetModifierAlt: boolean;
  41623. /**
  41624. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41625. */
  41626. keysRotationOffsetModifierCtrl: boolean;
  41627. /**
  41628. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41629. */
  41630. keysRotationOffsetModifierShift: boolean;
  41631. /**
  41632. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41633. */
  41634. keysRadiusIncr: number[];
  41635. /**
  41636. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41637. */
  41638. keysRadiusDecr: number[];
  41639. /**
  41640. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41641. */
  41642. keysRadiusModifierAlt: boolean;
  41643. /**
  41644. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41645. */
  41646. keysRadiusModifierCtrl: boolean;
  41647. /**
  41648. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41649. */
  41650. keysRadiusModifierShift: boolean;
  41651. /**
  41652. * Defines the rate of change of heightOffset.
  41653. */
  41654. heightSensibility: number;
  41655. /**
  41656. * Defines the rate of change of rotationOffset.
  41657. */
  41658. rotationSensibility: number;
  41659. /**
  41660. * Defines the rate of change of radius.
  41661. */
  41662. radiusSensibility: number;
  41663. private _keys;
  41664. private _ctrlPressed;
  41665. private _altPressed;
  41666. private _shiftPressed;
  41667. private _onCanvasBlurObserver;
  41668. private _onKeyboardObserver;
  41669. private _engine;
  41670. private _scene;
  41671. /**
  41672. * Attach the input controls to a specific dom element to get the input from.
  41673. * @param element Defines the element the controls should be listened from
  41674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41675. */
  41676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41677. /**
  41678. * Detach the current controls from the specified dom element.
  41679. * @param element Defines the element to stop listening the inputs from
  41680. */
  41681. detachControl(element: Nullable<HTMLElement>): void;
  41682. /**
  41683. * Update the current camera state depending on the inputs that have been used this frame.
  41684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41685. */
  41686. checkInputs(): void;
  41687. /**
  41688. * Gets the class name of the current input.
  41689. * @returns the class name
  41690. */
  41691. getClassName(): string;
  41692. /**
  41693. * Get the friendly name associated with the input class.
  41694. * @returns the input friendly name
  41695. */
  41696. getSimpleName(): string;
  41697. /**
  41698. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41699. * allow modification of the heightOffset value.
  41700. */
  41701. private _modifierHeightOffset;
  41702. /**
  41703. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41704. * allow modification of the rotationOffset value.
  41705. */
  41706. private _modifierRotationOffset;
  41707. /**
  41708. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41709. * allow modification of the radius value.
  41710. */
  41711. private _modifierRadius;
  41712. }
  41713. }
  41714. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41715. import { Nullable } from "babylonjs/types";
  41716. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41717. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41718. import { Observable } from "babylonjs/Misc/observable";
  41719. module "babylonjs/Cameras/freeCameraInputsManager" {
  41720. interface FreeCameraInputsManager {
  41721. /**
  41722. * @hidden
  41723. */
  41724. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41725. /**
  41726. * Add orientation input support to the input manager.
  41727. * @returns the current input manager
  41728. */
  41729. addDeviceOrientation(): FreeCameraInputsManager;
  41730. }
  41731. }
  41732. /**
  41733. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41734. * Screen rotation is taken into account.
  41735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41736. */
  41737. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41738. private _camera;
  41739. private _screenOrientationAngle;
  41740. private _constantTranform;
  41741. private _screenQuaternion;
  41742. private _alpha;
  41743. private _beta;
  41744. private _gamma;
  41745. /**
  41746. * Can be used to detect if a device orientation sensor is available on a device
  41747. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41748. * @returns a promise that will resolve on orientation change
  41749. */
  41750. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41751. /**
  41752. * @hidden
  41753. */
  41754. _onDeviceOrientationChangedObservable: Observable<void>;
  41755. /**
  41756. * Instantiates a new input
  41757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41758. */
  41759. constructor();
  41760. /**
  41761. * Define the camera controlled by the input.
  41762. */
  41763. get camera(): FreeCamera;
  41764. set camera(camera: FreeCamera);
  41765. /**
  41766. * Attach the input controls to a specific dom element to get the input from.
  41767. * @param element Defines the element the controls should be listened from
  41768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41769. */
  41770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41771. private _orientationChanged;
  41772. private _deviceOrientation;
  41773. /**
  41774. * Detach the current controls from the specified dom element.
  41775. * @param element Defines the element to stop listening the inputs from
  41776. */
  41777. detachControl(element: Nullable<HTMLElement>): void;
  41778. /**
  41779. * Update the current camera state depending on the inputs that have been used this frame.
  41780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41781. */
  41782. checkInputs(): void;
  41783. /**
  41784. * Gets the class name of the current intput.
  41785. * @returns the class name
  41786. */
  41787. getClassName(): string;
  41788. /**
  41789. * Get the friendly name associated with the input class.
  41790. * @returns the input friendly name
  41791. */
  41792. getSimpleName(): string;
  41793. }
  41794. }
  41795. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41796. import { Nullable } from "babylonjs/types";
  41797. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41798. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41799. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41800. /**
  41801. * Manage the gamepad inputs to control a free camera.
  41802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41803. */
  41804. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41805. /**
  41806. * Define the camera the input is attached to.
  41807. */
  41808. camera: FreeCamera;
  41809. /**
  41810. * Define the Gamepad controlling the input
  41811. */
  41812. gamepad: Nullable<Gamepad>;
  41813. /**
  41814. * Defines the gamepad rotation sensiblity.
  41815. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41816. */
  41817. gamepadAngularSensibility: number;
  41818. /**
  41819. * Defines the gamepad move sensiblity.
  41820. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41821. */
  41822. gamepadMoveSensibility: number;
  41823. private _yAxisScale;
  41824. /**
  41825. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41826. */
  41827. get invertYAxis(): boolean;
  41828. set invertYAxis(value: boolean);
  41829. private _onGamepadConnectedObserver;
  41830. private _onGamepadDisconnectedObserver;
  41831. private _cameraTransform;
  41832. private _deltaTransform;
  41833. private _vector3;
  41834. private _vector2;
  41835. /**
  41836. * Attach the input controls to a specific dom element to get the input from.
  41837. * @param element Defines the element the controls should be listened from
  41838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41839. */
  41840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41841. /**
  41842. * Detach the current controls from the specified dom element.
  41843. * @param element Defines the element to stop listening the inputs from
  41844. */
  41845. detachControl(element: Nullable<HTMLElement>): void;
  41846. /**
  41847. * Update the current camera state depending on the inputs that have been used this frame.
  41848. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41849. */
  41850. checkInputs(): void;
  41851. /**
  41852. * Gets the class name of the current intput.
  41853. * @returns the class name
  41854. */
  41855. getClassName(): string;
  41856. /**
  41857. * Get the friendly name associated with the input class.
  41858. * @returns the input friendly name
  41859. */
  41860. getSimpleName(): string;
  41861. }
  41862. }
  41863. declare module "babylonjs/Misc/virtualJoystick" {
  41864. import { Nullable } from "babylonjs/types";
  41865. import { Vector3 } from "babylonjs/Maths/math.vector";
  41866. /**
  41867. * Defines the potential axis of a Joystick
  41868. */
  41869. export enum JoystickAxis {
  41870. /** X axis */
  41871. X = 0,
  41872. /** Y axis */
  41873. Y = 1,
  41874. /** Z axis */
  41875. Z = 2
  41876. }
  41877. /**
  41878. * Class used to define virtual joystick (used in touch mode)
  41879. */
  41880. export class VirtualJoystick {
  41881. /**
  41882. * Gets or sets a boolean indicating that left and right values must be inverted
  41883. */
  41884. reverseLeftRight: boolean;
  41885. /**
  41886. * Gets or sets a boolean indicating that up and down values must be inverted
  41887. */
  41888. reverseUpDown: boolean;
  41889. /**
  41890. * Gets the offset value for the position (ie. the change of the position value)
  41891. */
  41892. deltaPosition: Vector3;
  41893. /**
  41894. * Gets a boolean indicating if the virtual joystick was pressed
  41895. */
  41896. pressed: boolean;
  41897. /**
  41898. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41899. */
  41900. static Canvas: Nullable<HTMLCanvasElement>;
  41901. private static _globalJoystickIndex;
  41902. private static vjCanvasContext;
  41903. private static vjCanvasWidth;
  41904. private static vjCanvasHeight;
  41905. private static halfWidth;
  41906. private _action;
  41907. private _axisTargetedByLeftAndRight;
  41908. private _axisTargetedByUpAndDown;
  41909. private _joystickSensibility;
  41910. private _inversedSensibility;
  41911. private _joystickPointerID;
  41912. private _joystickColor;
  41913. private _joystickPointerPos;
  41914. private _joystickPreviousPointerPos;
  41915. private _joystickPointerStartPos;
  41916. private _deltaJoystickVector;
  41917. private _leftJoystick;
  41918. private _touches;
  41919. private _onPointerDownHandlerRef;
  41920. private _onPointerMoveHandlerRef;
  41921. private _onPointerUpHandlerRef;
  41922. private _onResize;
  41923. /**
  41924. * Creates a new virtual joystick
  41925. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41926. */
  41927. constructor(leftJoystick?: boolean);
  41928. /**
  41929. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41930. * @param newJoystickSensibility defines the new sensibility
  41931. */
  41932. setJoystickSensibility(newJoystickSensibility: number): void;
  41933. private _onPointerDown;
  41934. private _onPointerMove;
  41935. private _onPointerUp;
  41936. /**
  41937. * Change the color of the virtual joystick
  41938. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41939. */
  41940. setJoystickColor(newColor: string): void;
  41941. /**
  41942. * Defines a callback to call when the joystick is touched
  41943. * @param action defines the callback
  41944. */
  41945. setActionOnTouch(action: () => any): void;
  41946. /**
  41947. * Defines which axis you'd like to control for left & right
  41948. * @param axis defines the axis to use
  41949. */
  41950. setAxisForLeftRight(axis: JoystickAxis): void;
  41951. /**
  41952. * Defines which axis you'd like to control for up & down
  41953. * @param axis defines the axis to use
  41954. */
  41955. setAxisForUpDown(axis: JoystickAxis): void;
  41956. private _drawVirtualJoystick;
  41957. /**
  41958. * Release internal HTML canvas
  41959. */
  41960. releaseCanvas(): void;
  41961. }
  41962. }
  41963. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41964. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41965. import { Nullable } from "babylonjs/types";
  41966. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41967. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41968. module "babylonjs/Cameras/freeCameraInputsManager" {
  41969. interface FreeCameraInputsManager {
  41970. /**
  41971. * Add virtual joystick input support to the input manager.
  41972. * @returns the current input manager
  41973. */
  41974. addVirtualJoystick(): FreeCameraInputsManager;
  41975. }
  41976. }
  41977. /**
  41978. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41980. */
  41981. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41982. /**
  41983. * Defines the camera the input is attached to.
  41984. */
  41985. camera: FreeCamera;
  41986. private _leftjoystick;
  41987. private _rightjoystick;
  41988. /**
  41989. * Gets the left stick of the virtual joystick.
  41990. * @returns The virtual Joystick
  41991. */
  41992. getLeftJoystick(): VirtualJoystick;
  41993. /**
  41994. * Gets the right stick of the virtual joystick.
  41995. * @returns The virtual Joystick
  41996. */
  41997. getRightJoystick(): VirtualJoystick;
  41998. /**
  41999. * Update the current camera state depending on the inputs that have been used this frame.
  42000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42001. */
  42002. checkInputs(): void;
  42003. /**
  42004. * Attach the input controls to a specific dom element to get the input from.
  42005. * @param element Defines the element the controls should be listened from
  42006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42007. */
  42008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42009. /**
  42010. * Detach the current controls from the specified dom element.
  42011. * @param element Defines the element to stop listening the inputs from
  42012. */
  42013. detachControl(element: Nullable<HTMLElement>): void;
  42014. /**
  42015. * Gets the class name of the current intput.
  42016. * @returns the class name
  42017. */
  42018. getClassName(): string;
  42019. /**
  42020. * Get the friendly name associated with the input class.
  42021. * @returns the input friendly name
  42022. */
  42023. getSimpleName(): string;
  42024. }
  42025. }
  42026. declare module "babylonjs/Cameras/Inputs/index" {
  42027. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42028. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42029. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42030. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42031. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42032. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42033. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42034. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42035. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42036. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42037. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42038. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42039. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42040. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42041. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42042. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42043. }
  42044. declare module "babylonjs/Cameras/touchCamera" {
  42045. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42046. import { Scene } from "babylonjs/scene";
  42047. import { Vector3 } from "babylonjs/Maths/math.vector";
  42048. /**
  42049. * This represents a FPS type of camera controlled by touch.
  42050. * This is like a universal camera minus the Gamepad controls.
  42051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42052. */
  42053. export class TouchCamera extends FreeCamera {
  42054. /**
  42055. * Defines the touch sensibility for rotation.
  42056. * The higher the faster.
  42057. */
  42058. get touchAngularSensibility(): number;
  42059. set touchAngularSensibility(value: number);
  42060. /**
  42061. * Defines the touch sensibility for move.
  42062. * The higher the faster.
  42063. */
  42064. get touchMoveSensibility(): number;
  42065. set touchMoveSensibility(value: number);
  42066. /**
  42067. * Instantiates a new touch camera.
  42068. * This represents a FPS type of camera controlled by touch.
  42069. * This is like a universal camera minus the Gamepad controls.
  42070. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42071. * @param name Define the name of the camera in the scene
  42072. * @param position Define the start position of the camera in the scene
  42073. * @param scene Define the scene the camera belongs to
  42074. */
  42075. constructor(name: string, position: Vector3, scene: Scene);
  42076. /**
  42077. * Gets the current object class name.
  42078. * @return the class name
  42079. */
  42080. getClassName(): string;
  42081. /** @hidden */
  42082. _setupInputs(): void;
  42083. }
  42084. }
  42085. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42086. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42087. import { Scene } from "babylonjs/scene";
  42088. import { Vector3 } from "babylonjs/Maths/math.vector";
  42089. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42090. import { Axis } from "babylonjs/Maths/math.axis";
  42091. /**
  42092. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42093. * being tilted forward or back and left or right.
  42094. */
  42095. export class DeviceOrientationCamera extends FreeCamera {
  42096. private _initialQuaternion;
  42097. private _quaternionCache;
  42098. private _tmpDragQuaternion;
  42099. private _disablePointerInputWhenUsingDeviceOrientation;
  42100. /**
  42101. * Creates a new device orientation camera
  42102. * @param name The name of the camera
  42103. * @param position The start position camera
  42104. * @param scene The scene the camera belongs to
  42105. */
  42106. constructor(name: string, position: Vector3, scene: Scene);
  42107. /**
  42108. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42109. */
  42110. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42111. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42112. private _dragFactor;
  42113. /**
  42114. * Enabled turning on the y axis when the orientation sensor is active
  42115. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42116. */
  42117. enableHorizontalDragging(dragFactor?: number): void;
  42118. /**
  42119. * Gets the current instance class name ("DeviceOrientationCamera").
  42120. * This helps avoiding instanceof at run time.
  42121. * @returns the class name
  42122. */
  42123. getClassName(): string;
  42124. /**
  42125. * @hidden
  42126. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42127. */
  42128. _checkInputs(): void;
  42129. /**
  42130. * Reset the camera to its default orientation on the specified axis only.
  42131. * @param axis The axis to reset
  42132. */
  42133. resetToCurrentRotation(axis?: Axis): void;
  42134. }
  42135. }
  42136. declare module "babylonjs/Gamepads/xboxGamepad" {
  42137. import { Observable } from "babylonjs/Misc/observable";
  42138. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42139. /**
  42140. * Defines supported buttons for XBox360 compatible gamepads
  42141. */
  42142. export enum Xbox360Button {
  42143. /** A */
  42144. A = 0,
  42145. /** B */
  42146. B = 1,
  42147. /** X */
  42148. X = 2,
  42149. /** Y */
  42150. Y = 3,
  42151. /** Start */
  42152. Start = 4,
  42153. /** Back */
  42154. Back = 5,
  42155. /** Left button */
  42156. LB = 6,
  42157. /** Right button */
  42158. RB = 7,
  42159. /** Left stick */
  42160. LeftStick = 8,
  42161. /** Right stick */
  42162. RightStick = 9
  42163. }
  42164. /** Defines values for XBox360 DPad */
  42165. export enum Xbox360Dpad {
  42166. /** Up */
  42167. Up = 0,
  42168. /** Down */
  42169. Down = 1,
  42170. /** Left */
  42171. Left = 2,
  42172. /** Right */
  42173. Right = 3
  42174. }
  42175. /**
  42176. * Defines a XBox360 gamepad
  42177. */
  42178. export class Xbox360Pad extends Gamepad {
  42179. private _leftTrigger;
  42180. private _rightTrigger;
  42181. private _onlefttriggerchanged;
  42182. private _onrighttriggerchanged;
  42183. private _onbuttondown;
  42184. private _onbuttonup;
  42185. private _ondpaddown;
  42186. private _ondpadup;
  42187. /** Observable raised when a button is pressed */
  42188. onButtonDownObservable: Observable<Xbox360Button>;
  42189. /** Observable raised when a button is released */
  42190. onButtonUpObservable: Observable<Xbox360Button>;
  42191. /** Observable raised when a pad is pressed */
  42192. onPadDownObservable: Observable<Xbox360Dpad>;
  42193. /** Observable raised when a pad is released */
  42194. onPadUpObservable: Observable<Xbox360Dpad>;
  42195. private _buttonA;
  42196. private _buttonB;
  42197. private _buttonX;
  42198. private _buttonY;
  42199. private _buttonBack;
  42200. private _buttonStart;
  42201. private _buttonLB;
  42202. private _buttonRB;
  42203. private _buttonLeftStick;
  42204. private _buttonRightStick;
  42205. private _dPadUp;
  42206. private _dPadDown;
  42207. private _dPadLeft;
  42208. private _dPadRight;
  42209. private _isXboxOnePad;
  42210. /**
  42211. * Creates a new XBox360 gamepad object
  42212. * @param id defines the id of this gamepad
  42213. * @param index defines its index
  42214. * @param gamepad defines the internal HTML gamepad object
  42215. * @param xboxOne defines if it is a XBox One gamepad
  42216. */
  42217. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42218. /**
  42219. * Defines the callback to call when left trigger is pressed
  42220. * @param callback defines the callback to use
  42221. */
  42222. onlefttriggerchanged(callback: (value: number) => void): void;
  42223. /**
  42224. * Defines the callback to call when right trigger is pressed
  42225. * @param callback defines the callback to use
  42226. */
  42227. onrighttriggerchanged(callback: (value: number) => void): void;
  42228. /**
  42229. * Gets the left trigger value
  42230. */
  42231. get leftTrigger(): number;
  42232. /**
  42233. * Sets the left trigger value
  42234. */
  42235. set leftTrigger(newValue: number);
  42236. /**
  42237. * Gets the right trigger value
  42238. */
  42239. get rightTrigger(): number;
  42240. /**
  42241. * Sets the right trigger value
  42242. */
  42243. set rightTrigger(newValue: number);
  42244. /**
  42245. * Defines the callback to call when a button is pressed
  42246. * @param callback defines the callback to use
  42247. */
  42248. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42249. /**
  42250. * Defines the callback to call when a button is released
  42251. * @param callback defines the callback to use
  42252. */
  42253. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42254. /**
  42255. * Defines the callback to call when a pad is pressed
  42256. * @param callback defines the callback to use
  42257. */
  42258. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42259. /**
  42260. * Defines the callback to call when a pad is released
  42261. * @param callback defines the callback to use
  42262. */
  42263. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42264. private _setButtonValue;
  42265. private _setDPadValue;
  42266. /**
  42267. * Gets the value of the `A` button
  42268. */
  42269. get buttonA(): number;
  42270. /**
  42271. * Sets the value of the `A` button
  42272. */
  42273. set buttonA(value: number);
  42274. /**
  42275. * Gets the value of the `B` button
  42276. */
  42277. get buttonB(): number;
  42278. /**
  42279. * Sets the value of the `B` button
  42280. */
  42281. set buttonB(value: number);
  42282. /**
  42283. * Gets the value of the `X` button
  42284. */
  42285. get buttonX(): number;
  42286. /**
  42287. * Sets the value of the `X` button
  42288. */
  42289. set buttonX(value: number);
  42290. /**
  42291. * Gets the value of the `Y` button
  42292. */
  42293. get buttonY(): number;
  42294. /**
  42295. * Sets the value of the `Y` button
  42296. */
  42297. set buttonY(value: number);
  42298. /**
  42299. * Gets the value of the `Start` button
  42300. */
  42301. get buttonStart(): number;
  42302. /**
  42303. * Sets the value of the `Start` button
  42304. */
  42305. set buttonStart(value: number);
  42306. /**
  42307. * Gets the value of the `Back` button
  42308. */
  42309. get buttonBack(): number;
  42310. /**
  42311. * Sets the value of the `Back` button
  42312. */
  42313. set buttonBack(value: number);
  42314. /**
  42315. * Gets the value of the `Left` button
  42316. */
  42317. get buttonLB(): number;
  42318. /**
  42319. * Sets the value of the `Left` button
  42320. */
  42321. set buttonLB(value: number);
  42322. /**
  42323. * Gets the value of the `Right` button
  42324. */
  42325. get buttonRB(): number;
  42326. /**
  42327. * Sets the value of the `Right` button
  42328. */
  42329. set buttonRB(value: number);
  42330. /**
  42331. * Gets the value of the Left joystick
  42332. */
  42333. get buttonLeftStick(): number;
  42334. /**
  42335. * Sets the value of the Left joystick
  42336. */
  42337. set buttonLeftStick(value: number);
  42338. /**
  42339. * Gets the value of the Right joystick
  42340. */
  42341. get buttonRightStick(): number;
  42342. /**
  42343. * Sets the value of the Right joystick
  42344. */
  42345. set buttonRightStick(value: number);
  42346. /**
  42347. * Gets the value of D-pad up
  42348. */
  42349. get dPadUp(): number;
  42350. /**
  42351. * Sets the value of D-pad up
  42352. */
  42353. set dPadUp(value: number);
  42354. /**
  42355. * Gets the value of D-pad down
  42356. */
  42357. get dPadDown(): number;
  42358. /**
  42359. * Sets the value of D-pad down
  42360. */
  42361. set dPadDown(value: number);
  42362. /**
  42363. * Gets the value of D-pad left
  42364. */
  42365. get dPadLeft(): number;
  42366. /**
  42367. * Sets the value of D-pad left
  42368. */
  42369. set dPadLeft(value: number);
  42370. /**
  42371. * Gets the value of D-pad right
  42372. */
  42373. get dPadRight(): number;
  42374. /**
  42375. * Sets the value of D-pad right
  42376. */
  42377. set dPadRight(value: number);
  42378. /**
  42379. * Force the gamepad to synchronize with device values
  42380. */
  42381. update(): void;
  42382. /**
  42383. * Disposes the gamepad
  42384. */
  42385. dispose(): void;
  42386. }
  42387. }
  42388. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42389. import { Observable } from "babylonjs/Misc/observable";
  42390. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42391. /**
  42392. * Defines supported buttons for DualShock compatible gamepads
  42393. */
  42394. export enum DualShockButton {
  42395. /** Cross */
  42396. Cross = 0,
  42397. /** Circle */
  42398. Circle = 1,
  42399. /** Square */
  42400. Square = 2,
  42401. /** Triangle */
  42402. Triangle = 3,
  42403. /** Options */
  42404. Options = 4,
  42405. /** Share */
  42406. Share = 5,
  42407. /** L1 */
  42408. L1 = 6,
  42409. /** R1 */
  42410. R1 = 7,
  42411. /** Left stick */
  42412. LeftStick = 8,
  42413. /** Right stick */
  42414. RightStick = 9
  42415. }
  42416. /** Defines values for DualShock DPad */
  42417. export enum DualShockDpad {
  42418. /** Up */
  42419. Up = 0,
  42420. /** Down */
  42421. Down = 1,
  42422. /** Left */
  42423. Left = 2,
  42424. /** Right */
  42425. Right = 3
  42426. }
  42427. /**
  42428. * Defines a DualShock gamepad
  42429. */
  42430. export class DualShockPad extends Gamepad {
  42431. private _leftTrigger;
  42432. private _rightTrigger;
  42433. private _onlefttriggerchanged;
  42434. private _onrighttriggerchanged;
  42435. private _onbuttondown;
  42436. private _onbuttonup;
  42437. private _ondpaddown;
  42438. private _ondpadup;
  42439. /** Observable raised when a button is pressed */
  42440. onButtonDownObservable: Observable<DualShockButton>;
  42441. /** Observable raised when a button is released */
  42442. onButtonUpObservable: Observable<DualShockButton>;
  42443. /** Observable raised when a pad is pressed */
  42444. onPadDownObservable: Observable<DualShockDpad>;
  42445. /** Observable raised when a pad is released */
  42446. onPadUpObservable: Observable<DualShockDpad>;
  42447. private _buttonCross;
  42448. private _buttonCircle;
  42449. private _buttonSquare;
  42450. private _buttonTriangle;
  42451. private _buttonShare;
  42452. private _buttonOptions;
  42453. private _buttonL1;
  42454. private _buttonR1;
  42455. private _buttonLeftStick;
  42456. private _buttonRightStick;
  42457. private _dPadUp;
  42458. private _dPadDown;
  42459. private _dPadLeft;
  42460. private _dPadRight;
  42461. /**
  42462. * Creates a new DualShock gamepad object
  42463. * @param id defines the id of this gamepad
  42464. * @param index defines its index
  42465. * @param gamepad defines the internal HTML gamepad object
  42466. */
  42467. constructor(id: string, index: number, gamepad: any);
  42468. /**
  42469. * Defines the callback to call when left trigger is pressed
  42470. * @param callback defines the callback to use
  42471. */
  42472. onlefttriggerchanged(callback: (value: number) => void): void;
  42473. /**
  42474. * Defines the callback to call when right trigger is pressed
  42475. * @param callback defines the callback to use
  42476. */
  42477. onrighttriggerchanged(callback: (value: number) => void): void;
  42478. /**
  42479. * Gets the left trigger value
  42480. */
  42481. get leftTrigger(): number;
  42482. /**
  42483. * Sets the left trigger value
  42484. */
  42485. set leftTrigger(newValue: number);
  42486. /**
  42487. * Gets the right trigger value
  42488. */
  42489. get rightTrigger(): number;
  42490. /**
  42491. * Sets the right trigger value
  42492. */
  42493. set rightTrigger(newValue: number);
  42494. /**
  42495. * Defines the callback to call when a button is pressed
  42496. * @param callback defines the callback to use
  42497. */
  42498. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42499. /**
  42500. * Defines the callback to call when a button is released
  42501. * @param callback defines the callback to use
  42502. */
  42503. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42504. /**
  42505. * Defines the callback to call when a pad is pressed
  42506. * @param callback defines the callback to use
  42507. */
  42508. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42509. /**
  42510. * Defines the callback to call when a pad is released
  42511. * @param callback defines the callback to use
  42512. */
  42513. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42514. private _setButtonValue;
  42515. private _setDPadValue;
  42516. /**
  42517. * Gets the value of the `Cross` button
  42518. */
  42519. get buttonCross(): number;
  42520. /**
  42521. * Sets the value of the `Cross` button
  42522. */
  42523. set buttonCross(value: number);
  42524. /**
  42525. * Gets the value of the `Circle` button
  42526. */
  42527. get buttonCircle(): number;
  42528. /**
  42529. * Sets the value of the `Circle` button
  42530. */
  42531. set buttonCircle(value: number);
  42532. /**
  42533. * Gets the value of the `Square` button
  42534. */
  42535. get buttonSquare(): number;
  42536. /**
  42537. * Sets the value of the `Square` button
  42538. */
  42539. set buttonSquare(value: number);
  42540. /**
  42541. * Gets the value of the `Triangle` button
  42542. */
  42543. get buttonTriangle(): number;
  42544. /**
  42545. * Sets the value of the `Triangle` button
  42546. */
  42547. set buttonTriangle(value: number);
  42548. /**
  42549. * Gets the value of the `Options` button
  42550. */
  42551. get buttonOptions(): number;
  42552. /**
  42553. * Sets the value of the `Options` button
  42554. */
  42555. set buttonOptions(value: number);
  42556. /**
  42557. * Gets the value of the `Share` button
  42558. */
  42559. get buttonShare(): number;
  42560. /**
  42561. * Sets the value of the `Share` button
  42562. */
  42563. set buttonShare(value: number);
  42564. /**
  42565. * Gets the value of the `L1` button
  42566. */
  42567. get buttonL1(): number;
  42568. /**
  42569. * Sets the value of the `L1` button
  42570. */
  42571. set buttonL1(value: number);
  42572. /**
  42573. * Gets the value of the `R1` button
  42574. */
  42575. get buttonR1(): number;
  42576. /**
  42577. * Sets the value of the `R1` button
  42578. */
  42579. set buttonR1(value: number);
  42580. /**
  42581. * Gets the value of the Left joystick
  42582. */
  42583. get buttonLeftStick(): number;
  42584. /**
  42585. * Sets the value of the Left joystick
  42586. */
  42587. set buttonLeftStick(value: number);
  42588. /**
  42589. * Gets the value of the Right joystick
  42590. */
  42591. get buttonRightStick(): number;
  42592. /**
  42593. * Sets the value of the Right joystick
  42594. */
  42595. set buttonRightStick(value: number);
  42596. /**
  42597. * Gets the value of D-pad up
  42598. */
  42599. get dPadUp(): number;
  42600. /**
  42601. * Sets the value of D-pad up
  42602. */
  42603. set dPadUp(value: number);
  42604. /**
  42605. * Gets the value of D-pad down
  42606. */
  42607. get dPadDown(): number;
  42608. /**
  42609. * Sets the value of D-pad down
  42610. */
  42611. set dPadDown(value: number);
  42612. /**
  42613. * Gets the value of D-pad left
  42614. */
  42615. get dPadLeft(): number;
  42616. /**
  42617. * Sets the value of D-pad left
  42618. */
  42619. set dPadLeft(value: number);
  42620. /**
  42621. * Gets the value of D-pad right
  42622. */
  42623. get dPadRight(): number;
  42624. /**
  42625. * Sets the value of D-pad right
  42626. */
  42627. set dPadRight(value: number);
  42628. /**
  42629. * Force the gamepad to synchronize with device values
  42630. */
  42631. update(): void;
  42632. /**
  42633. * Disposes the gamepad
  42634. */
  42635. dispose(): void;
  42636. }
  42637. }
  42638. declare module "babylonjs/Gamepads/gamepadManager" {
  42639. import { Observable } from "babylonjs/Misc/observable";
  42640. import { Nullable } from "babylonjs/types";
  42641. import { Scene } from "babylonjs/scene";
  42642. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42643. /**
  42644. * Manager for handling gamepads
  42645. */
  42646. export class GamepadManager {
  42647. private _scene?;
  42648. private _babylonGamepads;
  42649. private _oneGamepadConnected;
  42650. /** @hidden */
  42651. _isMonitoring: boolean;
  42652. private _gamepadEventSupported;
  42653. private _gamepadSupport?;
  42654. /**
  42655. * observable to be triggered when the gamepad controller has been connected
  42656. */
  42657. onGamepadConnectedObservable: Observable<Gamepad>;
  42658. /**
  42659. * observable to be triggered when the gamepad controller has been disconnected
  42660. */
  42661. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42662. private _onGamepadConnectedEvent;
  42663. private _onGamepadDisconnectedEvent;
  42664. /**
  42665. * Initializes the gamepad manager
  42666. * @param _scene BabylonJS scene
  42667. */
  42668. constructor(_scene?: Scene | undefined);
  42669. /**
  42670. * The gamepads in the game pad manager
  42671. */
  42672. get gamepads(): Gamepad[];
  42673. /**
  42674. * Get the gamepad controllers based on type
  42675. * @param type The type of gamepad controller
  42676. * @returns Nullable gamepad
  42677. */
  42678. getGamepadByType(type?: number): Nullable<Gamepad>;
  42679. /**
  42680. * Disposes the gamepad manager
  42681. */
  42682. dispose(): void;
  42683. private _addNewGamepad;
  42684. private _startMonitoringGamepads;
  42685. private _stopMonitoringGamepads;
  42686. /** @hidden */
  42687. _checkGamepadsStatus(): void;
  42688. private _updateGamepadObjects;
  42689. }
  42690. }
  42691. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42692. import { Nullable } from "babylonjs/types";
  42693. import { Scene } from "babylonjs/scene";
  42694. import { ISceneComponent } from "babylonjs/sceneComponent";
  42695. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42696. module "babylonjs/scene" {
  42697. interface Scene {
  42698. /** @hidden */
  42699. _gamepadManager: Nullable<GamepadManager>;
  42700. /**
  42701. * Gets the gamepad manager associated with the scene
  42702. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42703. */
  42704. gamepadManager: GamepadManager;
  42705. }
  42706. }
  42707. module "babylonjs/Cameras/freeCameraInputsManager" {
  42708. /**
  42709. * Interface representing a free camera inputs manager
  42710. */
  42711. interface FreeCameraInputsManager {
  42712. /**
  42713. * Adds gamepad input support to the FreeCameraInputsManager.
  42714. * @returns the FreeCameraInputsManager
  42715. */
  42716. addGamepad(): FreeCameraInputsManager;
  42717. }
  42718. }
  42719. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42720. /**
  42721. * Interface representing an arc rotate camera inputs manager
  42722. */
  42723. interface ArcRotateCameraInputsManager {
  42724. /**
  42725. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42726. * @returns the camera inputs manager
  42727. */
  42728. addGamepad(): ArcRotateCameraInputsManager;
  42729. }
  42730. }
  42731. /**
  42732. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42733. */
  42734. export class GamepadSystemSceneComponent implements ISceneComponent {
  42735. /**
  42736. * The component name helpfull to identify the component in the list of scene components.
  42737. */
  42738. readonly name: string;
  42739. /**
  42740. * The scene the component belongs to.
  42741. */
  42742. scene: Scene;
  42743. /**
  42744. * Creates a new instance of the component for the given scene
  42745. * @param scene Defines the scene to register the component in
  42746. */
  42747. constructor(scene: Scene);
  42748. /**
  42749. * Registers the component in a given scene
  42750. */
  42751. register(): void;
  42752. /**
  42753. * Rebuilds the elements related to this component in case of
  42754. * context lost for instance.
  42755. */
  42756. rebuild(): void;
  42757. /**
  42758. * Disposes the component and the associated ressources
  42759. */
  42760. dispose(): void;
  42761. private _beforeCameraUpdate;
  42762. }
  42763. }
  42764. declare module "babylonjs/Cameras/universalCamera" {
  42765. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42766. import { Scene } from "babylonjs/scene";
  42767. import { Vector3 } from "babylonjs/Maths/math.vector";
  42768. import "babylonjs/Gamepads/gamepadSceneComponent";
  42769. /**
  42770. * 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,
  42771. * which still works and will still be found in many Playgrounds.
  42772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42773. */
  42774. export class UniversalCamera extends TouchCamera {
  42775. /**
  42776. * Defines the gamepad rotation sensiblity.
  42777. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42778. */
  42779. get gamepadAngularSensibility(): number;
  42780. set gamepadAngularSensibility(value: number);
  42781. /**
  42782. * Defines the gamepad move sensiblity.
  42783. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42784. */
  42785. get gamepadMoveSensibility(): number;
  42786. set gamepadMoveSensibility(value: number);
  42787. /**
  42788. * 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,
  42789. * which still works and will still be found in many Playgrounds.
  42790. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42791. * @param name Define the name of the camera in the scene
  42792. * @param position Define the start position of the camera in the scene
  42793. * @param scene Define the scene the camera belongs to
  42794. */
  42795. constructor(name: string, position: Vector3, scene: Scene);
  42796. /**
  42797. * Gets the current object class name.
  42798. * @return the class name
  42799. */
  42800. getClassName(): string;
  42801. }
  42802. }
  42803. declare module "babylonjs/Cameras/gamepadCamera" {
  42804. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42805. import { Scene } from "babylonjs/scene";
  42806. import { Vector3 } from "babylonjs/Maths/math.vector";
  42807. /**
  42808. * This represents a FPS type of camera. This is only here for back compat purpose.
  42809. * Please use the UniversalCamera instead as both are identical.
  42810. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42811. */
  42812. export class GamepadCamera extends UniversalCamera {
  42813. /**
  42814. * Instantiates a new Gamepad Camera
  42815. * This represents a FPS type of camera. This is only here for back compat purpose.
  42816. * Please use the UniversalCamera instead as both are identical.
  42817. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42818. * @param name Define the name of the camera in the scene
  42819. * @param position Define the start position of the camera in the scene
  42820. * @param scene Define the scene the camera belongs to
  42821. */
  42822. constructor(name: string, position: Vector3, scene: Scene);
  42823. /**
  42824. * Gets the current object class name.
  42825. * @return the class name
  42826. */
  42827. getClassName(): string;
  42828. }
  42829. }
  42830. declare module "babylonjs/Shaders/pass.fragment" {
  42831. /** @hidden */
  42832. export var passPixelShader: {
  42833. name: string;
  42834. shader: string;
  42835. };
  42836. }
  42837. declare module "babylonjs/Shaders/passCube.fragment" {
  42838. /** @hidden */
  42839. export var passCubePixelShader: {
  42840. name: string;
  42841. shader: string;
  42842. };
  42843. }
  42844. declare module "babylonjs/PostProcesses/passPostProcess" {
  42845. import { Nullable } from "babylonjs/types";
  42846. import { Camera } from "babylonjs/Cameras/camera";
  42847. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42848. import { Engine } from "babylonjs/Engines/engine";
  42849. import "babylonjs/Shaders/pass.fragment";
  42850. import "babylonjs/Shaders/passCube.fragment";
  42851. /**
  42852. * PassPostProcess which produces an output the same as it's input
  42853. */
  42854. export class PassPostProcess extends PostProcess {
  42855. /**
  42856. * Creates the PassPostProcess
  42857. * @param name The name of the effect.
  42858. * @param options The required width/height ratio to downsize to before computing the render pass.
  42859. * @param camera The camera to apply the render pass to.
  42860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42861. * @param engine The engine which the post process will be applied. (default: current engine)
  42862. * @param reusable If the post process can be reused on the same frame. (default: false)
  42863. * @param textureType The type of texture to be used when performing the post processing.
  42864. * @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)
  42865. */
  42866. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42867. }
  42868. /**
  42869. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42870. */
  42871. export class PassCubePostProcess extends PostProcess {
  42872. private _face;
  42873. /**
  42874. * Gets or sets the cube face to display.
  42875. * * 0 is +X
  42876. * * 1 is -X
  42877. * * 2 is +Y
  42878. * * 3 is -Y
  42879. * * 4 is +Z
  42880. * * 5 is -Z
  42881. */
  42882. get face(): number;
  42883. set face(value: number);
  42884. /**
  42885. * Creates the PassCubePostProcess
  42886. * @param name The name of the effect.
  42887. * @param options The required width/height ratio to downsize to before computing the render pass.
  42888. * @param camera The camera to apply the render pass to.
  42889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42890. * @param engine The engine which the post process will be applied. (default: current engine)
  42891. * @param reusable If the post process can be reused on the same frame. (default: false)
  42892. * @param textureType The type of texture to be used when performing the post processing.
  42893. * @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)
  42894. */
  42895. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42896. }
  42897. }
  42898. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42899. /** @hidden */
  42900. export var anaglyphPixelShader: {
  42901. name: string;
  42902. shader: string;
  42903. };
  42904. }
  42905. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42906. import { Engine } from "babylonjs/Engines/engine";
  42907. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42908. import { Camera } from "babylonjs/Cameras/camera";
  42909. import "babylonjs/Shaders/anaglyph.fragment";
  42910. /**
  42911. * Postprocess used to generate anaglyphic rendering
  42912. */
  42913. export class AnaglyphPostProcess extends PostProcess {
  42914. private _passedProcess;
  42915. /**
  42916. * Creates a new AnaglyphPostProcess
  42917. * @param name defines postprocess name
  42918. * @param options defines creation options or target ratio scale
  42919. * @param rigCameras defines cameras using this postprocess
  42920. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42921. * @param engine defines hosting engine
  42922. * @param reusable defines if the postprocess will be reused multiple times per frame
  42923. */
  42924. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42925. }
  42926. }
  42927. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42928. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42929. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42930. import { Scene } from "babylonjs/scene";
  42931. import { Vector3 } from "babylonjs/Maths/math.vector";
  42932. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42933. /**
  42934. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42935. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42936. */
  42937. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42938. /**
  42939. * Creates a new AnaglyphArcRotateCamera
  42940. * @param name defines camera name
  42941. * @param alpha defines alpha angle (in radians)
  42942. * @param beta defines beta angle (in radians)
  42943. * @param radius defines radius
  42944. * @param target defines camera target
  42945. * @param interaxialDistance defines distance between each color axis
  42946. * @param scene defines the hosting scene
  42947. */
  42948. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42949. /**
  42950. * Gets camera class name
  42951. * @returns AnaglyphArcRotateCamera
  42952. */
  42953. getClassName(): string;
  42954. }
  42955. }
  42956. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42957. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42958. import { Scene } from "babylonjs/scene";
  42959. import { Vector3 } from "babylonjs/Maths/math.vector";
  42960. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42961. /**
  42962. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42963. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42964. */
  42965. export class AnaglyphFreeCamera extends FreeCamera {
  42966. /**
  42967. * Creates a new AnaglyphFreeCamera
  42968. * @param name defines camera name
  42969. * @param position defines initial position
  42970. * @param interaxialDistance defines distance between each color axis
  42971. * @param scene defines the hosting scene
  42972. */
  42973. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42974. /**
  42975. * Gets camera class name
  42976. * @returns AnaglyphFreeCamera
  42977. */
  42978. getClassName(): string;
  42979. }
  42980. }
  42981. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42982. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42983. import { Scene } from "babylonjs/scene";
  42984. import { Vector3 } from "babylonjs/Maths/math.vector";
  42985. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42986. /**
  42987. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42988. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42989. */
  42990. export class AnaglyphGamepadCamera extends GamepadCamera {
  42991. /**
  42992. * Creates a new AnaglyphGamepadCamera
  42993. * @param name defines camera name
  42994. * @param position defines initial position
  42995. * @param interaxialDistance defines distance between each color axis
  42996. * @param scene defines the hosting scene
  42997. */
  42998. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42999. /**
  43000. * Gets camera class name
  43001. * @returns AnaglyphGamepadCamera
  43002. */
  43003. getClassName(): string;
  43004. }
  43005. }
  43006. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43007. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43008. import { Scene } from "babylonjs/scene";
  43009. import { Vector3 } from "babylonjs/Maths/math.vector";
  43010. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43011. /**
  43012. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43013. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43014. */
  43015. export class AnaglyphUniversalCamera extends UniversalCamera {
  43016. /**
  43017. * Creates a new AnaglyphUniversalCamera
  43018. * @param name defines camera name
  43019. * @param position defines initial position
  43020. * @param interaxialDistance defines distance between each color axis
  43021. * @param scene defines the hosting scene
  43022. */
  43023. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43024. /**
  43025. * Gets camera class name
  43026. * @returns AnaglyphUniversalCamera
  43027. */
  43028. getClassName(): string;
  43029. }
  43030. }
  43031. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43032. /** @hidden */
  43033. export var stereoscopicInterlacePixelShader: {
  43034. name: string;
  43035. shader: string;
  43036. };
  43037. }
  43038. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43039. import { Camera } from "babylonjs/Cameras/camera";
  43040. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43041. import { Engine } from "babylonjs/Engines/engine";
  43042. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43043. /**
  43044. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43045. */
  43046. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43047. private _stepSize;
  43048. private _passedProcess;
  43049. /**
  43050. * Initializes a StereoscopicInterlacePostProcessI
  43051. * @param name The name of the effect.
  43052. * @param rigCameras The rig cameras to be appled to the post process
  43053. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43054. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43056. * @param engine The engine which the post process will be applied. (default: current engine)
  43057. * @param reusable If the post process can be reused on the same frame. (default: false)
  43058. */
  43059. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43060. }
  43061. /**
  43062. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43063. */
  43064. export class StereoscopicInterlacePostProcess extends PostProcess {
  43065. private _stepSize;
  43066. private _passedProcess;
  43067. /**
  43068. * Initializes a StereoscopicInterlacePostProcess
  43069. * @param name The name of the effect.
  43070. * @param rigCameras The rig cameras to be appled to the post process
  43071. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43073. * @param engine The engine which the post process will be applied. (default: current engine)
  43074. * @param reusable If the post process can be reused on the same frame. (default: false)
  43075. */
  43076. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43077. }
  43078. }
  43079. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43080. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43081. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43082. import { Scene } from "babylonjs/scene";
  43083. import { Vector3 } from "babylonjs/Maths/math.vector";
  43084. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43085. /**
  43086. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43087. * @see http://doc.babylonjs.com/features/cameras
  43088. */
  43089. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43090. /**
  43091. * Creates a new StereoscopicArcRotateCamera
  43092. * @param name defines camera name
  43093. * @param alpha defines alpha angle (in radians)
  43094. * @param beta defines beta angle (in radians)
  43095. * @param radius defines radius
  43096. * @param target defines camera target
  43097. * @param interaxialDistance defines distance between each color axis
  43098. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43099. * @param scene defines the hosting scene
  43100. */
  43101. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43102. /**
  43103. * Gets camera class name
  43104. * @returns StereoscopicArcRotateCamera
  43105. */
  43106. getClassName(): string;
  43107. }
  43108. }
  43109. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43110. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43111. import { Scene } from "babylonjs/scene";
  43112. import { Vector3 } from "babylonjs/Maths/math.vector";
  43113. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43114. /**
  43115. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43116. * @see http://doc.babylonjs.com/features/cameras
  43117. */
  43118. export class StereoscopicFreeCamera extends FreeCamera {
  43119. /**
  43120. * Creates a new StereoscopicFreeCamera
  43121. * @param name defines camera name
  43122. * @param position defines initial position
  43123. * @param interaxialDistance defines distance between each color axis
  43124. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43125. * @param scene defines the hosting scene
  43126. */
  43127. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43128. /**
  43129. * Gets camera class name
  43130. * @returns StereoscopicFreeCamera
  43131. */
  43132. getClassName(): string;
  43133. }
  43134. }
  43135. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43136. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43137. import { Scene } from "babylonjs/scene";
  43138. import { Vector3 } from "babylonjs/Maths/math.vector";
  43139. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43140. /**
  43141. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43142. * @see http://doc.babylonjs.com/features/cameras
  43143. */
  43144. export class StereoscopicGamepadCamera extends GamepadCamera {
  43145. /**
  43146. * Creates a new StereoscopicGamepadCamera
  43147. * @param name defines camera name
  43148. * @param position defines initial position
  43149. * @param interaxialDistance defines distance between each color axis
  43150. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43151. * @param scene defines the hosting scene
  43152. */
  43153. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43154. /**
  43155. * Gets camera class name
  43156. * @returns StereoscopicGamepadCamera
  43157. */
  43158. getClassName(): string;
  43159. }
  43160. }
  43161. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43162. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43163. import { Scene } from "babylonjs/scene";
  43164. import { Vector3 } from "babylonjs/Maths/math.vector";
  43165. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43166. /**
  43167. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43168. * @see http://doc.babylonjs.com/features/cameras
  43169. */
  43170. export class StereoscopicUniversalCamera extends UniversalCamera {
  43171. /**
  43172. * Creates a new StereoscopicUniversalCamera
  43173. * @param name defines camera name
  43174. * @param position defines initial position
  43175. * @param interaxialDistance defines distance between each color axis
  43176. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43177. * @param scene defines the hosting scene
  43178. */
  43179. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43180. /**
  43181. * Gets camera class name
  43182. * @returns StereoscopicUniversalCamera
  43183. */
  43184. getClassName(): string;
  43185. }
  43186. }
  43187. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43188. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43189. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43190. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43191. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43192. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43193. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43194. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43195. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43196. }
  43197. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43198. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43199. import { Scene } from "babylonjs/scene";
  43200. import { Vector3 } from "babylonjs/Maths/math.vector";
  43201. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43202. /**
  43203. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43204. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43205. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43206. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43207. */
  43208. export class VirtualJoysticksCamera extends FreeCamera {
  43209. /**
  43210. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43211. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43212. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43213. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43214. * @param name Define the name of the camera in the scene
  43215. * @param position Define the start position of the camera in the scene
  43216. * @param scene Define the scene the camera belongs to
  43217. */
  43218. constructor(name: string, position: Vector3, scene: Scene);
  43219. /**
  43220. * Gets the current object class name.
  43221. * @return the class name
  43222. */
  43223. getClassName(): string;
  43224. }
  43225. }
  43226. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43227. import { Matrix } from "babylonjs/Maths/math.vector";
  43228. /**
  43229. * This represents all the required metrics to create a VR camera.
  43230. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43231. */
  43232. export class VRCameraMetrics {
  43233. /**
  43234. * Define the horizontal resolution off the screen.
  43235. */
  43236. hResolution: number;
  43237. /**
  43238. * Define the vertical resolution off the screen.
  43239. */
  43240. vResolution: number;
  43241. /**
  43242. * Define the horizontal screen size.
  43243. */
  43244. hScreenSize: number;
  43245. /**
  43246. * Define the vertical screen size.
  43247. */
  43248. vScreenSize: number;
  43249. /**
  43250. * Define the vertical screen center position.
  43251. */
  43252. vScreenCenter: number;
  43253. /**
  43254. * Define the distance of the eyes to the screen.
  43255. */
  43256. eyeToScreenDistance: number;
  43257. /**
  43258. * Define the distance between both lenses
  43259. */
  43260. lensSeparationDistance: number;
  43261. /**
  43262. * Define the distance between both viewer's eyes.
  43263. */
  43264. interpupillaryDistance: number;
  43265. /**
  43266. * Define the distortion factor of the VR postprocess.
  43267. * Please, touch with care.
  43268. */
  43269. distortionK: number[];
  43270. /**
  43271. * Define the chromatic aberration correction factors for the VR post process.
  43272. */
  43273. chromaAbCorrection: number[];
  43274. /**
  43275. * Define the scale factor of the post process.
  43276. * The smaller the better but the slower.
  43277. */
  43278. postProcessScaleFactor: number;
  43279. /**
  43280. * Define an offset for the lens center.
  43281. */
  43282. lensCenterOffset: number;
  43283. /**
  43284. * Define if the current vr camera should compensate the distortion of the lense or not.
  43285. */
  43286. compensateDistortion: boolean;
  43287. /**
  43288. * Defines if multiview should be enabled when rendering (Default: false)
  43289. */
  43290. multiviewEnabled: boolean;
  43291. /**
  43292. * Gets the rendering aspect ratio based on the provided resolutions.
  43293. */
  43294. get aspectRatio(): number;
  43295. /**
  43296. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43297. */
  43298. get aspectRatioFov(): number;
  43299. /**
  43300. * @hidden
  43301. */
  43302. get leftHMatrix(): Matrix;
  43303. /**
  43304. * @hidden
  43305. */
  43306. get rightHMatrix(): Matrix;
  43307. /**
  43308. * @hidden
  43309. */
  43310. get leftPreViewMatrix(): Matrix;
  43311. /**
  43312. * @hidden
  43313. */
  43314. get rightPreViewMatrix(): Matrix;
  43315. /**
  43316. * Get the default VRMetrics based on the most generic setup.
  43317. * @returns the default vr metrics
  43318. */
  43319. static GetDefault(): VRCameraMetrics;
  43320. }
  43321. }
  43322. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43323. /** @hidden */
  43324. export var vrDistortionCorrectionPixelShader: {
  43325. name: string;
  43326. shader: string;
  43327. };
  43328. }
  43329. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43330. import { Camera } from "babylonjs/Cameras/camera";
  43331. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43333. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43334. /**
  43335. * VRDistortionCorrectionPostProcess used for mobile VR
  43336. */
  43337. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43338. private _isRightEye;
  43339. private _distortionFactors;
  43340. private _postProcessScaleFactor;
  43341. private _lensCenterOffset;
  43342. private _scaleIn;
  43343. private _scaleFactor;
  43344. private _lensCenter;
  43345. /**
  43346. * Initializes the VRDistortionCorrectionPostProcess
  43347. * @param name The name of the effect.
  43348. * @param camera The camera to apply the render pass to.
  43349. * @param isRightEye If this is for the right eye distortion
  43350. * @param vrMetrics All the required metrics for the VR camera
  43351. */
  43352. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43353. }
  43354. }
  43355. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43356. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43357. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43358. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43359. import { Scene } from "babylonjs/scene";
  43360. import { Vector3 } from "babylonjs/Maths/math.vector";
  43361. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43362. import "babylonjs/Cameras/RigModes/vrRigMode";
  43363. /**
  43364. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43365. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43366. */
  43367. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43368. /**
  43369. * Creates a new VRDeviceOrientationArcRotateCamera
  43370. * @param name defines camera name
  43371. * @param alpha defines the camera rotation along the logitudinal axis
  43372. * @param beta defines the camera rotation along the latitudinal axis
  43373. * @param radius defines the camera distance from its target
  43374. * @param target defines the camera target
  43375. * @param scene defines the scene the camera belongs to
  43376. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43377. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43378. */
  43379. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43380. /**
  43381. * Gets camera class name
  43382. * @returns VRDeviceOrientationArcRotateCamera
  43383. */
  43384. getClassName(): string;
  43385. }
  43386. }
  43387. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43388. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43389. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43390. import { Scene } from "babylonjs/scene";
  43391. import { Vector3 } from "babylonjs/Maths/math.vector";
  43392. import "babylonjs/Cameras/RigModes/vrRigMode";
  43393. /**
  43394. * Camera used to simulate VR rendering (based on FreeCamera)
  43395. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43396. */
  43397. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43398. /**
  43399. * Creates a new VRDeviceOrientationFreeCamera
  43400. * @param name defines camera name
  43401. * @param position defines the start position of the camera
  43402. * @param scene defines the scene the camera belongs to
  43403. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43404. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43405. */
  43406. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43407. /**
  43408. * Gets camera class name
  43409. * @returns VRDeviceOrientationFreeCamera
  43410. */
  43411. getClassName(): string;
  43412. }
  43413. }
  43414. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43415. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43416. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43417. import { Scene } from "babylonjs/scene";
  43418. import { Vector3 } from "babylonjs/Maths/math.vector";
  43419. import "babylonjs/Gamepads/gamepadSceneComponent";
  43420. /**
  43421. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43422. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43423. */
  43424. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43425. /**
  43426. * Creates a new VRDeviceOrientationGamepadCamera
  43427. * @param name defines camera name
  43428. * @param position defines the start position of the camera
  43429. * @param scene defines the scene the camera belongs to
  43430. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43431. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43432. */
  43433. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43434. /**
  43435. * Gets camera class name
  43436. * @returns VRDeviceOrientationGamepadCamera
  43437. */
  43438. getClassName(): string;
  43439. }
  43440. }
  43441. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43442. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43443. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43444. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43445. /** @hidden */
  43446. export var imageProcessingPixelShader: {
  43447. name: string;
  43448. shader: string;
  43449. };
  43450. }
  43451. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43452. import { Nullable } from "babylonjs/types";
  43453. import { Color4 } from "babylonjs/Maths/math.color";
  43454. import { Camera } from "babylonjs/Cameras/camera";
  43455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43456. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43457. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43458. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43459. import { Engine } from "babylonjs/Engines/engine";
  43460. import "babylonjs/Shaders/imageProcessing.fragment";
  43461. import "babylonjs/Shaders/postprocess.vertex";
  43462. /**
  43463. * ImageProcessingPostProcess
  43464. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43465. */
  43466. export class ImageProcessingPostProcess extends PostProcess {
  43467. /**
  43468. * Default configuration related to image processing available in the PBR Material.
  43469. */
  43470. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43471. /**
  43472. * Gets the image processing configuration used either in this material.
  43473. */
  43474. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43475. /**
  43476. * Sets the Default image processing configuration used either in the this material.
  43477. *
  43478. * If sets to null, the scene one is in use.
  43479. */
  43480. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43481. /**
  43482. * Keep track of the image processing observer to allow dispose and replace.
  43483. */
  43484. private _imageProcessingObserver;
  43485. /**
  43486. * Attaches a new image processing configuration to the PBR Material.
  43487. * @param configuration
  43488. */
  43489. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43490. /**
  43491. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43492. */
  43493. get colorCurves(): Nullable<ColorCurves>;
  43494. /**
  43495. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43496. */
  43497. set colorCurves(value: Nullable<ColorCurves>);
  43498. /**
  43499. * Gets wether the color curves effect is enabled.
  43500. */
  43501. get colorCurvesEnabled(): boolean;
  43502. /**
  43503. * Sets wether the color curves effect is enabled.
  43504. */
  43505. set colorCurvesEnabled(value: boolean);
  43506. /**
  43507. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43508. */
  43509. get colorGradingTexture(): Nullable<BaseTexture>;
  43510. /**
  43511. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43512. */
  43513. set colorGradingTexture(value: Nullable<BaseTexture>);
  43514. /**
  43515. * Gets wether the color grading effect is enabled.
  43516. */
  43517. get colorGradingEnabled(): boolean;
  43518. /**
  43519. * Gets wether the color grading effect is enabled.
  43520. */
  43521. set colorGradingEnabled(value: boolean);
  43522. /**
  43523. * Gets exposure used in the effect.
  43524. */
  43525. get exposure(): number;
  43526. /**
  43527. * Sets exposure used in the effect.
  43528. */
  43529. set exposure(value: number);
  43530. /**
  43531. * Gets wether tonemapping is enabled or not.
  43532. */
  43533. get toneMappingEnabled(): boolean;
  43534. /**
  43535. * Sets wether tonemapping is enabled or not
  43536. */
  43537. set toneMappingEnabled(value: boolean);
  43538. /**
  43539. * Gets the type of tone mapping effect.
  43540. */
  43541. get toneMappingType(): number;
  43542. /**
  43543. * Sets the type of tone mapping effect.
  43544. */
  43545. set toneMappingType(value: number);
  43546. /**
  43547. * Gets contrast used in the effect.
  43548. */
  43549. get contrast(): number;
  43550. /**
  43551. * Sets contrast used in the effect.
  43552. */
  43553. set contrast(value: number);
  43554. /**
  43555. * Gets Vignette stretch size.
  43556. */
  43557. get vignetteStretch(): number;
  43558. /**
  43559. * Sets Vignette stretch size.
  43560. */
  43561. set vignetteStretch(value: number);
  43562. /**
  43563. * Gets Vignette centre X Offset.
  43564. */
  43565. get vignetteCentreX(): number;
  43566. /**
  43567. * Sets Vignette centre X Offset.
  43568. */
  43569. set vignetteCentreX(value: number);
  43570. /**
  43571. * Gets Vignette centre Y Offset.
  43572. */
  43573. get vignetteCentreY(): number;
  43574. /**
  43575. * Sets Vignette centre Y Offset.
  43576. */
  43577. set vignetteCentreY(value: number);
  43578. /**
  43579. * Gets Vignette weight or intensity of the vignette effect.
  43580. */
  43581. get vignetteWeight(): number;
  43582. /**
  43583. * Sets Vignette weight or intensity of the vignette effect.
  43584. */
  43585. set vignetteWeight(value: number);
  43586. /**
  43587. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43588. * if vignetteEnabled is set to true.
  43589. */
  43590. get vignetteColor(): Color4;
  43591. /**
  43592. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43593. * if vignetteEnabled is set to true.
  43594. */
  43595. set vignetteColor(value: Color4);
  43596. /**
  43597. * Gets Camera field of view used by the Vignette effect.
  43598. */
  43599. get vignetteCameraFov(): number;
  43600. /**
  43601. * Sets Camera field of view used by the Vignette effect.
  43602. */
  43603. set vignetteCameraFov(value: number);
  43604. /**
  43605. * Gets the vignette blend mode allowing different kind of effect.
  43606. */
  43607. get vignetteBlendMode(): number;
  43608. /**
  43609. * Sets the vignette blend mode allowing different kind of effect.
  43610. */
  43611. set vignetteBlendMode(value: number);
  43612. /**
  43613. * Gets wether the vignette effect is enabled.
  43614. */
  43615. get vignetteEnabled(): boolean;
  43616. /**
  43617. * Sets wether the vignette effect is enabled.
  43618. */
  43619. set vignetteEnabled(value: boolean);
  43620. private _fromLinearSpace;
  43621. /**
  43622. * Gets wether the input of the processing is in Gamma or Linear Space.
  43623. */
  43624. get fromLinearSpace(): boolean;
  43625. /**
  43626. * Sets wether the input of the processing is in Gamma or Linear Space.
  43627. */
  43628. set fromLinearSpace(value: boolean);
  43629. /**
  43630. * Defines cache preventing GC.
  43631. */
  43632. private _defines;
  43633. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43634. /**
  43635. * "ImageProcessingPostProcess"
  43636. * @returns "ImageProcessingPostProcess"
  43637. */
  43638. getClassName(): string;
  43639. protected _updateParameters(): void;
  43640. dispose(camera?: Camera): void;
  43641. }
  43642. }
  43643. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43644. import { Scene } from "babylonjs/scene";
  43645. import { Color3 } from "babylonjs/Maths/math.color";
  43646. import { Mesh } from "babylonjs/Meshes/mesh";
  43647. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43648. import { Nullable } from "babylonjs/types";
  43649. /**
  43650. * Class containing static functions to help procedurally build meshes
  43651. */
  43652. export class GroundBuilder {
  43653. /**
  43654. * Creates a ground mesh
  43655. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43656. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43658. * @param name defines the name of the mesh
  43659. * @param options defines the options used to create the mesh
  43660. * @param scene defines the hosting scene
  43661. * @returns the ground mesh
  43662. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43663. */
  43664. static CreateGround(name: string, options: {
  43665. width?: number;
  43666. height?: number;
  43667. subdivisions?: number;
  43668. subdivisionsX?: number;
  43669. subdivisionsY?: number;
  43670. updatable?: boolean;
  43671. }, scene: any): Mesh;
  43672. /**
  43673. * Creates a tiled ground mesh
  43674. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43675. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43676. * * 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
  43677. * * 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
  43678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43679. * @param name defines the name of the mesh
  43680. * @param options defines the options used to create the mesh
  43681. * @param scene defines the hosting scene
  43682. * @returns the tiled ground mesh
  43683. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43684. */
  43685. static CreateTiledGround(name: string, options: {
  43686. xmin: number;
  43687. zmin: number;
  43688. xmax: number;
  43689. zmax: number;
  43690. subdivisions?: {
  43691. w: number;
  43692. h: number;
  43693. };
  43694. precision?: {
  43695. w: number;
  43696. h: number;
  43697. };
  43698. updatable?: boolean;
  43699. }, scene?: Nullable<Scene>): Mesh;
  43700. /**
  43701. * Creates a ground mesh from a height map
  43702. * * The parameter `url` sets the URL of the height map image resource.
  43703. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43704. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43705. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43706. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43707. * * 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.
  43708. * * 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).
  43709. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43711. * @param name defines the name of the mesh
  43712. * @param url defines the url to the height map
  43713. * @param options defines the options used to create the mesh
  43714. * @param scene defines the hosting scene
  43715. * @returns the ground mesh
  43716. * @see https://doc.babylonjs.com/babylon101/height_map
  43717. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43718. */
  43719. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43720. width?: number;
  43721. height?: number;
  43722. subdivisions?: number;
  43723. minHeight?: number;
  43724. maxHeight?: number;
  43725. colorFilter?: Color3;
  43726. alphaFilter?: number;
  43727. updatable?: boolean;
  43728. onReady?: (mesh: GroundMesh) => void;
  43729. }, scene?: Nullable<Scene>): GroundMesh;
  43730. }
  43731. }
  43732. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43733. import { Vector4 } from "babylonjs/Maths/math.vector";
  43734. import { Mesh } from "babylonjs/Meshes/mesh";
  43735. /**
  43736. * Class containing static functions to help procedurally build meshes
  43737. */
  43738. export class TorusBuilder {
  43739. /**
  43740. * Creates a torus mesh
  43741. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43742. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43743. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43747. * @param name defines the name of the mesh
  43748. * @param options defines the options used to create the mesh
  43749. * @param scene defines the hosting scene
  43750. * @returns the torus mesh
  43751. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43752. */
  43753. static CreateTorus(name: string, options: {
  43754. diameter?: number;
  43755. thickness?: number;
  43756. tessellation?: number;
  43757. updatable?: boolean;
  43758. sideOrientation?: number;
  43759. frontUVs?: Vector4;
  43760. backUVs?: Vector4;
  43761. }, scene: any): Mesh;
  43762. }
  43763. }
  43764. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43765. import { Vector4 } from "babylonjs/Maths/math.vector";
  43766. import { Color4 } from "babylonjs/Maths/math.color";
  43767. import { Mesh } from "babylonjs/Meshes/mesh";
  43768. /**
  43769. * Class containing static functions to help procedurally build meshes
  43770. */
  43771. export class CylinderBuilder {
  43772. /**
  43773. * Creates a cylinder or a cone mesh
  43774. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43775. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43776. * * 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.
  43777. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43778. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43779. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43780. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43781. * * 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).
  43782. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43783. * * 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).
  43784. * * 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
  43785. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43786. * * 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
  43787. * * 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.
  43788. * * If `enclose` is false, a ring surface is one element.
  43789. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43790. * * 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
  43791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43794. * @param name defines the name of the mesh
  43795. * @param options defines the options used to create the mesh
  43796. * @param scene defines the hosting scene
  43797. * @returns the cylinder mesh
  43798. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43799. */
  43800. static CreateCylinder(name: string, options: {
  43801. height?: number;
  43802. diameterTop?: number;
  43803. diameterBottom?: number;
  43804. diameter?: number;
  43805. tessellation?: number;
  43806. subdivisions?: number;
  43807. arc?: number;
  43808. faceColors?: Color4[];
  43809. faceUV?: Vector4[];
  43810. updatable?: boolean;
  43811. hasRings?: boolean;
  43812. enclose?: boolean;
  43813. cap?: number;
  43814. sideOrientation?: number;
  43815. frontUVs?: Vector4;
  43816. backUVs?: Vector4;
  43817. }, scene: any): Mesh;
  43818. }
  43819. }
  43820. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43821. import { Nullable } from "babylonjs/types";
  43822. import { IDisposable } from "babylonjs/scene";
  43823. /**
  43824. * States of the webXR experience
  43825. */
  43826. export enum WebXRState {
  43827. /**
  43828. * Transitioning to being in XR mode
  43829. */
  43830. ENTERING_XR = 0,
  43831. /**
  43832. * Transitioning to non XR mode
  43833. */
  43834. EXITING_XR = 1,
  43835. /**
  43836. * In XR mode and presenting
  43837. */
  43838. IN_XR = 2,
  43839. /**
  43840. * Not entered XR mode
  43841. */
  43842. NOT_IN_XR = 3
  43843. }
  43844. /**
  43845. * Abstraction of the XR render target
  43846. */
  43847. export interface WebXRRenderTarget extends IDisposable {
  43848. /**
  43849. * xrpresent context of the canvas which can be used to display/mirror xr content
  43850. */
  43851. canvasContext: WebGLRenderingContext;
  43852. /**
  43853. * xr layer for the canvas
  43854. */
  43855. xrLayer: Nullable<XRWebGLLayer>;
  43856. /**
  43857. * Initializes the xr layer for the session
  43858. * @param xrSession xr session
  43859. * @returns a promise that will resolve once the XR Layer has been created
  43860. */
  43861. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43862. }
  43863. }
  43864. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43865. import { Nullable } from "babylonjs/types";
  43866. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43867. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43868. /**
  43869. * COnfiguration object for WebXR output canvas
  43870. */
  43871. export class WebXRManagedOutputCanvasOptions {
  43872. /**
  43873. * Options for this XR Layer output
  43874. */
  43875. canvasOptions?: XRWebGLLayerOptions;
  43876. /**
  43877. * CSS styling for a newly created canvas (if not provided)
  43878. */
  43879. newCanvasCssStyle?: string;
  43880. /**
  43881. * An optional canvas in case you wish to create it yourself and provide it here.
  43882. * If not provided, a new canvas will be created
  43883. */
  43884. canvasElement?: HTMLCanvasElement;
  43885. /**
  43886. * Get the default values of the configuration object
  43887. * @returns default values of this configuration object
  43888. */
  43889. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43890. }
  43891. /**
  43892. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43893. */
  43894. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43895. private _options;
  43896. private _engine;
  43897. private _canvas;
  43898. /**
  43899. * Rendering context of the canvas which can be used to display/mirror xr content
  43900. */
  43901. canvasContext: WebGLRenderingContext;
  43902. /**
  43903. * xr layer for the canvas
  43904. */
  43905. xrLayer: Nullable<XRWebGLLayer>;
  43906. /**
  43907. * Initializes the xr layer for the session
  43908. * @param xrSession xr session
  43909. * @returns a promise that will resolve once the XR Layer has been created
  43910. */
  43911. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43912. /**
  43913. * Initializes the canvas to be added/removed upon entering/exiting xr
  43914. * @param _xrSessionManager The XR Session manager
  43915. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43916. */
  43917. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43918. /**
  43919. * Disposes of the object
  43920. */
  43921. dispose(): void;
  43922. private _setManagedOutputCanvas;
  43923. private _addCanvas;
  43924. private _removeCanvas;
  43925. }
  43926. }
  43927. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43928. import { Observable } from "babylonjs/Misc/observable";
  43929. import { Nullable } from "babylonjs/types";
  43930. import { IDisposable, Scene } from "babylonjs/scene";
  43931. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43932. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43933. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43934. /**
  43935. * Manages an XRSession to work with Babylon's engine
  43936. * @see https://doc.babylonjs.com/how_to/webxr
  43937. */
  43938. export class WebXRSessionManager implements IDisposable {
  43939. /** The scene which the session should be created for */
  43940. scene: Scene;
  43941. /**
  43942. * Fires every time a new xrFrame arrives which can be used to update the camera
  43943. */
  43944. onXRFrameObservable: Observable<XRFrame>;
  43945. /**
  43946. * Fires when the xr session is ended either by the device or manually done
  43947. */
  43948. onXRSessionEnded: Observable<any>;
  43949. /**
  43950. * Fires when the xr session is ended either by the device or manually done
  43951. */
  43952. onXRSessionInit: Observable<XRSession>;
  43953. /**
  43954. * Fires when the reference space changed
  43955. */
  43956. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43957. /**
  43958. * Underlying xr session
  43959. */
  43960. session: XRSession;
  43961. /**
  43962. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43963. * or get the offset the player is currently at.
  43964. */
  43965. viewerReferenceSpace: XRReferenceSpace;
  43966. private _referenceSpace;
  43967. /**
  43968. * The current reference space used in this session. This reference space can constantly change!
  43969. * It is mainly used to offset the camera's position.
  43970. */
  43971. get referenceSpace(): XRReferenceSpace;
  43972. /**
  43973. * Set a new reference space and triggers the observable
  43974. */
  43975. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43976. /**
  43977. * The base reference space from which the session started. good if you want to reset your
  43978. * reference space
  43979. */
  43980. baseReferenceSpace: XRReferenceSpace;
  43981. /**
  43982. * Used just in case of a failure to initialize an immersive session.
  43983. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43984. */
  43985. defaultHeightCompensation: number;
  43986. /**
  43987. * Current XR frame
  43988. */
  43989. currentFrame: Nullable<XRFrame>;
  43990. /** WebXR timestamp updated every frame */
  43991. currentTimestamp: number;
  43992. private _xrNavigator;
  43993. private baseLayer;
  43994. private _rttProvider;
  43995. private _sessionEnded;
  43996. /**
  43997. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43998. * @param scene The scene which the session should be created for
  43999. */
  44000. constructor(
  44001. /** The scene which the session should be created for */
  44002. scene: Scene);
  44003. /**
  44004. * Initializes the manager
  44005. * After initialization enterXR can be called to start an XR session
  44006. * @returns Promise which resolves after it is initialized
  44007. */
  44008. initializeAsync(): Promise<void>;
  44009. /**
  44010. * Initializes an xr session
  44011. * @param xrSessionMode mode to initialize
  44012. * @param xrSessionInit defines optional and required values to pass to the session builder
  44013. * @returns a promise which will resolve once the session has been initialized
  44014. */
  44015. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44016. /**
  44017. * Sets the reference space on the xr session
  44018. * @param referenceSpace space to set
  44019. * @returns a promise that will resolve once the reference space has been set
  44020. */
  44021. setReferenceSpaceAsync(referenceSpace?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44022. /**
  44023. * Resets the reference space to the one started the session
  44024. */
  44025. resetReferenceSpace(): void;
  44026. /**
  44027. * Updates the render state of the session
  44028. * @param state state to set
  44029. * @returns a promise that resolves once the render state has been updated
  44030. */
  44031. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44032. /**
  44033. * Starts rendering to the xr layer
  44034. */
  44035. runXRRenderLoop(): void;
  44036. /**
  44037. * Gets the correct render target texture to be rendered this frame for this eye
  44038. * @param eye the eye for which to get the render target
  44039. * @returns the render target for the specified eye
  44040. */
  44041. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44042. /**
  44043. * Stops the xrSession and restores the renderloop
  44044. * @returns Promise which resolves after it exits XR
  44045. */
  44046. exitXRAsync(): Promise<void>;
  44047. /**
  44048. * Checks if a session would be supported for the creation options specified
  44049. * @param sessionMode session mode to check if supported eg. immersive-vr
  44050. * @returns true if supported
  44051. */
  44052. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44053. /**
  44054. * Creates a WebXRRenderTarget object for the XR session
  44055. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44056. * @param options optional options to provide when creating a new render target
  44057. * @returns a WebXR render target to which the session can render
  44058. */
  44059. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44060. /**
  44061. * @hidden
  44062. * Converts the render layer of xrSession to a render target
  44063. * @param session session to create render target for
  44064. * @param scene scene the new render target should be created for
  44065. * @param baseLayer the webgl layer to create the render target for
  44066. */
  44067. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44068. /**
  44069. * Disposes of the session manager
  44070. */
  44071. dispose(): void;
  44072. /**
  44073. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44074. * @param sessionMode defines the session to test
  44075. * @returns a promise with boolean as final value
  44076. */
  44077. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44078. }
  44079. }
  44080. declare module "babylonjs/Cameras/XR/webXRCamera" {
  44081. import { Scene } from "babylonjs/scene";
  44082. import { Camera } from "babylonjs/Cameras/camera";
  44083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44084. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44085. /**
  44086. * WebXR Camera which holds the views for the xrSession
  44087. * @see https://doc.babylonjs.com/how_to/webxr
  44088. */
  44089. export class WebXRCamera extends FreeCamera {
  44090. private _xrSessionManager;
  44091. /**
  44092. * Is the camera in debug mode. Used when using an emulator
  44093. */
  44094. debugMode: boolean;
  44095. private _firstFrame;
  44096. private _referencedPosition;
  44097. private _referenceQuaternion;
  44098. private _xrInvPositionCache;
  44099. private _xrInvQuaternionCache;
  44100. /**
  44101. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44102. * @param name the name of the camera
  44103. * @param scene the scene to add the camera to
  44104. */
  44105. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44106. private _updateNumberOfRigCameras;
  44107. /**
  44108. * Sets this camera's transformation based on a non-vr camera
  44109. * @param otherCamera the non-vr camera to copy the transformation from
  44110. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44111. */
  44112. setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace?: boolean): void;
  44113. /** @hidden */
  44114. _updateForDualEyeDebugging(): void;
  44115. private _updateReferenceSpace;
  44116. private _updateReferenceSpaceOffset;
  44117. private _updateFromXRSession;
  44118. }
  44119. }
  44120. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  44121. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44122. import { IDisposable } from "babylonjs/scene";
  44123. /**
  44124. * Defining the interface required for a (webxr) feature
  44125. */
  44126. export interface IWebXRFeature extends IDisposable {
  44127. /**
  44128. * Is this feature attached
  44129. */
  44130. attached: boolean;
  44131. /**
  44132. * Attach the feature to the session
  44133. * Will usually be called by the features manager
  44134. *
  44135. * @returns true if successful.
  44136. */
  44137. attach(): boolean;
  44138. /**
  44139. * Detach the feature from the session
  44140. * Will usually be called by the features manager
  44141. *
  44142. * @returns true if successful.
  44143. */
  44144. detach(): boolean;
  44145. }
  44146. /**
  44147. * Defining the constructor of a feature. Used to register the modules.
  44148. */
  44149. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44150. /**
  44151. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44152. * It is mainly used in AR sessions.
  44153. *
  44154. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44155. */
  44156. export class WebXRFeaturesManager implements IDisposable {
  44157. private _xrSessionManager;
  44158. private static readonly _AvailableFeatures;
  44159. /**
  44160. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44161. * Mainly used internally.
  44162. *
  44163. * @param featureName the name of the feature to register
  44164. * @param constructorFunction the function used to construct the module
  44165. * @param version the (babylon) version of the module
  44166. * @param stable is that a stable version of this module
  44167. */
  44168. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44169. /**
  44170. * Returns a constructor of a specific feature.
  44171. *
  44172. * @param featureName the name of the feature to construct
  44173. * @param version the version of the feature to load
  44174. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44175. * @param options optional options provided to the module.
  44176. * @returns a function that, when called, will return a new instance of this feature
  44177. */
  44178. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44179. /**
  44180. * Return the latest unstable version of this feature
  44181. * @param featureName the name of the feature to search
  44182. * @returns the version number. if not found will return -1
  44183. */
  44184. static GetLatestVersionOfFeature(featureName: string): number;
  44185. /**
  44186. * Return the latest stable version of this feature
  44187. * @param featureName the name of the feature to search
  44188. * @returns the version number. if not found will return -1
  44189. */
  44190. static GetStableVersionOfFeature(featureName: string): number;
  44191. /**
  44192. * Can be used to return the list of features currently registered
  44193. *
  44194. * @returns an Array of available features
  44195. */
  44196. static GetAvailableFeatures(): string[];
  44197. /**
  44198. * Gets the versions available for a specific feature
  44199. * @param featureName the name of the feature
  44200. * @returns an array with the available versions
  44201. */
  44202. static GetAvailableVersions(featureName: string): string[];
  44203. private _features;
  44204. /**
  44205. * constructs a new features manages.
  44206. *
  44207. * @param _xrSessionManager an instance of WebXRSessionManager
  44208. */
  44209. constructor(_xrSessionManager: WebXRSessionManager);
  44210. /**
  44211. * 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.
  44212. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  44213. *
  44214. * @param featureName the name of the feature to load or the class of the feature
  44215. * @param version optional version to load. if not provided the latest version will be enabled
  44216. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44217. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44218. * @returns a new constructed feature or throws an error if feature not found.
  44219. */
  44220. enableFeature(featureName: string | {
  44221. Name: string;
  44222. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44223. /**
  44224. * Used to disable an already-enabled feature
  44225. * The feature will be disposed and will be recreated once enabled.
  44226. * @param featureName the feature to disable
  44227. * @returns true if disable was successful
  44228. */
  44229. disableFeature(featureName: string | {
  44230. Name: string;
  44231. }): boolean;
  44232. /**
  44233. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44234. * Can be used during a session to start a feature
  44235. * @param featureName the name of feature to attach
  44236. */
  44237. attachFeature(featureName: string): void;
  44238. /**
  44239. * Can be used inside a session or when the session ends to detach a specific feature
  44240. * @param featureName the name of the feature to detach
  44241. */
  44242. detachFeature(featureName: string): void;
  44243. /**
  44244. * Get the list of enabled features
  44245. * @returns an array of enabled features
  44246. */
  44247. getEnabledFeatures(): string[];
  44248. /**
  44249. * get the implementation of an enabled feature.
  44250. * @param featureName the name of the feature to load
  44251. * @returns the feature class, if found
  44252. */
  44253. getEnabledFeature(featureName: string): IWebXRFeature;
  44254. /**
  44255. * dispose this features manager
  44256. */
  44257. dispose(): void;
  44258. }
  44259. }
  44260. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44261. import { Observable } from "babylonjs/Misc/observable";
  44262. import { IDisposable, Scene } from "babylonjs/scene";
  44263. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44264. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44265. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44266. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44267. /**
  44268. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44269. * @see https://doc.babylonjs.com/how_to/webxr
  44270. */
  44271. export class WebXRExperienceHelper implements IDisposable {
  44272. private scene;
  44273. /**
  44274. * Camera used to render xr content
  44275. */
  44276. camera: WebXRCamera;
  44277. /**
  44278. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44279. */
  44280. state: WebXRState;
  44281. private _setState;
  44282. /**
  44283. * Fires when the state of the experience helper has changed
  44284. */
  44285. onStateChangedObservable: Observable<WebXRState>;
  44286. /**
  44287. * Observers registered here will be triggered after the camera's initial transformation is set
  44288. * This can be used to set a different ground level or an extra rotation.
  44289. *
  44290. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44291. * to the position set after this observable is done executing.
  44292. */
  44293. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44294. /** Session manager used to keep track of xr session */
  44295. sessionManager: WebXRSessionManager;
  44296. /** A features manager for this xr session */
  44297. featuresManager: WebXRFeaturesManager;
  44298. private _nonVRCamera;
  44299. private _originalSceneAutoClear;
  44300. private _supported;
  44301. /**
  44302. * Creates the experience helper
  44303. * @param scene the scene to attach the experience helper to
  44304. * @returns a promise for the experience helper
  44305. */
  44306. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44307. /**
  44308. * Creates a WebXRExperienceHelper
  44309. * @param scene The scene the helper should be created in
  44310. */
  44311. private constructor();
  44312. /**
  44313. * Exits XR mode and returns the scene to its original state
  44314. * @returns promise that resolves after xr mode has exited
  44315. */
  44316. exitXRAsync(): Promise<void>;
  44317. /**
  44318. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44319. * @param sessionMode options for the XR session
  44320. * @param referenceSpaceType frame of reference of the XR session
  44321. * @param renderTarget the output canvas that will be used to enter XR mode
  44322. * @returns promise that resolves after xr mode has entered
  44323. */
  44324. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44325. /**
  44326. * Disposes of the experience helper
  44327. */
  44328. dispose(): void;
  44329. private _nonXRToXRCamera;
  44330. }
  44331. }
  44332. declare module "babylonjs/Cameras/XR/motionController/webXRControllerComponent" {
  44333. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  44334. import { Observable } from "babylonjs/Misc/observable";
  44335. import { IDisposable } from "babylonjs/scene";
  44336. /**
  44337. * X-Y values for axes in WebXR
  44338. */
  44339. export interface IWebXRMotionControllerAxesValue {
  44340. /**
  44341. * The value of the x axis
  44342. */
  44343. x: number;
  44344. /**
  44345. * The value of the y-axis
  44346. */
  44347. y: number;
  44348. }
  44349. /**
  44350. * changed / previous values for the values of this component
  44351. */
  44352. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44353. /**
  44354. * current (this frame) value
  44355. */
  44356. current: T;
  44357. /**
  44358. * previous (last change) value
  44359. */
  44360. previous: T;
  44361. }
  44362. /**
  44363. * Represents changes in the component between current frame and last values recorded
  44364. */
  44365. export interface IWebXRMotionControllerComponentChanges {
  44366. /**
  44367. * will be populated with previous and current values if touched changed
  44368. */
  44369. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44370. /**
  44371. * will be populated with previous and current values if pressed changed
  44372. */
  44373. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44374. /**
  44375. * will be populated with previous and current values if value changed
  44376. */
  44377. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44378. /**
  44379. * will be populated with previous and current values if axes changed
  44380. */
  44381. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44382. }
  44383. /**
  44384. * This class represents a single component (for example button or thumbstick) of a motion controller
  44385. */
  44386. export class WebXRControllerComponent implements IDisposable {
  44387. /**
  44388. * the id of this component
  44389. */
  44390. id: string;
  44391. /**
  44392. * the type of the component
  44393. */
  44394. type: MotionControllerComponentType;
  44395. private _buttonIndex;
  44396. private _axesIndices;
  44397. /**
  44398. * Thumbstick component type
  44399. */
  44400. static THUMBSTICK: string;
  44401. /**
  44402. * Touchpad component type
  44403. */
  44404. static TOUCHPAD: string;
  44405. /**
  44406. * trigger component type
  44407. */
  44408. static TRIGGER: string;
  44409. /**
  44410. * squeeze component type
  44411. */
  44412. static SQUEEZE: string;
  44413. /**
  44414. * Observers registered here will be triggered when the state of a button changes
  44415. * State change is either pressed / touched / value
  44416. */
  44417. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44418. /**
  44419. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44420. * the axes data changes
  44421. */
  44422. onAxisValueChanged: Observable<{
  44423. x: number;
  44424. y: number;
  44425. }>;
  44426. private _currentValue;
  44427. private _touched;
  44428. private _pressed;
  44429. private _axes;
  44430. private _changes;
  44431. /**
  44432. * Creates a new component for a motion controller.
  44433. * It is created by the motion controller itself
  44434. *
  44435. * @param id the id of this component
  44436. * @param type the type of the component
  44437. * @param _buttonIndex index in the buttons array of the gamepad
  44438. * @param _axesIndices indices of the values in the axes array of the gamepad
  44439. */
  44440. constructor(
  44441. /**
  44442. * the id of this component
  44443. */
  44444. id: string,
  44445. /**
  44446. * the type of the component
  44447. */
  44448. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44449. /**
  44450. * Get the current value of this component
  44451. */
  44452. get value(): number;
  44453. /**
  44454. * is the button currently pressed
  44455. */
  44456. get pressed(): boolean;
  44457. /**
  44458. * is the button currently touched
  44459. */
  44460. get touched(): boolean;
  44461. /**
  44462. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44463. */
  44464. get axes(): IWebXRMotionControllerAxesValue;
  44465. /**
  44466. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44467. */
  44468. get changes(): IWebXRMotionControllerComponentChanges;
  44469. /**
  44470. * Is this component a button (hence - pressable)
  44471. * @returns true if can be pressed
  44472. */
  44473. isButton(): boolean;
  44474. /**
  44475. * Are there axes correlating to this component
  44476. * @return true is axes data is available
  44477. */
  44478. isAxes(): boolean;
  44479. /**
  44480. * update this component using the gamepad object it is in. Called on every frame
  44481. * @param nativeController the native gamepad controller object
  44482. */
  44483. update(nativeController: IMinimalMotionControllerObject): void;
  44484. /**
  44485. * Dispose this component
  44486. */
  44487. dispose(): void;
  44488. }
  44489. }
  44490. declare module "babylonjs/Loading/sceneLoader" {
  44491. import { Observable } from "babylonjs/Misc/observable";
  44492. import { Nullable } from "babylonjs/types";
  44493. import { Scene } from "babylonjs/scene";
  44494. import { Engine } from "babylonjs/Engines/engine";
  44495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44496. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44497. import { AssetContainer } from "babylonjs/assetContainer";
  44498. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44499. import { Skeleton } from "babylonjs/Bones/skeleton";
  44500. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44501. import { WebRequest } from "babylonjs/Misc/webRequest";
  44502. /**
  44503. * Class used to represent data loading progression
  44504. */
  44505. export class SceneLoaderProgressEvent {
  44506. /** defines if data length to load can be evaluated */
  44507. readonly lengthComputable: boolean;
  44508. /** defines the loaded data length */
  44509. readonly loaded: number;
  44510. /** defines the data length to load */
  44511. readonly total: number;
  44512. /**
  44513. * Create a new progress event
  44514. * @param lengthComputable defines if data length to load can be evaluated
  44515. * @param loaded defines the loaded data length
  44516. * @param total defines the data length to load
  44517. */
  44518. constructor(
  44519. /** defines if data length to load can be evaluated */
  44520. lengthComputable: boolean,
  44521. /** defines the loaded data length */
  44522. loaded: number,
  44523. /** defines the data length to load */
  44524. total: number);
  44525. /**
  44526. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44527. * @param event defines the source event
  44528. * @returns a new SceneLoaderProgressEvent
  44529. */
  44530. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44531. }
  44532. /**
  44533. * Interface used by SceneLoader plugins to define supported file extensions
  44534. */
  44535. export interface ISceneLoaderPluginExtensions {
  44536. /**
  44537. * Defines the list of supported extensions
  44538. */
  44539. [extension: string]: {
  44540. isBinary: boolean;
  44541. };
  44542. }
  44543. /**
  44544. * Interface used by SceneLoader plugin factory
  44545. */
  44546. export interface ISceneLoaderPluginFactory {
  44547. /**
  44548. * Defines the name of the factory
  44549. */
  44550. name: string;
  44551. /**
  44552. * Function called to create a new plugin
  44553. * @return the new plugin
  44554. */
  44555. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44556. /**
  44557. * The callback that returns true if the data can be directly loaded.
  44558. * @param data string containing the file data
  44559. * @returns if the data can be loaded directly
  44560. */
  44561. canDirectLoad?(data: string): boolean;
  44562. }
  44563. /**
  44564. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44565. */
  44566. export interface ISceneLoaderPluginBase {
  44567. /**
  44568. * The friendly name of this plugin.
  44569. */
  44570. name: string;
  44571. /**
  44572. * The file extensions supported by this plugin.
  44573. */
  44574. extensions: string | ISceneLoaderPluginExtensions;
  44575. /**
  44576. * The callback called when loading from a url.
  44577. * @param scene scene loading this url
  44578. * @param url url to load
  44579. * @param onSuccess callback called when the file successfully loads
  44580. * @param onProgress callback called while file is loading (if the server supports this mode)
  44581. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44582. * @param onError callback called when the file fails to load
  44583. * @returns a file request object
  44584. */
  44585. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44586. /**
  44587. * The callback called when loading from a file object.
  44588. * @param scene scene loading this file
  44589. * @param file defines the file to load
  44590. * @param onSuccess defines the callback to call when data is loaded
  44591. * @param onProgress defines the callback to call during loading process
  44592. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44593. * @param onError defines the callback to call when an error occurs
  44594. * @returns a file request object
  44595. */
  44596. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44597. /**
  44598. * The callback that returns true if the data can be directly loaded.
  44599. * @param data string containing the file data
  44600. * @returns if the data can be loaded directly
  44601. */
  44602. canDirectLoad?(data: string): boolean;
  44603. /**
  44604. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44605. * @param scene scene loading this data
  44606. * @param data string containing the data
  44607. * @returns data to pass to the plugin
  44608. */
  44609. directLoad?(scene: Scene, data: string): any;
  44610. /**
  44611. * The callback that allows custom handling of the root url based on the response url.
  44612. * @param rootUrl the original root url
  44613. * @param responseURL the response url if available
  44614. * @returns the new root url
  44615. */
  44616. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44617. }
  44618. /**
  44619. * Interface used to define a SceneLoader plugin
  44620. */
  44621. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44622. /**
  44623. * Import meshes into a scene.
  44624. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44625. * @param scene The scene to import into
  44626. * @param data The data to import
  44627. * @param rootUrl The root url for scene and resources
  44628. * @param meshes The meshes array to import into
  44629. * @param particleSystems The particle systems array to import into
  44630. * @param skeletons The skeletons array to import into
  44631. * @param onError The callback when import fails
  44632. * @returns True if successful or false otherwise
  44633. */
  44634. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44635. /**
  44636. * Load into a scene.
  44637. * @param scene The scene to load into
  44638. * @param data The data to import
  44639. * @param rootUrl The root url for scene and resources
  44640. * @param onError The callback when import fails
  44641. * @returns True if successful or false otherwise
  44642. */
  44643. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44644. /**
  44645. * Load into an asset container.
  44646. * @param scene The scene to load into
  44647. * @param data The data to import
  44648. * @param rootUrl The root url for scene and resources
  44649. * @param onError The callback when import fails
  44650. * @returns The loaded asset container
  44651. */
  44652. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44653. }
  44654. /**
  44655. * Interface used to define an async SceneLoader plugin
  44656. */
  44657. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44658. /**
  44659. * Import meshes into a scene.
  44660. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44661. * @param scene The scene to import into
  44662. * @param data The data to import
  44663. * @param rootUrl The root url for scene and resources
  44664. * @param onProgress The callback when the load progresses
  44665. * @param fileName Defines the name of the file to load
  44666. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44667. */
  44668. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44669. meshes: AbstractMesh[];
  44670. particleSystems: IParticleSystem[];
  44671. skeletons: Skeleton[];
  44672. animationGroups: AnimationGroup[];
  44673. }>;
  44674. /**
  44675. * Load into a scene.
  44676. * @param scene The scene to load into
  44677. * @param data The data to import
  44678. * @param rootUrl The root url for scene and resources
  44679. * @param onProgress The callback when the load progresses
  44680. * @param fileName Defines the name of the file to load
  44681. * @returns Nothing
  44682. */
  44683. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44684. /**
  44685. * Load into an asset container.
  44686. * @param scene The scene to load into
  44687. * @param data The data to import
  44688. * @param rootUrl The root url for scene and resources
  44689. * @param onProgress The callback when the load progresses
  44690. * @param fileName Defines the name of the file to load
  44691. * @returns The loaded asset container
  44692. */
  44693. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44694. }
  44695. /**
  44696. * Mode that determines how to handle old animation groups before loading new ones.
  44697. */
  44698. export enum SceneLoaderAnimationGroupLoadingMode {
  44699. /**
  44700. * Reset all old animations to initial state then dispose them.
  44701. */
  44702. Clean = 0,
  44703. /**
  44704. * Stop all old animations.
  44705. */
  44706. Stop = 1,
  44707. /**
  44708. * Restart old animations from first frame.
  44709. */
  44710. Sync = 2,
  44711. /**
  44712. * Old animations remains untouched.
  44713. */
  44714. NoSync = 3
  44715. }
  44716. /**
  44717. * Class used to load scene from various file formats using registered plugins
  44718. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44719. */
  44720. export class SceneLoader {
  44721. /**
  44722. * No logging while loading
  44723. */
  44724. static readonly NO_LOGGING: number;
  44725. /**
  44726. * Minimal logging while loading
  44727. */
  44728. static readonly MINIMAL_LOGGING: number;
  44729. /**
  44730. * Summary logging while loading
  44731. */
  44732. static readonly SUMMARY_LOGGING: number;
  44733. /**
  44734. * Detailled logging while loading
  44735. */
  44736. static readonly DETAILED_LOGGING: number;
  44737. /**
  44738. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44739. */
  44740. static get ForceFullSceneLoadingForIncremental(): boolean;
  44741. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44742. /**
  44743. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44744. */
  44745. static get ShowLoadingScreen(): boolean;
  44746. static set ShowLoadingScreen(value: boolean);
  44747. /**
  44748. * Defines the current logging level (while loading the scene)
  44749. * @ignorenaming
  44750. */
  44751. static get loggingLevel(): number;
  44752. static set loggingLevel(value: number);
  44753. /**
  44754. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44755. */
  44756. static get CleanBoneMatrixWeights(): boolean;
  44757. static set CleanBoneMatrixWeights(value: boolean);
  44758. /**
  44759. * Event raised when a plugin is used to load a scene
  44760. */
  44761. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44762. private static _registeredPlugins;
  44763. private static _getDefaultPlugin;
  44764. private static _getPluginForExtension;
  44765. private static _getPluginForDirectLoad;
  44766. private static _getPluginForFilename;
  44767. private static _getDirectLoad;
  44768. private static _loadData;
  44769. private static _getFileInfo;
  44770. /**
  44771. * Gets a plugin that can load the given extension
  44772. * @param extension defines the extension to load
  44773. * @returns a plugin or null if none works
  44774. */
  44775. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44776. /**
  44777. * Gets a boolean indicating that the given extension can be loaded
  44778. * @param extension defines the extension to load
  44779. * @returns true if the extension is supported
  44780. */
  44781. static IsPluginForExtensionAvailable(extension: string): boolean;
  44782. /**
  44783. * Adds a new plugin to the list of registered plugins
  44784. * @param plugin defines the plugin to add
  44785. */
  44786. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44787. /**
  44788. * Import meshes into a scene
  44789. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44790. * @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)
  44791. * @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)
  44792. * @param scene the instance of BABYLON.Scene to append to
  44793. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44794. * @param onProgress a callback with a progress event for each file being loaded
  44795. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44796. * @param pluginExtension the extension used to determine the plugin
  44797. * @returns The loaded plugin
  44798. */
  44799. 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>;
  44800. /**
  44801. * Import meshes into a scene
  44802. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44803. * @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)
  44804. * @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)
  44805. * @param scene the instance of BABYLON.Scene to append to
  44806. * @param onProgress a callback with a progress event for each file being loaded
  44807. * @param pluginExtension the extension used to determine the plugin
  44808. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44809. */
  44810. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44811. meshes: AbstractMesh[];
  44812. particleSystems: IParticleSystem[];
  44813. skeletons: Skeleton[];
  44814. animationGroups: AnimationGroup[];
  44815. }>;
  44816. /**
  44817. * Load a scene
  44818. * @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)
  44819. * @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)
  44820. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44821. * @param onSuccess a callback with the scene when import succeeds
  44822. * @param onProgress a callback with a progress event for each file being loaded
  44823. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44824. * @param pluginExtension the extension used to determine the plugin
  44825. * @returns The loaded plugin
  44826. */
  44827. 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>;
  44828. /**
  44829. * Load a scene
  44830. * @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)
  44831. * @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)
  44832. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44833. * @param onProgress a callback with a progress event for each file being loaded
  44834. * @param pluginExtension the extension used to determine the plugin
  44835. * @returns The loaded scene
  44836. */
  44837. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44838. /**
  44839. * Append a scene
  44840. * @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)
  44841. * @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)
  44842. * @param scene is the instance of BABYLON.Scene to append to
  44843. * @param onSuccess a callback with the scene when import succeeds
  44844. * @param onProgress a callback with a progress event for each file being loaded
  44845. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44846. * @param pluginExtension the extension used to determine the plugin
  44847. * @returns The loaded plugin
  44848. */
  44849. 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>;
  44850. /**
  44851. * Append a scene
  44852. * @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)
  44853. * @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)
  44854. * @param scene is the instance of BABYLON.Scene to append to
  44855. * @param onProgress a callback with a progress event for each file being loaded
  44856. * @param pluginExtension the extension used to determine the plugin
  44857. * @returns The given scene
  44858. */
  44859. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44860. /**
  44861. * Load a scene into an asset container
  44862. * @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)
  44863. * @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)
  44864. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44865. * @param onSuccess a callback with the scene when import succeeds
  44866. * @param onProgress a callback with a progress event for each file being loaded
  44867. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44868. * @param pluginExtension the extension used to determine the plugin
  44869. * @returns The loaded plugin
  44870. */
  44871. 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>;
  44872. /**
  44873. * Load a scene into an asset container
  44874. * @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)
  44875. * @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)
  44876. * @param scene is the instance of Scene to append to
  44877. * @param onProgress a callback with a progress event for each file being loaded
  44878. * @param pluginExtension the extension used to determine the plugin
  44879. * @returns The loaded asset container
  44880. */
  44881. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44882. /**
  44883. * Import animations from a file into a scene
  44884. * @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)
  44885. * @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)
  44886. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44887. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44888. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44889. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44890. * @param onSuccess a callback with the scene when import succeeds
  44891. * @param onProgress a callback with a progress event for each file being loaded
  44892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44893. */
  44894. 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;
  44895. /**
  44896. * Import animations from a file into a scene
  44897. * @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)
  44898. * @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)
  44899. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44900. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44901. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44902. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44903. * @param onSuccess a callback with the scene when import succeeds
  44904. * @param onProgress a callback with a progress event for each file being loaded
  44905. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44906. * @returns the updated scene with imported animations
  44907. */
  44908. 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>;
  44909. }
  44910. }
  44911. declare module "babylonjs/Cameras/XR/motionController/webXRAbstractController" {
  44912. import { IDisposable, Scene } from "babylonjs/scene";
  44913. import { WebXRControllerComponent } from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  44914. import { Observable } from "babylonjs/Misc/observable";
  44915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44916. import { Nullable } from "babylonjs/types";
  44917. /**
  44918. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44919. */
  44920. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  44921. /**
  44922. * The type of components available in motion controllers.
  44923. * This is not the name of the component.
  44924. */
  44925. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44926. /**
  44927. * The schema of motion controller layout.
  44928. * No object will be initialized using this interface
  44929. * This is used just to define the profile.
  44930. */
  44931. export interface IMotionControllerLayout {
  44932. /**
  44933. * Defines the main button component id
  44934. */
  44935. selectComponentId: string;
  44936. /**
  44937. * Available components (unsorted)
  44938. */
  44939. components: {
  44940. /**
  44941. * A map of component Ids
  44942. */
  44943. [componentId: string]: {
  44944. /**
  44945. * The type of input the component outputs
  44946. */
  44947. type: MotionControllerComponentType;
  44948. };
  44949. };
  44950. /**
  44951. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  44952. */
  44953. gamepad?: {
  44954. /**
  44955. * Is the mapping based on the xr-standard defined here:
  44956. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  44957. */
  44958. mapping: "" | "xr-standard";
  44959. /**
  44960. * The buttons available in this input in the right order
  44961. * index of this button will be the index in the gamepadObject.buttons array
  44962. * correlates to the componentId in components
  44963. */
  44964. buttons: Array<string | null>;
  44965. /**
  44966. * Definition of the axes of the gamepad input, sorted
  44967. * Correlates to componentIds in the components map
  44968. */
  44969. axes: Array<{
  44970. /**
  44971. * The component id that the axis correlates to
  44972. */
  44973. componentId: string;
  44974. /**
  44975. * X or Y Axis
  44976. */
  44977. axis: "x-axis" | "y-axis";
  44978. } | null>;
  44979. };
  44980. }
  44981. /**
  44982. * A definition for the layout map in the input profile
  44983. */
  44984. export interface IMotionControllerLayoutMap {
  44985. /**
  44986. * Layouts with handness type as a key
  44987. */
  44988. [handness: string]: IMotionControllerLayout;
  44989. }
  44990. /**
  44991. * The XR Input profile schema
  44992. * Profiles can be found here:
  44993. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44994. */
  44995. export interface IMotionControllerProfile {
  44996. /**
  44997. * The id of this profile
  44998. * correlates to the profile(s) in the xrInput.profiles array
  44999. */
  45000. profileId: string;
  45001. /**
  45002. * fallback profiles for this profileId
  45003. */
  45004. fallbackProfileIds: string[];
  45005. /**
  45006. * The layout map, with handness as key
  45007. */
  45008. layouts: IMotionControllerLayoutMap;
  45009. }
  45010. /**
  45011. * A helper-interface for the 3 meshes needed for controller button animation
  45012. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45013. */
  45014. export interface IMotionControllerButtonMeshMap {
  45015. /**
  45016. * The mesh that will be changed when value changes
  45017. */
  45018. valueMesh: AbstractMesh;
  45019. /**
  45020. * the mesh that defines the pressed value mesh position.
  45021. * This is used to find the max-position of this button
  45022. */
  45023. pressedMesh: AbstractMesh;
  45024. /**
  45025. * the mesh that defines the unpressed value mesh position.
  45026. * This is used to find the min (or initial) position of this button
  45027. */
  45028. unpressedMesh: AbstractMesh;
  45029. }
  45030. /**
  45031. * A helper-interface for the 3 meshes needed for controller axis animation.
  45032. * This will be expanded when touchpad animations are fully supported
  45033. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45034. */
  45035. export interface IMotionControllerAxisMeshMap {
  45036. /**
  45037. * The mesh that will be changed when axis value changes
  45038. */
  45039. valueMesh: AbstractMesh;
  45040. /**
  45041. * the mesh that defines the minimum value mesh position.
  45042. */
  45043. minMesh: AbstractMesh;
  45044. /**
  45045. * the mesh that defines the maximum value mesh position.
  45046. */
  45047. maxMesh: AbstractMesh;
  45048. }
  45049. /**
  45050. * The elements needed for change-detection of the gamepad objects in motion controllers
  45051. */
  45052. export interface IMinimalMotionControllerObject {
  45053. /**
  45054. * An array of available buttons
  45055. */
  45056. buttons: Array<{
  45057. /**
  45058. * Value of the button/trigger
  45059. */
  45060. value: number;
  45061. /**
  45062. * If the button/trigger is currently touched
  45063. */
  45064. touched: boolean;
  45065. /**
  45066. * If the button/trigger is currently pressed
  45067. */
  45068. pressed: boolean;
  45069. }>;
  45070. /**
  45071. * Available axes of this controller
  45072. */
  45073. axes: number[];
  45074. }
  45075. /**
  45076. * An Abstract Motion controller
  45077. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45078. * Each component has an observable to check for changes in value and state
  45079. */
  45080. export abstract class WebXRAbstractMotionController implements IDisposable {
  45081. protected scene: Scene;
  45082. protected layout: IMotionControllerLayout;
  45083. /**
  45084. * The gamepad object correlating to this controller
  45085. */
  45086. gamepadObject: IMinimalMotionControllerObject;
  45087. /**
  45088. * handness (left/right/none) of this controller
  45089. */
  45090. handness: MotionControllerHandness;
  45091. /**
  45092. * Component type map
  45093. */
  45094. static ComponentType: {
  45095. TRIGGER: string;
  45096. SQUEEZE: string;
  45097. TOUCHPAD: string;
  45098. THUMBSTICK: string;
  45099. BUTTON: string;
  45100. };
  45101. /**
  45102. * The profile id of this motion controller
  45103. */
  45104. abstract profileId: string;
  45105. /**
  45106. * A map of components (WebXRControllerComponent) in this motion controller
  45107. * Components have a ComponentType and can also have both button and axis definitions
  45108. */
  45109. readonly components: {
  45110. [id: string]: WebXRControllerComponent;
  45111. };
  45112. /**
  45113. * Observers registered here will be triggered when the model of this controller is done loading
  45114. */
  45115. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45116. /**
  45117. * The root mesh of the model. It is null if the model was not yet initialized
  45118. */
  45119. rootMesh: Nullable<AbstractMesh>;
  45120. private _modelReady;
  45121. /**
  45122. * constructs a new abstract motion controller
  45123. * @param scene the scene to which the model of the controller will be added
  45124. * @param layout The profile layout to load
  45125. * @param gamepadObject The gamepad object correlating to this controller
  45126. * @param handness handness (left/right/none) of this controller
  45127. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45128. */
  45129. constructor(scene: Scene, layout: IMotionControllerLayout,
  45130. /**
  45131. * The gamepad object correlating to this controller
  45132. */
  45133. gamepadObject: IMinimalMotionControllerObject,
  45134. /**
  45135. * handness (left/right/none) of this controller
  45136. */
  45137. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45138. private _initComponent;
  45139. /**
  45140. * Update this model using the current XRFrame
  45141. * @param xrFrame the current xr frame to use and update the model
  45142. */
  45143. updateFromXRFrame(xrFrame: XRFrame): void;
  45144. /**
  45145. * Get the list of components available in this motion controller
  45146. * @returns an array of strings correlating to available components
  45147. */
  45148. getComponentTypes(): string[];
  45149. /**
  45150. * Get the main (Select) component of this controller as defined in the layout
  45151. * @returns the main component of this controller
  45152. */
  45153. getMainComponent(): WebXRControllerComponent;
  45154. /**
  45155. * get a component based an its component id as defined in layout.components
  45156. * @param id the id of the component
  45157. * @returns the component correlates to the id or undefined if not found
  45158. */
  45159. getComponent(id: string): WebXRControllerComponent;
  45160. /**
  45161. * Loads the model correlating to this controller
  45162. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45163. * @returns A promise fulfilled with the result of the model loading
  45164. */
  45165. loadModel(): Promise<boolean>;
  45166. /**
  45167. * Update the model itself with the current frame data
  45168. * @param xrFrame the frame to use for updating the model mesh
  45169. */
  45170. protected updateModel(xrFrame: XRFrame): void;
  45171. /**
  45172. * Moves the axis on the controller mesh based on its current state
  45173. * @param axis the index of the axis
  45174. * @param axisValue the value of the axis which determines the meshes new position
  45175. * @hidden
  45176. */
  45177. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  45178. /**
  45179. * Moves the buttons on the controller mesh based on their current state
  45180. * @param buttonName the name of the button to move
  45181. * @param buttonValue the value of the button which determines the buttons new position
  45182. */
  45183. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  45184. private _getGenericFilenameAndPath;
  45185. private _getGenericParentMesh;
  45186. /**
  45187. * Get the filename and path for this controller's model
  45188. * @returns a map of filename and path
  45189. */
  45190. protected abstract _getFilenameAndPath(): {
  45191. filename: string;
  45192. path: string;
  45193. };
  45194. /**
  45195. * This function will be called after the model was successfully loaded and can be used
  45196. * for mesh transformations before it is available for the user
  45197. * @param meshes the loaded meshes
  45198. */
  45199. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45200. /**
  45201. * Set the root mesh for this controller. Important for the WebXR controller class
  45202. * @param meshes the loaded meshes
  45203. */
  45204. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45205. /**
  45206. * A function executed each frame that updates the mesh (if needed)
  45207. * @param xrFrame the current xrFrame
  45208. */
  45209. protected abstract _updateModel(xrFrame: XRFrame): void;
  45210. /**
  45211. * This function is called before the mesh is loaded. It checks for loading constraints.
  45212. * For example, this function can check if the GLB loader is available
  45213. * If this function returns false, the generic controller will be loaded instead
  45214. * @returns Is the client ready to load the mesh
  45215. */
  45216. protected abstract _getModelLoadingConstraints(): boolean;
  45217. /**
  45218. * Dispose this controller, the model mesh and all its components
  45219. */
  45220. dispose(): void;
  45221. }
  45222. }
  45223. declare module "babylonjs/Cameras/XR/motionController/webXRGenericMotionController" {
  45224. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45226. import { Scene } from "babylonjs/scene";
  45227. /**
  45228. * A generic trigger-only motion controller for WebXR
  45229. */
  45230. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45231. /**
  45232. * Static version of the profile id of this controller
  45233. */
  45234. static ProfileId: string;
  45235. profileId: string;
  45236. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45237. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45238. protected _updateModel(): void;
  45239. protected _getFilenameAndPath(): {
  45240. filename: string;
  45241. path: string;
  45242. };
  45243. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45244. protected _getModelLoadingConstraints(): boolean;
  45245. }
  45246. }
  45247. declare module "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager" {
  45248. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45249. import { Scene } from "babylonjs/scene";
  45250. /**
  45251. * A construction function type to create a new controller based on an xrInput object
  45252. */
  45253. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45254. /**
  45255. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45256. *
  45257. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45258. * it should be replaced with auto-loaded controllers.
  45259. *
  45260. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45261. */
  45262. export class WebXRMotionControllerManager {
  45263. private static _AvailableControllers;
  45264. private static _Fallbacks;
  45265. /**
  45266. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45267. *
  45268. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45269. *
  45270. * @param type the profile type to register
  45271. * @param constructFunction the function to be called when loading this profile
  45272. */
  45273. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45274. /**
  45275. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45276. * The order of search:
  45277. *
  45278. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45279. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45280. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45281. * 4) return the generic trigger controller if none were found
  45282. *
  45283. * @param xrInput the xrInput to which a new controller is initialized
  45284. * @param scene the scene to which the model will be added
  45285. * @param forceProfile force a certain profile for this controller
  45286. * @return the motion controller class for this profile id or the generic standard class if none was found
  45287. */
  45288. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  45289. /**
  45290. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45291. * @param profileId the profile to which a fallback needs to be found
  45292. * @return an array with corresponding fallback profiles
  45293. */
  45294. static FindFallbackWithProfileId(profileId: string): string[];
  45295. /**
  45296. * Register a fallback to a specific profile.
  45297. * @param profileId the profileId that will receive the fallbacks
  45298. * @param fallbacks A list of fallback profiles
  45299. */
  45300. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45301. /**
  45302. * Register the default fallbacks.
  45303. * This function is called automatically when this file is imported.
  45304. */
  45305. static DefaultFallbacks(): void;
  45306. }
  45307. }
  45308. declare module "babylonjs/Cameras/XR/webXRController" {
  45309. import { Observable } from "babylonjs/Misc/observable";
  45310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45311. import { Ray } from "babylonjs/Culling/ray";
  45312. import { Scene } from "babylonjs/scene";
  45313. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45314. /**
  45315. * Configuration options for the WebXR controller creation
  45316. */
  45317. export interface IWebXRControllerOptions {
  45318. /**
  45319. * Force a specific controller type for this controller.
  45320. * This can be used when creating your own profile or when testing different controllers
  45321. */
  45322. forceControllerProfile?: string;
  45323. }
  45324. /**
  45325. * Represents an XR controller
  45326. */
  45327. export class WebXRController {
  45328. private _scene;
  45329. /** The underlying input source for the controller */
  45330. inputSource: XRInputSource;
  45331. private _options;
  45332. /**
  45333. * 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
  45334. */
  45335. grip?: AbstractMesh;
  45336. /**
  45337. * Pointer which can be used to select objects or attach a visible laser to
  45338. */
  45339. pointer: AbstractMesh;
  45340. /**
  45341. * If available, this is the gamepad object related to this controller.
  45342. * Using this object it is possible to get click events and trackpad changes of the
  45343. * webxr controller that is currently being used.
  45344. */
  45345. motionController?: WebXRAbstractMotionController;
  45346. /**
  45347. * Event that fires when the controller is removed/disposed
  45348. */
  45349. onDisposeObservable: Observable<{}>;
  45350. private _tmpQuaternion;
  45351. private _tmpVector;
  45352. private _uniqueId;
  45353. /**
  45354. * Creates the controller
  45355. * @see https://doc.babylonjs.com/how_to/webxr
  45356. * @param _scene the scene which the controller should be associated to
  45357. * @param inputSource the underlying input source for the controller
  45358. * @param _options options for this controller creation
  45359. */
  45360. constructor(_scene: Scene,
  45361. /** The underlying input source for the controller */
  45362. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45363. /**
  45364. * Get this controllers unique id
  45365. */
  45366. get uniqueId(): string;
  45367. /**
  45368. * Updates the controller pose based on the given XRFrame
  45369. * @param xrFrame xr frame to update the pose with
  45370. * @param referenceSpace reference space to use
  45371. */
  45372. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45373. /**
  45374. * Gets a world space ray coming from the controller
  45375. * @param result the resulting ray
  45376. */
  45377. getWorldPointerRayToRef(result: Ray): void;
  45378. /**
  45379. * Disposes of the object
  45380. */
  45381. dispose(): void;
  45382. }
  45383. }
  45384. declare module "babylonjs/Cameras/XR/webXRInput" {
  45385. import { Observable } from "babylonjs/Misc/observable";
  45386. import { IDisposable } from "babylonjs/scene";
  45387. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45388. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45389. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  45390. /**
  45391. * The schema for initialization options of the XR Input class
  45392. */
  45393. export interface IWebXRInputOptions {
  45394. /**
  45395. * If set to true no model will be automatically loaded
  45396. */
  45397. doNotLoadControllerMeshes?: boolean;
  45398. /**
  45399. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45400. * If not found, the xr input profile data will be used.
  45401. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45402. */
  45403. forceInputProfile?: string;
  45404. }
  45405. /**
  45406. * XR input used to track XR inputs such as controllers/rays
  45407. */
  45408. export class WebXRInput implements IDisposable {
  45409. /**
  45410. * the xr session manager for this session
  45411. */
  45412. xrSessionManager: WebXRSessionManager;
  45413. /**
  45414. * the WebXR camera for this session. Mainly used for teleportation
  45415. */
  45416. xrCamera: WebXRCamera;
  45417. private readonly options;
  45418. /**
  45419. * XR controllers being tracked
  45420. */
  45421. controllers: Array<WebXRController>;
  45422. private _frameObserver;
  45423. private _sessionEndedObserver;
  45424. private _sessionInitObserver;
  45425. /**
  45426. * Event when a controller has been connected/added
  45427. */
  45428. onControllerAddedObservable: Observable<WebXRController>;
  45429. /**
  45430. * Event when a controller has been removed/disconnected
  45431. */
  45432. onControllerRemovedObservable: Observable<WebXRController>;
  45433. /**
  45434. * Initializes the WebXRInput
  45435. * @param xrSessionManager the xr session manager for this session
  45436. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45437. * @param options = initialization options for this xr input
  45438. */
  45439. constructor(
  45440. /**
  45441. * the xr session manager for this session
  45442. */
  45443. xrSessionManager: WebXRSessionManager,
  45444. /**
  45445. * the WebXR camera for this session. Mainly used for teleportation
  45446. */
  45447. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45448. private _onInputSourcesChange;
  45449. private _addAndRemoveControllers;
  45450. /**
  45451. * Disposes of the object
  45452. */
  45453. dispose(): void;
  45454. }
  45455. }
  45456. declare module "babylonjs/Cameras/XR/features/WebXRAbstractFeature" {
  45457. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45458. import { Observable, EventState } from "babylonjs/Misc/observable";
  45459. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45460. /**
  45461. * This is the base class for all WebXR features.
  45462. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45463. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45464. */
  45465. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45466. protected _xrSessionManager: WebXRSessionManager;
  45467. /**
  45468. * Construct a new (abstract) webxr feature
  45469. * @param _xrSessionManager the xr session manager for this feature
  45470. */
  45471. constructor(_xrSessionManager: WebXRSessionManager);
  45472. private _attached;
  45473. private _removeOnDetach;
  45474. /**
  45475. * Is this feature attached
  45476. */
  45477. get attached(): boolean;
  45478. /**
  45479. * attach this feature
  45480. *
  45481. * @returns true if successful, false is failed or already attached
  45482. */
  45483. attach(): boolean;
  45484. /**
  45485. * detach this feature.
  45486. *
  45487. * @returns true if successful, false if failed or already detached
  45488. */
  45489. detach(): boolean;
  45490. /**
  45491. * Dispose this feature and all of the resources attached
  45492. */
  45493. dispose(): void;
  45494. /**
  45495. * Code in this function will be executed on each xrFrame received from the browser.
  45496. * This function will not execute after the feature is detached.
  45497. * @param _xrFrame the current frame
  45498. */
  45499. protected _onXRFrame(_xrFrame: XRFrame): void;
  45500. /**
  45501. * This is used to register callbacks that will automatically be removed when detach is called.
  45502. * @param observable the observable to which the observer will be attached
  45503. * @param callback the callback to register
  45504. */
  45505. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45506. }
  45507. }
  45508. declare module "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection" {
  45509. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45510. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45511. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45512. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45513. import { Nullable } from "babylonjs/types";
  45514. import { Color3 } from "babylonjs/Maths/math.color";
  45515. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  45516. /**
  45517. * Options interface for the pointer selection module
  45518. */
  45519. export interface IWebXRControllerPointerSelectionOptions {
  45520. /**
  45521. * the xr input to use with this pointer selection
  45522. */
  45523. xrInput: WebXRInput;
  45524. /**
  45525. * Different button type to use instead of the main component
  45526. */
  45527. overrideButtonId?: string;
  45528. /**
  45529. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  45530. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45531. * 3000 means 3 seconds between pointing at something and selecting it
  45532. */
  45533. timeToSelect?: number;
  45534. /**
  45535. * 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)
  45536. * If not disabled, the last picked point will be used to execute a pointer up event
  45537. * If disabled, pointer up event will be triggered right after the pointer down event.
  45538. * Used in screen and gaze target ray mode only
  45539. */
  45540. disablePointerUpOnTouchOut: boolean;
  45541. /**
  45542. * For gaze mode (time to select instead of press)
  45543. */
  45544. forceGazeMode: boolean;
  45545. /**
  45546. * 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
  45547. * to start a new countdown to the pointer down event.
  45548. * Defaults to 1.
  45549. */
  45550. gazeModePointerMovedFactor?: number;
  45551. }
  45552. /**
  45553. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45554. */
  45555. export class WebXRControllerPointerSelection extends WebXRAbstractFeature implements IWebXRFeature {
  45556. private readonly _options;
  45557. /**
  45558. * The module's name
  45559. */
  45560. static readonly Name: string;
  45561. /**
  45562. * The (Babylon) version of this module.
  45563. * This is an integer representing the implementation version.
  45564. * This number does not correspond to the webxr specs version
  45565. */
  45566. static readonly Version: number;
  45567. /**
  45568. * This color will be set to the laser pointer when selection is triggered
  45569. */
  45570. laserPointerPickedColor: Color3;
  45571. /**
  45572. * This color will be applied to the selection ring when selection is triggered
  45573. */
  45574. selectionMeshPickedColor: Color3;
  45575. /**
  45576. * default color of the selection ring
  45577. */
  45578. selectionMeshDefaultColor: Color3;
  45579. /**
  45580. * Default color of the laser pointer
  45581. */
  45582. lasterPointerDefaultColor: Color3;
  45583. /**
  45584. * Should the laser pointer be displayed
  45585. */
  45586. displayLaserPointer: boolean;
  45587. /**
  45588. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45589. */
  45590. displaySelectionMesh: boolean;
  45591. private static _idCounter;
  45592. private _tmpRay;
  45593. private _controllers;
  45594. private _scene;
  45595. /**
  45596. * constructs a new background remover module
  45597. * @param _xrSessionManager the session manager for this module
  45598. * @param _options read-only options to be used in this module
  45599. */
  45600. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45601. /**
  45602. * attach this feature
  45603. * Will usually be called by the features manager
  45604. *
  45605. * @returns true if successful.
  45606. */
  45607. attach(): boolean;
  45608. /**
  45609. * detach this feature.
  45610. * Will usually be called by the features manager
  45611. *
  45612. * @returns true if successful.
  45613. */
  45614. detach(): boolean;
  45615. /**
  45616. * Get the xr controller that correlates to the pointer id in the pointer event
  45617. *
  45618. * @param id the pointer id to search for
  45619. * @returns the controller that correlates to this id or null if not found
  45620. */
  45621. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  45622. protected _onXRFrame(_xrFrame: XRFrame): void;
  45623. private _attachController;
  45624. private _attachScreenRayMode;
  45625. private _attachGazeMode;
  45626. private _tmpVectorForPickCompare;
  45627. private _pickingMoved;
  45628. private _attachTrackedPointerRayMode;
  45629. private _detachController;
  45630. private _generateNewMeshPair;
  45631. private _convertNormalToDirectionOfRay;
  45632. private _updatePointerDistance;
  45633. }
  45634. }
  45635. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45636. import { Nullable } from "babylonjs/types";
  45637. import { Observable } from "babylonjs/Misc/observable";
  45638. import { IDisposable, Scene } from "babylonjs/scene";
  45639. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45640. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45641. /**
  45642. * Button which can be used to enter a different mode of XR
  45643. */
  45644. export class WebXREnterExitUIButton {
  45645. /** button element */
  45646. element: HTMLElement;
  45647. /** XR initialization options for the button */
  45648. sessionMode: XRSessionMode;
  45649. /** Reference space type */
  45650. referenceSpaceType: XRReferenceSpaceType;
  45651. /**
  45652. * Creates a WebXREnterExitUIButton
  45653. * @param element button element
  45654. * @param sessionMode XR initialization session mode
  45655. * @param referenceSpaceType the type of reference space to be used
  45656. */
  45657. constructor(
  45658. /** button element */
  45659. element: HTMLElement,
  45660. /** XR initialization options for the button */
  45661. sessionMode: XRSessionMode,
  45662. /** Reference space type */
  45663. referenceSpaceType: XRReferenceSpaceType);
  45664. /**
  45665. * Overwritable function which can be used to update the button's visuals when the state changes
  45666. * @param activeButton the current active button in the UI
  45667. */
  45668. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45669. }
  45670. /**
  45671. * Options to create the webXR UI
  45672. */
  45673. export class WebXREnterExitUIOptions {
  45674. /**
  45675. * Context to enter xr with
  45676. */
  45677. renderTarget?: Nullable<WebXRRenderTarget>;
  45678. /**
  45679. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45680. */
  45681. customButtons?: Array<WebXREnterExitUIButton>;
  45682. /**
  45683. * A session mode to use when creating the default button.
  45684. * Default is immersive-vr
  45685. */
  45686. sessionMode?: XRSessionMode;
  45687. /**
  45688. * A reference space type to use when creating the default button.
  45689. * Default is local-floor
  45690. */
  45691. referenceSpaceType?: XRReferenceSpaceType;
  45692. }
  45693. /**
  45694. * UI to allow the user to enter/exit XR mode
  45695. */
  45696. export class WebXREnterExitUI implements IDisposable {
  45697. private scene;
  45698. /** version of the options passed to this UI */
  45699. options: WebXREnterExitUIOptions;
  45700. private _overlay;
  45701. private _buttons;
  45702. private _activeButton;
  45703. /**
  45704. * Fired every time the active button is changed.
  45705. *
  45706. * When xr is entered via a button that launches xr that button will be the callback parameter
  45707. *
  45708. * When exiting xr the callback parameter will be null)
  45709. */
  45710. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45711. /**
  45712. * Creates UI to allow the user to enter/exit XR mode
  45713. * @param scene the scene to add the ui to
  45714. * @param helper the xr experience helper to enter/exit xr with
  45715. * @param options options to configure the UI
  45716. * @returns the created ui
  45717. */
  45718. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45719. /**
  45720. *
  45721. * @param scene babylon scene object to use
  45722. * @param options (read-only) version of the options passed to this UI
  45723. */
  45724. private constructor();
  45725. private _updateButtons;
  45726. /**
  45727. * Disposes of the object
  45728. */
  45729. dispose(): void;
  45730. }
  45731. }
  45732. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45733. import { Vector3 } from "babylonjs/Maths/math.vector";
  45734. import { Color4 } from "babylonjs/Maths/math.color";
  45735. import { Nullable } from "babylonjs/types";
  45736. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45737. import { Scene } from "babylonjs/scene";
  45738. /**
  45739. * Class containing static functions to help procedurally build meshes
  45740. */
  45741. export class LinesBuilder {
  45742. /**
  45743. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45744. * * 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
  45745. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45746. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45747. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45748. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45749. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45750. * * 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
  45751. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45754. * @param name defines the name of the new line system
  45755. * @param options defines the options used to create the line system
  45756. * @param scene defines the hosting scene
  45757. * @returns a new line system mesh
  45758. */
  45759. static CreateLineSystem(name: string, options: {
  45760. lines: Vector3[][];
  45761. updatable?: boolean;
  45762. instance?: Nullable<LinesMesh>;
  45763. colors?: Nullable<Color4[][]>;
  45764. useVertexAlpha?: boolean;
  45765. }, scene: Nullable<Scene>): LinesMesh;
  45766. /**
  45767. * Creates a line mesh
  45768. * 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
  45769. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45770. * * The parameter `points` is an array successive Vector3
  45771. * * 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
  45772. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45773. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45774. * * When updating an instance, remember that only point positions can change, not the number of points
  45775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45777. * @param name defines the name of the new line system
  45778. * @param options defines the options used to create the line system
  45779. * @param scene defines the hosting scene
  45780. * @returns a new line mesh
  45781. */
  45782. static CreateLines(name: string, options: {
  45783. points: Vector3[];
  45784. updatable?: boolean;
  45785. instance?: Nullable<LinesMesh>;
  45786. colors?: Color4[];
  45787. useVertexAlpha?: boolean;
  45788. }, scene?: Nullable<Scene>): LinesMesh;
  45789. /**
  45790. * Creates a dashed line mesh
  45791. * * 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
  45792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45793. * * The parameter `points` is an array successive Vector3
  45794. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45795. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45796. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45797. * * 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
  45798. * * When updating an instance, remember that only point positions can change, not the number of points
  45799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45800. * @param name defines the name of the mesh
  45801. * @param options defines the options used to create the mesh
  45802. * @param scene defines the hosting scene
  45803. * @returns the dashed line mesh
  45804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45805. */
  45806. static CreateDashedLines(name: string, options: {
  45807. points: Vector3[];
  45808. dashSize?: number;
  45809. gapSize?: number;
  45810. dashNb?: number;
  45811. updatable?: boolean;
  45812. instance?: LinesMesh;
  45813. }, scene?: Nullable<Scene>): LinesMesh;
  45814. }
  45815. }
  45816. declare module "babylonjs/Cameras/XR/features/WebXRControllerTeleportation" {
  45817. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45818. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45819. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45821. import { Material } from "babylonjs/Materials/material";
  45822. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  45823. /**
  45824. * The options container for the teleportation module
  45825. */
  45826. export interface IWebXRTeleportationOptions {
  45827. /**
  45828. * Babylon XR Input class for controller
  45829. */
  45830. xrInput: WebXRInput;
  45831. /**
  45832. * A list of meshes to use as floor meshes.
  45833. * Meshes can be added and removed after initializing the feature using the
  45834. * addFloorMesh and removeFloorMesh functions
  45835. * If empty, rotation will still work
  45836. */
  45837. floorMeshes?: AbstractMesh[];
  45838. /**
  45839. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45840. * If you want to support rotation, make sure your mesh has a direction indicator.
  45841. *
  45842. * When left untouched, the default mesh will be initialized.
  45843. */
  45844. teleportationTargetMesh?: AbstractMesh;
  45845. /**
  45846. * Values to configure the default target mesh
  45847. */
  45848. defaultTargetMeshOptions?: {
  45849. /**
  45850. * Fill color of the teleportation area
  45851. */
  45852. teleportationFillColor?: string;
  45853. /**
  45854. * Border color for the teleportation area
  45855. */
  45856. teleportationBorderColor?: string;
  45857. /**
  45858. * Override the default material of the torus and arrow
  45859. */
  45860. torusArrowMaterial?: Material;
  45861. /**
  45862. * Disable the mesh's animation sequence
  45863. */
  45864. disableAnimation?: boolean;
  45865. };
  45866. /**
  45867. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  45868. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  45869. */
  45870. useMainComponentOnly?: boolean;
  45871. /**
  45872. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  45873. */
  45874. timeToTeleport?: number;
  45875. }
  45876. /**
  45877. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  45878. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  45879. * the input of the attached controllers.
  45880. */
  45881. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature implements IWebXRFeature {
  45882. private _options;
  45883. /**
  45884. * The module's name
  45885. */
  45886. static readonly Name: string;
  45887. /**
  45888. * The (Babylon) version of this module.
  45889. * This is an integer representing the implementation version.
  45890. * This number does not correspond to the webxr specs version
  45891. */
  45892. static readonly Version: number;
  45893. /**
  45894. * Is rotation enabled when moving forward?
  45895. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45896. */
  45897. rotationEnabled: boolean;
  45898. /**
  45899. * Should the module support parabolic ray on top of direct ray
  45900. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45901. * Very helpful when moving between floors / different heights
  45902. */
  45903. parabolicRayEnabled: boolean;
  45904. /**
  45905. * The distance from the user to the inspection point in the direction of the controller
  45906. * A higher number will allow the user to move further
  45907. * defaults to 5 (meters, in xr units)
  45908. */
  45909. parabolicCheckRadius: number;
  45910. /**
  45911. * How much rotation should be applied when rotating right and left
  45912. */
  45913. rotationAngle: number;
  45914. /**
  45915. * Distance to travel when moving backwards
  45916. */
  45917. backwardsTeleportationDistance: number;
  45918. /**
  45919. * Add a new mesh to the floor meshes array
  45920. * @param mesh the mesh to use as floor mesh
  45921. */
  45922. addFloorMesh(mesh: AbstractMesh): void;
  45923. /**
  45924. * Remove a mesh from the floor meshes array
  45925. * @param mesh the mesh to remove
  45926. */
  45927. removeFloorMesh(mesh: AbstractMesh): void;
  45928. /**
  45929. * Remove a mesh from the floor meshes array using its name
  45930. * @param name the mesh name to remove
  45931. */
  45932. removeFloorMeshByName(name: string): void;
  45933. private _tmpRay;
  45934. private _tmpVector;
  45935. private _floorMeshes;
  45936. private _controllers;
  45937. /**
  45938. * constructs a new anchor system
  45939. * @param _xrSessionManager an instance of WebXRSessionManager
  45940. * @param _options configuration object for this feature
  45941. */
  45942. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45943. private _selectionFeature;
  45944. /**
  45945. * This function sets a selection feature that will be disabled when
  45946. * the forward ray is shown and will be reattached when hidden.
  45947. * This is used to remove the selection rays when moving.
  45948. * @param selectionFeature the feature to disable when forward movement is enabled
  45949. */
  45950. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45951. attach(): boolean;
  45952. detach(): boolean;
  45953. dispose(): void;
  45954. protected _onXRFrame(_xrFrame: XRFrame): void;
  45955. private _currentTeleportationControllerId;
  45956. private _attachController;
  45957. private _teleportForward;
  45958. private _detachController;
  45959. private createDefaultTargetMesh;
  45960. private setTargetMeshVisibility;
  45961. private setTargetMeshPosition;
  45962. private _quadraticBezierCurve;
  45963. private showParabolicPath;
  45964. }
  45965. }
  45966. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45967. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45968. import { Scene } from "babylonjs/scene";
  45969. import { WebXRInput, IWebXRInputOptions } from "babylonjs/Cameras/XR/webXRInput";
  45970. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  45971. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45972. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45974. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45975. import { WebXRMotionControllerTeleportation } from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  45976. /**
  45977. * Options for the default xr helper
  45978. */
  45979. export class WebXRDefaultExperienceOptions {
  45980. /**
  45981. * Floor meshes that will be used for teleporting
  45982. */
  45983. floorMeshes?: Array<AbstractMesh>;
  45984. /**
  45985. * Enable or disable default UI to enter XR
  45986. */
  45987. disableDefaultUI?: boolean;
  45988. /**
  45989. * optional configuration for the output canvas
  45990. */
  45991. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45992. /**
  45993. * optional UI options. This can be used among other to change session mode and reference space type
  45994. */
  45995. uiOptions?: WebXREnterExitUIOptions;
  45996. /**
  45997. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45998. */
  45999. inputOptions?: IWebXRInputOptions;
  46000. /**
  46001. * Should teleportation not initialize. defaults to false.
  46002. */
  46003. disableTeleportation?: boolean;
  46004. }
  46005. /**
  46006. * Default experience which provides a similar setup to the previous webVRExperience
  46007. */
  46008. export class WebXRDefaultExperience {
  46009. /**
  46010. * Base experience
  46011. */
  46012. baseExperience: WebXRExperienceHelper;
  46013. /**
  46014. * Input experience extension
  46015. */
  46016. input: WebXRInput;
  46017. /**
  46018. * Enables laser pointer and selection
  46019. */
  46020. pointerSelection: WebXRControllerPointerSelection;
  46021. /**
  46022. * Enables teleportation
  46023. */
  46024. teleportation: WebXRMotionControllerTeleportation;
  46025. /**
  46026. * Enables ui for entering/exiting xr
  46027. */
  46028. enterExitUI: WebXREnterExitUI;
  46029. /**
  46030. * Default target xr should render to
  46031. */
  46032. renderTarget: WebXRRenderTarget;
  46033. /**
  46034. * Creates the default xr experience
  46035. * @param scene scene
  46036. * @param options options for basic configuration
  46037. * @returns resulting WebXRDefaultExperience
  46038. */
  46039. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46040. private constructor();
  46041. /**
  46042. * DIsposes of the experience helper
  46043. */
  46044. dispose(): void;
  46045. }
  46046. }
  46047. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46048. import { Observable } from "babylonjs/Misc/observable";
  46049. import { Nullable } from "babylonjs/types";
  46050. import { Camera } from "babylonjs/Cameras/camera";
  46051. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46052. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46053. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46054. import { Scene } from "babylonjs/scene";
  46055. import { Vector3 } from "babylonjs/Maths/math.vector";
  46056. import { Color3 } from "babylonjs/Maths/math.color";
  46057. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46059. import { Mesh } from "babylonjs/Meshes/mesh";
  46060. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46061. import { EasingFunction } from "babylonjs/Animations/easing";
  46062. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46063. import "babylonjs/Meshes/Builders/groundBuilder";
  46064. import "babylonjs/Meshes/Builders/torusBuilder";
  46065. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46066. import "babylonjs/Gamepads/gamepadSceneComponent";
  46067. import "babylonjs/Animations/animatable";
  46068. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46069. /**
  46070. * Options to modify the vr teleportation behavior.
  46071. */
  46072. export interface VRTeleportationOptions {
  46073. /**
  46074. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46075. */
  46076. floorMeshName?: string;
  46077. /**
  46078. * A list of meshes to be used as the teleportation floor. (default: empty)
  46079. */
  46080. floorMeshes?: Mesh[];
  46081. /**
  46082. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46083. */
  46084. teleportationMode?: number;
  46085. /**
  46086. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46087. */
  46088. teleportationTime?: number;
  46089. /**
  46090. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46091. */
  46092. teleportationSpeed?: number;
  46093. /**
  46094. * The easing function used in the animation or null for Linear. (default CircleEase)
  46095. */
  46096. easingFunction?: EasingFunction;
  46097. }
  46098. /**
  46099. * Options to modify the vr experience helper's behavior.
  46100. */
  46101. export interface VRExperienceHelperOptions extends WebVROptions {
  46102. /**
  46103. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46104. */
  46105. createDeviceOrientationCamera?: boolean;
  46106. /**
  46107. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46108. */
  46109. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46110. /**
  46111. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46112. */
  46113. laserToggle?: boolean;
  46114. /**
  46115. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46116. */
  46117. floorMeshes?: Mesh[];
  46118. /**
  46119. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46120. */
  46121. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46122. /**
  46123. * Defines if WebXR should be used instead of WebVR (if available)
  46124. */
  46125. useXR?: boolean;
  46126. }
  46127. /**
  46128. * Event containing information after VR has been entered
  46129. */
  46130. export class OnAfterEnteringVRObservableEvent {
  46131. /**
  46132. * If entering vr was successful
  46133. */
  46134. success: boolean;
  46135. }
  46136. /**
  46137. * Helps to quickly add VR support to an existing scene.
  46138. * See http://doc.babylonjs.com/how_to/webvr_helper
  46139. */
  46140. export class VRExperienceHelper {
  46141. /** Options to modify the vr experience helper's behavior. */
  46142. webVROptions: VRExperienceHelperOptions;
  46143. private _scene;
  46144. private _position;
  46145. private _btnVR;
  46146. private _btnVRDisplayed;
  46147. private _webVRsupported;
  46148. private _webVRready;
  46149. private _webVRrequesting;
  46150. private _webVRpresenting;
  46151. private _hasEnteredVR;
  46152. private _fullscreenVRpresenting;
  46153. private _inputElement;
  46154. private _webVRCamera;
  46155. private _vrDeviceOrientationCamera;
  46156. private _deviceOrientationCamera;
  46157. private _existingCamera;
  46158. private _onKeyDown;
  46159. private _onVrDisplayPresentChange;
  46160. private _onVRDisplayChanged;
  46161. private _onVRRequestPresentStart;
  46162. private _onVRRequestPresentComplete;
  46163. /**
  46164. * 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)
  46165. */
  46166. enableGazeEvenWhenNoPointerLock: boolean;
  46167. /**
  46168. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46169. */
  46170. exitVROnDoubleTap: boolean;
  46171. /**
  46172. * Observable raised right before entering VR.
  46173. */
  46174. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46175. /**
  46176. * Observable raised when entering VR has completed.
  46177. */
  46178. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46179. /**
  46180. * Observable raised when exiting VR.
  46181. */
  46182. onExitingVRObservable: Observable<VRExperienceHelper>;
  46183. /**
  46184. * Observable raised when controller mesh is loaded.
  46185. */
  46186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46187. /** Return this.onEnteringVRObservable
  46188. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46189. */
  46190. get onEnteringVR(): Observable<VRExperienceHelper>;
  46191. /** Return this.onExitingVRObservable
  46192. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46193. */
  46194. get onExitingVR(): Observable<VRExperienceHelper>;
  46195. /** Return this.onControllerMeshLoadedObservable
  46196. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46197. */
  46198. get onControllerMeshLoaded(): Observable<WebVRController>;
  46199. private _rayLength;
  46200. private _useCustomVRButton;
  46201. private _teleportationRequested;
  46202. private _teleportActive;
  46203. private _floorMeshName;
  46204. private _floorMeshesCollection;
  46205. private _teleportationMode;
  46206. private _teleportationTime;
  46207. private _teleportationSpeed;
  46208. private _teleportationEasing;
  46209. private _rotationAllowed;
  46210. private _teleportBackwardsVector;
  46211. private _teleportationTarget;
  46212. private _isDefaultTeleportationTarget;
  46213. private _postProcessMove;
  46214. private _teleportationFillColor;
  46215. private _teleportationBorderColor;
  46216. private _rotationAngle;
  46217. private _haloCenter;
  46218. private _cameraGazer;
  46219. private _padSensibilityUp;
  46220. private _padSensibilityDown;
  46221. private _leftController;
  46222. private _rightController;
  46223. private _gazeColor;
  46224. private _laserColor;
  46225. private _pickedLaserColor;
  46226. private _pickedGazeColor;
  46227. /**
  46228. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46229. */
  46230. onNewMeshSelected: Observable<AbstractMesh>;
  46231. /**
  46232. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46233. * This observable will provide the mesh and the controller used to select the mesh
  46234. */
  46235. onMeshSelectedWithController: Observable<{
  46236. mesh: AbstractMesh;
  46237. controller: WebVRController;
  46238. }>;
  46239. /**
  46240. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46241. */
  46242. onNewMeshPicked: Observable<PickingInfo>;
  46243. private _circleEase;
  46244. /**
  46245. * Observable raised before camera teleportation
  46246. */
  46247. onBeforeCameraTeleport: Observable<Vector3>;
  46248. /**
  46249. * Observable raised after camera teleportation
  46250. */
  46251. onAfterCameraTeleport: Observable<Vector3>;
  46252. /**
  46253. * Observable raised when current selected mesh gets unselected
  46254. */
  46255. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46256. private _raySelectionPredicate;
  46257. /**
  46258. * To be optionaly changed by user to define custom ray selection
  46259. */
  46260. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46261. /**
  46262. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46263. */
  46264. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46265. /**
  46266. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46267. */
  46268. teleportationEnabled: boolean;
  46269. private _defaultHeight;
  46270. private _teleportationInitialized;
  46271. private _interactionsEnabled;
  46272. private _interactionsRequested;
  46273. private _displayGaze;
  46274. private _displayLaserPointer;
  46275. /**
  46276. * The mesh used to display where the user is going to teleport.
  46277. */
  46278. get teleportationTarget(): Mesh;
  46279. /**
  46280. * Sets the mesh to be used to display where the user is going to teleport.
  46281. */
  46282. set teleportationTarget(value: Mesh);
  46283. /**
  46284. * 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
  46285. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46286. * See http://doc.babylonjs.com/resources/baking_transformations
  46287. */
  46288. get gazeTrackerMesh(): Mesh;
  46289. set gazeTrackerMesh(value: Mesh);
  46290. /**
  46291. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46292. */
  46293. updateGazeTrackerScale: boolean;
  46294. /**
  46295. * If the gaze trackers color should be updated when selecting meshes
  46296. */
  46297. updateGazeTrackerColor: boolean;
  46298. /**
  46299. * If the controller laser color should be updated when selecting meshes
  46300. */
  46301. updateControllerLaserColor: boolean;
  46302. /**
  46303. * The gaze tracking mesh corresponding to the left controller
  46304. */
  46305. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46306. /**
  46307. * The gaze tracking mesh corresponding to the right controller
  46308. */
  46309. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46310. /**
  46311. * If the ray of the gaze should be displayed.
  46312. */
  46313. get displayGaze(): boolean;
  46314. /**
  46315. * Sets if the ray of the gaze should be displayed.
  46316. */
  46317. set displayGaze(value: boolean);
  46318. /**
  46319. * If the ray of the LaserPointer should be displayed.
  46320. */
  46321. get displayLaserPointer(): boolean;
  46322. /**
  46323. * Sets if the ray of the LaserPointer should be displayed.
  46324. */
  46325. set displayLaserPointer(value: boolean);
  46326. /**
  46327. * The deviceOrientationCamera used as the camera when not in VR.
  46328. */
  46329. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46330. /**
  46331. * Based on the current WebVR support, returns the current VR camera used.
  46332. */
  46333. get currentVRCamera(): Nullable<Camera>;
  46334. /**
  46335. * The webVRCamera which is used when in VR.
  46336. */
  46337. get webVRCamera(): WebVRFreeCamera;
  46338. /**
  46339. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46340. */
  46341. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46342. /**
  46343. * The html button that is used to trigger entering into VR.
  46344. */
  46345. get vrButton(): Nullable<HTMLButtonElement>;
  46346. private get _teleportationRequestInitiated();
  46347. /**
  46348. * Defines wether or not Pointer lock should be requested when switching to
  46349. * full screen.
  46350. */
  46351. requestPointerLockOnFullScreen: boolean;
  46352. /**
  46353. * If asking to force XR, this will be populated with the default xr experience
  46354. */
  46355. xr: WebXRDefaultExperience;
  46356. /**
  46357. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46358. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46359. */
  46360. xrTestDone: boolean;
  46361. /**
  46362. * Instantiates a VRExperienceHelper.
  46363. * Helps to quickly add VR support to an existing scene.
  46364. * @param scene The scene the VRExperienceHelper belongs to.
  46365. * @param webVROptions Options to modify the vr experience helper's behavior.
  46366. */
  46367. constructor(scene: Scene,
  46368. /** Options to modify the vr experience helper's behavior. */
  46369. webVROptions?: VRExperienceHelperOptions);
  46370. private completeVRInit;
  46371. private _onDefaultMeshLoaded;
  46372. private _onResize;
  46373. private _onFullscreenChange;
  46374. /**
  46375. * Gets a value indicating if we are currently in VR mode.
  46376. */
  46377. get isInVRMode(): boolean;
  46378. private onVrDisplayPresentChange;
  46379. private onVRDisplayChanged;
  46380. private moveButtonToBottomRight;
  46381. private displayVRButton;
  46382. private updateButtonVisibility;
  46383. private _cachedAngularSensibility;
  46384. /**
  46385. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46386. * Otherwise, will use the fullscreen API.
  46387. */
  46388. enterVR(): void;
  46389. /**
  46390. * Attempt to exit VR, or fullscreen.
  46391. */
  46392. exitVR(): void;
  46393. /**
  46394. * The position of the vr experience helper.
  46395. */
  46396. get position(): Vector3;
  46397. /**
  46398. * Sets the position of the vr experience helper.
  46399. */
  46400. set position(value: Vector3);
  46401. /**
  46402. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46403. */
  46404. enableInteractions(): void;
  46405. private get _noControllerIsActive();
  46406. private beforeRender;
  46407. private _isTeleportationFloor;
  46408. /**
  46409. * Adds a floor mesh to be used for teleportation.
  46410. * @param floorMesh the mesh to be used for teleportation.
  46411. */
  46412. addFloorMesh(floorMesh: Mesh): void;
  46413. /**
  46414. * Removes a floor mesh from being used for teleportation.
  46415. * @param floorMesh the mesh to be removed.
  46416. */
  46417. removeFloorMesh(floorMesh: Mesh): void;
  46418. /**
  46419. * Enables interactions and teleportation using the VR controllers and gaze.
  46420. * @param vrTeleportationOptions options to modify teleportation behavior.
  46421. */
  46422. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46423. private _onNewGamepadConnected;
  46424. private _tryEnableInteractionOnController;
  46425. private _onNewGamepadDisconnected;
  46426. private _enableInteractionOnController;
  46427. private _checkTeleportWithRay;
  46428. private _checkRotate;
  46429. private _checkTeleportBackwards;
  46430. private _enableTeleportationOnController;
  46431. private _createTeleportationCircles;
  46432. private _displayTeleportationTarget;
  46433. private _hideTeleportationTarget;
  46434. private _rotateCamera;
  46435. private _moveTeleportationSelectorTo;
  46436. private _workingVector;
  46437. private _workingQuaternion;
  46438. private _workingMatrix;
  46439. /**
  46440. * Time Constant Teleportation Mode
  46441. */
  46442. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46443. /**
  46444. * Speed Constant Teleportation Mode
  46445. */
  46446. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46447. /**
  46448. * Teleports the users feet to the desired location
  46449. * @param location The location where the user's feet should be placed
  46450. */
  46451. teleportCamera(location: Vector3): void;
  46452. private _convertNormalToDirectionOfRay;
  46453. private _castRayAndSelectObject;
  46454. private _notifySelectedMeshUnselected;
  46455. /**
  46456. * Permanently set new colors for the laser pointer
  46457. * @param color the new laser color
  46458. * @param pickedColor the new laser color when picked mesh detected
  46459. */
  46460. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46461. /**
  46462. * Permanently set new colors for the gaze pointer
  46463. * @param color the new gaze color
  46464. * @param pickedColor the new gaze color when picked mesh detected
  46465. */
  46466. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46467. /**
  46468. * Sets the color of the laser ray from the vr controllers.
  46469. * @param color new color for the ray.
  46470. */
  46471. changeLaserColor(color: Color3): void;
  46472. /**
  46473. * Sets the color of the ray from the vr headsets gaze.
  46474. * @param color new color for the ray.
  46475. */
  46476. changeGazeColor(color: Color3): void;
  46477. /**
  46478. * Exits VR and disposes of the vr experience helper
  46479. */
  46480. dispose(): void;
  46481. /**
  46482. * Gets the name of the VRExperienceHelper class
  46483. * @returns "VRExperienceHelper"
  46484. */
  46485. getClassName(): string;
  46486. }
  46487. }
  46488. declare module "babylonjs/Cameras/VR/index" {
  46489. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  46490. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  46491. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46492. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  46493. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  46494. export * from "babylonjs/Cameras/VR/webVRCamera";
  46495. }
  46496. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  46497. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46498. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46499. import { Observable } from "babylonjs/Misc/observable";
  46500. import { Matrix } from "babylonjs/Maths/math.vector";
  46501. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46502. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46503. /**
  46504. * Options used for hit testing
  46505. */
  46506. export interface IWebXRHitTestOptions {
  46507. /**
  46508. * Only test when user interacted with the scene. Default - hit test every frame
  46509. */
  46510. testOnPointerDownOnly?: boolean;
  46511. /**
  46512. * The node to use to transform the local results to world coordinates
  46513. */
  46514. worldParentNode?: TransformNode;
  46515. }
  46516. /**
  46517. * Interface defining the babylon result of raycasting/hit-test
  46518. */
  46519. export interface IWebXRHitResult {
  46520. /**
  46521. * The native hit test result
  46522. */
  46523. xrHitResult: XRHitResult;
  46524. /**
  46525. * Transformation matrix that can be applied to a node that will put it in the hit point location
  46526. */
  46527. transformationMatrix: Matrix;
  46528. }
  46529. /**
  46530. * The currently-working hit-test module.
  46531. * Hit test (or raycasting) is used to interact with the real world.
  46532. * For further information read here - https://github.com/immersive-web/hit-test
  46533. */
  46534. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRFeature {
  46535. /**
  46536. * options to use when constructing this feature
  46537. */
  46538. readonly options: IWebXRHitTestOptions;
  46539. /**
  46540. * The module's name
  46541. */
  46542. static readonly Name: string;
  46543. /**
  46544. * The (Babylon) version of this module.
  46545. * This is an integer representing the implementation version.
  46546. * This number does not correspond to the webxr specs version
  46547. */
  46548. static readonly Version: number;
  46549. /**
  46550. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  46551. * @param event the (select) event to use to select with
  46552. * @param referenceSpace the reference space to use for this hit test
  46553. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46554. */
  46555. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  46556. /**
  46557. * execute a hit test with an XR Ray
  46558. *
  46559. * @param xrSession a native xrSession that will execute this hit test
  46560. * @param xrRay the ray (position and direction) to use for raycasting
  46561. * @param referenceSpace native XR reference space to use for the hit-test
  46562. * @param filter filter function that will filter the results
  46563. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46564. */
  46565. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  46566. /**
  46567. * Triggered when new babylon (transformed) hit test results are available
  46568. */
  46569. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  46570. private _onSelectEnabled;
  46571. /**
  46572. * Creates a new instance of the (legacy version) hit test feature
  46573. * @param _xrSessionManager an instance of WebXRSessionManager
  46574. * @param options options to use when constructing this feature
  46575. */
  46576. constructor(_xrSessionManager: WebXRSessionManager,
  46577. /**
  46578. * options to use when constructing this feature
  46579. */
  46580. options?: IWebXRHitTestOptions);
  46581. /**
  46582. * Populated with the last native XR Hit Results
  46583. */
  46584. lastNativeXRHitResults: XRHitResult[];
  46585. /**
  46586. * attach this feature
  46587. * Will usually be called by the features manager
  46588. *
  46589. * @returns true if successful.
  46590. */
  46591. attach(): boolean;
  46592. /**
  46593. * detach this feature.
  46594. * Will usually be called by the features manager
  46595. *
  46596. * @returns true if successful.
  46597. */
  46598. detach(): boolean;
  46599. private _onHitTestResults;
  46600. private _origin;
  46601. private _direction;
  46602. private _mat;
  46603. protected _onXRFrame(frame: XRFrame): void;
  46604. private _onSelect;
  46605. /**
  46606. * Dispose this feature and all of the resources attached
  46607. */
  46608. dispose(): void;
  46609. }
  46610. }
  46611. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  46612. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46614. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46615. import { Observable } from "babylonjs/Misc/observable";
  46616. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  46617. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46618. /**
  46619. * Options used in the plane detector module
  46620. */
  46621. export interface IWebXRPlaneDetectorOptions {
  46622. /**
  46623. * The node to use to transform the local results to world coordinates
  46624. */
  46625. worldParentNode?: TransformNode;
  46626. }
  46627. /**
  46628. * A babylon interface for a webxr plane.
  46629. * A Plane is actually a polygon, built from N points in space
  46630. */
  46631. export interface IWebXRPlane {
  46632. /**
  46633. * a babylon-assigned ID for this polygon
  46634. */
  46635. id: number;
  46636. /**
  46637. * the native xr-plane object
  46638. */
  46639. xrPlane: XRPlane;
  46640. /**
  46641. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  46642. */
  46643. polygonDefinition: Array<Vector3>;
  46644. /**
  46645. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  46646. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  46647. */
  46648. transformationMatrix: Matrix;
  46649. }
  46650. /**
  46651. * The plane detector is used to detect planes in the real world when in AR
  46652. * For more information see https://github.com/immersive-web/real-world-geometry/
  46653. */
  46654. export class WebXRPlaneDetector extends WebXRAbstractFeature implements IWebXRFeature {
  46655. private _options;
  46656. /**
  46657. * The module's name
  46658. */
  46659. static readonly Name: string;
  46660. /**
  46661. * The (Babylon) version of this module.
  46662. * This is an integer representing the implementation version.
  46663. * This number does not correspond to the webxr specs version
  46664. */
  46665. static readonly Version: number;
  46666. /**
  46667. * Observers registered here will be executed when a new plane was added to the session
  46668. */
  46669. onPlaneAddedObservable: Observable<IWebXRPlane>;
  46670. /**
  46671. * Observers registered here will be executed when a plane is no longer detected in the session
  46672. */
  46673. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  46674. /**
  46675. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  46676. * This can execute N times every frame
  46677. */
  46678. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  46679. private _enabled;
  46680. private _detectedPlanes;
  46681. private _lastFrameDetected;
  46682. /**
  46683. * construct a new Plane Detector
  46684. * @param _xrSessionManager an instance of xr Session manager
  46685. * @param _options configuration to use when constructing this feature
  46686. */
  46687. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  46688. protected _onXRFrame(frame: XRFrame): void;
  46689. /**
  46690. * Dispose this feature and all of the resources attached
  46691. */
  46692. dispose(): void;
  46693. private _updatePlaneWithXRPlane;
  46694. /**
  46695. * avoiding using Array.find for global support.
  46696. * @param xrPlane the plane to find in the array
  46697. */
  46698. private findIndexInPlaneArray;
  46699. }
  46700. }
  46701. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46702. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46703. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46704. import { Observable } from "babylonjs/Misc/observable";
  46705. import { Matrix } from "babylonjs/Maths/math.vector";
  46706. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46707. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46708. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46709. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46710. /**
  46711. * Configuration options of the anchor system
  46712. */
  46713. export interface IWebXRAnchorSystemOptions {
  46714. /**
  46715. * a node that will be used to convert local to world coordinates
  46716. */
  46717. worldParentNode?: TransformNode;
  46718. /**
  46719. * should the anchor system use plane detection.
  46720. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46721. */
  46722. usePlaneDetection?: boolean;
  46723. /**
  46724. * Should a new anchor be added every time a select event is triggered
  46725. */
  46726. addAnchorOnSelect?: boolean;
  46727. }
  46728. /**
  46729. * A babylon container for an XR Anchor
  46730. */
  46731. export interface IWebXRAnchor {
  46732. /**
  46733. * A babylon-assigned ID for this anchor
  46734. */
  46735. id: number;
  46736. /**
  46737. * The native anchor object
  46738. */
  46739. xrAnchor: XRAnchor;
  46740. /**
  46741. * Transformation matrix to apply to an object attached to this anchor
  46742. */
  46743. transformationMatrix: Matrix;
  46744. }
  46745. /**
  46746. * An implementation of the anchor system of WebXR.
  46747. * Note that the current documented implementation is not available in any browser. Future implementations
  46748. * will use the frame to create an anchor and not the session or a detected plane
  46749. * For further information see https://github.com/immersive-web/anchors/
  46750. */
  46751. export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFeature {
  46752. private _options;
  46753. /**
  46754. * The module's name
  46755. */
  46756. static readonly Name: string;
  46757. /**
  46758. * The (Babylon) version of this module.
  46759. * This is an integer representing the implementation version.
  46760. * This number does not correspond to the webxr specs version
  46761. */
  46762. static readonly Version: number;
  46763. /**
  46764. * Observers registered here will be executed when a new anchor was added to the session
  46765. */
  46766. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46767. /**
  46768. * Observers registered here will be executed when an existing anchor updates
  46769. * This can execute N times every frame
  46770. */
  46771. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46772. /**
  46773. * Observers registered here will be executed when an anchor was removed from the session
  46774. */
  46775. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46776. private _planeDetector;
  46777. private _hitTestModule;
  46778. private _enabled;
  46779. private _trackedAnchors;
  46780. private _lastFrameDetected;
  46781. /**
  46782. * constructs a new anchor system
  46783. * @param _xrSessionManager an instance of WebXRSessionManager
  46784. * @param _options configuration object for this feature
  46785. */
  46786. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46787. /**
  46788. * set the plane detector to use in order to create anchors from frames
  46789. * @param planeDetector the plane-detector module to use
  46790. * @param enable enable plane-anchors. default is true
  46791. */
  46792. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46793. /**
  46794. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46795. * @param hitTestModule the hit-test module to use.
  46796. */
  46797. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46798. /**
  46799. * attach this feature
  46800. * Will usually be called by the features manager
  46801. *
  46802. * @returns true if successful.
  46803. */
  46804. attach(): boolean;
  46805. /**
  46806. * detach this feature.
  46807. * Will usually be called by the features manager
  46808. *
  46809. * @returns true if successful.
  46810. */
  46811. detach(): boolean;
  46812. /**
  46813. * Dispose this feature and all of the resources attached
  46814. */
  46815. dispose(): void;
  46816. protected _onXRFrame(frame: XRFrame): void;
  46817. private _onSelect;
  46818. /**
  46819. * Add anchor at a specific XR point.
  46820. *
  46821. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46822. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46823. * @returns a promise the fulfills when the anchor was created
  46824. */
  46825. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46826. private _updateAnchorWithXRFrame;
  46827. /**
  46828. * avoiding using Array.find for global support.
  46829. * @param xrAnchor the plane to find in the array
  46830. */
  46831. private _findIndexInAnchorArray;
  46832. }
  46833. }
  46834. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46835. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46836. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46838. import { Observable } from "babylonjs/Misc/observable";
  46839. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46840. /**
  46841. * Options interface for the background remover plugin
  46842. */
  46843. export interface IWebXRBackgroundRemoverOptions {
  46844. /**
  46845. * don't disable the environment helper
  46846. */
  46847. ignoreEnvironmentHelper?: boolean;
  46848. /**
  46849. * flags to configure the removal of the environment helper.
  46850. * If not set, the entire background will be removed. If set, flags should be set as well.
  46851. */
  46852. environmentHelperRemovalFlags?: {
  46853. /**
  46854. * Should the skybox be removed (default false)
  46855. */
  46856. skyBox?: boolean;
  46857. /**
  46858. * Should the ground be removed (default false)
  46859. */
  46860. ground?: boolean;
  46861. };
  46862. /**
  46863. * Further background meshes to disable when entering AR
  46864. */
  46865. backgroundMeshes?: AbstractMesh[];
  46866. }
  46867. /**
  46868. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46869. */
  46870. export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWebXRFeature {
  46871. /**
  46872. * read-only options to be used in this module
  46873. */
  46874. readonly options: IWebXRBackgroundRemoverOptions;
  46875. /**
  46876. * The module's name
  46877. */
  46878. static readonly Name: string;
  46879. /**
  46880. * The (Babylon) version of this module.
  46881. * This is an integer representing the implementation version.
  46882. * This number does not correspond to the webxr specs version
  46883. */
  46884. static readonly Version: number;
  46885. /**
  46886. * registered observers will be triggered when the background state changes
  46887. */
  46888. onBackgroundStateChangedObservable: Observable<boolean>;
  46889. /**
  46890. * constructs a new background remover module
  46891. * @param _xrSessionManager the session manager for this module
  46892. * @param options read-only options to be used in this module
  46893. */
  46894. constructor(_xrSessionManager: WebXRSessionManager,
  46895. /**
  46896. * read-only options to be used in this module
  46897. */
  46898. options?: IWebXRBackgroundRemoverOptions);
  46899. /**
  46900. * attach this feature
  46901. * Will usually be called by the features manager
  46902. *
  46903. * @returns true if successful.
  46904. */
  46905. attach(): boolean;
  46906. /**
  46907. * detach this feature.
  46908. * Will usually be called by the features manager
  46909. *
  46910. * @returns true if successful.
  46911. */
  46912. detach(): boolean;
  46913. private _setBackgroundState;
  46914. /**
  46915. * Dispose this feature and all of the resources attached
  46916. */
  46917. dispose(): void;
  46918. }
  46919. }
  46920. declare module "babylonjs/Cameras/XR/features/index" {
  46921. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46922. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46923. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46924. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46925. export * from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  46926. export * from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  46927. }
  46928. declare module "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController" {
  46929. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46931. import { Scene } from "babylonjs/scene";
  46932. /**
  46933. * The motion controller class for all microsoft mixed reality controllers
  46934. */
  46935. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  46936. /**
  46937. * The base url used to load the left and right controller models
  46938. */
  46939. static MODEL_BASE_URL: string;
  46940. /**
  46941. * The name of the left controller model file
  46942. */
  46943. static MODEL_LEFT_FILENAME: string;
  46944. /**
  46945. * The name of the right controller model file
  46946. */
  46947. static MODEL_RIGHT_FILENAME: string;
  46948. profileId: string;
  46949. protected readonly _mapping: {
  46950. defaultButton: {
  46951. "valueNodeName": string;
  46952. "unpressedNodeName": string;
  46953. "pressedNodeName": string;
  46954. };
  46955. defaultAxis: {
  46956. "valueNodeName": string;
  46957. "minNodeName": string;
  46958. "maxNodeName": string;
  46959. };
  46960. buttons: {
  46961. "xr-standard-trigger": {
  46962. "rootNodeName": string;
  46963. "componentProperty": string;
  46964. "states": string[];
  46965. };
  46966. "xr-standard-squeeze": {
  46967. "rootNodeName": string;
  46968. "componentProperty": string;
  46969. "states": string[];
  46970. };
  46971. "xr-standard-touchpad": {
  46972. "rootNodeName": string;
  46973. "labelAnchorNodeName": string;
  46974. "touchPointNodeName": string;
  46975. };
  46976. "xr-standard-thumbstick": {
  46977. "rootNodeName": string;
  46978. "componentProperty": string;
  46979. "states": string[];
  46980. };
  46981. };
  46982. axes: {
  46983. "xr-standard-touchpad": {
  46984. "x-axis": {
  46985. "rootNodeName": string;
  46986. };
  46987. "y-axis": {
  46988. "rootNodeName": string;
  46989. };
  46990. };
  46991. "xr-standard-thumbstick": {
  46992. "x-axis": {
  46993. "rootNodeName": string;
  46994. };
  46995. "y-axis": {
  46996. "rootNodeName": string;
  46997. };
  46998. };
  46999. };
  47000. };
  47001. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  47002. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47003. private _getChildByName;
  47004. private _getImmediateChildByName;
  47005. protected _getFilenameAndPath(): {
  47006. filename: string;
  47007. path: string;
  47008. };
  47009. protected _updateModel(): void;
  47010. protected _getModelLoadingConstraints(): boolean;
  47011. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47012. }
  47013. }
  47014. declare module "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController" {
  47015. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47017. import { Scene } from "babylonjs/scene";
  47018. /**
  47019. * The motion controller class for oculus touch (quest, rift).
  47020. * This class supports legacy mapping as well the standard xr mapping
  47021. */
  47022. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  47023. private _forceLegacyControllers;
  47024. /**
  47025. * The base url used to load the left and right controller models
  47026. */
  47027. static MODEL_BASE_URL: string;
  47028. /**
  47029. * The name of the left controller model file
  47030. */
  47031. static MODEL_LEFT_FILENAME: string;
  47032. /**
  47033. * The name of the right controller model file
  47034. */
  47035. static MODEL_RIGHT_FILENAME: string;
  47036. /**
  47037. * Base Url for the Quest controller model.
  47038. */
  47039. static QUEST_MODEL_BASE_URL: string;
  47040. profileId: string;
  47041. private _modelRootNode;
  47042. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  47043. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47044. protected _getFilenameAndPath(): {
  47045. filename: string;
  47046. path: string;
  47047. };
  47048. /**
  47049. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  47050. * between the touch and touch 2.
  47051. */
  47052. private _isQuest;
  47053. protected _updateModel(): void;
  47054. protected _getModelLoadingConstraints(): boolean;
  47055. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47056. }
  47057. }
  47058. declare module "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController" {
  47059. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47060. import { Scene } from "babylonjs/scene";
  47061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47062. /**
  47063. * The motion controller class for the standard HTC-Vive controllers
  47064. */
  47065. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  47066. /**
  47067. * The base url used to load the left and right controller models
  47068. */
  47069. static MODEL_BASE_URL: string;
  47070. /**
  47071. * File name for the controller model.
  47072. */
  47073. static MODEL_FILENAME: string;
  47074. profileId: string;
  47075. private _modelRootNode;
  47076. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  47077. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47078. protected _getFilenameAndPath(): {
  47079. filename: string;
  47080. path: string;
  47081. };
  47082. protected _updateModel(): void;
  47083. protected _getModelLoadingConstraints(): boolean;
  47084. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47085. }
  47086. }
  47087. declare module "babylonjs/Cameras/XR/motionController/index" {
  47088. export * from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47089. export * from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  47090. export * from "babylonjs/Cameras/XR/motionController/webXRGenericMotionController";
  47091. export * from "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController";
  47092. export * from "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager";
  47093. export * from "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController";
  47094. export * from "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController";
  47095. }
  47096. declare module "babylonjs/Cameras/XR/index" {
  47097. export * from "babylonjs/Cameras/XR/webXRCamera";
  47098. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  47099. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47100. export * from "babylonjs/Cameras/XR/webXRInput";
  47101. export * from "babylonjs/Cameras/XR/webXRController";
  47102. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  47103. export * from "babylonjs/Cameras/XR/webXRTypes";
  47104. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  47105. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  47106. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  47107. export * from "babylonjs/Cameras/XR/features/index";
  47108. export * from "babylonjs/Cameras/XR/motionController/index";
  47109. }
  47110. declare module "babylonjs/Cameras/RigModes/index" {
  47111. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47112. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47113. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47114. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47115. }
  47116. declare module "babylonjs/Cameras/index" {
  47117. export * from "babylonjs/Cameras/Inputs/index";
  47118. export * from "babylonjs/Cameras/cameraInputsManager";
  47119. export * from "babylonjs/Cameras/camera";
  47120. export * from "babylonjs/Cameras/targetCamera";
  47121. export * from "babylonjs/Cameras/freeCamera";
  47122. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47123. export * from "babylonjs/Cameras/touchCamera";
  47124. export * from "babylonjs/Cameras/arcRotateCamera";
  47125. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47126. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47127. export * from "babylonjs/Cameras/flyCamera";
  47128. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47129. export * from "babylonjs/Cameras/followCamera";
  47130. export * from "babylonjs/Cameras/followCameraInputsManager";
  47131. export * from "babylonjs/Cameras/gamepadCamera";
  47132. export * from "babylonjs/Cameras/Stereoscopic/index";
  47133. export * from "babylonjs/Cameras/universalCamera";
  47134. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47135. export * from "babylonjs/Cameras/VR/index";
  47136. export * from "babylonjs/Cameras/XR/index";
  47137. export * from "babylonjs/Cameras/RigModes/index";
  47138. }
  47139. declare module "babylonjs/Collisions/index" {
  47140. export * from "babylonjs/Collisions/collider";
  47141. export * from "babylonjs/Collisions/collisionCoordinator";
  47142. export * from "babylonjs/Collisions/pickingInfo";
  47143. export * from "babylonjs/Collisions/intersectionInfo";
  47144. export * from "babylonjs/Collisions/meshCollisionData";
  47145. }
  47146. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47147. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47148. import { Vector3 } from "babylonjs/Maths/math.vector";
  47149. import { Ray } from "babylonjs/Culling/ray";
  47150. import { Plane } from "babylonjs/Maths/math.plane";
  47151. /**
  47152. * Contains an array of blocks representing the octree
  47153. */
  47154. export interface IOctreeContainer<T> {
  47155. /**
  47156. * Blocks within the octree
  47157. */
  47158. blocks: Array<OctreeBlock<T>>;
  47159. }
  47160. /**
  47161. * Class used to store a cell in an octree
  47162. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47163. */
  47164. export class OctreeBlock<T> {
  47165. /**
  47166. * Gets the content of the current block
  47167. */
  47168. entries: T[];
  47169. /**
  47170. * Gets the list of block children
  47171. */
  47172. blocks: Array<OctreeBlock<T>>;
  47173. private _depth;
  47174. private _maxDepth;
  47175. private _capacity;
  47176. private _minPoint;
  47177. private _maxPoint;
  47178. private _boundingVectors;
  47179. private _creationFunc;
  47180. /**
  47181. * Creates a new block
  47182. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47183. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47184. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47185. * @param depth defines the current depth of this block in the octree
  47186. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47187. * @param creationFunc defines a callback to call when an element is added to the block
  47188. */
  47189. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47190. /**
  47191. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47192. */
  47193. get capacity(): number;
  47194. /**
  47195. * Gets the minimum vector (in world space) of the block's bounding box
  47196. */
  47197. get minPoint(): Vector3;
  47198. /**
  47199. * Gets the maximum vector (in world space) of the block's bounding box
  47200. */
  47201. get maxPoint(): Vector3;
  47202. /**
  47203. * Add a new element to this block
  47204. * @param entry defines the element to add
  47205. */
  47206. addEntry(entry: T): void;
  47207. /**
  47208. * Remove an element from this block
  47209. * @param entry defines the element to remove
  47210. */
  47211. removeEntry(entry: T): void;
  47212. /**
  47213. * Add an array of elements to this block
  47214. * @param entries defines the array of elements to add
  47215. */
  47216. addEntries(entries: T[]): void;
  47217. /**
  47218. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47219. * @param frustumPlanes defines the frustum planes to test
  47220. * @param selection defines the array to store current content if selection is positive
  47221. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47222. */
  47223. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47224. /**
  47225. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47226. * @param sphereCenter defines the bounding sphere center
  47227. * @param sphereRadius defines the bounding sphere radius
  47228. * @param selection defines the array to store current content if selection is positive
  47229. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47230. */
  47231. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47232. /**
  47233. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47234. * @param ray defines the ray to test with
  47235. * @param selection defines the array to store current content if selection is positive
  47236. */
  47237. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47238. /**
  47239. * Subdivide the content into child blocks (this block will then be empty)
  47240. */
  47241. createInnerBlocks(): void;
  47242. /**
  47243. * @hidden
  47244. */
  47245. 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;
  47246. }
  47247. }
  47248. declare module "babylonjs/Culling/Octrees/octree" {
  47249. import { SmartArray } from "babylonjs/Misc/smartArray";
  47250. import { Vector3 } from "babylonjs/Maths/math.vector";
  47251. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47253. import { Ray } from "babylonjs/Culling/ray";
  47254. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47255. import { Plane } from "babylonjs/Maths/math.plane";
  47256. /**
  47257. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47258. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47259. */
  47260. export class Octree<T> {
  47261. /** 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.) */
  47262. maxDepth: number;
  47263. /**
  47264. * Blocks within the octree containing objects
  47265. */
  47266. blocks: Array<OctreeBlock<T>>;
  47267. /**
  47268. * Content stored in the octree
  47269. */
  47270. dynamicContent: T[];
  47271. private _maxBlockCapacity;
  47272. private _selectionContent;
  47273. private _creationFunc;
  47274. /**
  47275. * Creates a octree
  47276. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47277. * @param creationFunc function to be used to instatiate the octree
  47278. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47279. * @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.)
  47280. */
  47281. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47282. /** 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.) */
  47283. maxDepth?: number);
  47284. /**
  47285. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47286. * @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);
  47287. * @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);
  47288. * @param entries meshes to be added to the octree blocks
  47289. */
  47290. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47291. /**
  47292. * Adds a mesh to the octree
  47293. * @param entry Mesh to add to the octree
  47294. */
  47295. addMesh(entry: T): void;
  47296. /**
  47297. * Remove an element from the octree
  47298. * @param entry defines the element to remove
  47299. */
  47300. removeMesh(entry: T): void;
  47301. /**
  47302. * Selects an array of meshes within the frustum
  47303. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47304. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47305. * @returns array of meshes within the frustum
  47306. */
  47307. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47308. /**
  47309. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47310. * @param sphereCenter defines the bounding sphere center
  47311. * @param sphereRadius defines the bounding sphere radius
  47312. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47313. * @returns an array of objects that intersect the sphere
  47314. */
  47315. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47316. /**
  47317. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47318. * @param ray defines the ray to test with
  47319. * @returns array of intersected objects
  47320. */
  47321. intersectsRay(ray: Ray): SmartArray<T>;
  47322. /**
  47323. * Adds a mesh into the octree block if it intersects the block
  47324. */
  47325. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47326. /**
  47327. * Adds a submesh into the octree block if it intersects the block
  47328. */
  47329. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47330. }
  47331. }
  47332. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47333. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47334. import { Scene } from "babylonjs/scene";
  47335. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47337. import { Ray } from "babylonjs/Culling/ray";
  47338. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47339. import { Collider } from "babylonjs/Collisions/collider";
  47340. module "babylonjs/scene" {
  47341. interface Scene {
  47342. /**
  47343. * @hidden
  47344. * Backing Filed
  47345. */
  47346. _selectionOctree: Octree<AbstractMesh>;
  47347. /**
  47348. * Gets the octree used to boost mesh selection (picking)
  47349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47350. */
  47351. selectionOctree: Octree<AbstractMesh>;
  47352. /**
  47353. * Creates or updates the octree used to boost selection (picking)
  47354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47355. * @param maxCapacity defines the maximum capacity per leaf
  47356. * @param maxDepth defines the maximum depth of the octree
  47357. * @returns an octree of AbstractMesh
  47358. */
  47359. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47360. }
  47361. }
  47362. module "babylonjs/Meshes/abstractMesh" {
  47363. interface AbstractMesh {
  47364. /**
  47365. * @hidden
  47366. * Backing Field
  47367. */
  47368. _submeshesOctree: Octree<SubMesh>;
  47369. /**
  47370. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47371. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47372. * @param maxCapacity defines the maximum size of each block (64 by default)
  47373. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47374. * @returns the new octree
  47375. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47377. */
  47378. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47379. }
  47380. }
  47381. /**
  47382. * Defines the octree scene component responsible to manage any octrees
  47383. * in a given scene.
  47384. */
  47385. export class OctreeSceneComponent {
  47386. /**
  47387. * The component name help to identify the component in the list of scene components.
  47388. */
  47389. readonly name: string;
  47390. /**
  47391. * The scene the component belongs to.
  47392. */
  47393. scene: Scene;
  47394. /**
  47395. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47396. */
  47397. readonly checksIsEnabled: boolean;
  47398. /**
  47399. * Creates a new instance of the component for the given scene
  47400. * @param scene Defines the scene to register the component in
  47401. */
  47402. constructor(scene: Scene);
  47403. /**
  47404. * Registers the component in a given scene
  47405. */
  47406. register(): void;
  47407. /**
  47408. * Return the list of active meshes
  47409. * @returns the list of active meshes
  47410. */
  47411. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47412. /**
  47413. * Return the list of active sub meshes
  47414. * @param mesh The mesh to get the candidates sub meshes from
  47415. * @returns the list of active sub meshes
  47416. */
  47417. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47418. private _tempRay;
  47419. /**
  47420. * Return the list of sub meshes intersecting with a given local ray
  47421. * @param mesh defines the mesh to find the submesh for
  47422. * @param localRay defines the ray in local space
  47423. * @returns the list of intersecting sub meshes
  47424. */
  47425. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47426. /**
  47427. * Return the list of sub meshes colliding with a collider
  47428. * @param mesh defines the mesh to find the submesh for
  47429. * @param collider defines the collider to evaluate the collision against
  47430. * @returns the list of colliding sub meshes
  47431. */
  47432. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47433. /**
  47434. * Rebuilds the elements related to this component in case of
  47435. * context lost for instance.
  47436. */
  47437. rebuild(): void;
  47438. /**
  47439. * Disposes the component and the associated ressources.
  47440. */
  47441. dispose(): void;
  47442. }
  47443. }
  47444. declare module "babylonjs/Culling/Octrees/index" {
  47445. export * from "babylonjs/Culling/Octrees/octree";
  47446. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47447. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47448. }
  47449. declare module "babylonjs/Culling/index" {
  47450. export * from "babylonjs/Culling/boundingBox";
  47451. export * from "babylonjs/Culling/boundingInfo";
  47452. export * from "babylonjs/Culling/boundingSphere";
  47453. export * from "babylonjs/Culling/Octrees/index";
  47454. export * from "babylonjs/Culling/ray";
  47455. }
  47456. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  47457. import { IDisposable, Scene } from "babylonjs/scene";
  47458. import { Nullable } from "babylonjs/types";
  47459. import { Observable } from "babylonjs/Misc/observable";
  47460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47461. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  47462. import { Camera } from "babylonjs/Cameras/camera";
  47463. /**
  47464. * Renders a layer on top of an existing scene
  47465. */
  47466. export class UtilityLayerRenderer implements IDisposable {
  47467. /** the original scene that will be rendered on top of */
  47468. originalScene: Scene;
  47469. private _pointerCaptures;
  47470. private _lastPointerEvents;
  47471. private static _DefaultUtilityLayer;
  47472. private static _DefaultKeepDepthUtilityLayer;
  47473. private _sharedGizmoLight;
  47474. private _renderCamera;
  47475. /**
  47476. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47477. * @returns the camera that is used when rendering the utility layer
  47478. */
  47479. getRenderCamera(): Nullable<Camera>;
  47480. /**
  47481. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47482. * @param cam the camera that should be used when rendering the utility layer
  47483. */
  47484. setRenderCamera(cam: Nullable<Camera>): void;
  47485. /**
  47486. * @hidden
  47487. * Light which used by gizmos to get light shading
  47488. */
  47489. _getSharedGizmoLight(): HemisphericLight;
  47490. /**
  47491. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47492. */
  47493. pickUtilitySceneFirst: boolean;
  47494. /**
  47495. * 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)
  47496. */
  47497. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47498. /**
  47499. * 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)
  47500. */
  47501. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47502. /**
  47503. * The scene that is rendered on top of the original scene
  47504. */
  47505. utilityLayerScene: Scene;
  47506. /**
  47507. * If the utility layer should automatically be rendered on top of existing scene
  47508. */
  47509. shouldRender: boolean;
  47510. /**
  47511. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47512. */
  47513. onlyCheckPointerDownEvents: boolean;
  47514. /**
  47515. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47516. */
  47517. processAllEvents: boolean;
  47518. /**
  47519. * Observable raised when the pointer move from the utility layer scene to the main scene
  47520. */
  47521. onPointerOutObservable: Observable<number>;
  47522. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47523. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47524. private _afterRenderObserver;
  47525. private _sceneDisposeObserver;
  47526. private _originalPointerObserver;
  47527. /**
  47528. * Instantiates a UtilityLayerRenderer
  47529. * @param originalScene the original scene that will be rendered on top of
  47530. * @param handleEvents boolean indicating if the utility layer should handle events
  47531. */
  47532. constructor(
  47533. /** the original scene that will be rendered on top of */
  47534. originalScene: Scene, handleEvents?: boolean);
  47535. private _notifyObservers;
  47536. /**
  47537. * Renders the utility layers scene on top of the original scene
  47538. */
  47539. render(): void;
  47540. /**
  47541. * Disposes of the renderer
  47542. */
  47543. dispose(): void;
  47544. private _updateCamera;
  47545. }
  47546. }
  47547. declare module "babylonjs/Gizmos/gizmo" {
  47548. import { Nullable } from "babylonjs/types";
  47549. import { IDisposable } from "babylonjs/scene";
  47550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47551. import { Mesh } from "babylonjs/Meshes/mesh";
  47552. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47553. /**
  47554. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47555. */
  47556. export class Gizmo implements IDisposable {
  47557. /** The utility layer the gizmo will be added to */
  47558. gizmoLayer: UtilityLayerRenderer;
  47559. /**
  47560. * The root mesh of the gizmo
  47561. */
  47562. _rootMesh: Mesh;
  47563. private _attachedMesh;
  47564. /**
  47565. * Ratio for the scale of the gizmo (Default: 1)
  47566. */
  47567. scaleRatio: number;
  47568. /**
  47569. * If a custom mesh has been set (Default: false)
  47570. */
  47571. protected _customMeshSet: boolean;
  47572. /**
  47573. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47574. * * When set, interactions will be enabled
  47575. */
  47576. get attachedMesh(): Nullable<AbstractMesh>;
  47577. set attachedMesh(value: Nullable<AbstractMesh>);
  47578. /**
  47579. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47580. * @param mesh The mesh to replace the default mesh of the gizmo
  47581. */
  47582. setCustomMesh(mesh: Mesh): void;
  47583. /**
  47584. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47585. */
  47586. updateGizmoRotationToMatchAttachedMesh: boolean;
  47587. /**
  47588. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47589. */
  47590. updateGizmoPositionToMatchAttachedMesh: boolean;
  47591. /**
  47592. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47593. */
  47594. updateScale: boolean;
  47595. protected _interactionsEnabled: boolean;
  47596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47597. private _beforeRenderObserver;
  47598. private _tempVector;
  47599. /**
  47600. * Creates a gizmo
  47601. * @param gizmoLayer The utility layer the gizmo will be added to
  47602. */
  47603. constructor(
  47604. /** The utility layer the gizmo will be added to */
  47605. gizmoLayer?: UtilityLayerRenderer);
  47606. /**
  47607. * Updates the gizmo to match the attached mesh's position/rotation
  47608. */
  47609. protected _update(): void;
  47610. /**
  47611. * Disposes of the gizmo
  47612. */
  47613. dispose(): void;
  47614. }
  47615. }
  47616. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47617. import { Observable } from "babylonjs/Misc/observable";
  47618. import { Nullable } from "babylonjs/types";
  47619. import { Vector3 } from "babylonjs/Maths/math.vector";
  47620. import { Color3 } from "babylonjs/Maths/math.color";
  47621. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47623. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47624. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47625. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47626. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47627. import { Scene } from "babylonjs/scene";
  47628. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47629. /**
  47630. * Single plane drag gizmo
  47631. */
  47632. export class PlaneDragGizmo extends Gizmo {
  47633. /**
  47634. * Drag behavior responsible for the gizmos dragging interactions
  47635. */
  47636. dragBehavior: PointerDragBehavior;
  47637. private _pointerObserver;
  47638. /**
  47639. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47640. */
  47641. snapDistance: number;
  47642. /**
  47643. * Event that fires each time the gizmo snaps to a new location.
  47644. * * snapDistance is the the change in distance
  47645. */
  47646. onSnapObservable: Observable<{
  47647. snapDistance: number;
  47648. }>;
  47649. private _plane;
  47650. private _coloredMaterial;
  47651. private _hoverMaterial;
  47652. private _isEnabled;
  47653. private _parent;
  47654. /** @hidden */
  47655. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47656. /** @hidden */
  47657. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47658. /**
  47659. * Creates a PlaneDragGizmo
  47660. * @param gizmoLayer The utility layer the gizmo will be added to
  47661. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47662. * @param color The color of the gizmo
  47663. */
  47664. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47665. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47666. /**
  47667. * If the gizmo is enabled
  47668. */
  47669. set isEnabled(value: boolean);
  47670. get isEnabled(): boolean;
  47671. /**
  47672. * Disposes of the gizmo
  47673. */
  47674. dispose(): void;
  47675. }
  47676. }
  47677. declare module "babylonjs/Gizmos/positionGizmo" {
  47678. import { Observable } from "babylonjs/Misc/observable";
  47679. import { Nullable } from "babylonjs/types";
  47680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47681. import { Mesh } from "babylonjs/Meshes/mesh";
  47682. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47683. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47684. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47685. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47686. /**
  47687. * Gizmo that enables dragging a mesh along 3 axis
  47688. */
  47689. export class PositionGizmo extends Gizmo {
  47690. /**
  47691. * Internal gizmo used for interactions on the x axis
  47692. */
  47693. xGizmo: AxisDragGizmo;
  47694. /**
  47695. * Internal gizmo used for interactions on the y axis
  47696. */
  47697. yGizmo: AxisDragGizmo;
  47698. /**
  47699. * Internal gizmo used for interactions on the z axis
  47700. */
  47701. zGizmo: AxisDragGizmo;
  47702. /**
  47703. * Internal gizmo used for interactions on the yz plane
  47704. */
  47705. xPlaneGizmo: PlaneDragGizmo;
  47706. /**
  47707. * Internal gizmo used for interactions on the xz plane
  47708. */
  47709. yPlaneGizmo: PlaneDragGizmo;
  47710. /**
  47711. * Internal gizmo used for interactions on the xy plane
  47712. */
  47713. zPlaneGizmo: PlaneDragGizmo;
  47714. /**
  47715. * private variables
  47716. */
  47717. private _meshAttached;
  47718. private _updateGizmoRotationToMatchAttachedMesh;
  47719. private _snapDistance;
  47720. private _scaleRatio;
  47721. /** Fires an event when any of it's sub gizmos are dragged */
  47722. onDragStartObservable: Observable<unknown>;
  47723. /** Fires an event when any of it's sub gizmos are released from dragging */
  47724. onDragEndObservable: Observable<unknown>;
  47725. /**
  47726. * If set to true, planar drag is enabled
  47727. */
  47728. private _planarGizmoEnabled;
  47729. get attachedMesh(): Nullable<AbstractMesh>;
  47730. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47731. /**
  47732. * Creates a PositionGizmo
  47733. * @param gizmoLayer The utility layer the gizmo will be added to
  47734. */
  47735. constructor(gizmoLayer?: UtilityLayerRenderer);
  47736. /**
  47737. * If the planar drag gizmo is enabled
  47738. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47739. */
  47740. set planarGizmoEnabled(value: boolean);
  47741. get planarGizmoEnabled(): boolean;
  47742. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47743. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47744. /**
  47745. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47746. */
  47747. set snapDistance(value: number);
  47748. get snapDistance(): number;
  47749. /**
  47750. * Ratio for the scale of the gizmo (Default: 1)
  47751. */
  47752. set scaleRatio(value: number);
  47753. get scaleRatio(): number;
  47754. /**
  47755. * Disposes of the gizmo
  47756. */
  47757. dispose(): void;
  47758. /**
  47759. * CustomMeshes are not supported by this gizmo
  47760. * @param mesh The mesh to replace the default mesh of the gizmo
  47761. */
  47762. setCustomMesh(mesh: Mesh): void;
  47763. }
  47764. }
  47765. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47766. import { Observable } from "babylonjs/Misc/observable";
  47767. import { Nullable } from "babylonjs/types";
  47768. import { Vector3 } from "babylonjs/Maths/math.vector";
  47769. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47771. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47772. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47773. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47774. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47775. import { Scene } from "babylonjs/scene";
  47776. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47777. import { Color3 } from "babylonjs/Maths/math.color";
  47778. /**
  47779. * Single axis drag gizmo
  47780. */
  47781. export class AxisDragGizmo extends Gizmo {
  47782. /**
  47783. * Drag behavior responsible for the gizmos dragging interactions
  47784. */
  47785. dragBehavior: PointerDragBehavior;
  47786. private _pointerObserver;
  47787. /**
  47788. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47789. */
  47790. snapDistance: number;
  47791. /**
  47792. * Event that fires each time the gizmo snaps to a new location.
  47793. * * snapDistance is the the change in distance
  47794. */
  47795. onSnapObservable: Observable<{
  47796. snapDistance: number;
  47797. }>;
  47798. private _isEnabled;
  47799. private _parent;
  47800. private _arrow;
  47801. private _coloredMaterial;
  47802. private _hoverMaterial;
  47803. /** @hidden */
  47804. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47805. /** @hidden */
  47806. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47807. /**
  47808. * Creates an AxisDragGizmo
  47809. * @param gizmoLayer The utility layer the gizmo will be added to
  47810. * @param dragAxis The axis which the gizmo will be able to drag on
  47811. * @param color The color of the gizmo
  47812. */
  47813. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47814. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47815. /**
  47816. * If the gizmo is enabled
  47817. */
  47818. set isEnabled(value: boolean);
  47819. get isEnabled(): boolean;
  47820. /**
  47821. * Disposes of the gizmo
  47822. */
  47823. dispose(): void;
  47824. }
  47825. }
  47826. declare module "babylonjs/Debug/axesViewer" {
  47827. import { Vector3 } from "babylonjs/Maths/math.vector";
  47828. import { Nullable } from "babylonjs/types";
  47829. import { Scene } from "babylonjs/scene";
  47830. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47831. /**
  47832. * The Axes viewer will show 3 axes in a specific point in space
  47833. */
  47834. export class AxesViewer {
  47835. private _xAxis;
  47836. private _yAxis;
  47837. private _zAxis;
  47838. private _scaleLinesFactor;
  47839. private _instanced;
  47840. /**
  47841. * Gets the hosting scene
  47842. */
  47843. scene: Scene;
  47844. /**
  47845. * Gets or sets a number used to scale line length
  47846. */
  47847. scaleLines: number;
  47848. /** Gets the node hierarchy used to render x-axis */
  47849. get xAxis(): TransformNode;
  47850. /** Gets the node hierarchy used to render y-axis */
  47851. get yAxis(): TransformNode;
  47852. /** Gets the node hierarchy used to render z-axis */
  47853. get zAxis(): TransformNode;
  47854. /**
  47855. * Creates a new AxesViewer
  47856. * @param scene defines the hosting scene
  47857. * @param scaleLines defines a number used to scale line length (1 by default)
  47858. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47859. * @param xAxis defines the node hierarchy used to render the x-axis
  47860. * @param yAxis defines the node hierarchy used to render the y-axis
  47861. * @param zAxis defines the node hierarchy used to render the z-axis
  47862. */
  47863. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47864. /**
  47865. * Force the viewer to update
  47866. * @param position defines the position of the viewer
  47867. * @param xaxis defines the x axis of the viewer
  47868. * @param yaxis defines the y axis of the viewer
  47869. * @param zaxis defines the z axis of the viewer
  47870. */
  47871. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47872. /**
  47873. * Creates an instance of this axes viewer.
  47874. * @returns a new axes viewer with instanced meshes
  47875. */
  47876. createInstance(): AxesViewer;
  47877. /** Releases resources */
  47878. dispose(): void;
  47879. private static _SetRenderingGroupId;
  47880. }
  47881. }
  47882. declare module "babylonjs/Debug/boneAxesViewer" {
  47883. import { Nullable } from "babylonjs/types";
  47884. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47885. import { Vector3 } from "babylonjs/Maths/math.vector";
  47886. import { Mesh } from "babylonjs/Meshes/mesh";
  47887. import { Bone } from "babylonjs/Bones/bone";
  47888. import { Scene } from "babylonjs/scene";
  47889. /**
  47890. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47891. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47892. */
  47893. export class BoneAxesViewer extends AxesViewer {
  47894. /**
  47895. * Gets or sets the target mesh where to display the axes viewer
  47896. */
  47897. mesh: Nullable<Mesh>;
  47898. /**
  47899. * Gets or sets the target bone where to display the axes viewer
  47900. */
  47901. bone: Nullable<Bone>;
  47902. /** Gets current position */
  47903. pos: Vector3;
  47904. /** Gets direction of X axis */
  47905. xaxis: Vector3;
  47906. /** Gets direction of Y axis */
  47907. yaxis: Vector3;
  47908. /** Gets direction of Z axis */
  47909. zaxis: Vector3;
  47910. /**
  47911. * Creates a new BoneAxesViewer
  47912. * @param scene defines the hosting scene
  47913. * @param bone defines the target bone
  47914. * @param mesh defines the target mesh
  47915. * @param scaleLines defines a scaling factor for line length (1 by default)
  47916. */
  47917. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47918. /**
  47919. * Force the viewer to update
  47920. */
  47921. update(): void;
  47922. /** Releases resources */
  47923. dispose(): void;
  47924. }
  47925. }
  47926. declare module "babylonjs/Debug/debugLayer" {
  47927. import { Scene } from "babylonjs/scene";
  47928. /**
  47929. * Interface used to define scene explorer extensibility option
  47930. */
  47931. export interface IExplorerExtensibilityOption {
  47932. /**
  47933. * Define the option label
  47934. */
  47935. label: string;
  47936. /**
  47937. * Defines the action to execute on click
  47938. */
  47939. action: (entity: any) => void;
  47940. }
  47941. /**
  47942. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47943. */
  47944. export interface IExplorerExtensibilityGroup {
  47945. /**
  47946. * Defines a predicate to test if a given type mut be extended
  47947. */
  47948. predicate: (entity: any) => boolean;
  47949. /**
  47950. * Gets the list of options added to a type
  47951. */
  47952. entries: IExplorerExtensibilityOption[];
  47953. }
  47954. /**
  47955. * Interface used to define the options to use to create the Inspector
  47956. */
  47957. export interface IInspectorOptions {
  47958. /**
  47959. * Display in overlay mode (default: false)
  47960. */
  47961. overlay?: boolean;
  47962. /**
  47963. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47964. */
  47965. globalRoot?: HTMLElement;
  47966. /**
  47967. * Display the Scene explorer
  47968. */
  47969. showExplorer?: boolean;
  47970. /**
  47971. * Display the property inspector
  47972. */
  47973. showInspector?: boolean;
  47974. /**
  47975. * Display in embed mode (both panes on the right)
  47976. */
  47977. embedMode?: boolean;
  47978. /**
  47979. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47980. */
  47981. handleResize?: boolean;
  47982. /**
  47983. * Allow the panes to popup (default: true)
  47984. */
  47985. enablePopup?: boolean;
  47986. /**
  47987. * Allow the panes to be closed by users (default: true)
  47988. */
  47989. enableClose?: boolean;
  47990. /**
  47991. * Optional list of extensibility entries
  47992. */
  47993. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47994. /**
  47995. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47996. */
  47997. inspectorURL?: string;
  47998. /**
  47999. * Optional initial tab (default to DebugLayerTab.Properties)
  48000. */
  48001. initialTab?: DebugLayerTab;
  48002. }
  48003. module "babylonjs/scene" {
  48004. interface Scene {
  48005. /**
  48006. * @hidden
  48007. * Backing field
  48008. */
  48009. _debugLayer: DebugLayer;
  48010. /**
  48011. * Gets the debug layer (aka Inspector) associated with the scene
  48012. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48013. */
  48014. debugLayer: DebugLayer;
  48015. }
  48016. }
  48017. /**
  48018. * Enum of inspector action tab
  48019. */
  48020. export enum DebugLayerTab {
  48021. /**
  48022. * Properties tag (default)
  48023. */
  48024. Properties = 0,
  48025. /**
  48026. * Debug tab
  48027. */
  48028. Debug = 1,
  48029. /**
  48030. * Statistics tab
  48031. */
  48032. Statistics = 2,
  48033. /**
  48034. * Tools tab
  48035. */
  48036. Tools = 3,
  48037. /**
  48038. * Settings tab
  48039. */
  48040. Settings = 4
  48041. }
  48042. /**
  48043. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48044. * what is happening in your scene
  48045. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48046. */
  48047. export class DebugLayer {
  48048. /**
  48049. * Define the url to get the inspector script from.
  48050. * By default it uses the babylonjs CDN.
  48051. * @ignoreNaming
  48052. */
  48053. static InspectorURL: string;
  48054. private _scene;
  48055. private BJSINSPECTOR;
  48056. private _onPropertyChangedObservable?;
  48057. /**
  48058. * Observable triggered when a property is changed through the inspector.
  48059. */
  48060. get onPropertyChangedObservable(): any;
  48061. /**
  48062. * Instantiates a new debug layer.
  48063. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48064. * what is happening in your scene
  48065. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48066. * @param scene Defines the scene to inspect
  48067. */
  48068. constructor(scene: Scene);
  48069. /** Creates the inspector window. */
  48070. private _createInspector;
  48071. /**
  48072. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48073. * @param entity defines the entity to select
  48074. * @param lineContainerTitle defines the specific block to highlight
  48075. */
  48076. select(entity: any, lineContainerTitle?: string): void;
  48077. /** Get the inspector from bundle or global */
  48078. private _getGlobalInspector;
  48079. /**
  48080. * Get if the inspector is visible or not.
  48081. * @returns true if visible otherwise, false
  48082. */
  48083. isVisible(): boolean;
  48084. /**
  48085. * Hide the inspector and close its window.
  48086. */
  48087. hide(): void;
  48088. /**
  48089. * Launch the debugLayer.
  48090. * @param config Define the configuration of the inspector
  48091. * @return a promise fulfilled when the debug layer is visible
  48092. */
  48093. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48094. }
  48095. }
  48096. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48097. import { Nullable } from "babylonjs/types";
  48098. import { Scene } from "babylonjs/scene";
  48099. import { Vector4 } from "babylonjs/Maths/math.vector";
  48100. import { Color4 } from "babylonjs/Maths/math.color";
  48101. import { Mesh } from "babylonjs/Meshes/mesh";
  48102. /**
  48103. * Class containing static functions to help procedurally build meshes
  48104. */
  48105. export class BoxBuilder {
  48106. /**
  48107. * Creates a box mesh
  48108. * * The parameter `size` sets the size (float) of each box side (default 1)
  48109. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48110. * * 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)
  48111. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48115. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48116. * @param name defines the name of the mesh
  48117. * @param options defines the options used to create the mesh
  48118. * @param scene defines the hosting scene
  48119. * @returns the box mesh
  48120. */
  48121. static CreateBox(name: string, options: {
  48122. size?: number;
  48123. width?: number;
  48124. height?: number;
  48125. depth?: number;
  48126. faceUV?: Vector4[];
  48127. faceColors?: Color4[];
  48128. sideOrientation?: number;
  48129. frontUVs?: Vector4;
  48130. backUVs?: Vector4;
  48131. wrap?: boolean;
  48132. topBaseAt?: number;
  48133. bottomBaseAt?: number;
  48134. updatable?: boolean;
  48135. }, scene?: Nullable<Scene>): Mesh;
  48136. }
  48137. }
  48138. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48139. import { Vector4 } from "babylonjs/Maths/math.vector";
  48140. import { Mesh } from "babylonjs/Meshes/mesh";
  48141. import { Scene } from "babylonjs/scene";
  48142. import { Nullable } from "babylonjs/types";
  48143. /**
  48144. * Class containing static functions to help procedurally build meshes
  48145. */
  48146. export class SphereBuilder {
  48147. /**
  48148. * Creates a sphere mesh
  48149. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48150. * * 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`)
  48151. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48152. * * 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
  48153. * * 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)
  48154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48157. * @param name defines the name of the mesh
  48158. * @param options defines the options used to create the mesh
  48159. * @param scene defines the hosting scene
  48160. * @returns the sphere mesh
  48161. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48162. */
  48163. static CreateSphere(name: string, options: {
  48164. segments?: number;
  48165. diameter?: number;
  48166. diameterX?: number;
  48167. diameterY?: number;
  48168. diameterZ?: number;
  48169. arc?: number;
  48170. slice?: number;
  48171. sideOrientation?: number;
  48172. frontUVs?: Vector4;
  48173. backUVs?: Vector4;
  48174. updatable?: boolean;
  48175. }, scene?: Nullable<Scene>): Mesh;
  48176. }
  48177. }
  48178. declare module "babylonjs/Debug/physicsViewer" {
  48179. import { Nullable } from "babylonjs/types";
  48180. import { Scene } from "babylonjs/scene";
  48181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48182. import { Mesh } from "babylonjs/Meshes/mesh";
  48183. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48184. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48185. /**
  48186. * Used to show the physics impostor around the specific mesh
  48187. */
  48188. export class PhysicsViewer {
  48189. /** @hidden */
  48190. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48191. /** @hidden */
  48192. protected _meshes: Array<Nullable<AbstractMesh>>;
  48193. /** @hidden */
  48194. protected _scene: Nullable<Scene>;
  48195. /** @hidden */
  48196. protected _numMeshes: number;
  48197. /** @hidden */
  48198. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48199. private _renderFunction;
  48200. private _utilityLayer;
  48201. private _debugBoxMesh;
  48202. private _debugSphereMesh;
  48203. private _debugCylinderMesh;
  48204. private _debugMaterial;
  48205. private _debugMeshMeshes;
  48206. /**
  48207. * Creates a new PhysicsViewer
  48208. * @param scene defines the hosting scene
  48209. */
  48210. constructor(scene: Scene);
  48211. /** @hidden */
  48212. protected _updateDebugMeshes(): void;
  48213. /**
  48214. * Renders a specified physic impostor
  48215. * @param impostor defines the impostor to render
  48216. * @param targetMesh defines the mesh represented by the impostor
  48217. * @returns the new debug mesh used to render the impostor
  48218. */
  48219. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48220. /**
  48221. * Hides a specified physic impostor
  48222. * @param impostor defines the impostor to hide
  48223. */
  48224. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48225. private _getDebugMaterial;
  48226. private _getDebugBoxMesh;
  48227. private _getDebugSphereMesh;
  48228. private _getDebugCylinderMesh;
  48229. private _getDebugMeshMesh;
  48230. private _getDebugMesh;
  48231. /** Releases all resources */
  48232. dispose(): void;
  48233. }
  48234. }
  48235. declare module "babylonjs/Debug/rayHelper" {
  48236. import { Nullable } from "babylonjs/types";
  48237. import { Ray } from "babylonjs/Culling/ray";
  48238. import { Vector3 } from "babylonjs/Maths/math.vector";
  48239. import { Color3 } from "babylonjs/Maths/math.color";
  48240. import { Scene } from "babylonjs/scene";
  48241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48242. import "babylonjs/Meshes/Builders/linesBuilder";
  48243. /**
  48244. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48245. * in order to better appreciate the issue one might have.
  48246. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48247. */
  48248. export class RayHelper {
  48249. /**
  48250. * Defines the ray we are currently tryin to visualize.
  48251. */
  48252. ray: Nullable<Ray>;
  48253. private _renderPoints;
  48254. private _renderLine;
  48255. private _renderFunction;
  48256. private _scene;
  48257. private _updateToMeshFunction;
  48258. private _attachedToMesh;
  48259. private _meshSpaceDirection;
  48260. private _meshSpaceOrigin;
  48261. /**
  48262. * Helper function to create a colored helper in a scene in one line.
  48263. * @param ray Defines the ray we are currently tryin to visualize
  48264. * @param scene Defines the scene the ray is used in
  48265. * @param color Defines the color we want to see the ray in
  48266. * @returns The newly created ray helper.
  48267. */
  48268. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48269. /**
  48270. * Instantiate a new ray helper.
  48271. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48272. * in order to better appreciate the issue one might have.
  48273. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48274. * @param ray Defines the ray we are currently tryin to visualize
  48275. */
  48276. constructor(ray: Ray);
  48277. /**
  48278. * Shows the ray we are willing to debug.
  48279. * @param scene Defines the scene the ray needs to be rendered in
  48280. * @param color Defines the color the ray needs to be rendered in
  48281. */
  48282. show(scene: Scene, color?: Color3): void;
  48283. /**
  48284. * Hides the ray we are debugging.
  48285. */
  48286. hide(): void;
  48287. private _render;
  48288. /**
  48289. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48290. * @param mesh Defines the mesh we want the helper attached to
  48291. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48292. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48293. * @param length Defines the length of the ray
  48294. */
  48295. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48296. /**
  48297. * Detach the ray helper from the mesh it has previously been attached to.
  48298. */
  48299. detachFromMesh(): void;
  48300. private _updateToMesh;
  48301. /**
  48302. * Dispose the helper and release its associated resources.
  48303. */
  48304. dispose(): void;
  48305. }
  48306. }
  48307. declare module "babylonjs/Debug/skeletonViewer" {
  48308. import { Color3 } from "babylonjs/Maths/math.color";
  48309. import { Scene } from "babylonjs/scene";
  48310. import { Nullable } from "babylonjs/types";
  48311. import { Skeleton } from "babylonjs/Bones/skeleton";
  48312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48313. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48314. /**
  48315. * Class used to render a debug view of a given skeleton
  48316. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48317. */
  48318. export class SkeletonViewer {
  48319. /** defines the skeleton to render */
  48320. skeleton: Skeleton;
  48321. /** defines the mesh attached to the skeleton */
  48322. mesh: AbstractMesh;
  48323. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48324. autoUpdateBonesMatrices: boolean;
  48325. /** defines the rendering group id to use with the viewer */
  48326. renderingGroupId: number;
  48327. /** Gets or sets the color used to render the skeleton */
  48328. color: Color3;
  48329. private _scene;
  48330. private _debugLines;
  48331. private _debugMesh;
  48332. private _isEnabled;
  48333. private _renderFunction;
  48334. private _utilityLayer;
  48335. /**
  48336. * Returns the mesh used to render the bones
  48337. */
  48338. get debugMesh(): Nullable<LinesMesh>;
  48339. /**
  48340. * Creates a new SkeletonViewer
  48341. * @param skeleton defines the skeleton to render
  48342. * @param mesh defines the mesh attached to the skeleton
  48343. * @param scene defines the hosting scene
  48344. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48345. * @param renderingGroupId defines the rendering group id to use with the viewer
  48346. */
  48347. constructor(
  48348. /** defines the skeleton to render */
  48349. skeleton: Skeleton,
  48350. /** defines the mesh attached to the skeleton */
  48351. mesh: AbstractMesh, scene: Scene,
  48352. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48353. autoUpdateBonesMatrices?: boolean,
  48354. /** defines the rendering group id to use with the viewer */
  48355. renderingGroupId?: number);
  48356. /** Gets or sets a boolean indicating if the viewer is enabled */
  48357. set isEnabled(value: boolean);
  48358. get isEnabled(): boolean;
  48359. private _getBonePosition;
  48360. private _getLinesForBonesWithLength;
  48361. private _getLinesForBonesNoLength;
  48362. /** Update the viewer to sync with current skeleton state */
  48363. update(): void;
  48364. /** Release associated resources */
  48365. dispose(): void;
  48366. }
  48367. }
  48368. declare module "babylonjs/Debug/index" {
  48369. export * from "babylonjs/Debug/axesViewer";
  48370. export * from "babylonjs/Debug/boneAxesViewer";
  48371. export * from "babylonjs/Debug/debugLayer";
  48372. export * from "babylonjs/Debug/physicsViewer";
  48373. export * from "babylonjs/Debug/rayHelper";
  48374. export * from "babylonjs/Debug/skeletonViewer";
  48375. }
  48376. declare module "babylonjs/Engines/nullEngine" {
  48377. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48378. import { Scene } from "babylonjs/scene";
  48379. import { Engine } from "babylonjs/Engines/engine";
  48380. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48383. import { Effect } from "babylonjs/Materials/effect";
  48384. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48385. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48386. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48387. /**
  48388. * Options to create the null engine
  48389. */
  48390. export class NullEngineOptions {
  48391. /**
  48392. * Render width (Default: 512)
  48393. */
  48394. renderWidth: number;
  48395. /**
  48396. * Render height (Default: 256)
  48397. */
  48398. renderHeight: number;
  48399. /**
  48400. * Texture size (Default: 512)
  48401. */
  48402. textureSize: number;
  48403. /**
  48404. * If delta time between frames should be constant
  48405. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48406. */
  48407. deterministicLockstep: boolean;
  48408. /**
  48409. * Maximum about of steps between frames (Default: 4)
  48410. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48411. */
  48412. lockstepMaxSteps: number;
  48413. }
  48414. /**
  48415. * The null engine class provides support for headless version of babylon.js.
  48416. * This can be used in server side scenario or for testing purposes
  48417. */
  48418. export class NullEngine extends Engine {
  48419. private _options;
  48420. /**
  48421. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48422. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48423. * @returns true if engine is in deterministic lock step mode
  48424. */
  48425. isDeterministicLockStep(): boolean;
  48426. /**
  48427. * Gets the max steps when engine is running in deterministic lock step
  48428. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48429. * @returns the max steps
  48430. */
  48431. getLockstepMaxSteps(): number;
  48432. /**
  48433. * Gets the current hardware scaling level.
  48434. * By default the hardware scaling level is computed from the window device ratio.
  48435. * 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.
  48436. * @returns a number indicating the current hardware scaling level
  48437. */
  48438. getHardwareScalingLevel(): number;
  48439. constructor(options?: NullEngineOptions);
  48440. /**
  48441. * Creates a vertex buffer
  48442. * @param vertices the data for the vertex buffer
  48443. * @returns the new WebGL static buffer
  48444. */
  48445. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48446. /**
  48447. * Creates a new index buffer
  48448. * @param indices defines the content of the index buffer
  48449. * @param updatable defines if the index buffer must be updatable
  48450. * @returns a new webGL buffer
  48451. */
  48452. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48453. /**
  48454. * Clear the current render buffer or the current render target (if any is set up)
  48455. * @param color defines the color to use
  48456. * @param backBuffer defines if the back buffer must be cleared
  48457. * @param depth defines if the depth buffer must be cleared
  48458. * @param stencil defines if the stencil buffer must be cleared
  48459. */
  48460. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48461. /**
  48462. * Gets the current render width
  48463. * @param useScreen defines if screen size must be used (or the current render target if any)
  48464. * @returns a number defining the current render width
  48465. */
  48466. getRenderWidth(useScreen?: boolean): number;
  48467. /**
  48468. * Gets the current render height
  48469. * @param useScreen defines if screen size must be used (or the current render target if any)
  48470. * @returns a number defining the current render height
  48471. */
  48472. getRenderHeight(useScreen?: boolean): number;
  48473. /**
  48474. * Set the WebGL's viewport
  48475. * @param viewport defines the viewport element to be used
  48476. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48477. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48478. */
  48479. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48480. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48481. /**
  48482. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48483. * @param pipelineContext defines the pipeline context to use
  48484. * @param uniformsNames defines the list of uniform names
  48485. * @returns an array of webGL uniform locations
  48486. */
  48487. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48488. /**
  48489. * Gets the lsit of active attributes for a given webGL program
  48490. * @param pipelineContext defines the pipeline context to use
  48491. * @param attributesNames defines the list of attribute names to get
  48492. * @returns an array of indices indicating the offset of each attribute
  48493. */
  48494. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48495. /**
  48496. * Binds an effect to the webGL context
  48497. * @param effect defines the effect to bind
  48498. */
  48499. bindSamplers(effect: Effect): void;
  48500. /**
  48501. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48502. * @param effect defines the effect to activate
  48503. */
  48504. enableEffect(effect: Effect): void;
  48505. /**
  48506. * Set various states to the webGL context
  48507. * @param culling defines backface culling state
  48508. * @param zOffset defines the value to apply to zOffset (0 by default)
  48509. * @param force defines if states must be applied even if cache is up to date
  48510. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48511. */
  48512. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48513. /**
  48514. * Set the value of an uniform to an array of int32
  48515. * @param uniform defines the webGL uniform location where to store the value
  48516. * @param array defines the array of int32 to store
  48517. */
  48518. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48519. /**
  48520. * Set the value of an uniform to an array of int32 (stored as vec2)
  48521. * @param uniform defines the webGL uniform location where to store the value
  48522. * @param array defines the array of int32 to store
  48523. */
  48524. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48525. /**
  48526. * Set the value of an uniform to an array of int32 (stored as vec3)
  48527. * @param uniform defines the webGL uniform location where to store the value
  48528. * @param array defines the array of int32 to store
  48529. */
  48530. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48531. /**
  48532. * Set the value of an uniform to an array of int32 (stored as vec4)
  48533. * @param uniform defines the webGL uniform location where to store the value
  48534. * @param array defines the array of int32 to store
  48535. */
  48536. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48537. /**
  48538. * Set the value of an uniform to an array of float32
  48539. * @param uniform defines the webGL uniform location where to store the value
  48540. * @param array defines the array of float32 to store
  48541. */
  48542. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48543. /**
  48544. * Set the value of an uniform to an array of float32 (stored as vec2)
  48545. * @param uniform defines the webGL uniform location where to store the value
  48546. * @param array defines the array of float32 to store
  48547. */
  48548. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48549. /**
  48550. * Set the value of an uniform to an array of float32 (stored as vec3)
  48551. * @param uniform defines the webGL uniform location where to store the value
  48552. * @param array defines the array of float32 to store
  48553. */
  48554. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48555. /**
  48556. * Set the value of an uniform to an array of float32 (stored as vec4)
  48557. * @param uniform defines the webGL uniform location where to store the value
  48558. * @param array defines the array of float32 to store
  48559. */
  48560. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48561. /**
  48562. * Set the value of an uniform to an array of number
  48563. * @param uniform defines the webGL uniform location where to store the value
  48564. * @param array defines the array of number to store
  48565. */
  48566. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48567. /**
  48568. * Set the value of an uniform to an array of number (stored as vec2)
  48569. * @param uniform defines the webGL uniform location where to store the value
  48570. * @param array defines the array of number to store
  48571. */
  48572. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48573. /**
  48574. * Set the value of an uniform to an array of number (stored as vec3)
  48575. * @param uniform defines the webGL uniform location where to store the value
  48576. * @param array defines the array of number to store
  48577. */
  48578. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48579. /**
  48580. * Set the value of an uniform to an array of number (stored as vec4)
  48581. * @param uniform defines the webGL uniform location where to store the value
  48582. * @param array defines the array of number to store
  48583. */
  48584. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48585. /**
  48586. * Set the value of an uniform to an array of float32 (stored as matrices)
  48587. * @param uniform defines the webGL uniform location where to store the value
  48588. * @param matrices defines the array of float32 to store
  48589. */
  48590. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48591. /**
  48592. * Set the value of an uniform to a matrix (3x3)
  48593. * @param uniform defines the webGL uniform location where to store the value
  48594. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48595. */
  48596. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48597. /**
  48598. * Set the value of an uniform to a matrix (2x2)
  48599. * @param uniform defines the webGL uniform location where to store the value
  48600. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48601. */
  48602. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48603. /**
  48604. * Set the value of an uniform to a number (float)
  48605. * @param uniform defines the webGL uniform location where to store the value
  48606. * @param value defines the float number to store
  48607. */
  48608. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48609. /**
  48610. * Set the value of an uniform to a vec2
  48611. * @param uniform defines the webGL uniform location where to store the value
  48612. * @param x defines the 1st component of the value
  48613. * @param y defines the 2nd component of the value
  48614. */
  48615. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48616. /**
  48617. * Set the value of an uniform to a vec3
  48618. * @param uniform defines the webGL uniform location where to store the value
  48619. * @param x defines the 1st component of the value
  48620. * @param y defines the 2nd component of the value
  48621. * @param z defines the 3rd component of the value
  48622. */
  48623. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48624. /**
  48625. * Set the value of an uniform to a boolean
  48626. * @param uniform defines the webGL uniform location where to store the value
  48627. * @param bool defines the boolean to store
  48628. */
  48629. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48630. /**
  48631. * Set the value of an uniform to a vec4
  48632. * @param uniform defines the webGL uniform location where to store the value
  48633. * @param x defines the 1st component of the value
  48634. * @param y defines the 2nd component of the value
  48635. * @param z defines the 3rd component of the value
  48636. * @param w defines the 4th component of the value
  48637. */
  48638. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48639. /**
  48640. * Sets the current alpha mode
  48641. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48642. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48643. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48644. */
  48645. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48646. /**
  48647. * Bind webGl buffers directly to the webGL context
  48648. * @param vertexBuffers defines the vertex buffer to bind
  48649. * @param indexBuffer defines the index buffer to bind
  48650. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48651. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48652. * @param effect defines the effect associated with the vertex buffer
  48653. */
  48654. bindBuffers(vertexBuffers: {
  48655. [key: string]: VertexBuffer;
  48656. }, indexBuffer: DataBuffer, effect: Effect): void;
  48657. /**
  48658. * Force the entire cache to be cleared
  48659. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48660. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48661. */
  48662. wipeCaches(bruteForce?: boolean): void;
  48663. /**
  48664. * Send a draw order
  48665. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48666. * @param indexStart defines the starting index
  48667. * @param indexCount defines the number of index to draw
  48668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48669. */
  48670. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48671. /**
  48672. * Draw a list of indexed primitives
  48673. * @param fillMode defines the primitive to use
  48674. * @param indexStart defines the starting index
  48675. * @param indexCount defines the number of index to draw
  48676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48677. */
  48678. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48679. /**
  48680. * Draw a list of unindexed primitives
  48681. * @param fillMode defines the primitive to use
  48682. * @param verticesStart defines the index of first vertex to draw
  48683. * @param verticesCount defines the count of vertices to draw
  48684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48685. */
  48686. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48687. /** @hidden */
  48688. _createTexture(): WebGLTexture;
  48689. /** @hidden */
  48690. _releaseTexture(texture: InternalTexture): void;
  48691. /**
  48692. * Usually called from Texture.ts.
  48693. * Passed information to create a WebGLTexture
  48694. * @param urlArg defines a value which contains one of the following:
  48695. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48696. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48697. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48698. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48699. * @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)
  48700. * @param scene needed for loading to the correct scene
  48701. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48702. * @param onLoad optional callback to be called upon successful completion
  48703. * @param onError optional callback to be called upon failure
  48704. * @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
  48705. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48706. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48707. * @param forcedExtension defines the extension to use to pick the right loader
  48708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48709. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48710. */
  48711. 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;
  48712. /**
  48713. * Creates a new render target texture
  48714. * @param size defines the size of the texture
  48715. * @param options defines the options used to create the texture
  48716. * @returns a new render target texture stored in an InternalTexture
  48717. */
  48718. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48719. /**
  48720. * Update the sampling mode of a given texture
  48721. * @param samplingMode defines the required sampling mode
  48722. * @param texture defines the texture to update
  48723. */
  48724. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48725. /**
  48726. * Binds the frame buffer to the specified texture.
  48727. * @param texture The texture to render to or null for the default canvas
  48728. * @param faceIndex The face of the texture to render to in case of cube texture
  48729. * @param requiredWidth The width of the target to render to
  48730. * @param requiredHeight The height of the target to render to
  48731. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48732. * @param lodLevel defines le lod level to bind to the frame buffer
  48733. */
  48734. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48735. /**
  48736. * Unbind the current render target texture from the webGL context
  48737. * @param texture defines the render target texture to unbind
  48738. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48739. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48740. */
  48741. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48742. /**
  48743. * Creates a dynamic vertex buffer
  48744. * @param vertices the data for the dynamic vertex buffer
  48745. * @returns the new WebGL dynamic buffer
  48746. */
  48747. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48748. /**
  48749. * Update the content of a dynamic texture
  48750. * @param texture defines the texture to update
  48751. * @param canvas defines the canvas containing the source
  48752. * @param invertY defines if data must be stored with Y axis inverted
  48753. * @param premulAlpha defines if alpha is stored as premultiplied
  48754. * @param format defines the format of the data
  48755. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48756. */
  48757. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48758. /**
  48759. * Gets a boolean indicating if all created effects are ready
  48760. * @returns true if all effects are ready
  48761. */
  48762. areAllEffectsReady(): boolean;
  48763. /**
  48764. * @hidden
  48765. * Get the current error code of the webGL context
  48766. * @returns the error code
  48767. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48768. */
  48769. getError(): number;
  48770. /** @hidden */
  48771. _getUnpackAlignement(): number;
  48772. /** @hidden */
  48773. _unpackFlipY(value: boolean): void;
  48774. /**
  48775. * Update a dynamic index buffer
  48776. * @param indexBuffer defines the target index buffer
  48777. * @param indices defines the data to update
  48778. * @param offset defines the offset in the target index buffer where update should start
  48779. */
  48780. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48781. /**
  48782. * Updates a dynamic vertex buffer.
  48783. * @param vertexBuffer the vertex buffer to update
  48784. * @param vertices the data used to update the vertex buffer
  48785. * @param byteOffset the byte offset of the data (optional)
  48786. * @param byteLength the byte length of the data (optional)
  48787. */
  48788. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48789. /** @hidden */
  48790. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48791. /** @hidden */
  48792. _bindTexture(channel: number, texture: InternalTexture): void;
  48793. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48794. /**
  48795. * 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
  48796. */
  48797. releaseEffects(): void;
  48798. displayLoadingUI(): void;
  48799. hideLoadingUI(): void;
  48800. /** @hidden */
  48801. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48802. /** @hidden */
  48803. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48804. /** @hidden */
  48805. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48806. /** @hidden */
  48807. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48808. }
  48809. }
  48810. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48811. import { Nullable, int } from "babylonjs/types";
  48812. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48813. /** @hidden */
  48814. export class _OcclusionDataStorage {
  48815. /** @hidden */
  48816. occlusionInternalRetryCounter: number;
  48817. /** @hidden */
  48818. isOcclusionQueryInProgress: boolean;
  48819. /** @hidden */
  48820. isOccluded: boolean;
  48821. /** @hidden */
  48822. occlusionRetryCount: number;
  48823. /** @hidden */
  48824. occlusionType: number;
  48825. /** @hidden */
  48826. occlusionQueryAlgorithmType: number;
  48827. }
  48828. module "babylonjs/Engines/engine" {
  48829. interface Engine {
  48830. /**
  48831. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48832. * @return the new query
  48833. */
  48834. createQuery(): WebGLQuery;
  48835. /**
  48836. * Delete and release a webGL query
  48837. * @param query defines the query to delete
  48838. * @return the current engine
  48839. */
  48840. deleteQuery(query: WebGLQuery): Engine;
  48841. /**
  48842. * Check if a given query has resolved and got its value
  48843. * @param query defines the query to check
  48844. * @returns true if the query got its value
  48845. */
  48846. isQueryResultAvailable(query: WebGLQuery): boolean;
  48847. /**
  48848. * Gets the value of a given query
  48849. * @param query defines the query to check
  48850. * @returns the value of the query
  48851. */
  48852. getQueryResult(query: WebGLQuery): number;
  48853. /**
  48854. * Initiates an occlusion query
  48855. * @param algorithmType defines the algorithm to use
  48856. * @param query defines the query to use
  48857. * @returns the current engine
  48858. * @see http://doc.babylonjs.com/features/occlusionquery
  48859. */
  48860. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48861. /**
  48862. * Ends an occlusion query
  48863. * @see http://doc.babylonjs.com/features/occlusionquery
  48864. * @param algorithmType defines the algorithm to use
  48865. * @returns the current engine
  48866. */
  48867. endOcclusionQuery(algorithmType: number): Engine;
  48868. /**
  48869. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48870. * Please note that only one query can be issued at a time
  48871. * @returns a time token used to track the time span
  48872. */
  48873. startTimeQuery(): Nullable<_TimeToken>;
  48874. /**
  48875. * Ends a time query
  48876. * @param token defines the token used to measure the time span
  48877. * @returns the time spent (in ns)
  48878. */
  48879. endTimeQuery(token: _TimeToken): int;
  48880. /** @hidden */
  48881. _currentNonTimestampToken: Nullable<_TimeToken>;
  48882. /** @hidden */
  48883. _createTimeQuery(): WebGLQuery;
  48884. /** @hidden */
  48885. _deleteTimeQuery(query: WebGLQuery): void;
  48886. /** @hidden */
  48887. _getGlAlgorithmType(algorithmType: number): number;
  48888. /** @hidden */
  48889. _getTimeQueryResult(query: WebGLQuery): any;
  48890. /** @hidden */
  48891. _getTimeQueryAvailability(query: WebGLQuery): any;
  48892. }
  48893. }
  48894. module "babylonjs/Meshes/abstractMesh" {
  48895. interface AbstractMesh {
  48896. /**
  48897. * Backing filed
  48898. * @hidden
  48899. */
  48900. __occlusionDataStorage: _OcclusionDataStorage;
  48901. /**
  48902. * Access property
  48903. * @hidden
  48904. */
  48905. _occlusionDataStorage: _OcclusionDataStorage;
  48906. /**
  48907. * 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.
  48908. * The default value is -1 which means don't break the query and wait till the result
  48909. * @see http://doc.babylonjs.com/features/occlusionquery
  48910. */
  48911. occlusionRetryCount: number;
  48912. /**
  48913. * 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:
  48914. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48915. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48916. * * 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.
  48917. * @see http://doc.babylonjs.com/features/occlusionquery
  48918. */
  48919. occlusionType: number;
  48920. /**
  48921. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48922. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48923. * * 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.
  48924. * @see http://doc.babylonjs.com/features/occlusionquery
  48925. */
  48926. occlusionQueryAlgorithmType: number;
  48927. /**
  48928. * 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
  48929. * @see http://doc.babylonjs.com/features/occlusionquery
  48930. */
  48931. isOccluded: boolean;
  48932. /**
  48933. * Flag to check the progress status of the query
  48934. * @see http://doc.babylonjs.com/features/occlusionquery
  48935. */
  48936. isOcclusionQueryInProgress: boolean;
  48937. }
  48938. }
  48939. }
  48940. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48941. import { Nullable } from "babylonjs/types";
  48942. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48943. /** @hidden */
  48944. export var _forceTransformFeedbackToBundle: boolean;
  48945. module "babylonjs/Engines/engine" {
  48946. interface Engine {
  48947. /**
  48948. * Creates a webGL transform feedback object
  48949. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48950. * @returns the webGL transform feedback object
  48951. */
  48952. createTransformFeedback(): WebGLTransformFeedback;
  48953. /**
  48954. * Delete a webGL transform feedback object
  48955. * @param value defines the webGL transform feedback object to delete
  48956. */
  48957. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48958. /**
  48959. * Bind a webGL transform feedback object to the webgl context
  48960. * @param value defines the webGL transform feedback object to bind
  48961. */
  48962. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48963. /**
  48964. * Begins a transform feedback operation
  48965. * @param usePoints defines if points or triangles must be used
  48966. */
  48967. beginTransformFeedback(usePoints: boolean): void;
  48968. /**
  48969. * Ends a transform feedback operation
  48970. */
  48971. endTransformFeedback(): void;
  48972. /**
  48973. * Specify the varyings to use with transform feedback
  48974. * @param program defines the associated webGL program
  48975. * @param value defines the list of strings representing the varying names
  48976. */
  48977. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48978. /**
  48979. * Bind a webGL buffer for a transform feedback operation
  48980. * @param value defines the webGL buffer to bind
  48981. */
  48982. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48983. }
  48984. }
  48985. }
  48986. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48987. import { Scene } from "babylonjs/scene";
  48988. import { Engine } from "babylonjs/Engines/engine";
  48989. import { Texture } from "babylonjs/Materials/Textures/texture";
  48990. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48991. import "babylonjs/Engines/Extensions/engine.multiRender";
  48992. /**
  48993. * Creation options of the multi render target texture.
  48994. */
  48995. export interface IMultiRenderTargetOptions {
  48996. /**
  48997. * Define if the texture needs to create mip maps after render.
  48998. */
  48999. generateMipMaps?: boolean;
  49000. /**
  49001. * Define the types of all the draw buffers we want to create
  49002. */
  49003. types?: number[];
  49004. /**
  49005. * Define the sampling modes of all the draw buffers we want to create
  49006. */
  49007. samplingModes?: number[];
  49008. /**
  49009. * Define if a depth buffer is required
  49010. */
  49011. generateDepthBuffer?: boolean;
  49012. /**
  49013. * Define if a stencil buffer is required
  49014. */
  49015. generateStencilBuffer?: boolean;
  49016. /**
  49017. * Define if a depth texture is required instead of a depth buffer
  49018. */
  49019. generateDepthTexture?: boolean;
  49020. /**
  49021. * Define the number of desired draw buffers
  49022. */
  49023. textureCount?: number;
  49024. /**
  49025. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49026. */
  49027. doNotChangeAspectRatio?: boolean;
  49028. /**
  49029. * Define the default type of the buffers we are creating
  49030. */
  49031. defaultType?: number;
  49032. }
  49033. /**
  49034. * A multi render target, like a render target provides the ability to render to a texture.
  49035. * Unlike the render target, it can render to several draw buffers in one draw.
  49036. * This is specially interesting in deferred rendering or for any effects requiring more than
  49037. * just one color from a single pass.
  49038. */
  49039. export class MultiRenderTarget extends RenderTargetTexture {
  49040. private _internalTextures;
  49041. private _textures;
  49042. private _multiRenderTargetOptions;
  49043. /**
  49044. * Get if draw buffers are currently supported by the used hardware and browser.
  49045. */
  49046. get isSupported(): boolean;
  49047. /**
  49048. * Get the list of textures generated by the multi render target.
  49049. */
  49050. get textures(): Texture[];
  49051. /**
  49052. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49053. */
  49054. get depthTexture(): Texture;
  49055. /**
  49056. * Set the wrapping mode on U of all the textures we are rendering to.
  49057. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49058. */
  49059. set wrapU(wrap: number);
  49060. /**
  49061. * Set the wrapping mode on V of all the textures we are rendering to.
  49062. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49063. */
  49064. set wrapV(wrap: number);
  49065. /**
  49066. * Instantiate a new multi render target texture.
  49067. * A multi render target, like a render target provides the ability to render to a texture.
  49068. * Unlike the render target, it can render to several draw buffers in one draw.
  49069. * This is specially interesting in deferred rendering or for any effects requiring more than
  49070. * just one color from a single pass.
  49071. * @param name Define the name of the texture
  49072. * @param size Define the size of the buffers to render to
  49073. * @param count Define the number of target we are rendering into
  49074. * @param scene Define the scene the texture belongs to
  49075. * @param options Define the options used to create the multi render target
  49076. */
  49077. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49078. /** @hidden */
  49079. _rebuild(): void;
  49080. private _createInternalTextures;
  49081. private _createTextures;
  49082. /**
  49083. * Define the number of samples used if MSAA is enabled.
  49084. */
  49085. get samples(): number;
  49086. set samples(value: number);
  49087. /**
  49088. * Resize all the textures in the multi render target.
  49089. * Be carrefull as it will recreate all the data in the new texture.
  49090. * @param size Define the new size
  49091. */
  49092. resize(size: any): void;
  49093. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49094. /**
  49095. * Dispose the render targets and their associated resources
  49096. */
  49097. dispose(): void;
  49098. /**
  49099. * Release all the underlying texture used as draw buffers.
  49100. */
  49101. releaseInternalTextures(): void;
  49102. }
  49103. }
  49104. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49106. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49107. import { Nullable } from "babylonjs/types";
  49108. module "babylonjs/Engines/thinEngine" {
  49109. interface ThinEngine {
  49110. /**
  49111. * Unbind a list of render target textures from the webGL context
  49112. * This is used only when drawBuffer extension or webGL2 are active
  49113. * @param textures defines the render target textures to unbind
  49114. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49115. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49116. */
  49117. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49118. /**
  49119. * Create a multi render target texture
  49120. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49121. * @param size defines the size of the texture
  49122. * @param options defines the creation options
  49123. * @returns the cube texture as an InternalTexture
  49124. */
  49125. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49126. /**
  49127. * Update the sample count for a given multiple render target texture
  49128. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49129. * @param textures defines the textures to update
  49130. * @param samples defines the sample count to set
  49131. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49132. */
  49133. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49134. }
  49135. }
  49136. }
  49137. declare module "babylonjs/Engines/Extensions/engine.views" {
  49138. import { Camera } from "babylonjs/Cameras/camera";
  49139. import { Nullable } from "babylonjs/types";
  49140. /**
  49141. * Class used to define an additional view for the engine
  49142. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49143. */
  49144. export class EngineView {
  49145. /** Defines the canvas where to render the view */
  49146. target: HTMLCanvasElement;
  49147. /** Defines an optional camera used to render the view (will use active camera else) */
  49148. camera?: Camera;
  49149. }
  49150. module "babylonjs/Engines/engine" {
  49151. interface Engine {
  49152. /**
  49153. * Gets or sets the HTML element to use for attaching events
  49154. */
  49155. inputElement: Nullable<HTMLElement>;
  49156. /**
  49157. * Gets the current engine view
  49158. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49159. */
  49160. activeView: Nullable<EngineView>;
  49161. /** Gets or sets the list of views */
  49162. views: EngineView[];
  49163. /**
  49164. * Register a new child canvas
  49165. * @param canvas defines the canvas to register
  49166. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49167. * @returns the associated view
  49168. */
  49169. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49170. /**
  49171. * Remove a registered child canvas
  49172. * @param canvas defines the canvas to remove
  49173. * @returns the current engine
  49174. */
  49175. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49176. }
  49177. }
  49178. }
  49179. declare module "babylonjs/Engines/Extensions/index" {
  49180. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49181. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49182. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49183. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49184. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49185. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49186. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49187. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49188. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49189. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49190. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49191. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49192. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49193. export * from "babylonjs/Engines/Extensions/engine.views";
  49194. }
  49195. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49196. import { Nullable } from "babylonjs/types";
  49197. /**
  49198. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49199. */
  49200. export interface CubeMapInfo {
  49201. /**
  49202. * The pixel array for the front face.
  49203. * This is stored in format, left to right, up to down format.
  49204. */
  49205. front: Nullable<ArrayBufferView>;
  49206. /**
  49207. * The pixel array for the back face.
  49208. * This is stored in format, left to right, up to down format.
  49209. */
  49210. back: Nullable<ArrayBufferView>;
  49211. /**
  49212. * The pixel array for the left face.
  49213. * This is stored in format, left to right, up to down format.
  49214. */
  49215. left: Nullable<ArrayBufferView>;
  49216. /**
  49217. * The pixel array for the right face.
  49218. * This is stored in format, left to right, up to down format.
  49219. */
  49220. right: Nullable<ArrayBufferView>;
  49221. /**
  49222. * The pixel array for the up face.
  49223. * This is stored in format, left to right, up to down format.
  49224. */
  49225. up: Nullable<ArrayBufferView>;
  49226. /**
  49227. * The pixel array for the down face.
  49228. * This is stored in format, left to right, up to down format.
  49229. */
  49230. down: Nullable<ArrayBufferView>;
  49231. /**
  49232. * The size of the cubemap stored.
  49233. *
  49234. * Each faces will be size * size pixels.
  49235. */
  49236. size: number;
  49237. /**
  49238. * The format of the texture.
  49239. *
  49240. * RGBA, RGB.
  49241. */
  49242. format: number;
  49243. /**
  49244. * The type of the texture data.
  49245. *
  49246. * UNSIGNED_INT, FLOAT.
  49247. */
  49248. type: number;
  49249. /**
  49250. * Specifies whether the texture is in gamma space.
  49251. */
  49252. gammaSpace: boolean;
  49253. }
  49254. /**
  49255. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49256. */
  49257. export class PanoramaToCubeMapTools {
  49258. private static FACE_FRONT;
  49259. private static FACE_BACK;
  49260. private static FACE_RIGHT;
  49261. private static FACE_LEFT;
  49262. private static FACE_DOWN;
  49263. private static FACE_UP;
  49264. /**
  49265. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49266. *
  49267. * @param float32Array The source data.
  49268. * @param inputWidth The width of the input panorama.
  49269. * @param inputHeight The height of the input panorama.
  49270. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49271. * @return The cubemap data
  49272. */
  49273. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49274. private static CreateCubemapTexture;
  49275. private static CalcProjectionSpherical;
  49276. }
  49277. }
  49278. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49279. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49281. import { Nullable } from "babylonjs/types";
  49282. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49283. /**
  49284. * Helper class dealing with the extraction of spherical polynomial dataArray
  49285. * from a cube map.
  49286. */
  49287. export class CubeMapToSphericalPolynomialTools {
  49288. private static FileFaces;
  49289. /**
  49290. * Converts a texture to the according Spherical Polynomial data.
  49291. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49292. *
  49293. * @param texture The texture to extract the information from.
  49294. * @return The Spherical Polynomial data.
  49295. */
  49296. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49297. /**
  49298. * Converts a cubemap to the according Spherical Polynomial data.
  49299. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49300. *
  49301. * @param cubeInfo The Cube map to extract the information from.
  49302. * @return The Spherical Polynomial data.
  49303. */
  49304. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49305. }
  49306. }
  49307. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49308. import { Nullable } from "babylonjs/types";
  49309. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49310. module "babylonjs/Materials/Textures/baseTexture" {
  49311. interface BaseTexture {
  49312. /**
  49313. * Get the polynomial representation of the texture data.
  49314. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49315. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49316. */
  49317. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49318. }
  49319. }
  49320. }
  49321. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49322. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49323. /** @hidden */
  49324. export var rgbdEncodePixelShader: {
  49325. name: string;
  49326. shader: string;
  49327. };
  49328. }
  49329. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49330. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49331. /** @hidden */
  49332. export var rgbdDecodePixelShader: {
  49333. name: string;
  49334. shader: string;
  49335. };
  49336. }
  49337. declare module "babylonjs/Misc/environmentTextureTools" {
  49338. import { Nullable } from "babylonjs/types";
  49339. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49341. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49342. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49343. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49344. import "babylonjs/Shaders/rgbdEncode.fragment";
  49345. import "babylonjs/Shaders/rgbdDecode.fragment";
  49346. /**
  49347. * Raw texture data and descriptor sufficient for WebGL texture upload
  49348. */
  49349. export interface EnvironmentTextureInfo {
  49350. /**
  49351. * Version of the environment map
  49352. */
  49353. version: number;
  49354. /**
  49355. * Width of image
  49356. */
  49357. width: number;
  49358. /**
  49359. * Irradiance information stored in the file.
  49360. */
  49361. irradiance: any;
  49362. /**
  49363. * Specular information stored in the file.
  49364. */
  49365. specular: any;
  49366. }
  49367. /**
  49368. * Defines One Image in the file. It requires only the position in the file
  49369. * as well as the length.
  49370. */
  49371. interface BufferImageData {
  49372. /**
  49373. * Length of the image data.
  49374. */
  49375. length: number;
  49376. /**
  49377. * Position of the data from the null terminator delimiting the end of the JSON.
  49378. */
  49379. position: number;
  49380. }
  49381. /**
  49382. * Defines the specular data enclosed in the file.
  49383. * This corresponds to the version 1 of the data.
  49384. */
  49385. export interface EnvironmentTextureSpecularInfoV1 {
  49386. /**
  49387. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49388. */
  49389. specularDataPosition?: number;
  49390. /**
  49391. * This contains all the images data needed to reconstruct the cubemap.
  49392. */
  49393. mipmaps: Array<BufferImageData>;
  49394. /**
  49395. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49396. */
  49397. lodGenerationScale: number;
  49398. }
  49399. /**
  49400. * Sets of helpers addressing the serialization and deserialization of environment texture
  49401. * stored in a BabylonJS env file.
  49402. * Those files are usually stored as .env files.
  49403. */
  49404. export class EnvironmentTextureTools {
  49405. /**
  49406. * Magic number identifying the env file.
  49407. */
  49408. private static _MagicBytes;
  49409. /**
  49410. * Gets the environment info from an env file.
  49411. * @param data The array buffer containing the .env bytes.
  49412. * @returns the environment file info (the json header) if successfully parsed.
  49413. */
  49414. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49415. /**
  49416. * Creates an environment texture from a loaded cube texture.
  49417. * @param texture defines the cube texture to convert in env file
  49418. * @return a promise containing the environment data if succesfull.
  49419. */
  49420. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49421. /**
  49422. * Creates a JSON representation of the spherical data.
  49423. * @param texture defines the texture containing the polynomials
  49424. * @return the JSON representation of the spherical info
  49425. */
  49426. private static _CreateEnvTextureIrradiance;
  49427. /**
  49428. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49429. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  49430. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49431. * @return the views described by info providing access to the underlying buffer
  49432. */
  49433. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49434. /**
  49435. * Uploads the texture info contained in the env file to the GPU.
  49436. * @param texture defines the internal texture to upload to
  49437. * @param arrayBuffer defines the buffer cotaining the data to load
  49438. * @param info defines the texture info retrieved through the GetEnvInfo method
  49439. * @returns a promise
  49440. */
  49441. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49442. private static _OnImageReadyAsync;
  49443. /**
  49444. * Uploads the levels of image data to the GPU.
  49445. * @param texture defines the internal texture to upload to
  49446. * @param imageData defines the array buffer views of image data [mipmap][face]
  49447. * @returns a promise
  49448. */
  49449. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49450. /**
  49451. * Uploads spherical polynomials information to the texture.
  49452. * @param texture defines the texture we are trying to upload the information to
  49453. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49454. */
  49455. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49456. /** @hidden */
  49457. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49458. }
  49459. }
  49460. declare module "babylonjs/Maths/math.vertexFormat" {
  49461. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49462. /**
  49463. * Contains position and normal vectors for a vertex
  49464. */
  49465. export class PositionNormalVertex {
  49466. /** the position of the vertex (defaut: 0,0,0) */
  49467. position: Vector3;
  49468. /** the normal of the vertex (defaut: 0,1,0) */
  49469. normal: Vector3;
  49470. /**
  49471. * Creates a PositionNormalVertex
  49472. * @param position the position of the vertex (defaut: 0,0,0)
  49473. * @param normal the normal of the vertex (defaut: 0,1,0)
  49474. */
  49475. constructor(
  49476. /** the position of the vertex (defaut: 0,0,0) */
  49477. position?: Vector3,
  49478. /** the normal of the vertex (defaut: 0,1,0) */
  49479. normal?: Vector3);
  49480. /**
  49481. * Clones the PositionNormalVertex
  49482. * @returns the cloned PositionNormalVertex
  49483. */
  49484. clone(): PositionNormalVertex;
  49485. }
  49486. /**
  49487. * Contains position, normal and uv vectors for a vertex
  49488. */
  49489. export class PositionNormalTextureVertex {
  49490. /** the position of the vertex (defaut: 0,0,0) */
  49491. position: Vector3;
  49492. /** the normal of the vertex (defaut: 0,1,0) */
  49493. normal: Vector3;
  49494. /** the uv of the vertex (default: 0,0) */
  49495. uv: Vector2;
  49496. /**
  49497. * Creates a PositionNormalTextureVertex
  49498. * @param position the position of the vertex (defaut: 0,0,0)
  49499. * @param normal the normal of the vertex (defaut: 0,1,0)
  49500. * @param uv the uv of the vertex (default: 0,0)
  49501. */
  49502. constructor(
  49503. /** the position of the vertex (defaut: 0,0,0) */
  49504. position?: Vector3,
  49505. /** the normal of the vertex (defaut: 0,1,0) */
  49506. normal?: Vector3,
  49507. /** the uv of the vertex (default: 0,0) */
  49508. uv?: Vector2);
  49509. /**
  49510. * Clones the PositionNormalTextureVertex
  49511. * @returns the cloned PositionNormalTextureVertex
  49512. */
  49513. clone(): PositionNormalTextureVertex;
  49514. }
  49515. }
  49516. declare module "babylonjs/Maths/math" {
  49517. export * from "babylonjs/Maths/math.axis";
  49518. export * from "babylonjs/Maths/math.color";
  49519. export * from "babylonjs/Maths/math.constants";
  49520. export * from "babylonjs/Maths/math.frustum";
  49521. export * from "babylonjs/Maths/math.path";
  49522. export * from "babylonjs/Maths/math.plane";
  49523. export * from "babylonjs/Maths/math.size";
  49524. export * from "babylonjs/Maths/math.vector";
  49525. export * from "babylonjs/Maths/math.vertexFormat";
  49526. export * from "babylonjs/Maths/math.viewport";
  49527. }
  49528. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49529. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49530. /** @hidden */
  49531. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49532. private _genericAttributeLocation;
  49533. private _varyingLocationCount;
  49534. private _varyingLocationMap;
  49535. private _replacements;
  49536. private _textureCount;
  49537. private _uniforms;
  49538. lineProcessor(line: string): string;
  49539. attributeProcessor(attribute: string): string;
  49540. varyingProcessor(varying: string, isFragment: boolean): string;
  49541. uniformProcessor(uniform: string): string;
  49542. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49543. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49544. }
  49545. }
  49546. declare module "babylonjs/Engines/nativeEngine" {
  49547. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49548. import { Engine } from "babylonjs/Engines/engine";
  49549. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49550. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49552. import { Effect } from "babylonjs/Materials/effect";
  49553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49554. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49555. import { IColor4Like } from "babylonjs/Maths/math.like";
  49556. import { Scene } from "babylonjs/scene";
  49557. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49558. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49559. /**
  49560. * Container for accessors for natively-stored mesh data buffers.
  49561. */
  49562. class NativeDataBuffer extends DataBuffer {
  49563. /**
  49564. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49565. */
  49566. nativeIndexBuffer?: any;
  49567. /**
  49568. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49569. */
  49570. nativeVertexBuffer?: any;
  49571. }
  49572. /** @hidden */
  49573. class NativeTexture extends InternalTexture {
  49574. getInternalTexture(): InternalTexture;
  49575. getViewCount(): number;
  49576. }
  49577. /** @hidden */
  49578. export class NativeEngine extends Engine {
  49579. private readonly _native;
  49580. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49581. private readonly INVALID_HANDLE;
  49582. getHardwareScalingLevel(): number;
  49583. constructor();
  49584. /**
  49585. * Can be used to override the current requestAnimationFrame requester.
  49586. * @hidden
  49587. */
  49588. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49589. /**
  49590. * Override default engine behavior.
  49591. * @param color
  49592. * @param backBuffer
  49593. * @param depth
  49594. * @param stencil
  49595. */
  49596. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49597. /**
  49598. * Gets host document
  49599. * @returns the host document object
  49600. */
  49601. getHostDocument(): Nullable<Document>;
  49602. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49603. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49604. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49605. recordVertexArrayObject(vertexBuffers: {
  49606. [key: string]: VertexBuffer;
  49607. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49608. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49609. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49610. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49611. /**
  49612. * Draw a list of indexed primitives
  49613. * @param fillMode defines the primitive to use
  49614. * @param indexStart defines the starting index
  49615. * @param indexCount defines the number of index to draw
  49616. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49617. */
  49618. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49619. /**
  49620. * Draw a list of unindexed primitives
  49621. * @param fillMode defines the primitive to use
  49622. * @param verticesStart defines the index of first vertex to draw
  49623. * @param verticesCount defines the count of vertices to draw
  49624. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49625. */
  49626. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49627. createPipelineContext(): IPipelineContext;
  49628. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49629. /** @hidden */
  49630. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49631. /** @hidden */
  49632. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49633. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49634. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49635. protected _setProgram(program: WebGLProgram): void;
  49636. _releaseEffect(effect: Effect): void;
  49637. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49638. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49639. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49640. bindSamplers(effect: Effect): void;
  49641. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49642. getRenderWidth(useScreen?: boolean): number;
  49643. getRenderHeight(useScreen?: boolean): number;
  49644. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49645. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49646. /**
  49647. * Set the z offset to apply to current rendering
  49648. * @param value defines the offset to apply
  49649. */
  49650. setZOffset(value: number): void;
  49651. /**
  49652. * Gets the current value of the zOffset
  49653. * @returns the current zOffset state
  49654. */
  49655. getZOffset(): number;
  49656. /**
  49657. * Enable or disable depth buffering
  49658. * @param enable defines the state to set
  49659. */
  49660. setDepthBuffer(enable: boolean): void;
  49661. /**
  49662. * Gets a boolean indicating if depth writing is enabled
  49663. * @returns the current depth writing state
  49664. */
  49665. getDepthWrite(): boolean;
  49666. /**
  49667. * Enable or disable depth writing
  49668. * @param enable defines the state to set
  49669. */
  49670. setDepthWrite(enable: boolean): void;
  49671. /**
  49672. * Enable or disable color writing
  49673. * @param enable defines the state to set
  49674. */
  49675. setColorWrite(enable: boolean): void;
  49676. /**
  49677. * Gets a boolean indicating if color writing is enabled
  49678. * @returns the current color writing state
  49679. */
  49680. getColorWrite(): boolean;
  49681. /**
  49682. * Sets alpha constants used by some alpha blending modes
  49683. * @param r defines the red component
  49684. * @param g defines the green component
  49685. * @param b defines the blue component
  49686. * @param a defines the alpha component
  49687. */
  49688. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49689. /**
  49690. * Sets the current alpha mode
  49691. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49692. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49694. */
  49695. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49696. /**
  49697. * Gets the current alpha mode
  49698. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49699. * @returns the current alpha mode
  49700. */
  49701. getAlphaMode(): number;
  49702. setInt(uniform: WebGLUniformLocation, int: number): void;
  49703. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49704. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49705. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49706. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49707. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49708. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49709. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49710. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49711. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49712. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49713. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49714. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49715. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49716. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49717. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49718. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49719. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49720. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49721. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49722. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49723. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49724. wipeCaches(bruteForce?: boolean): void;
  49725. _createTexture(): WebGLTexture;
  49726. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49727. /**
  49728. * Usually called from BABYLON.Texture.ts.
  49729. * Passed information to create a WebGLTexture
  49730. * @param urlArg defines a value which contains one of the following:
  49731. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49732. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49733. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49734. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49735. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49736. * @param scene needed for loading to the correct scene
  49737. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49738. * @param onLoad optional callback to be called upon successful completion
  49739. * @param onError optional callback to be called upon failure
  49740. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49741. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49742. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49743. * @param forcedExtension defines the extension to use to pick the right loader
  49744. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49745. */
  49746. 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;
  49747. /**
  49748. * Creates a cube texture
  49749. * @param rootUrl defines the url where the files to load is located
  49750. * @param scene defines the current scene
  49751. * @param files defines the list of files to load (1 per face)
  49752. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49753. * @param onLoad defines an optional callback raised when the texture is loaded
  49754. * @param onError defines an optional callback raised if there is an issue to load the texture
  49755. * @param format defines the format of the data
  49756. * @param forcedExtension defines the extension to use to pick the right loader
  49757. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49758. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49759. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49760. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49761. * @returns the cube texture as an InternalTexture
  49762. */
  49763. 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;
  49764. private _getSamplingFilter;
  49765. private static _GetNativeTextureFormat;
  49766. createRenderTargetTexture(size: number | {
  49767. width: number;
  49768. height: number;
  49769. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49770. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49771. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49772. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49773. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49774. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49775. /**
  49776. * Updates a dynamic vertex buffer.
  49777. * @param vertexBuffer the vertex buffer to update
  49778. * @param data the data used to update the vertex buffer
  49779. * @param byteOffset the byte offset of the data (optional)
  49780. * @param byteLength the byte length of the data (optional)
  49781. */
  49782. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49783. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49784. private _updateAnisotropicLevel;
  49785. private _getAddressMode;
  49786. /** @hidden */
  49787. _bindTexture(channel: number, texture: InternalTexture): void;
  49788. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49789. releaseEffects(): void;
  49790. /** @hidden */
  49791. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49792. /** @hidden */
  49793. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49794. /** @hidden */
  49795. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49796. /** @hidden */
  49797. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49798. }
  49799. }
  49800. declare module "babylonjs/Engines/index" {
  49801. export * from "babylonjs/Engines/constants";
  49802. export * from "babylonjs/Engines/engineCapabilities";
  49803. export * from "babylonjs/Engines/instancingAttributeInfo";
  49804. export * from "babylonjs/Engines/thinEngine";
  49805. export * from "babylonjs/Engines/engine";
  49806. export * from "babylonjs/Engines/engineStore";
  49807. export * from "babylonjs/Engines/nullEngine";
  49808. export * from "babylonjs/Engines/Extensions/index";
  49809. export * from "babylonjs/Engines/IPipelineContext";
  49810. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49811. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49812. export * from "babylonjs/Engines/nativeEngine";
  49813. }
  49814. declare module "babylonjs/Events/clipboardEvents" {
  49815. /**
  49816. * Gather the list of clipboard event types as constants.
  49817. */
  49818. export class ClipboardEventTypes {
  49819. /**
  49820. * The clipboard event is fired when a copy command is active (pressed).
  49821. */
  49822. static readonly COPY: number;
  49823. /**
  49824. * The clipboard event is fired when a cut command is active (pressed).
  49825. */
  49826. static readonly CUT: number;
  49827. /**
  49828. * The clipboard event is fired when a paste command is active (pressed).
  49829. */
  49830. static readonly PASTE: number;
  49831. }
  49832. /**
  49833. * This class is used to store clipboard related info for the onClipboardObservable event.
  49834. */
  49835. export class ClipboardInfo {
  49836. /**
  49837. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49838. */
  49839. type: number;
  49840. /**
  49841. * Defines the related dom event
  49842. */
  49843. event: ClipboardEvent;
  49844. /**
  49845. *Creates an instance of ClipboardInfo.
  49846. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49847. * @param event Defines the related dom event
  49848. */
  49849. constructor(
  49850. /**
  49851. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49852. */
  49853. type: number,
  49854. /**
  49855. * Defines the related dom event
  49856. */
  49857. event: ClipboardEvent);
  49858. /**
  49859. * Get the clipboard event's type from the keycode.
  49860. * @param keyCode Defines the keyCode for the current keyboard event.
  49861. * @return {number}
  49862. */
  49863. static GetTypeFromCharacter(keyCode: number): number;
  49864. }
  49865. }
  49866. declare module "babylonjs/Events/index" {
  49867. export * from "babylonjs/Events/keyboardEvents";
  49868. export * from "babylonjs/Events/pointerEvents";
  49869. export * from "babylonjs/Events/clipboardEvents";
  49870. }
  49871. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49872. import { Scene } from "babylonjs/scene";
  49873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49874. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49875. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49876. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49877. /**
  49878. * Google Daydream controller
  49879. */
  49880. export class DaydreamController extends WebVRController {
  49881. /**
  49882. * Base Url for the controller model.
  49883. */
  49884. static MODEL_BASE_URL: string;
  49885. /**
  49886. * File name for the controller model.
  49887. */
  49888. static MODEL_FILENAME: string;
  49889. /**
  49890. * Gamepad Id prefix used to identify Daydream Controller.
  49891. */
  49892. static readonly GAMEPAD_ID_PREFIX: string;
  49893. /**
  49894. * Creates a new DaydreamController from a gamepad
  49895. * @param vrGamepad the gamepad that the controller should be created from
  49896. */
  49897. constructor(vrGamepad: any);
  49898. /**
  49899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49900. * @param scene scene in which to add meshes
  49901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49902. */
  49903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49904. /**
  49905. * Called once for each button that changed state since the last frame
  49906. * @param buttonIdx Which button index changed
  49907. * @param state New state of the button
  49908. * @param changes Which properties on the state changed since last frame
  49909. */
  49910. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49911. }
  49912. }
  49913. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49914. import { Scene } from "babylonjs/scene";
  49915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49916. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49917. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49918. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49919. /**
  49920. * Gear VR Controller
  49921. */
  49922. export class GearVRController extends WebVRController {
  49923. /**
  49924. * Base Url for the controller model.
  49925. */
  49926. static MODEL_BASE_URL: string;
  49927. /**
  49928. * File name for the controller model.
  49929. */
  49930. static MODEL_FILENAME: string;
  49931. /**
  49932. * Gamepad Id prefix used to identify this controller.
  49933. */
  49934. static readonly GAMEPAD_ID_PREFIX: string;
  49935. private readonly _buttonIndexToObservableNameMap;
  49936. /**
  49937. * Creates a new GearVRController from a gamepad
  49938. * @param vrGamepad the gamepad that the controller should be created from
  49939. */
  49940. constructor(vrGamepad: any);
  49941. /**
  49942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49943. * @param scene scene in which to add meshes
  49944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49945. */
  49946. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49947. /**
  49948. * Called once for each button that changed state since the last frame
  49949. * @param buttonIdx Which button index changed
  49950. * @param state New state of the button
  49951. * @param changes Which properties on the state changed since last frame
  49952. */
  49953. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49954. }
  49955. }
  49956. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49957. import { Scene } from "babylonjs/scene";
  49958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49959. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49960. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49961. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49962. /**
  49963. * Generic Controller
  49964. */
  49965. export class GenericController extends WebVRController {
  49966. /**
  49967. * Base Url for the controller model.
  49968. */
  49969. static readonly MODEL_BASE_URL: string;
  49970. /**
  49971. * File name for the controller model.
  49972. */
  49973. static readonly MODEL_FILENAME: string;
  49974. /**
  49975. * Creates a new GenericController 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. * Called once for each button that changed state since the last frame
  49987. * @param buttonIdx Which button index changed
  49988. * @param state New state of the button
  49989. * @param changes Which properties on the state changed since last frame
  49990. */
  49991. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49992. }
  49993. }
  49994. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49995. import { Observable } from "babylonjs/Misc/observable";
  49996. import { Scene } from "babylonjs/scene";
  49997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49998. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49999. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50000. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50001. /**
  50002. * Oculus Touch Controller
  50003. */
  50004. export class OculusTouchController extends WebVRController {
  50005. /**
  50006. * Base Url for the controller model.
  50007. */
  50008. static MODEL_BASE_URL: string;
  50009. /**
  50010. * File name for the left controller model.
  50011. */
  50012. static MODEL_LEFT_FILENAME: string;
  50013. /**
  50014. * File name for the right controller model.
  50015. */
  50016. static MODEL_RIGHT_FILENAME: string;
  50017. /**
  50018. * Base Url for the Quest controller model.
  50019. */
  50020. static QUEST_MODEL_BASE_URL: string;
  50021. /**
  50022. * @hidden
  50023. * If the controllers are running on a device that needs the updated Quest controller models
  50024. */
  50025. static _IsQuest: boolean;
  50026. /**
  50027. * Fired when the secondary trigger on this controller is modified
  50028. */
  50029. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50030. /**
  50031. * Fired when the thumb rest on this controller is modified
  50032. */
  50033. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50034. /**
  50035. * Creates a new OculusTouchController from a gamepad
  50036. * @param vrGamepad the gamepad that the controller should be created from
  50037. */
  50038. constructor(vrGamepad: any);
  50039. /**
  50040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50041. * @param scene scene in which to add meshes
  50042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50043. */
  50044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50045. /**
  50046. * Fired when the A button on this controller is modified
  50047. */
  50048. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50049. /**
  50050. * Fired when the B button on this controller is modified
  50051. */
  50052. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50053. /**
  50054. * Fired when the X button on this controller is modified
  50055. */
  50056. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50057. /**
  50058. * Fired when the Y button on this controller is modified
  50059. */
  50060. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50061. /**
  50062. * Called once for each button that changed state since the last frame
  50063. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50064. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50065. * 2) secondary trigger (same)
  50066. * 3) A (right) X (left), touch, pressed = value
  50067. * 4) B / Y
  50068. * 5) thumb rest
  50069. * @param buttonIdx Which button index changed
  50070. * @param state New state of the button
  50071. * @param changes Which properties on the state changed since last frame
  50072. */
  50073. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50074. }
  50075. }
  50076. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50077. import { Scene } from "babylonjs/scene";
  50078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50079. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50080. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50081. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50082. import { Observable } from "babylonjs/Misc/observable";
  50083. /**
  50084. * Vive Controller
  50085. */
  50086. export class ViveController extends WebVRController {
  50087. /**
  50088. * Base Url for the controller model.
  50089. */
  50090. static MODEL_BASE_URL: string;
  50091. /**
  50092. * File name for the controller model.
  50093. */
  50094. static MODEL_FILENAME: string;
  50095. /**
  50096. * Creates a new ViveController from a gamepad
  50097. * @param vrGamepad the gamepad that the controller should be created from
  50098. */
  50099. constructor(vrGamepad: any);
  50100. /**
  50101. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50102. * @param scene scene in which to add meshes
  50103. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50104. */
  50105. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50106. /**
  50107. * Fired when the left button on this controller is modified
  50108. */
  50109. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50110. /**
  50111. * Fired when the right button on this controller is modified
  50112. */
  50113. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50114. /**
  50115. * Fired when the menu button on this controller is modified
  50116. */
  50117. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50118. /**
  50119. * Called once for each button that changed state since the last frame
  50120. * Vive mapping:
  50121. * 0: touchpad
  50122. * 1: trigger
  50123. * 2: left AND right buttons
  50124. * 3: menu button
  50125. * @param buttonIdx Which button index changed
  50126. * @param state New state of the button
  50127. * @param changes Which properties on the state changed since last frame
  50128. */
  50129. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50130. }
  50131. }
  50132. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50133. import { Observable } from "babylonjs/Misc/observable";
  50134. import { Scene } from "babylonjs/scene";
  50135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50136. import { Ray } from "babylonjs/Culling/ray";
  50137. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50138. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50139. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50140. /**
  50141. * Defines the WindowsMotionController object that the state of the windows motion controller
  50142. */
  50143. export class WindowsMotionController extends WebVRController {
  50144. /**
  50145. * The base url used to load the left and right controller models
  50146. */
  50147. static MODEL_BASE_URL: string;
  50148. /**
  50149. * The name of the left controller model file
  50150. */
  50151. static MODEL_LEFT_FILENAME: string;
  50152. /**
  50153. * The name of the right controller model file
  50154. */
  50155. static MODEL_RIGHT_FILENAME: string;
  50156. /**
  50157. * The controller name prefix for this controller type
  50158. */
  50159. static readonly GAMEPAD_ID_PREFIX: string;
  50160. /**
  50161. * The controller id pattern for this controller type
  50162. */
  50163. private static readonly GAMEPAD_ID_PATTERN;
  50164. private _loadedMeshInfo;
  50165. protected readonly _mapping: {
  50166. buttons: string[];
  50167. buttonMeshNames: {
  50168. 'trigger': string;
  50169. 'menu': string;
  50170. 'grip': string;
  50171. 'thumbstick': string;
  50172. 'trackpad': string;
  50173. };
  50174. buttonObservableNames: {
  50175. 'trigger': string;
  50176. 'menu': string;
  50177. 'grip': string;
  50178. 'thumbstick': string;
  50179. 'trackpad': string;
  50180. };
  50181. axisMeshNames: string[];
  50182. pointingPoseMeshName: string;
  50183. };
  50184. /**
  50185. * Fired when the trackpad on this controller is clicked
  50186. */
  50187. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50188. /**
  50189. * Fired when the trackpad on this controller is modified
  50190. */
  50191. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50192. /**
  50193. * The current x and y values of this controller's trackpad
  50194. */
  50195. trackpad: StickValues;
  50196. /**
  50197. * Creates a new WindowsMotionController from a gamepad
  50198. * @param vrGamepad the gamepad that the controller should be created from
  50199. */
  50200. constructor(vrGamepad: any);
  50201. /**
  50202. * Fired when the trigger on this controller is modified
  50203. */
  50204. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50205. /**
  50206. * Fired when the menu button on this controller is modified
  50207. */
  50208. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50209. /**
  50210. * Fired when the grip button on this controller is modified
  50211. */
  50212. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50213. /**
  50214. * Fired when the thumbstick button on this controller is modified
  50215. */
  50216. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50217. /**
  50218. * Fired when the touchpad button on this controller is modified
  50219. */
  50220. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50221. /**
  50222. * Fired when the touchpad values on this controller are modified
  50223. */
  50224. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50225. protected _updateTrackpad(): void;
  50226. /**
  50227. * Called once per frame by the engine.
  50228. */
  50229. update(): void;
  50230. /**
  50231. * Called once for each button that changed state since the last frame
  50232. * @param buttonIdx Which button index changed
  50233. * @param state New state of the button
  50234. * @param changes Which properties on the state changed since last frame
  50235. */
  50236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50237. /**
  50238. * Moves the buttons on the controller mesh based on their current state
  50239. * @param buttonName the name of the button to move
  50240. * @param buttonValue the value of the button which determines the buttons new position
  50241. */
  50242. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50243. /**
  50244. * Moves the axis on the controller mesh based on its current state
  50245. * @param axis the index of the axis
  50246. * @param axisValue the value of the axis which determines the meshes new position
  50247. * @hidden
  50248. */
  50249. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50250. /**
  50251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50252. * @param scene scene in which to add meshes
  50253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50254. */
  50255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50256. /**
  50257. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50258. * can be transformed by button presses and axes values, based on this._mapping.
  50259. *
  50260. * @param scene scene in which the meshes exist
  50261. * @param meshes list of meshes that make up the controller model to process
  50262. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50263. */
  50264. private processModel;
  50265. private createMeshInfo;
  50266. /**
  50267. * Gets the ray of the controller in the direction the controller is pointing
  50268. * @param length the length the resulting ray should be
  50269. * @returns a ray in the direction the controller is pointing
  50270. */
  50271. getForwardRay(length?: number): Ray;
  50272. /**
  50273. * Disposes of the controller
  50274. */
  50275. dispose(): void;
  50276. }
  50277. /**
  50278. * This class represents a new windows motion controller in XR.
  50279. */
  50280. export class XRWindowsMotionController extends WindowsMotionController {
  50281. /**
  50282. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50283. */
  50284. protected readonly _mapping: {
  50285. buttons: string[];
  50286. buttonMeshNames: {
  50287. 'trigger': string;
  50288. 'menu': string;
  50289. 'grip': string;
  50290. 'thumbstick': string;
  50291. 'trackpad': string;
  50292. };
  50293. buttonObservableNames: {
  50294. 'trigger': string;
  50295. 'menu': string;
  50296. 'grip': string;
  50297. 'thumbstick': string;
  50298. 'trackpad': string;
  50299. };
  50300. axisMeshNames: string[];
  50301. pointingPoseMeshName: string;
  50302. };
  50303. /**
  50304. * Construct a new XR-Based windows motion controller
  50305. *
  50306. * @param gamepadInfo the gamepad object from the browser
  50307. */
  50308. constructor(gamepadInfo: any);
  50309. /**
  50310. * holds the thumbstick values (X,Y)
  50311. */
  50312. thumbstickValues: StickValues;
  50313. /**
  50314. * Fired when the thumbstick on this controller is clicked
  50315. */
  50316. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50317. /**
  50318. * Fired when the thumbstick on this controller is modified
  50319. */
  50320. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50321. /**
  50322. * Fired when the touchpad button on this controller is modified
  50323. */
  50324. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50325. /**
  50326. * Fired when the touchpad values on this controller are modified
  50327. */
  50328. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50329. /**
  50330. * Fired when the thumbstick button on this controller is modified
  50331. * here to prevent breaking changes
  50332. */
  50333. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50334. /**
  50335. * updating the thumbstick(!) and not the trackpad.
  50336. * This is named this way due to the difference between WebVR and XR and to avoid
  50337. * changing the parent class.
  50338. */
  50339. protected _updateTrackpad(): void;
  50340. /**
  50341. * Disposes the class with joy
  50342. */
  50343. dispose(): void;
  50344. }
  50345. }
  50346. declare module "babylonjs/Gamepads/Controllers/index" {
  50347. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50348. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50349. export * from "babylonjs/Gamepads/Controllers/genericController";
  50350. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50351. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50352. export * from "babylonjs/Gamepads/Controllers/viveController";
  50353. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50354. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50355. }
  50356. declare module "babylonjs/Gamepads/index" {
  50357. export * from "babylonjs/Gamepads/Controllers/index";
  50358. export * from "babylonjs/Gamepads/gamepad";
  50359. export * from "babylonjs/Gamepads/gamepadManager";
  50360. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50361. export * from "babylonjs/Gamepads/xboxGamepad";
  50362. export * from "babylonjs/Gamepads/dualShockGamepad";
  50363. }
  50364. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50365. import { Scene } from "babylonjs/scene";
  50366. import { Vector4 } from "babylonjs/Maths/math.vector";
  50367. import { Color4 } from "babylonjs/Maths/math.color";
  50368. import { Mesh } from "babylonjs/Meshes/mesh";
  50369. import { Nullable } from "babylonjs/types";
  50370. /**
  50371. * Class containing static functions to help procedurally build meshes
  50372. */
  50373. export class PolyhedronBuilder {
  50374. /**
  50375. * Creates a polyhedron mesh
  50376. * * 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
  50377. * * The parameter `size` (positive float, default 1) sets the polygon size
  50378. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50379. * * 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`
  50380. * * 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
  50381. * * 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)`)
  50382. * * 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
  50383. * * 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
  50384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50387. * @param name defines the name of the mesh
  50388. * @param options defines the options used to create the mesh
  50389. * @param scene defines the hosting scene
  50390. * @returns the polyhedron mesh
  50391. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50392. */
  50393. static CreatePolyhedron(name: string, options: {
  50394. type?: number;
  50395. size?: number;
  50396. sizeX?: number;
  50397. sizeY?: number;
  50398. sizeZ?: number;
  50399. custom?: any;
  50400. faceUV?: Vector4[];
  50401. faceColors?: Color4[];
  50402. flat?: boolean;
  50403. updatable?: boolean;
  50404. sideOrientation?: number;
  50405. frontUVs?: Vector4;
  50406. backUVs?: Vector4;
  50407. }, scene?: Nullable<Scene>): Mesh;
  50408. }
  50409. }
  50410. declare module "babylonjs/Gizmos/scaleGizmo" {
  50411. import { Observable } from "babylonjs/Misc/observable";
  50412. import { Nullable } from "babylonjs/types";
  50413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50414. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50415. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50416. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50417. /**
  50418. * Gizmo that enables scaling a mesh along 3 axis
  50419. */
  50420. export class ScaleGizmo extends Gizmo {
  50421. /**
  50422. * Internal gizmo used for interactions on the x axis
  50423. */
  50424. xGizmo: AxisScaleGizmo;
  50425. /**
  50426. * Internal gizmo used for interactions on the y axis
  50427. */
  50428. yGizmo: AxisScaleGizmo;
  50429. /**
  50430. * Internal gizmo used for interactions on the z axis
  50431. */
  50432. zGizmo: AxisScaleGizmo;
  50433. /**
  50434. * Internal gizmo used to scale all axis equally
  50435. */
  50436. uniformScaleGizmo: AxisScaleGizmo;
  50437. private _meshAttached;
  50438. private _updateGizmoRotationToMatchAttachedMesh;
  50439. private _snapDistance;
  50440. private _scaleRatio;
  50441. private _uniformScalingMesh;
  50442. private _octahedron;
  50443. private _sensitivity;
  50444. /** Fires an event when any of it's sub gizmos are dragged */
  50445. onDragStartObservable: Observable<unknown>;
  50446. /** Fires an event when any of it's sub gizmos are released from dragging */
  50447. onDragEndObservable: Observable<unknown>;
  50448. get attachedMesh(): Nullable<AbstractMesh>;
  50449. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50450. /**
  50451. * Creates a ScaleGizmo
  50452. * @param gizmoLayer The utility layer the gizmo will be added to
  50453. */
  50454. constructor(gizmoLayer?: UtilityLayerRenderer);
  50455. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50456. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50457. /**
  50458. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50459. */
  50460. set snapDistance(value: number);
  50461. get snapDistance(): number;
  50462. /**
  50463. * Ratio for the scale of the gizmo (Default: 1)
  50464. */
  50465. set scaleRatio(value: number);
  50466. get scaleRatio(): number;
  50467. /**
  50468. * Sensitivity factor for dragging (Default: 1)
  50469. */
  50470. set sensitivity(value: number);
  50471. get sensitivity(): number;
  50472. /**
  50473. * Disposes of the gizmo
  50474. */
  50475. dispose(): void;
  50476. }
  50477. }
  50478. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50479. import { Observable } from "babylonjs/Misc/observable";
  50480. import { Nullable } from "babylonjs/types";
  50481. import { Vector3 } from "babylonjs/Maths/math.vector";
  50482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50483. import { Mesh } from "babylonjs/Meshes/mesh";
  50484. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50485. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50486. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50487. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50488. import { Color3 } from "babylonjs/Maths/math.color";
  50489. /**
  50490. * Single axis scale gizmo
  50491. */
  50492. export class AxisScaleGizmo extends Gizmo {
  50493. /**
  50494. * Drag behavior responsible for the gizmos dragging interactions
  50495. */
  50496. dragBehavior: PointerDragBehavior;
  50497. private _pointerObserver;
  50498. /**
  50499. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50500. */
  50501. snapDistance: number;
  50502. /**
  50503. * Event that fires each time the gizmo snaps to a new location.
  50504. * * snapDistance is the the change in distance
  50505. */
  50506. onSnapObservable: Observable<{
  50507. snapDistance: number;
  50508. }>;
  50509. /**
  50510. * If the scaling operation should be done on all axis (default: false)
  50511. */
  50512. uniformScaling: boolean;
  50513. /**
  50514. * Custom sensitivity value for the drag strength
  50515. */
  50516. sensitivity: number;
  50517. private _isEnabled;
  50518. private _parent;
  50519. private _arrow;
  50520. private _coloredMaterial;
  50521. private _hoverMaterial;
  50522. /**
  50523. * Creates an AxisScaleGizmo
  50524. * @param gizmoLayer The utility layer the gizmo will be added to
  50525. * @param dragAxis The axis which the gizmo will be able to scale on
  50526. * @param color The color of the gizmo
  50527. */
  50528. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50529. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50530. /**
  50531. * If the gizmo is enabled
  50532. */
  50533. set isEnabled(value: boolean);
  50534. get isEnabled(): boolean;
  50535. /**
  50536. * Disposes of the gizmo
  50537. */
  50538. dispose(): void;
  50539. /**
  50540. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50541. * @param mesh The mesh to replace the default mesh of the gizmo
  50542. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50543. */
  50544. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50545. }
  50546. }
  50547. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50548. import { Observable } from "babylonjs/Misc/observable";
  50549. import { Nullable } from "babylonjs/types";
  50550. import { Vector3 } from "babylonjs/Maths/math.vector";
  50551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50552. import { Mesh } from "babylonjs/Meshes/mesh";
  50553. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50554. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50555. import { Color3 } from "babylonjs/Maths/math.color";
  50556. import "babylonjs/Meshes/Builders/boxBuilder";
  50557. /**
  50558. * Bounding box gizmo
  50559. */
  50560. export class BoundingBoxGizmo extends Gizmo {
  50561. private _lineBoundingBox;
  50562. private _rotateSpheresParent;
  50563. private _scaleBoxesParent;
  50564. private _boundingDimensions;
  50565. private _renderObserver;
  50566. private _pointerObserver;
  50567. private _scaleDragSpeed;
  50568. private _tmpQuaternion;
  50569. private _tmpVector;
  50570. private _tmpRotationMatrix;
  50571. /**
  50572. * 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)
  50573. */
  50574. ignoreChildren: boolean;
  50575. /**
  50576. * 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)
  50577. */
  50578. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50579. /**
  50580. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50581. */
  50582. rotationSphereSize: number;
  50583. /**
  50584. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50585. */
  50586. scaleBoxSize: number;
  50587. /**
  50588. * 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)
  50589. */
  50590. fixedDragMeshScreenSize: boolean;
  50591. /**
  50592. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50593. */
  50594. fixedDragMeshScreenSizeDistanceFactor: number;
  50595. /**
  50596. * Fired when a rotation sphere or scale box is dragged
  50597. */
  50598. onDragStartObservable: Observable<{}>;
  50599. /**
  50600. * Fired when a scale box is dragged
  50601. */
  50602. onScaleBoxDragObservable: Observable<{}>;
  50603. /**
  50604. * Fired when a scale box drag is ended
  50605. */
  50606. onScaleBoxDragEndObservable: Observable<{}>;
  50607. /**
  50608. * Fired when a rotation sphere is dragged
  50609. */
  50610. onRotationSphereDragObservable: Observable<{}>;
  50611. /**
  50612. * Fired when a rotation sphere drag is ended
  50613. */
  50614. onRotationSphereDragEndObservable: Observable<{}>;
  50615. /**
  50616. * 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)
  50617. */
  50618. scalePivot: Nullable<Vector3>;
  50619. /**
  50620. * Mesh used as a pivot to rotate the attached mesh
  50621. */
  50622. private _anchorMesh;
  50623. private _existingMeshScale;
  50624. private _dragMesh;
  50625. private pointerDragBehavior;
  50626. private coloredMaterial;
  50627. private hoverColoredMaterial;
  50628. /**
  50629. * Sets the color of the bounding box gizmo
  50630. * @param color the color to set
  50631. */
  50632. setColor(color: Color3): void;
  50633. /**
  50634. * Creates an BoundingBoxGizmo
  50635. * @param gizmoLayer The utility layer the gizmo will be added to
  50636. * @param color The color of the gizmo
  50637. */
  50638. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50639. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50640. private _selectNode;
  50641. /**
  50642. * Updates the bounding box information for the Gizmo
  50643. */
  50644. updateBoundingBox(): void;
  50645. private _updateRotationSpheres;
  50646. private _updateScaleBoxes;
  50647. /**
  50648. * Enables rotation on the specified axis and disables rotation on the others
  50649. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50650. */
  50651. setEnabledRotationAxis(axis: string): void;
  50652. /**
  50653. * Enables/disables scaling
  50654. * @param enable if scaling should be enabled
  50655. */
  50656. setEnabledScaling(enable: boolean): void;
  50657. private _updateDummy;
  50658. /**
  50659. * Enables a pointer drag behavior on the bounding box of the gizmo
  50660. */
  50661. enableDragBehavior(): void;
  50662. /**
  50663. * Disposes of the gizmo
  50664. */
  50665. dispose(): void;
  50666. /**
  50667. * 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)
  50668. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50669. * @returns the bounding box mesh with the passed in mesh as a child
  50670. */
  50671. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50672. /**
  50673. * CustomMeshes are not supported by this gizmo
  50674. * @param mesh The mesh to replace the default mesh of the gizmo
  50675. */
  50676. setCustomMesh(mesh: Mesh): void;
  50677. }
  50678. }
  50679. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50680. import { Observable } from "babylonjs/Misc/observable";
  50681. import { Nullable } from "babylonjs/types";
  50682. import { Vector3 } from "babylonjs/Maths/math.vector";
  50683. import { Color3 } from "babylonjs/Maths/math.color";
  50684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50685. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50686. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50687. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50688. import "babylonjs/Meshes/Builders/linesBuilder";
  50689. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50690. /**
  50691. * Single plane rotation gizmo
  50692. */
  50693. export class PlaneRotationGizmo extends Gizmo {
  50694. /**
  50695. * Drag behavior responsible for the gizmos dragging interactions
  50696. */
  50697. dragBehavior: PointerDragBehavior;
  50698. private _pointerObserver;
  50699. /**
  50700. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50701. */
  50702. snapDistance: number;
  50703. /**
  50704. * Event that fires each time the gizmo snaps to a new location.
  50705. * * snapDistance is the the change in distance
  50706. */
  50707. onSnapObservable: Observable<{
  50708. snapDistance: number;
  50709. }>;
  50710. private _isEnabled;
  50711. private _parent;
  50712. /**
  50713. * Creates a PlaneRotationGizmo
  50714. * @param gizmoLayer The utility layer the gizmo will be added to
  50715. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50716. * @param color The color of the gizmo
  50717. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50718. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50719. */
  50720. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50721. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50722. /**
  50723. * If the gizmo is enabled
  50724. */
  50725. set isEnabled(value: boolean);
  50726. get isEnabled(): boolean;
  50727. /**
  50728. * Disposes of the gizmo
  50729. */
  50730. dispose(): void;
  50731. }
  50732. }
  50733. declare module "babylonjs/Gizmos/rotationGizmo" {
  50734. import { Observable } from "babylonjs/Misc/observable";
  50735. import { Nullable } from "babylonjs/types";
  50736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50737. import { Mesh } from "babylonjs/Meshes/mesh";
  50738. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50739. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50740. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50741. /**
  50742. * Gizmo that enables rotating a mesh along 3 axis
  50743. */
  50744. export class RotationGizmo extends Gizmo {
  50745. /**
  50746. * Internal gizmo used for interactions on the x axis
  50747. */
  50748. xGizmo: PlaneRotationGizmo;
  50749. /**
  50750. * Internal gizmo used for interactions on the y axis
  50751. */
  50752. yGizmo: PlaneRotationGizmo;
  50753. /**
  50754. * Internal gizmo used for interactions on the z axis
  50755. */
  50756. zGizmo: PlaneRotationGizmo;
  50757. /** Fires an event when any of it's sub gizmos are dragged */
  50758. onDragStartObservable: Observable<unknown>;
  50759. /** Fires an event when any of it's sub gizmos are released from dragging */
  50760. onDragEndObservable: Observable<unknown>;
  50761. private _meshAttached;
  50762. get attachedMesh(): Nullable<AbstractMesh>;
  50763. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50764. /**
  50765. * Creates a RotationGizmo
  50766. * @param gizmoLayer The utility layer the gizmo will be added to
  50767. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50768. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50769. */
  50770. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50771. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50772. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50773. /**
  50774. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50775. */
  50776. set snapDistance(value: number);
  50777. get snapDistance(): number;
  50778. /**
  50779. * Ratio for the scale of the gizmo (Default: 1)
  50780. */
  50781. set scaleRatio(value: number);
  50782. get scaleRatio(): number;
  50783. /**
  50784. * Disposes of the gizmo
  50785. */
  50786. dispose(): void;
  50787. /**
  50788. * CustomMeshes are not supported by this gizmo
  50789. * @param mesh The mesh to replace the default mesh of the gizmo
  50790. */
  50791. setCustomMesh(mesh: Mesh): void;
  50792. }
  50793. }
  50794. declare module "babylonjs/Gizmos/gizmoManager" {
  50795. import { Observable } from "babylonjs/Misc/observable";
  50796. import { Nullable } from "babylonjs/types";
  50797. import { Scene, IDisposable } from "babylonjs/scene";
  50798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50799. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50800. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50801. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50802. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50803. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50804. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50805. /**
  50806. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50807. */
  50808. export class GizmoManager implements IDisposable {
  50809. private scene;
  50810. /**
  50811. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50812. */
  50813. gizmos: {
  50814. positionGizmo: Nullable<PositionGizmo>;
  50815. rotationGizmo: Nullable<RotationGizmo>;
  50816. scaleGizmo: Nullable<ScaleGizmo>;
  50817. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50818. };
  50819. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50820. clearGizmoOnEmptyPointerEvent: boolean;
  50821. /** Fires an event when the manager is attached to a mesh */
  50822. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50823. private _gizmosEnabled;
  50824. private _pointerObserver;
  50825. private _attachedMesh;
  50826. private _boundingBoxColor;
  50827. private _defaultUtilityLayer;
  50828. private _defaultKeepDepthUtilityLayer;
  50829. /**
  50830. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50831. */
  50832. boundingBoxDragBehavior: SixDofDragBehavior;
  50833. /**
  50834. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50835. */
  50836. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50837. /**
  50838. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50839. */
  50840. usePointerToAttachGizmos: boolean;
  50841. /**
  50842. * Utility layer that the bounding box gizmo belongs to
  50843. */
  50844. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50845. /**
  50846. * Utility layer that all gizmos besides bounding box belong to
  50847. */
  50848. get utilityLayer(): UtilityLayerRenderer;
  50849. /**
  50850. * Instatiates a gizmo manager
  50851. * @param scene the scene to overlay the gizmos on top of
  50852. */
  50853. constructor(scene: Scene);
  50854. /**
  50855. * Attaches a set of gizmos to the specified mesh
  50856. * @param mesh The mesh the gizmo's should be attached to
  50857. */
  50858. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50859. /**
  50860. * If the position gizmo is enabled
  50861. */
  50862. set positionGizmoEnabled(value: boolean);
  50863. get positionGizmoEnabled(): boolean;
  50864. /**
  50865. * If the rotation gizmo is enabled
  50866. */
  50867. set rotationGizmoEnabled(value: boolean);
  50868. get rotationGizmoEnabled(): boolean;
  50869. /**
  50870. * If the scale gizmo is enabled
  50871. */
  50872. set scaleGizmoEnabled(value: boolean);
  50873. get scaleGizmoEnabled(): boolean;
  50874. /**
  50875. * If the boundingBox gizmo is enabled
  50876. */
  50877. set boundingBoxGizmoEnabled(value: boolean);
  50878. get boundingBoxGizmoEnabled(): boolean;
  50879. /**
  50880. * Disposes of the gizmo manager
  50881. */
  50882. dispose(): void;
  50883. }
  50884. }
  50885. declare module "babylonjs/Lights/directionalLight" {
  50886. import { Camera } from "babylonjs/Cameras/camera";
  50887. import { Scene } from "babylonjs/scene";
  50888. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50890. import { Light } from "babylonjs/Lights/light";
  50891. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50892. import { Effect } from "babylonjs/Materials/effect";
  50893. /**
  50894. * A directional light is defined by a direction (what a surprise!).
  50895. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50896. * 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.
  50897. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50898. */
  50899. export class DirectionalLight extends ShadowLight {
  50900. private _shadowFrustumSize;
  50901. /**
  50902. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50903. */
  50904. get shadowFrustumSize(): number;
  50905. /**
  50906. * Specifies a fix frustum size for the shadow generation.
  50907. */
  50908. set shadowFrustumSize(value: number);
  50909. private _shadowOrthoScale;
  50910. /**
  50911. * Gets the shadow projection scale against the optimal computed one.
  50912. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50913. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50914. */
  50915. get shadowOrthoScale(): number;
  50916. /**
  50917. * Sets the shadow projection scale against the optimal computed one.
  50918. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50919. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50920. */
  50921. set shadowOrthoScale(value: number);
  50922. /**
  50923. * Automatically compute the projection matrix to best fit (including all the casters)
  50924. * on each frame.
  50925. */
  50926. autoUpdateExtends: boolean;
  50927. /**
  50928. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50929. * on each frame. autoUpdateExtends must be set to true for this to work
  50930. */
  50931. autoCalcShadowZBounds: boolean;
  50932. private _orthoLeft;
  50933. private _orthoRight;
  50934. private _orthoTop;
  50935. private _orthoBottom;
  50936. /**
  50937. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50938. * The directional light is emitted from everywhere in the given direction.
  50939. * It can cast shadows.
  50940. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50941. * @param name The friendly name of the light
  50942. * @param direction The direction of the light
  50943. * @param scene The scene the light belongs to
  50944. */
  50945. constructor(name: string, direction: Vector3, scene: Scene);
  50946. /**
  50947. * Returns the string "DirectionalLight".
  50948. * @return The class name
  50949. */
  50950. getClassName(): string;
  50951. /**
  50952. * Returns the integer 1.
  50953. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50954. */
  50955. getTypeID(): number;
  50956. /**
  50957. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50958. * Returns the DirectionalLight Shadow projection matrix.
  50959. */
  50960. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50961. /**
  50962. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50963. * Returns the DirectionalLight Shadow projection matrix.
  50964. */
  50965. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50966. /**
  50967. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50968. * Returns the DirectionalLight Shadow projection matrix.
  50969. */
  50970. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50971. protected _buildUniformLayout(): void;
  50972. /**
  50973. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50974. * @param effect The effect to update
  50975. * @param lightIndex The index of the light in the effect to update
  50976. * @returns The directional light
  50977. */
  50978. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50979. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50980. /**
  50981. * Gets the minZ used for shadow according to both the scene and the light.
  50982. *
  50983. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50984. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50985. * @param activeCamera The camera we are returning the min for
  50986. * @returns the depth min z
  50987. */
  50988. getDepthMinZ(activeCamera: Camera): number;
  50989. /**
  50990. * Gets the maxZ used for shadow according to both the scene and the light.
  50991. *
  50992. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50993. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50994. * @param activeCamera The camera we are returning the max for
  50995. * @returns the depth max z
  50996. */
  50997. getDepthMaxZ(activeCamera: Camera): number;
  50998. /**
  50999. * Prepares the list of defines specific to the light type.
  51000. * @param defines the list of defines
  51001. * @param lightIndex defines the index of the light for the effect
  51002. */
  51003. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51004. }
  51005. }
  51006. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51007. import { Mesh } from "babylonjs/Meshes/mesh";
  51008. /**
  51009. * Class containing static functions to help procedurally build meshes
  51010. */
  51011. export class HemisphereBuilder {
  51012. /**
  51013. * Creates a hemisphere mesh
  51014. * @param name defines the name of the mesh
  51015. * @param options defines the options used to create the mesh
  51016. * @param scene defines the hosting scene
  51017. * @returns the hemisphere mesh
  51018. */
  51019. static CreateHemisphere(name: string, options: {
  51020. segments?: number;
  51021. diameter?: number;
  51022. sideOrientation?: number;
  51023. }, scene: any): Mesh;
  51024. }
  51025. }
  51026. declare module "babylonjs/Lights/spotLight" {
  51027. import { Nullable } from "babylonjs/types";
  51028. import { Scene } from "babylonjs/scene";
  51029. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51031. import { Effect } from "babylonjs/Materials/effect";
  51032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51033. import { Light } from "babylonjs/Lights/light";
  51034. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51035. /**
  51036. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51037. * These values define a cone of light starting from the position, emitting toward the direction.
  51038. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51039. * and the exponent defines the speed of the decay of the light with distance (reach).
  51040. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51041. */
  51042. export class SpotLight extends ShadowLight {
  51043. private _angle;
  51044. private _innerAngle;
  51045. private _cosHalfAngle;
  51046. private _lightAngleScale;
  51047. private _lightAngleOffset;
  51048. /**
  51049. * Gets the cone angle of the spot light in Radians.
  51050. */
  51051. get angle(): number;
  51052. /**
  51053. * Sets the cone angle of the spot light in Radians.
  51054. */
  51055. set angle(value: number);
  51056. /**
  51057. * Only used in gltf falloff mode, this defines the angle where
  51058. * the directional falloff will start before cutting at angle which could be seen
  51059. * as outer angle.
  51060. */
  51061. get innerAngle(): number;
  51062. /**
  51063. * Only used in gltf falloff mode, this defines the angle where
  51064. * the directional falloff will start before cutting at angle which could be seen
  51065. * as outer angle.
  51066. */
  51067. set innerAngle(value: number);
  51068. private _shadowAngleScale;
  51069. /**
  51070. * Allows scaling the angle of the light for shadow generation only.
  51071. */
  51072. get shadowAngleScale(): number;
  51073. /**
  51074. * Allows scaling the angle of the light for shadow generation only.
  51075. */
  51076. set shadowAngleScale(value: number);
  51077. /**
  51078. * The light decay speed with the distance from the emission spot.
  51079. */
  51080. exponent: number;
  51081. private _projectionTextureMatrix;
  51082. /**
  51083. * Allows reading the projecton texture
  51084. */
  51085. get projectionTextureMatrix(): Matrix;
  51086. protected _projectionTextureLightNear: number;
  51087. /**
  51088. * Gets the near clip of the Spotlight for texture projection.
  51089. */
  51090. get projectionTextureLightNear(): number;
  51091. /**
  51092. * Sets the near clip of the Spotlight for texture projection.
  51093. */
  51094. set projectionTextureLightNear(value: number);
  51095. protected _projectionTextureLightFar: number;
  51096. /**
  51097. * Gets the far clip of the Spotlight for texture projection.
  51098. */
  51099. get projectionTextureLightFar(): number;
  51100. /**
  51101. * Sets the far clip of the Spotlight for texture projection.
  51102. */
  51103. set projectionTextureLightFar(value: number);
  51104. protected _projectionTextureUpDirection: Vector3;
  51105. /**
  51106. * Gets the Up vector of the Spotlight for texture projection.
  51107. */
  51108. get projectionTextureUpDirection(): Vector3;
  51109. /**
  51110. * Sets the Up vector of the Spotlight for texture projection.
  51111. */
  51112. set projectionTextureUpDirection(value: Vector3);
  51113. private _projectionTexture;
  51114. /**
  51115. * Gets the projection texture of the light.
  51116. */
  51117. get projectionTexture(): Nullable<BaseTexture>;
  51118. /**
  51119. * Sets the projection texture of the light.
  51120. */
  51121. set projectionTexture(value: Nullable<BaseTexture>);
  51122. private _projectionTextureViewLightDirty;
  51123. private _projectionTextureProjectionLightDirty;
  51124. private _projectionTextureDirty;
  51125. private _projectionTextureViewTargetVector;
  51126. private _projectionTextureViewLightMatrix;
  51127. private _projectionTextureProjectionLightMatrix;
  51128. private _projectionTextureScalingMatrix;
  51129. /**
  51130. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51131. * It can cast shadows.
  51132. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51133. * @param name The light friendly name
  51134. * @param position The position of the spot light in the scene
  51135. * @param direction The direction of the light in the scene
  51136. * @param angle The cone angle of the light in Radians
  51137. * @param exponent The light decay speed with the distance from the emission spot
  51138. * @param scene The scene the lights belongs to
  51139. */
  51140. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51141. /**
  51142. * Returns the string "SpotLight".
  51143. * @returns the class name
  51144. */
  51145. getClassName(): string;
  51146. /**
  51147. * Returns the integer 2.
  51148. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51149. */
  51150. getTypeID(): number;
  51151. /**
  51152. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51153. */
  51154. protected _setDirection(value: Vector3): void;
  51155. /**
  51156. * Overrides the position setter to recompute the projection texture view light Matrix.
  51157. */
  51158. protected _setPosition(value: Vector3): void;
  51159. /**
  51160. * 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.
  51161. * Returns the SpotLight.
  51162. */
  51163. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51164. protected _computeProjectionTextureViewLightMatrix(): void;
  51165. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51166. /**
  51167. * Main function for light texture projection matrix computing.
  51168. */
  51169. protected _computeProjectionTextureMatrix(): void;
  51170. protected _buildUniformLayout(): void;
  51171. private _computeAngleValues;
  51172. /**
  51173. * Sets the passed Effect "effect" with the Light textures.
  51174. * @param effect The effect to update
  51175. * @param lightIndex The index of the light in the effect to update
  51176. * @returns The light
  51177. */
  51178. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51179. /**
  51180. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51181. * @param effect The effect to update
  51182. * @param lightIndex The index of the light in the effect to update
  51183. * @returns The spot light
  51184. */
  51185. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51186. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51187. /**
  51188. * Disposes the light and the associated resources.
  51189. */
  51190. dispose(): void;
  51191. /**
  51192. * Prepares the list of defines specific to the light type.
  51193. * @param defines the list of defines
  51194. * @param lightIndex defines the index of the light for the effect
  51195. */
  51196. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51197. }
  51198. }
  51199. declare module "babylonjs/Gizmos/lightGizmo" {
  51200. import { Nullable } from "babylonjs/types";
  51201. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51202. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51203. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51204. import { Light } from "babylonjs/Lights/light";
  51205. /**
  51206. * Gizmo that enables viewing a light
  51207. */
  51208. export class LightGizmo extends Gizmo {
  51209. private _lightMesh;
  51210. private _material;
  51211. private _cachedPosition;
  51212. private _cachedForward;
  51213. private _attachedMeshParent;
  51214. /**
  51215. * Creates a LightGizmo
  51216. * @param gizmoLayer The utility layer the gizmo will be added to
  51217. */
  51218. constructor(gizmoLayer?: UtilityLayerRenderer);
  51219. private _light;
  51220. /**
  51221. * The light that the gizmo is attached to
  51222. */
  51223. set light(light: Nullable<Light>);
  51224. get light(): Nullable<Light>;
  51225. /**
  51226. * Gets the material used to render the light gizmo
  51227. */
  51228. get material(): StandardMaterial;
  51229. /**
  51230. * @hidden
  51231. * Updates the gizmo to match the attached mesh's position/rotation
  51232. */
  51233. protected _update(): void;
  51234. private static _Scale;
  51235. /**
  51236. * Creates the lines for a light mesh
  51237. */
  51238. private static _CreateLightLines;
  51239. /**
  51240. * Disposes of the light gizmo
  51241. */
  51242. dispose(): void;
  51243. private static _CreateHemisphericLightMesh;
  51244. private static _CreatePointLightMesh;
  51245. private static _CreateSpotLightMesh;
  51246. private static _CreateDirectionalLightMesh;
  51247. }
  51248. }
  51249. declare module "babylonjs/Gizmos/index" {
  51250. export * from "babylonjs/Gizmos/axisDragGizmo";
  51251. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51252. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51253. export * from "babylonjs/Gizmos/gizmo";
  51254. export * from "babylonjs/Gizmos/gizmoManager";
  51255. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51256. export * from "babylonjs/Gizmos/positionGizmo";
  51257. export * from "babylonjs/Gizmos/rotationGizmo";
  51258. export * from "babylonjs/Gizmos/scaleGizmo";
  51259. export * from "babylonjs/Gizmos/lightGizmo";
  51260. export * from "babylonjs/Gizmos/planeDragGizmo";
  51261. }
  51262. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51263. /** @hidden */
  51264. export var backgroundFragmentDeclaration: {
  51265. name: string;
  51266. shader: string;
  51267. };
  51268. }
  51269. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51270. /** @hidden */
  51271. export var backgroundUboDeclaration: {
  51272. name: string;
  51273. shader: string;
  51274. };
  51275. }
  51276. declare module "babylonjs/Shaders/background.fragment" {
  51277. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51278. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51279. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51280. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51281. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51282. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51283. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51284. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51285. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51286. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51287. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51288. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51289. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51290. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51291. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51292. /** @hidden */
  51293. export var backgroundPixelShader: {
  51294. name: string;
  51295. shader: string;
  51296. };
  51297. }
  51298. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51299. /** @hidden */
  51300. export var backgroundVertexDeclaration: {
  51301. name: string;
  51302. shader: string;
  51303. };
  51304. }
  51305. declare module "babylonjs/Shaders/background.vertex" {
  51306. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51307. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51309. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51310. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51311. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51312. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51313. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51314. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51315. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51316. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51317. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51318. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51319. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51320. /** @hidden */
  51321. export var backgroundVertexShader: {
  51322. name: string;
  51323. shader: string;
  51324. };
  51325. }
  51326. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51327. import { Nullable, int, float } from "babylonjs/types";
  51328. import { Scene } from "babylonjs/scene";
  51329. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51330. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51332. import { Mesh } from "babylonjs/Meshes/mesh";
  51333. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51334. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51335. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51337. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51338. import { Color3 } from "babylonjs/Maths/math.color";
  51339. import "babylonjs/Shaders/background.fragment";
  51340. import "babylonjs/Shaders/background.vertex";
  51341. /**
  51342. * Background material used to create an efficient environement around your scene.
  51343. */
  51344. export class BackgroundMaterial extends PushMaterial {
  51345. /**
  51346. * Standard reflectance value at parallel view angle.
  51347. */
  51348. static StandardReflectance0: number;
  51349. /**
  51350. * Standard reflectance value at grazing angle.
  51351. */
  51352. static StandardReflectance90: number;
  51353. protected _primaryColor: Color3;
  51354. /**
  51355. * Key light Color (multiply against the environement texture)
  51356. */
  51357. primaryColor: Color3;
  51358. protected __perceptualColor: Nullable<Color3>;
  51359. /**
  51360. * Experimental Internal Use Only.
  51361. *
  51362. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51363. * This acts as a helper to set the primary color to a more "human friendly" value.
  51364. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51365. * output color as close as possible from the chosen value.
  51366. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51367. * part of lighting setup.)
  51368. */
  51369. get _perceptualColor(): Nullable<Color3>;
  51370. set _perceptualColor(value: Nullable<Color3>);
  51371. protected _primaryColorShadowLevel: float;
  51372. /**
  51373. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51374. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51375. */
  51376. get primaryColorShadowLevel(): float;
  51377. set primaryColorShadowLevel(value: float);
  51378. protected _primaryColorHighlightLevel: float;
  51379. /**
  51380. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51381. * The primary color is used at the level chosen to define what the white area would look.
  51382. */
  51383. get primaryColorHighlightLevel(): float;
  51384. set primaryColorHighlightLevel(value: float);
  51385. protected _reflectionTexture: Nullable<BaseTexture>;
  51386. /**
  51387. * Reflection Texture used in the material.
  51388. * Should be author in a specific way for the best result (refer to the documentation).
  51389. */
  51390. reflectionTexture: Nullable<BaseTexture>;
  51391. protected _reflectionBlur: float;
  51392. /**
  51393. * Reflection Texture level of blur.
  51394. *
  51395. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51396. * texture twice.
  51397. */
  51398. reflectionBlur: float;
  51399. protected _diffuseTexture: Nullable<BaseTexture>;
  51400. /**
  51401. * Diffuse Texture used in the material.
  51402. * Should be author in a specific way for the best result (refer to the documentation).
  51403. */
  51404. diffuseTexture: Nullable<BaseTexture>;
  51405. protected _shadowLights: Nullable<IShadowLight[]>;
  51406. /**
  51407. * Specify the list of lights casting shadow on the material.
  51408. * All scene shadow lights will be included if null.
  51409. */
  51410. shadowLights: Nullable<IShadowLight[]>;
  51411. protected _shadowLevel: float;
  51412. /**
  51413. * Helps adjusting the shadow to a softer level if required.
  51414. * 0 means black shadows and 1 means no shadows.
  51415. */
  51416. shadowLevel: float;
  51417. protected _sceneCenter: Vector3;
  51418. /**
  51419. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51420. * It is usually zero but might be interesting to modify according to your setup.
  51421. */
  51422. sceneCenter: Vector3;
  51423. protected _opacityFresnel: boolean;
  51424. /**
  51425. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51426. * This helps ensuring a nice transition when the camera goes under the ground.
  51427. */
  51428. opacityFresnel: boolean;
  51429. protected _reflectionFresnel: boolean;
  51430. /**
  51431. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51432. * This helps adding a mirror texture on the ground.
  51433. */
  51434. reflectionFresnel: boolean;
  51435. protected _reflectionFalloffDistance: number;
  51436. /**
  51437. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51438. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51439. */
  51440. reflectionFalloffDistance: number;
  51441. protected _reflectionAmount: number;
  51442. /**
  51443. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51444. */
  51445. reflectionAmount: number;
  51446. protected _reflectionReflectance0: number;
  51447. /**
  51448. * This specifies the weight of the reflection at grazing angle.
  51449. */
  51450. reflectionReflectance0: number;
  51451. protected _reflectionReflectance90: number;
  51452. /**
  51453. * This specifies the weight of the reflection at a perpendicular point of view.
  51454. */
  51455. reflectionReflectance90: number;
  51456. /**
  51457. * Sets the reflection reflectance fresnel values according to the default standard
  51458. * empirically know to work well :-)
  51459. */
  51460. set reflectionStandardFresnelWeight(value: number);
  51461. protected _useRGBColor: boolean;
  51462. /**
  51463. * Helps to directly use the maps channels instead of their level.
  51464. */
  51465. useRGBColor: boolean;
  51466. protected _enableNoise: boolean;
  51467. /**
  51468. * This helps reducing the banding effect that could occur on the background.
  51469. */
  51470. enableNoise: boolean;
  51471. /**
  51472. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51473. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51474. * Recommended to be keep at 1.0 except for special cases.
  51475. */
  51476. get fovMultiplier(): number;
  51477. set fovMultiplier(value: number);
  51478. private _fovMultiplier;
  51479. /**
  51480. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51481. */
  51482. useEquirectangularFOV: boolean;
  51483. private _maxSimultaneousLights;
  51484. /**
  51485. * Number of Simultaneous lights allowed on the material.
  51486. */
  51487. maxSimultaneousLights: int;
  51488. /**
  51489. * Default configuration related to image processing available in the Background Material.
  51490. */
  51491. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51492. /**
  51493. * Keep track of the image processing observer to allow dispose and replace.
  51494. */
  51495. private _imageProcessingObserver;
  51496. /**
  51497. * Attaches a new image processing configuration to the PBR Material.
  51498. * @param configuration (if null the scene configuration will be use)
  51499. */
  51500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51501. /**
  51502. * Gets the image processing configuration used either in this material.
  51503. */
  51504. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51505. /**
  51506. * Sets the Default image processing configuration used either in the this material.
  51507. *
  51508. * If sets to null, the scene one is in use.
  51509. */
  51510. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51511. /**
  51512. * Gets wether the color curves effect is enabled.
  51513. */
  51514. get cameraColorCurvesEnabled(): boolean;
  51515. /**
  51516. * Sets wether the color curves effect is enabled.
  51517. */
  51518. set cameraColorCurvesEnabled(value: boolean);
  51519. /**
  51520. * Gets wether the color grading effect is enabled.
  51521. */
  51522. get cameraColorGradingEnabled(): boolean;
  51523. /**
  51524. * Gets wether the color grading effect is enabled.
  51525. */
  51526. set cameraColorGradingEnabled(value: boolean);
  51527. /**
  51528. * Gets wether tonemapping is enabled or not.
  51529. */
  51530. get cameraToneMappingEnabled(): boolean;
  51531. /**
  51532. * Sets wether tonemapping is enabled or not
  51533. */
  51534. set cameraToneMappingEnabled(value: boolean);
  51535. /**
  51536. * The camera exposure used on this material.
  51537. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51538. * This corresponds to a photographic exposure.
  51539. */
  51540. get cameraExposure(): float;
  51541. /**
  51542. * The camera exposure used on this material.
  51543. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51544. * This corresponds to a photographic exposure.
  51545. */
  51546. set cameraExposure(value: float);
  51547. /**
  51548. * Gets The camera contrast used on this material.
  51549. */
  51550. get cameraContrast(): float;
  51551. /**
  51552. * Sets The camera contrast used on this material.
  51553. */
  51554. set cameraContrast(value: float);
  51555. /**
  51556. * Gets the Color Grading 2D Lookup Texture.
  51557. */
  51558. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51559. /**
  51560. * Sets the Color Grading 2D Lookup Texture.
  51561. */
  51562. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51563. /**
  51564. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51565. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51566. * 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;
  51567. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51568. */
  51569. get cameraColorCurves(): Nullable<ColorCurves>;
  51570. /**
  51571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51573. * 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;
  51574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51575. */
  51576. set cameraColorCurves(value: Nullable<ColorCurves>);
  51577. /**
  51578. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51579. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51580. */
  51581. switchToBGR: boolean;
  51582. private _renderTargets;
  51583. private _reflectionControls;
  51584. private _white;
  51585. private _primaryShadowColor;
  51586. private _primaryHighlightColor;
  51587. /**
  51588. * Instantiates a Background Material in the given scene
  51589. * @param name The friendly name of the material
  51590. * @param scene The scene to add the material to
  51591. */
  51592. constructor(name: string, scene: Scene);
  51593. /**
  51594. * Gets a boolean indicating that current material needs to register RTT
  51595. */
  51596. get hasRenderTargetTextures(): boolean;
  51597. /**
  51598. * The entire material has been created in order to prevent overdraw.
  51599. * @returns false
  51600. */
  51601. needAlphaTesting(): boolean;
  51602. /**
  51603. * The entire material has been created in order to prevent overdraw.
  51604. * @returns true if blending is enable
  51605. */
  51606. needAlphaBlending(): boolean;
  51607. /**
  51608. * Checks wether the material is ready to be rendered for a given mesh.
  51609. * @param mesh The mesh to render
  51610. * @param subMesh The submesh to check against
  51611. * @param useInstances Specify wether or not the material is used with instances
  51612. * @returns true if all the dependencies are ready (Textures, Effects...)
  51613. */
  51614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51615. /**
  51616. * Compute the primary color according to the chosen perceptual color.
  51617. */
  51618. private _computePrimaryColorFromPerceptualColor;
  51619. /**
  51620. * Compute the highlights and shadow colors according to their chosen levels.
  51621. */
  51622. private _computePrimaryColors;
  51623. /**
  51624. * Build the uniform buffer used in the material.
  51625. */
  51626. buildUniformLayout(): void;
  51627. /**
  51628. * Unbind the material.
  51629. */
  51630. unbind(): void;
  51631. /**
  51632. * Bind only the world matrix to the material.
  51633. * @param world The world matrix to bind.
  51634. */
  51635. bindOnlyWorldMatrix(world: Matrix): void;
  51636. /**
  51637. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51638. * @param world The world matrix to bind.
  51639. * @param subMesh The submesh to bind for.
  51640. */
  51641. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51642. /**
  51643. * Checks to see if a texture is used in the material.
  51644. * @param texture - Base texture to use.
  51645. * @returns - Boolean specifying if a texture is used in the material.
  51646. */
  51647. hasTexture(texture: BaseTexture): boolean;
  51648. /**
  51649. * Dispose the material.
  51650. * @param forceDisposeEffect Force disposal of the associated effect.
  51651. * @param forceDisposeTextures Force disposal of the associated textures.
  51652. */
  51653. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51654. /**
  51655. * Clones the material.
  51656. * @param name The cloned name.
  51657. * @returns The cloned material.
  51658. */
  51659. clone(name: string): BackgroundMaterial;
  51660. /**
  51661. * Serializes the current material to its JSON representation.
  51662. * @returns The JSON representation.
  51663. */
  51664. serialize(): any;
  51665. /**
  51666. * Gets the class name of the material
  51667. * @returns "BackgroundMaterial"
  51668. */
  51669. getClassName(): string;
  51670. /**
  51671. * Parse a JSON input to create back a background material.
  51672. * @param source The JSON data to parse
  51673. * @param scene The scene to create the parsed material in
  51674. * @param rootUrl The root url of the assets the material depends upon
  51675. * @returns the instantiated BackgroundMaterial.
  51676. */
  51677. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51678. }
  51679. }
  51680. declare module "babylonjs/Helpers/environmentHelper" {
  51681. import { Observable } from "babylonjs/Misc/observable";
  51682. import { Nullable } from "babylonjs/types";
  51683. import { Scene } from "babylonjs/scene";
  51684. import { Vector3 } from "babylonjs/Maths/math.vector";
  51685. import { Color3 } from "babylonjs/Maths/math.color";
  51686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51687. import { Mesh } from "babylonjs/Meshes/mesh";
  51688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51689. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51690. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51691. import "babylonjs/Meshes/Builders/planeBuilder";
  51692. import "babylonjs/Meshes/Builders/boxBuilder";
  51693. /**
  51694. * Represents the different options available during the creation of
  51695. * a Environment helper.
  51696. *
  51697. * This can control the default ground, skybox and image processing setup of your scene.
  51698. */
  51699. export interface IEnvironmentHelperOptions {
  51700. /**
  51701. * Specifies wether or not to create a ground.
  51702. * True by default.
  51703. */
  51704. createGround: boolean;
  51705. /**
  51706. * Specifies the ground size.
  51707. * 15 by default.
  51708. */
  51709. groundSize: number;
  51710. /**
  51711. * The texture used on the ground for the main color.
  51712. * Comes from the BabylonJS CDN by default.
  51713. *
  51714. * Remarks: Can be either a texture or a url.
  51715. */
  51716. groundTexture: string | BaseTexture;
  51717. /**
  51718. * The color mixed in the ground texture by default.
  51719. * BabylonJS clearColor by default.
  51720. */
  51721. groundColor: Color3;
  51722. /**
  51723. * Specifies the ground opacity.
  51724. * 1 by default.
  51725. */
  51726. groundOpacity: number;
  51727. /**
  51728. * Enables the ground to receive shadows.
  51729. * True by default.
  51730. */
  51731. enableGroundShadow: boolean;
  51732. /**
  51733. * Helps preventing the shadow to be fully black on the ground.
  51734. * 0.5 by default.
  51735. */
  51736. groundShadowLevel: number;
  51737. /**
  51738. * Creates a mirror texture attach to the ground.
  51739. * false by default.
  51740. */
  51741. enableGroundMirror: boolean;
  51742. /**
  51743. * Specifies the ground mirror size ratio.
  51744. * 0.3 by default as the default kernel is 64.
  51745. */
  51746. groundMirrorSizeRatio: number;
  51747. /**
  51748. * Specifies the ground mirror blur kernel size.
  51749. * 64 by default.
  51750. */
  51751. groundMirrorBlurKernel: number;
  51752. /**
  51753. * Specifies the ground mirror visibility amount.
  51754. * 1 by default
  51755. */
  51756. groundMirrorAmount: number;
  51757. /**
  51758. * Specifies the ground mirror reflectance weight.
  51759. * This uses the standard weight of the background material to setup the fresnel effect
  51760. * of the mirror.
  51761. * 1 by default.
  51762. */
  51763. groundMirrorFresnelWeight: number;
  51764. /**
  51765. * Specifies the ground mirror Falloff distance.
  51766. * This can helps reducing the size of the reflection.
  51767. * 0 by Default.
  51768. */
  51769. groundMirrorFallOffDistance: number;
  51770. /**
  51771. * Specifies the ground mirror texture type.
  51772. * Unsigned Int by Default.
  51773. */
  51774. groundMirrorTextureType: number;
  51775. /**
  51776. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51777. * the shown objects.
  51778. */
  51779. groundYBias: number;
  51780. /**
  51781. * Specifies wether or not to create a skybox.
  51782. * True by default.
  51783. */
  51784. createSkybox: boolean;
  51785. /**
  51786. * Specifies the skybox size.
  51787. * 20 by default.
  51788. */
  51789. skyboxSize: number;
  51790. /**
  51791. * The texture used on the skybox for the main color.
  51792. * Comes from the BabylonJS CDN by default.
  51793. *
  51794. * Remarks: Can be either a texture or a url.
  51795. */
  51796. skyboxTexture: string | BaseTexture;
  51797. /**
  51798. * The color mixed in the skybox texture by default.
  51799. * BabylonJS clearColor by default.
  51800. */
  51801. skyboxColor: Color3;
  51802. /**
  51803. * The background rotation around the Y axis of the scene.
  51804. * This helps aligning the key lights of your scene with the background.
  51805. * 0 by default.
  51806. */
  51807. backgroundYRotation: number;
  51808. /**
  51809. * Compute automatically the size of the elements to best fit with the scene.
  51810. */
  51811. sizeAuto: boolean;
  51812. /**
  51813. * Default position of the rootMesh if autoSize is not true.
  51814. */
  51815. rootPosition: Vector3;
  51816. /**
  51817. * Sets up the image processing in the scene.
  51818. * true by default.
  51819. */
  51820. setupImageProcessing: boolean;
  51821. /**
  51822. * The texture used as your environment texture in the scene.
  51823. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51824. *
  51825. * Remarks: Can be either a texture or a url.
  51826. */
  51827. environmentTexture: string | BaseTexture;
  51828. /**
  51829. * The value of the exposure to apply to the scene.
  51830. * 0.6 by default if setupImageProcessing is true.
  51831. */
  51832. cameraExposure: number;
  51833. /**
  51834. * The value of the contrast to apply to the scene.
  51835. * 1.6 by default if setupImageProcessing is true.
  51836. */
  51837. cameraContrast: number;
  51838. /**
  51839. * Specifies wether or not tonemapping should be enabled in the scene.
  51840. * true by default if setupImageProcessing is true.
  51841. */
  51842. toneMappingEnabled: boolean;
  51843. }
  51844. /**
  51845. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51846. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51847. * It also helps with the default setup of your imageProcessing configuration.
  51848. */
  51849. export class EnvironmentHelper {
  51850. /**
  51851. * Default ground texture URL.
  51852. */
  51853. private static _groundTextureCDNUrl;
  51854. /**
  51855. * Default skybox texture URL.
  51856. */
  51857. private static _skyboxTextureCDNUrl;
  51858. /**
  51859. * Default environment texture URL.
  51860. */
  51861. private static _environmentTextureCDNUrl;
  51862. /**
  51863. * Creates the default options for the helper.
  51864. */
  51865. private static _getDefaultOptions;
  51866. private _rootMesh;
  51867. /**
  51868. * Gets the root mesh created by the helper.
  51869. */
  51870. get rootMesh(): Mesh;
  51871. private _skybox;
  51872. /**
  51873. * Gets the skybox created by the helper.
  51874. */
  51875. get skybox(): Nullable<Mesh>;
  51876. private _skyboxTexture;
  51877. /**
  51878. * Gets the skybox texture created by the helper.
  51879. */
  51880. get skyboxTexture(): Nullable<BaseTexture>;
  51881. private _skyboxMaterial;
  51882. /**
  51883. * Gets the skybox material created by the helper.
  51884. */
  51885. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51886. private _ground;
  51887. /**
  51888. * Gets the ground mesh created by the helper.
  51889. */
  51890. get ground(): Nullable<Mesh>;
  51891. private _groundTexture;
  51892. /**
  51893. * Gets the ground texture created by the helper.
  51894. */
  51895. get groundTexture(): Nullable<BaseTexture>;
  51896. private _groundMirror;
  51897. /**
  51898. * Gets the ground mirror created by the helper.
  51899. */
  51900. get groundMirror(): Nullable<MirrorTexture>;
  51901. /**
  51902. * Gets the ground mirror render list to helps pushing the meshes
  51903. * you wish in the ground reflection.
  51904. */
  51905. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51906. private _groundMaterial;
  51907. /**
  51908. * Gets the ground material created by the helper.
  51909. */
  51910. get groundMaterial(): Nullable<BackgroundMaterial>;
  51911. /**
  51912. * Stores the creation options.
  51913. */
  51914. private readonly _scene;
  51915. private _options;
  51916. /**
  51917. * This observable will be notified with any error during the creation of the environment,
  51918. * mainly texture creation errors.
  51919. */
  51920. onErrorObservable: Observable<{
  51921. message?: string;
  51922. exception?: any;
  51923. }>;
  51924. /**
  51925. * constructor
  51926. * @param options Defines the options we want to customize the helper
  51927. * @param scene The scene to add the material to
  51928. */
  51929. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51930. /**
  51931. * Updates the background according to the new options
  51932. * @param options
  51933. */
  51934. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51935. /**
  51936. * Sets the primary color of all the available elements.
  51937. * @param color the main color to affect to the ground and the background
  51938. */
  51939. setMainColor(color: Color3): void;
  51940. /**
  51941. * Setup the image processing according to the specified options.
  51942. */
  51943. private _setupImageProcessing;
  51944. /**
  51945. * Setup the environment texture according to the specified options.
  51946. */
  51947. private _setupEnvironmentTexture;
  51948. /**
  51949. * Setup the background according to the specified options.
  51950. */
  51951. private _setupBackground;
  51952. /**
  51953. * Get the scene sizes according to the setup.
  51954. */
  51955. private _getSceneSize;
  51956. /**
  51957. * Setup the ground according to the specified options.
  51958. */
  51959. private _setupGround;
  51960. /**
  51961. * Setup the ground material according to the specified options.
  51962. */
  51963. private _setupGroundMaterial;
  51964. /**
  51965. * Setup the ground diffuse texture according to the specified options.
  51966. */
  51967. private _setupGroundDiffuseTexture;
  51968. /**
  51969. * Setup the ground mirror texture according to the specified options.
  51970. */
  51971. private _setupGroundMirrorTexture;
  51972. /**
  51973. * Setup the ground to receive the mirror texture.
  51974. */
  51975. private _setupMirrorInGroundMaterial;
  51976. /**
  51977. * Setup the skybox according to the specified options.
  51978. */
  51979. private _setupSkybox;
  51980. /**
  51981. * Setup the skybox material according to the specified options.
  51982. */
  51983. private _setupSkyboxMaterial;
  51984. /**
  51985. * Setup the skybox reflection texture according to the specified options.
  51986. */
  51987. private _setupSkyboxReflectionTexture;
  51988. private _errorHandler;
  51989. /**
  51990. * Dispose all the elements created by the Helper.
  51991. */
  51992. dispose(): void;
  51993. }
  51994. }
  51995. declare module "babylonjs/Helpers/photoDome" {
  51996. import { Observable } from "babylonjs/Misc/observable";
  51997. import { Nullable } from "babylonjs/types";
  51998. import { Scene } from "babylonjs/scene";
  51999. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52000. import { Mesh } from "babylonjs/Meshes/mesh";
  52001. import { Texture } from "babylonjs/Materials/Textures/texture";
  52002. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52003. import "babylonjs/Meshes/Builders/sphereBuilder";
  52004. /**
  52005. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52006. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52007. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52008. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52009. */
  52010. export class PhotoDome extends TransformNode {
  52011. /**
  52012. * Define the image as a Monoscopic panoramic 360 image.
  52013. */
  52014. static readonly MODE_MONOSCOPIC: number;
  52015. /**
  52016. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52017. */
  52018. static readonly MODE_TOPBOTTOM: number;
  52019. /**
  52020. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52021. */
  52022. static readonly MODE_SIDEBYSIDE: number;
  52023. private _useDirectMapping;
  52024. /**
  52025. * The texture being displayed on the sphere
  52026. */
  52027. protected _photoTexture: Texture;
  52028. /**
  52029. * Gets or sets the texture being displayed on the sphere
  52030. */
  52031. get photoTexture(): Texture;
  52032. set photoTexture(value: Texture);
  52033. /**
  52034. * Observable raised when an error occured while loading the 360 image
  52035. */
  52036. onLoadErrorObservable: Observable<string>;
  52037. /**
  52038. * The skybox material
  52039. */
  52040. protected _material: BackgroundMaterial;
  52041. /**
  52042. * The surface used for the skybox
  52043. */
  52044. protected _mesh: Mesh;
  52045. /**
  52046. * Gets the mesh used for the skybox.
  52047. */
  52048. get mesh(): Mesh;
  52049. /**
  52050. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52051. * Also see the options.resolution property.
  52052. */
  52053. get fovMultiplier(): number;
  52054. set fovMultiplier(value: number);
  52055. private _imageMode;
  52056. /**
  52057. * Gets or set the current video mode for the video. It can be:
  52058. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52059. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52060. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52061. */
  52062. get imageMode(): number;
  52063. set imageMode(value: number);
  52064. /**
  52065. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52066. * @param name Element's name, child elements will append suffixes for their own names.
  52067. * @param urlsOfPhoto defines the url of the photo to display
  52068. * @param options defines an object containing optional or exposed sub element properties
  52069. * @param onError defines a callback called when an error occured while loading the texture
  52070. */
  52071. constructor(name: string, urlOfPhoto: string, options: {
  52072. resolution?: number;
  52073. size?: number;
  52074. useDirectMapping?: boolean;
  52075. faceForward?: boolean;
  52076. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52077. private _onBeforeCameraRenderObserver;
  52078. private _changeImageMode;
  52079. /**
  52080. * Releases resources associated with this node.
  52081. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52082. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52083. */
  52084. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52085. }
  52086. }
  52087. declare module "babylonjs/Misc/rgbdTextureTools" {
  52088. import "babylonjs/Shaders/rgbdDecode.fragment";
  52089. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52090. import { Texture } from "babylonjs/Materials/Textures/texture";
  52091. /**
  52092. * Class used to host RGBD texture specific utilities
  52093. */
  52094. export class RGBDTextureTools {
  52095. /**
  52096. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52097. * @param texture the texture to expand.
  52098. */
  52099. static ExpandRGBDTexture(texture: Texture): void;
  52100. }
  52101. }
  52102. declare module "babylonjs/Misc/brdfTextureTools" {
  52103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52104. import { Scene } from "babylonjs/scene";
  52105. /**
  52106. * Class used to host texture specific utilities
  52107. */
  52108. export class BRDFTextureTools {
  52109. /**
  52110. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52111. * @param scene defines the hosting scene
  52112. * @returns the environment BRDF texture
  52113. */
  52114. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52115. private static _environmentBRDFBase64Texture;
  52116. }
  52117. }
  52118. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52119. import { Nullable } from "babylonjs/types";
  52120. import { Color3 } from "babylonjs/Maths/math.color";
  52121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52122. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52124. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52125. import { Engine } from "babylonjs/Engines/engine";
  52126. import { Scene } from "babylonjs/scene";
  52127. /**
  52128. * @hidden
  52129. */
  52130. export interface IMaterialClearCoatDefines {
  52131. CLEARCOAT: boolean;
  52132. CLEARCOAT_DEFAULTIOR: boolean;
  52133. CLEARCOAT_TEXTURE: boolean;
  52134. CLEARCOAT_TEXTUREDIRECTUV: number;
  52135. CLEARCOAT_BUMP: boolean;
  52136. CLEARCOAT_BUMPDIRECTUV: number;
  52137. CLEARCOAT_TINT: boolean;
  52138. CLEARCOAT_TINT_TEXTURE: boolean;
  52139. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52140. /** @hidden */
  52141. _areTexturesDirty: boolean;
  52142. }
  52143. /**
  52144. * Define the code related to the clear coat parameters of the pbr material.
  52145. */
  52146. export class PBRClearCoatConfiguration {
  52147. /**
  52148. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52149. * The default fits with a polyurethane material.
  52150. */
  52151. private static readonly _DefaultIndexOfRefraction;
  52152. private _isEnabled;
  52153. /**
  52154. * Defines if the clear coat is enabled in the material.
  52155. */
  52156. isEnabled: boolean;
  52157. /**
  52158. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52159. */
  52160. intensity: number;
  52161. /**
  52162. * Defines the clear coat layer roughness.
  52163. */
  52164. roughness: number;
  52165. private _indexOfRefraction;
  52166. /**
  52167. * Defines the index of refraction of the clear coat.
  52168. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52169. * The default fits with a polyurethane material.
  52170. * Changing the default value is more performance intensive.
  52171. */
  52172. indexOfRefraction: number;
  52173. private _texture;
  52174. /**
  52175. * Stores the clear coat values in a texture.
  52176. */
  52177. texture: Nullable<BaseTexture>;
  52178. private _bumpTexture;
  52179. /**
  52180. * Define the clear coat specific bump texture.
  52181. */
  52182. bumpTexture: Nullable<BaseTexture>;
  52183. private _isTintEnabled;
  52184. /**
  52185. * Defines if the clear coat tint is enabled in the material.
  52186. */
  52187. isTintEnabled: boolean;
  52188. /**
  52189. * Defines the clear coat tint of the material.
  52190. * This is only use if tint is enabled
  52191. */
  52192. tintColor: Color3;
  52193. /**
  52194. * Defines the distance at which the tint color should be found in the
  52195. * clear coat media.
  52196. * This is only use if tint is enabled
  52197. */
  52198. tintColorAtDistance: number;
  52199. /**
  52200. * Defines the clear coat layer thickness.
  52201. * This is only use if tint is enabled
  52202. */
  52203. tintThickness: number;
  52204. private _tintTexture;
  52205. /**
  52206. * Stores the clear tint values in a texture.
  52207. * rgb is tint
  52208. * a is a thickness factor
  52209. */
  52210. tintTexture: Nullable<BaseTexture>;
  52211. /** @hidden */
  52212. private _internalMarkAllSubMeshesAsTexturesDirty;
  52213. /** @hidden */
  52214. _markAllSubMeshesAsTexturesDirty(): void;
  52215. /**
  52216. * Instantiate a new istance of clear coat configuration.
  52217. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52218. */
  52219. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52220. /**
  52221. * Gets wehter the submesh is ready to be used or not.
  52222. * @param defines the list of "defines" to update.
  52223. * @param scene defines the scene the material belongs to.
  52224. * @param engine defines the engine the material belongs to.
  52225. * @param disableBumpMap defines wether the material disables bump or not.
  52226. * @returns - boolean indicating that the submesh is ready or not.
  52227. */
  52228. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52229. /**
  52230. * Checks to see if a texture is used in the material.
  52231. * @param defines the list of "defines" to update.
  52232. * @param scene defines the scene to the material belongs to.
  52233. */
  52234. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52235. /**
  52236. * Binds the material data.
  52237. * @param uniformBuffer defines the Uniform buffer to fill in.
  52238. * @param scene defines the scene the material belongs to.
  52239. * @param engine defines the engine the material belongs to.
  52240. * @param disableBumpMap defines wether the material disables bump or not.
  52241. * @param isFrozen defines wether the material is frozen or not.
  52242. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52243. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52244. */
  52245. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52246. /**
  52247. * Checks to see if a texture is used in the material.
  52248. * @param texture - Base texture to use.
  52249. * @returns - Boolean specifying if a texture is used in the material.
  52250. */
  52251. hasTexture(texture: BaseTexture): boolean;
  52252. /**
  52253. * Returns an array of the actively used textures.
  52254. * @param activeTextures Array of BaseTextures
  52255. */
  52256. getActiveTextures(activeTextures: BaseTexture[]): void;
  52257. /**
  52258. * Returns the animatable textures.
  52259. * @param animatables Array of animatable textures.
  52260. */
  52261. getAnimatables(animatables: IAnimatable[]): void;
  52262. /**
  52263. * Disposes the resources of the material.
  52264. * @param forceDisposeTextures - Forces the disposal of all textures.
  52265. */
  52266. dispose(forceDisposeTextures?: boolean): void;
  52267. /**
  52268. * Get the current class name of the texture useful for serialization or dynamic coding.
  52269. * @returns "PBRClearCoatConfiguration"
  52270. */
  52271. getClassName(): string;
  52272. /**
  52273. * Add fallbacks to the effect fallbacks list.
  52274. * @param defines defines the Base texture to use.
  52275. * @param fallbacks defines the current fallback list.
  52276. * @param currentRank defines the current fallback rank.
  52277. * @returns the new fallback rank.
  52278. */
  52279. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52280. /**
  52281. * Add the required uniforms to the current list.
  52282. * @param uniforms defines the current uniform list.
  52283. */
  52284. static AddUniforms(uniforms: string[]): void;
  52285. /**
  52286. * Add the required samplers to the current list.
  52287. * @param samplers defines the current sampler list.
  52288. */
  52289. static AddSamplers(samplers: string[]): void;
  52290. /**
  52291. * Add the required uniforms to the current buffer.
  52292. * @param uniformBuffer defines the current uniform buffer.
  52293. */
  52294. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52295. /**
  52296. * Makes a duplicate of the current configuration into another one.
  52297. * @param clearCoatConfiguration define the config where to copy the info
  52298. */
  52299. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52300. /**
  52301. * Serializes this clear coat configuration.
  52302. * @returns - An object with the serialized config.
  52303. */
  52304. serialize(): any;
  52305. /**
  52306. * Parses a anisotropy Configuration from a serialized object.
  52307. * @param source - Serialized object.
  52308. * @param scene Defines the scene we are parsing for
  52309. * @param rootUrl Defines the rootUrl to load from
  52310. */
  52311. parse(source: any, scene: Scene, rootUrl: string): void;
  52312. }
  52313. }
  52314. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52315. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52317. import { Vector2 } from "babylonjs/Maths/math.vector";
  52318. import { Scene } from "babylonjs/scene";
  52319. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52320. import { Nullable } from "babylonjs/types";
  52321. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52322. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52323. /**
  52324. * @hidden
  52325. */
  52326. export interface IMaterialAnisotropicDefines {
  52327. ANISOTROPIC: boolean;
  52328. ANISOTROPIC_TEXTURE: boolean;
  52329. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52330. MAINUV1: boolean;
  52331. _areTexturesDirty: boolean;
  52332. _needUVs: boolean;
  52333. }
  52334. /**
  52335. * Define the code related to the anisotropic parameters of the pbr material.
  52336. */
  52337. export class PBRAnisotropicConfiguration {
  52338. private _isEnabled;
  52339. /**
  52340. * Defines if the anisotropy is enabled in the material.
  52341. */
  52342. isEnabled: boolean;
  52343. /**
  52344. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52345. */
  52346. intensity: number;
  52347. /**
  52348. * Defines if the effect is along the tangents, bitangents or in between.
  52349. * By default, the effect is "strectching" the highlights along the tangents.
  52350. */
  52351. direction: Vector2;
  52352. private _texture;
  52353. /**
  52354. * Stores the anisotropy values in a texture.
  52355. * rg is direction (like normal from -1 to 1)
  52356. * b is a intensity
  52357. */
  52358. texture: Nullable<BaseTexture>;
  52359. /** @hidden */
  52360. private _internalMarkAllSubMeshesAsTexturesDirty;
  52361. /** @hidden */
  52362. _markAllSubMeshesAsTexturesDirty(): void;
  52363. /**
  52364. * Instantiate a new istance of anisotropy configuration.
  52365. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52366. */
  52367. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52368. /**
  52369. * Specifies that the submesh is ready to be used.
  52370. * @param defines the list of "defines" to update.
  52371. * @param scene defines the scene the material belongs to.
  52372. * @returns - boolean indicating that the submesh is ready or not.
  52373. */
  52374. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52375. /**
  52376. * Checks to see if a texture is used in the material.
  52377. * @param defines the list of "defines" to update.
  52378. * @param mesh the mesh we are preparing the defines for.
  52379. * @param scene defines the scene the material belongs to.
  52380. */
  52381. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52382. /**
  52383. * Binds the material data.
  52384. * @param uniformBuffer defines the Uniform buffer to fill in.
  52385. * @param scene defines the scene the material belongs to.
  52386. * @param isFrozen defines wether the material is frozen or not.
  52387. */
  52388. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52389. /**
  52390. * Checks to see if a texture is used in the material.
  52391. * @param texture - Base texture to use.
  52392. * @returns - Boolean specifying if a texture is used in the material.
  52393. */
  52394. hasTexture(texture: BaseTexture): boolean;
  52395. /**
  52396. * Returns an array of the actively used textures.
  52397. * @param activeTextures Array of BaseTextures
  52398. */
  52399. getActiveTextures(activeTextures: BaseTexture[]): void;
  52400. /**
  52401. * Returns the animatable textures.
  52402. * @param animatables Array of animatable textures.
  52403. */
  52404. getAnimatables(animatables: IAnimatable[]): void;
  52405. /**
  52406. * Disposes the resources of the material.
  52407. * @param forceDisposeTextures - Forces the disposal of all textures.
  52408. */
  52409. dispose(forceDisposeTextures?: boolean): void;
  52410. /**
  52411. * Get the current class name of the texture useful for serialization or dynamic coding.
  52412. * @returns "PBRAnisotropicConfiguration"
  52413. */
  52414. getClassName(): string;
  52415. /**
  52416. * Add fallbacks to the effect fallbacks list.
  52417. * @param defines defines the Base texture to use.
  52418. * @param fallbacks defines the current fallback list.
  52419. * @param currentRank defines the current fallback rank.
  52420. * @returns the new fallback rank.
  52421. */
  52422. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52423. /**
  52424. * Add the required uniforms to the current list.
  52425. * @param uniforms defines the current uniform list.
  52426. */
  52427. static AddUniforms(uniforms: string[]): void;
  52428. /**
  52429. * Add the required uniforms to the current buffer.
  52430. * @param uniformBuffer defines the current uniform buffer.
  52431. */
  52432. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52433. /**
  52434. * Add the required samplers to the current list.
  52435. * @param samplers defines the current sampler list.
  52436. */
  52437. static AddSamplers(samplers: string[]): void;
  52438. /**
  52439. * Makes a duplicate of the current configuration into another one.
  52440. * @param anisotropicConfiguration define the config where to copy the info
  52441. */
  52442. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52443. /**
  52444. * Serializes this anisotropy configuration.
  52445. * @returns - An object with the serialized config.
  52446. */
  52447. serialize(): any;
  52448. /**
  52449. * Parses a anisotropy Configuration from a serialized object.
  52450. * @param source - Serialized object.
  52451. * @param scene Defines the scene we are parsing for
  52452. * @param rootUrl Defines the rootUrl to load from
  52453. */
  52454. parse(source: any, scene: Scene, rootUrl: string): void;
  52455. }
  52456. }
  52457. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52458. import { Scene } from "babylonjs/scene";
  52459. /**
  52460. * @hidden
  52461. */
  52462. export interface IMaterialBRDFDefines {
  52463. BRDF_V_HEIGHT_CORRELATED: boolean;
  52464. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52465. SPHERICAL_HARMONICS: boolean;
  52466. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52467. /** @hidden */
  52468. _areMiscDirty: boolean;
  52469. }
  52470. /**
  52471. * Define the code related to the BRDF parameters of the pbr material.
  52472. */
  52473. export class PBRBRDFConfiguration {
  52474. /**
  52475. * Default value used for the energy conservation.
  52476. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52477. */
  52478. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52479. /**
  52480. * Default value used for the Smith Visibility Height Correlated mode.
  52481. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52482. */
  52483. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52484. /**
  52485. * Default value used for the IBL diffuse part.
  52486. * This can help switching back to the polynomials mode globally which is a tiny bit
  52487. * less GPU intensive at the drawback of a lower quality.
  52488. */
  52489. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52490. /**
  52491. * Default value used for activating energy conservation for the specular workflow.
  52492. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52493. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52494. */
  52495. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52496. private _useEnergyConservation;
  52497. /**
  52498. * Defines if the material uses energy conservation.
  52499. */
  52500. useEnergyConservation: boolean;
  52501. private _useSmithVisibilityHeightCorrelated;
  52502. /**
  52503. * LEGACY Mode set to false
  52504. * Defines if the material uses height smith correlated visibility term.
  52505. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52506. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52507. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52508. * Not relying on height correlated will also disable energy conservation.
  52509. */
  52510. useSmithVisibilityHeightCorrelated: boolean;
  52511. private _useSphericalHarmonics;
  52512. /**
  52513. * LEGACY Mode set to false
  52514. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52515. * diffuse part of the IBL.
  52516. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52517. * to the ground truth.
  52518. */
  52519. useSphericalHarmonics: boolean;
  52520. private _useSpecularGlossinessInputEnergyConservation;
  52521. /**
  52522. * Defines if the material uses energy conservation, when the specular workflow is active.
  52523. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52524. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52525. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52526. */
  52527. useSpecularGlossinessInputEnergyConservation: boolean;
  52528. /** @hidden */
  52529. private _internalMarkAllSubMeshesAsMiscDirty;
  52530. /** @hidden */
  52531. _markAllSubMeshesAsMiscDirty(): void;
  52532. /**
  52533. * Instantiate a new istance of clear coat configuration.
  52534. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52535. */
  52536. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52537. /**
  52538. * Checks to see if a texture is used in the material.
  52539. * @param defines the list of "defines" to update.
  52540. */
  52541. prepareDefines(defines: IMaterialBRDFDefines): void;
  52542. /**
  52543. * Get the current class name of the texture useful for serialization or dynamic coding.
  52544. * @returns "PBRClearCoatConfiguration"
  52545. */
  52546. getClassName(): string;
  52547. /**
  52548. * Makes a duplicate of the current configuration into another one.
  52549. * @param brdfConfiguration define the config where to copy the info
  52550. */
  52551. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52552. /**
  52553. * Serializes this BRDF configuration.
  52554. * @returns - An object with the serialized config.
  52555. */
  52556. serialize(): any;
  52557. /**
  52558. * Parses a anisotropy Configuration from a serialized object.
  52559. * @param source - Serialized object.
  52560. * @param scene Defines the scene we are parsing for
  52561. * @param rootUrl Defines the rootUrl to load from
  52562. */
  52563. parse(source: any, scene: Scene, rootUrl: string): void;
  52564. }
  52565. }
  52566. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52567. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52568. import { Color3 } from "babylonjs/Maths/math.color";
  52569. import { Scene } from "babylonjs/scene";
  52570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52571. import { Nullable } from "babylonjs/types";
  52572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52573. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52574. /**
  52575. * @hidden
  52576. */
  52577. export interface IMaterialSheenDefines {
  52578. SHEEN: boolean;
  52579. SHEEN_TEXTURE: boolean;
  52580. SHEEN_TEXTUREDIRECTUV: number;
  52581. SHEEN_LINKWITHALBEDO: boolean;
  52582. /** @hidden */
  52583. _areTexturesDirty: boolean;
  52584. }
  52585. /**
  52586. * Define the code related to the Sheen parameters of the pbr material.
  52587. */
  52588. export class PBRSheenConfiguration {
  52589. private _isEnabled;
  52590. /**
  52591. * Defines if the material uses sheen.
  52592. */
  52593. isEnabled: boolean;
  52594. private _linkSheenWithAlbedo;
  52595. /**
  52596. * Defines if the sheen is linked to the sheen color.
  52597. */
  52598. linkSheenWithAlbedo: boolean;
  52599. /**
  52600. * Defines the sheen intensity.
  52601. */
  52602. intensity: number;
  52603. /**
  52604. * Defines the sheen color.
  52605. */
  52606. color: Color3;
  52607. private _texture;
  52608. /**
  52609. * Stores the sheen tint values in a texture.
  52610. * rgb is tint
  52611. * a is a intensity
  52612. */
  52613. texture: Nullable<BaseTexture>;
  52614. /** @hidden */
  52615. private _internalMarkAllSubMeshesAsTexturesDirty;
  52616. /** @hidden */
  52617. _markAllSubMeshesAsTexturesDirty(): void;
  52618. /**
  52619. * Instantiate a new istance of clear coat configuration.
  52620. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52621. */
  52622. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52623. /**
  52624. * Specifies that the submesh is ready to be used.
  52625. * @param defines the list of "defines" to update.
  52626. * @param scene defines the scene the material belongs to.
  52627. * @returns - boolean indicating that the submesh is ready or not.
  52628. */
  52629. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52630. /**
  52631. * Checks to see if a texture is used in the material.
  52632. * @param defines the list of "defines" to update.
  52633. * @param scene defines the scene the material belongs to.
  52634. */
  52635. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52636. /**
  52637. * Binds the material data.
  52638. * @param uniformBuffer defines the Uniform buffer to fill in.
  52639. * @param scene defines the scene the material belongs to.
  52640. * @param isFrozen defines wether the material is frozen or not.
  52641. */
  52642. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52643. /**
  52644. * Checks to see if a texture is used in the material.
  52645. * @param texture - Base texture to use.
  52646. * @returns - Boolean specifying if a texture is used in the material.
  52647. */
  52648. hasTexture(texture: BaseTexture): boolean;
  52649. /**
  52650. * Returns an array of the actively used textures.
  52651. * @param activeTextures Array of BaseTextures
  52652. */
  52653. getActiveTextures(activeTextures: BaseTexture[]): void;
  52654. /**
  52655. * Returns the animatable textures.
  52656. * @param animatables Array of animatable textures.
  52657. */
  52658. getAnimatables(animatables: IAnimatable[]): void;
  52659. /**
  52660. * Disposes the resources of the material.
  52661. * @param forceDisposeTextures - Forces the disposal of all textures.
  52662. */
  52663. dispose(forceDisposeTextures?: boolean): void;
  52664. /**
  52665. * Get the current class name of the texture useful for serialization or dynamic coding.
  52666. * @returns "PBRSheenConfiguration"
  52667. */
  52668. getClassName(): string;
  52669. /**
  52670. * Add fallbacks to the effect fallbacks list.
  52671. * @param defines defines the Base texture to use.
  52672. * @param fallbacks defines the current fallback list.
  52673. * @param currentRank defines the current fallback rank.
  52674. * @returns the new fallback rank.
  52675. */
  52676. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52677. /**
  52678. * Add the required uniforms to the current list.
  52679. * @param uniforms defines the current uniform list.
  52680. */
  52681. static AddUniforms(uniforms: string[]): void;
  52682. /**
  52683. * Add the required uniforms to the current buffer.
  52684. * @param uniformBuffer defines the current uniform buffer.
  52685. */
  52686. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52687. /**
  52688. * Add the required samplers to the current list.
  52689. * @param samplers defines the current sampler list.
  52690. */
  52691. static AddSamplers(samplers: string[]): void;
  52692. /**
  52693. * Makes a duplicate of the current configuration into another one.
  52694. * @param sheenConfiguration define the config where to copy the info
  52695. */
  52696. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52697. /**
  52698. * Serializes this BRDF configuration.
  52699. * @returns - An object with the serialized config.
  52700. */
  52701. serialize(): any;
  52702. /**
  52703. * Parses a anisotropy Configuration from a serialized object.
  52704. * @param source - Serialized object.
  52705. * @param scene Defines the scene we are parsing for
  52706. * @param rootUrl Defines the rootUrl to load from
  52707. */
  52708. parse(source: any, scene: Scene, rootUrl: string): void;
  52709. }
  52710. }
  52711. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52712. import { Nullable } from "babylonjs/types";
  52713. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52714. import { Color3 } from "babylonjs/Maths/math.color";
  52715. import { SmartArray } from "babylonjs/Misc/smartArray";
  52716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52717. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52718. import { Effect } from "babylonjs/Materials/effect";
  52719. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52720. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52721. import { Engine } from "babylonjs/Engines/engine";
  52722. import { Scene } from "babylonjs/scene";
  52723. /**
  52724. * @hidden
  52725. */
  52726. export interface IMaterialSubSurfaceDefines {
  52727. SUBSURFACE: boolean;
  52728. SS_REFRACTION: boolean;
  52729. SS_TRANSLUCENCY: boolean;
  52730. SS_SCATERRING: boolean;
  52731. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52732. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52733. SS_REFRACTIONMAP_3D: boolean;
  52734. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52735. SS_LODINREFRACTIONALPHA: boolean;
  52736. SS_GAMMAREFRACTION: boolean;
  52737. SS_RGBDREFRACTION: boolean;
  52738. SS_LINEARSPECULARREFRACTION: boolean;
  52739. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52740. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52741. /** @hidden */
  52742. _areTexturesDirty: boolean;
  52743. }
  52744. /**
  52745. * Define the code related to the sub surface parameters of the pbr material.
  52746. */
  52747. export class PBRSubSurfaceConfiguration {
  52748. private _isRefractionEnabled;
  52749. /**
  52750. * Defines if the refraction is enabled in the material.
  52751. */
  52752. isRefractionEnabled: boolean;
  52753. private _isTranslucencyEnabled;
  52754. /**
  52755. * Defines if the translucency is enabled in the material.
  52756. */
  52757. isTranslucencyEnabled: boolean;
  52758. private _isScatteringEnabled;
  52759. /**
  52760. * Defines the refraction intensity of the material.
  52761. * The refraction when enabled replaces the Diffuse part of the material.
  52762. * The intensity helps transitionning between diffuse and refraction.
  52763. */
  52764. refractionIntensity: number;
  52765. /**
  52766. * Defines the translucency intensity of the material.
  52767. * When translucency has been enabled, this defines how much of the "translucency"
  52768. * is addded to the diffuse part of the material.
  52769. */
  52770. translucencyIntensity: number;
  52771. /**
  52772. * Defines the scattering intensity of the material.
  52773. * When scattering has been enabled, this defines how much of the "scattered light"
  52774. * is addded to the diffuse part of the material.
  52775. */
  52776. scatteringIntensity: number;
  52777. private _thicknessTexture;
  52778. /**
  52779. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52780. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52781. * 0 would mean minimumThickness
  52782. * 1 would mean maximumThickness
  52783. * The other channels might be use as a mask to vary the different effects intensity.
  52784. */
  52785. thicknessTexture: Nullable<BaseTexture>;
  52786. private _refractionTexture;
  52787. /**
  52788. * Defines the texture to use for refraction.
  52789. */
  52790. refractionTexture: Nullable<BaseTexture>;
  52791. private _indexOfRefraction;
  52792. /**
  52793. * Defines the index of refraction used in the material.
  52794. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52795. */
  52796. indexOfRefraction: number;
  52797. private _invertRefractionY;
  52798. /**
  52799. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52800. */
  52801. invertRefractionY: boolean;
  52802. private _linkRefractionWithTransparency;
  52803. /**
  52804. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52805. * Materials half opaque for instance using refraction could benefit from this control.
  52806. */
  52807. linkRefractionWithTransparency: boolean;
  52808. /**
  52809. * Defines the minimum thickness stored in the thickness map.
  52810. * If no thickness map is defined, this value will be used to simulate thickness.
  52811. */
  52812. minimumThickness: number;
  52813. /**
  52814. * Defines the maximum thickness stored in the thickness map.
  52815. */
  52816. maximumThickness: number;
  52817. /**
  52818. * Defines the volume tint of the material.
  52819. * This is used for both translucency and scattering.
  52820. */
  52821. tintColor: Color3;
  52822. /**
  52823. * Defines the distance at which the tint color should be found in the media.
  52824. * This is used for refraction only.
  52825. */
  52826. tintColorAtDistance: number;
  52827. /**
  52828. * Defines how far each channel transmit through the media.
  52829. * It is defined as a color to simplify it selection.
  52830. */
  52831. diffusionDistance: Color3;
  52832. private _useMaskFromThicknessTexture;
  52833. /**
  52834. * Stores the intensity of the different subsurface effects in the thickness texture.
  52835. * * the green channel is the translucency intensity.
  52836. * * the blue channel is the scattering intensity.
  52837. * * the alpha channel is the refraction intensity.
  52838. */
  52839. useMaskFromThicknessTexture: boolean;
  52840. /** @hidden */
  52841. private _internalMarkAllSubMeshesAsTexturesDirty;
  52842. /** @hidden */
  52843. _markAllSubMeshesAsTexturesDirty(): void;
  52844. /**
  52845. * Instantiate a new istance of sub surface configuration.
  52846. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52847. */
  52848. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52849. /**
  52850. * Gets wehter the submesh is ready to be used or not.
  52851. * @param defines the list of "defines" to update.
  52852. * @param scene defines the scene the material belongs to.
  52853. * @returns - boolean indicating that the submesh is ready or not.
  52854. */
  52855. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52856. /**
  52857. * Checks to see if a texture is used in the material.
  52858. * @param defines the list of "defines" to update.
  52859. * @param scene defines the scene to the material belongs to.
  52860. */
  52861. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52862. /**
  52863. * Binds the material data.
  52864. * @param uniformBuffer defines the Uniform buffer to fill in.
  52865. * @param scene defines the scene the material belongs to.
  52866. * @param engine defines the engine the material belongs to.
  52867. * @param isFrozen defines wether the material is frozen or not.
  52868. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52869. */
  52870. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52871. /**
  52872. * Unbinds the material from the mesh.
  52873. * @param activeEffect defines the effect that should be unbound from.
  52874. * @returns true if unbound, otherwise false
  52875. */
  52876. unbind(activeEffect: Effect): boolean;
  52877. /**
  52878. * Returns the texture used for refraction or null if none is used.
  52879. * @param scene defines the scene the material belongs to.
  52880. * @returns - Refraction texture if present. If no refraction texture and refraction
  52881. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52882. */
  52883. private _getRefractionTexture;
  52884. /**
  52885. * Returns true if alpha blending should be disabled.
  52886. */
  52887. get disableAlphaBlending(): boolean;
  52888. /**
  52889. * Fills the list of render target textures.
  52890. * @param renderTargets the list of render targets to update
  52891. */
  52892. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52893. /**
  52894. * Checks to see if a texture is used in the material.
  52895. * @param texture - Base texture to use.
  52896. * @returns - Boolean specifying if a texture is used in the material.
  52897. */
  52898. hasTexture(texture: BaseTexture): boolean;
  52899. /**
  52900. * Gets a boolean indicating that current material needs to register RTT
  52901. * @returns true if this uses a render target otherwise false.
  52902. */
  52903. hasRenderTargetTextures(): boolean;
  52904. /**
  52905. * Returns an array of the actively used textures.
  52906. * @param activeTextures Array of BaseTextures
  52907. */
  52908. getActiveTextures(activeTextures: BaseTexture[]): void;
  52909. /**
  52910. * Returns the animatable textures.
  52911. * @param animatables Array of animatable textures.
  52912. */
  52913. getAnimatables(animatables: IAnimatable[]): void;
  52914. /**
  52915. * Disposes the resources of the material.
  52916. * @param forceDisposeTextures - Forces the disposal of all textures.
  52917. */
  52918. dispose(forceDisposeTextures?: boolean): void;
  52919. /**
  52920. * Get the current class name of the texture useful for serialization or dynamic coding.
  52921. * @returns "PBRSubSurfaceConfiguration"
  52922. */
  52923. getClassName(): string;
  52924. /**
  52925. * Add fallbacks to the effect fallbacks list.
  52926. * @param defines defines the Base texture to use.
  52927. * @param fallbacks defines the current fallback list.
  52928. * @param currentRank defines the current fallback rank.
  52929. * @returns the new fallback rank.
  52930. */
  52931. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52932. /**
  52933. * Add the required uniforms to the current list.
  52934. * @param uniforms defines the current uniform list.
  52935. */
  52936. static AddUniforms(uniforms: string[]): void;
  52937. /**
  52938. * Add the required samplers to the current list.
  52939. * @param samplers defines the current sampler list.
  52940. */
  52941. static AddSamplers(samplers: string[]): void;
  52942. /**
  52943. * Add the required uniforms to the current buffer.
  52944. * @param uniformBuffer defines the current uniform buffer.
  52945. */
  52946. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52947. /**
  52948. * Makes a duplicate of the current configuration into another one.
  52949. * @param configuration define the config where to copy the info
  52950. */
  52951. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52952. /**
  52953. * Serializes this Sub Surface configuration.
  52954. * @returns - An object with the serialized config.
  52955. */
  52956. serialize(): any;
  52957. /**
  52958. * Parses a anisotropy Configuration from a serialized object.
  52959. * @param source - Serialized object.
  52960. * @param scene Defines the scene we are parsing for
  52961. * @param rootUrl Defines the rootUrl to load from
  52962. */
  52963. parse(source: any, scene: Scene, rootUrl: string): void;
  52964. }
  52965. }
  52966. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52967. /** @hidden */
  52968. export var pbrFragmentDeclaration: {
  52969. name: string;
  52970. shader: string;
  52971. };
  52972. }
  52973. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52974. /** @hidden */
  52975. export var pbrUboDeclaration: {
  52976. name: string;
  52977. shader: string;
  52978. };
  52979. }
  52980. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52981. /** @hidden */
  52982. export var pbrFragmentExtraDeclaration: {
  52983. name: string;
  52984. shader: string;
  52985. };
  52986. }
  52987. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52988. /** @hidden */
  52989. export var pbrFragmentSamplersDeclaration: {
  52990. name: string;
  52991. shader: string;
  52992. };
  52993. }
  52994. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52995. /** @hidden */
  52996. export var pbrHelperFunctions: {
  52997. name: string;
  52998. shader: string;
  52999. };
  53000. }
  53001. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53002. /** @hidden */
  53003. export var harmonicsFunctions: {
  53004. name: string;
  53005. shader: string;
  53006. };
  53007. }
  53008. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53009. /** @hidden */
  53010. export var pbrDirectLightingSetupFunctions: {
  53011. name: string;
  53012. shader: string;
  53013. };
  53014. }
  53015. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53016. /** @hidden */
  53017. export var pbrDirectLightingFalloffFunctions: {
  53018. name: string;
  53019. shader: string;
  53020. };
  53021. }
  53022. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53023. /** @hidden */
  53024. export var pbrBRDFFunctions: {
  53025. name: string;
  53026. shader: string;
  53027. };
  53028. }
  53029. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53030. /** @hidden */
  53031. export var pbrDirectLightingFunctions: {
  53032. name: string;
  53033. shader: string;
  53034. };
  53035. }
  53036. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53037. /** @hidden */
  53038. export var pbrIBLFunctions: {
  53039. name: string;
  53040. shader: string;
  53041. };
  53042. }
  53043. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53044. /** @hidden */
  53045. export var pbrDebug: {
  53046. name: string;
  53047. shader: string;
  53048. };
  53049. }
  53050. declare module "babylonjs/Shaders/pbr.fragment" {
  53051. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53052. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53053. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53054. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53055. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53056. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53057. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53059. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53060. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53061. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53062. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53063. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53064. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53065. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53066. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53067. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53068. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53069. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53070. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53071. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53072. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53073. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53074. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53075. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53076. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53077. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53078. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53079. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53080. /** @hidden */
  53081. export var pbrPixelShader: {
  53082. name: string;
  53083. shader: string;
  53084. };
  53085. }
  53086. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53087. /** @hidden */
  53088. export var pbrVertexDeclaration: {
  53089. name: string;
  53090. shader: string;
  53091. };
  53092. }
  53093. declare module "babylonjs/Shaders/pbr.vertex" {
  53094. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53095. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53096. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53098. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53099. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53100. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53101. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53102. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53103. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53104. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53105. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53106. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53107. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53108. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53109. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53110. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53111. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53112. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53113. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53114. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53115. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53116. /** @hidden */
  53117. export var pbrVertexShader: {
  53118. name: string;
  53119. shader: string;
  53120. };
  53121. }
  53122. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53123. import { Nullable } from "babylonjs/types";
  53124. import { Scene } from "babylonjs/scene";
  53125. import { Matrix } from "babylonjs/Maths/math.vector";
  53126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53128. import { Mesh } from "babylonjs/Meshes/mesh";
  53129. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53130. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53131. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53132. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53133. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53134. import { Color3 } from "babylonjs/Maths/math.color";
  53135. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53136. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53137. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53138. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53140. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53141. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53142. import "babylonjs/Shaders/pbr.fragment";
  53143. import "babylonjs/Shaders/pbr.vertex";
  53144. /**
  53145. * Manages the defines for the PBR Material.
  53146. * @hidden
  53147. */
  53148. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53149. PBR: boolean;
  53150. MAINUV1: boolean;
  53151. MAINUV2: boolean;
  53152. UV1: boolean;
  53153. UV2: boolean;
  53154. ALBEDO: boolean;
  53155. ALBEDODIRECTUV: number;
  53156. VERTEXCOLOR: boolean;
  53157. AMBIENT: boolean;
  53158. AMBIENTDIRECTUV: number;
  53159. AMBIENTINGRAYSCALE: boolean;
  53160. OPACITY: boolean;
  53161. VERTEXALPHA: boolean;
  53162. OPACITYDIRECTUV: number;
  53163. OPACITYRGB: boolean;
  53164. ALPHATEST: boolean;
  53165. DEPTHPREPASS: boolean;
  53166. ALPHABLEND: boolean;
  53167. ALPHAFROMALBEDO: boolean;
  53168. ALPHATESTVALUE: string;
  53169. SPECULAROVERALPHA: boolean;
  53170. RADIANCEOVERALPHA: boolean;
  53171. ALPHAFRESNEL: boolean;
  53172. LINEARALPHAFRESNEL: boolean;
  53173. PREMULTIPLYALPHA: boolean;
  53174. EMISSIVE: boolean;
  53175. EMISSIVEDIRECTUV: number;
  53176. REFLECTIVITY: boolean;
  53177. REFLECTIVITYDIRECTUV: number;
  53178. SPECULARTERM: boolean;
  53179. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53180. MICROSURFACEAUTOMATIC: boolean;
  53181. LODBASEDMICROSFURACE: boolean;
  53182. MICROSURFACEMAP: boolean;
  53183. MICROSURFACEMAPDIRECTUV: number;
  53184. METALLICWORKFLOW: boolean;
  53185. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53186. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53187. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53188. AOSTOREINMETALMAPRED: boolean;
  53189. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53190. ENVIRONMENTBRDF: boolean;
  53191. ENVIRONMENTBRDF_RGBD: boolean;
  53192. NORMAL: boolean;
  53193. TANGENT: boolean;
  53194. BUMP: boolean;
  53195. BUMPDIRECTUV: number;
  53196. OBJECTSPACE_NORMALMAP: boolean;
  53197. PARALLAX: boolean;
  53198. PARALLAXOCCLUSION: boolean;
  53199. NORMALXYSCALE: boolean;
  53200. LIGHTMAP: boolean;
  53201. LIGHTMAPDIRECTUV: number;
  53202. USELIGHTMAPASSHADOWMAP: boolean;
  53203. GAMMALIGHTMAP: boolean;
  53204. RGBDLIGHTMAP: boolean;
  53205. REFLECTION: boolean;
  53206. REFLECTIONMAP_3D: boolean;
  53207. REFLECTIONMAP_SPHERICAL: boolean;
  53208. REFLECTIONMAP_PLANAR: boolean;
  53209. REFLECTIONMAP_CUBIC: boolean;
  53210. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53211. REFLECTIONMAP_PROJECTION: boolean;
  53212. REFLECTIONMAP_SKYBOX: boolean;
  53213. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  53214. REFLECTIONMAP_EXPLICIT: boolean;
  53215. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53216. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53217. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53218. INVERTCUBICMAP: boolean;
  53219. USESPHERICALFROMREFLECTIONMAP: boolean;
  53220. USEIRRADIANCEMAP: boolean;
  53221. SPHERICAL_HARMONICS: boolean;
  53222. USESPHERICALINVERTEX: boolean;
  53223. REFLECTIONMAP_OPPOSITEZ: boolean;
  53224. LODINREFLECTIONALPHA: boolean;
  53225. GAMMAREFLECTION: boolean;
  53226. RGBDREFLECTION: boolean;
  53227. LINEARSPECULARREFLECTION: boolean;
  53228. RADIANCEOCCLUSION: boolean;
  53229. HORIZONOCCLUSION: boolean;
  53230. INSTANCES: boolean;
  53231. NUM_BONE_INFLUENCERS: number;
  53232. BonesPerMesh: number;
  53233. BONETEXTURE: boolean;
  53234. NONUNIFORMSCALING: boolean;
  53235. MORPHTARGETS: boolean;
  53236. MORPHTARGETS_NORMAL: boolean;
  53237. MORPHTARGETS_TANGENT: boolean;
  53238. MORPHTARGETS_UV: boolean;
  53239. NUM_MORPH_INFLUENCERS: number;
  53240. IMAGEPROCESSING: boolean;
  53241. VIGNETTE: boolean;
  53242. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53243. VIGNETTEBLENDMODEOPAQUE: boolean;
  53244. TONEMAPPING: boolean;
  53245. TONEMAPPING_ACES: boolean;
  53246. CONTRAST: boolean;
  53247. COLORCURVES: boolean;
  53248. COLORGRADING: boolean;
  53249. COLORGRADING3D: boolean;
  53250. SAMPLER3DGREENDEPTH: boolean;
  53251. SAMPLER3DBGRMAP: boolean;
  53252. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53253. EXPOSURE: boolean;
  53254. MULTIVIEW: boolean;
  53255. USEPHYSICALLIGHTFALLOFF: boolean;
  53256. USEGLTFLIGHTFALLOFF: boolean;
  53257. TWOSIDEDLIGHTING: boolean;
  53258. SHADOWFLOAT: boolean;
  53259. CLIPPLANE: boolean;
  53260. CLIPPLANE2: boolean;
  53261. CLIPPLANE3: boolean;
  53262. CLIPPLANE4: boolean;
  53263. CLIPPLANE5: boolean;
  53264. CLIPPLANE6: boolean;
  53265. POINTSIZE: boolean;
  53266. FOG: boolean;
  53267. LOGARITHMICDEPTH: boolean;
  53268. FORCENORMALFORWARD: boolean;
  53269. SPECULARAA: boolean;
  53270. CLEARCOAT: boolean;
  53271. CLEARCOAT_DEFAULTIOR: boolean;
  53272. CLEARCOAT_TEXTURE: boolean;
  53273. CLEARCOAT_TEXTUREDIRECTUV: number;
  53274. CLEARCOAT_BUMP: boolean;
  53275. CLEARCOAT_BUMPDIRECTUV: number;
  53276. CLEARCOAT_TINT: boolean;
  53277. CLEARCOAT_TINT_TEXTURE: boolean;
  53278. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53279. ANISOTROPIC: boolean;
  53280. ANISOTROPIC_TEXTURE: boolean;
  53281. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53282. BRDF_V_HEIGHT_CORRELATED: boolean;
  53283. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53284. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53285. SHEEN: boolean;
  53286. SHEEN_TEXTURE: boolean;
  53287. SHEEN_TEXTUREDIRECTUV: number;
  53288. SHEEN_LINKWITHALBEDO: boolean;
  53289. SUBSURFACE: boolean;
  53290. SS_REFRACTION: boolean;
  53291. SS_TRANSLUCENCY: boolean;
  53292. SS_SCATERRING: boolean;
  53293. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53294. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53295. SS_REFRACTIONMAP_3D: boolean;
  53296. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53297. SS_LODINREFRACTIONALPHA: boolean;
  53298. SS_GAMMAREFRACTION: boolean;
  53299. SS_RGBDREFRACTION: boolean;
  53300. SS_LINEARSPECULARREFRACTION: boolean;
  53301. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53302. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53303. UNLIT: boolean;
  53304. DEBUGMODE: number;
  53305. /**
  53306. * Initializes the PBR Material defines.
  53307. */
  53308. constructor();
  53309. /**
  53310. * Resets the PBR Material defines.
  53311. */
  53312. reset(): void;
  53313. }
  53314. /**
  53315. * The Physically based material base class of BJS.
  53316. *
  53317. * This offers the main features of a standard PBR material.
  53318. * For more information, please refer to the documentation :
  53319. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53320. */
  53321. export abstract class PBRBaseMaterial extends PushMaterial {
  53322. /**
  53323. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53324. */
  53325. static readonly PBRMATERIAL_OPAQUE: number;
  53326. /**
  53327. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53328. */
  53329. static readonly PBRMATERIAL_ALPHATEST: number;
  53330. /**
  53331. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53332. */
  53333. static readonly PBRMATERIAL_ALPHABLEND: number;
  53334. /**
  53335. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53336. * They are also discarded below the alpha cutoff threshold to improve performances.
  53337. */
  53338. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53339. /**
  53340. * Defines the default value of how much AO map is occluding the analytical lights
  53341. * (point spot...).
  53342. */
  53343. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53344. /**
  53345. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53346. */
  53347. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53348. /**
  53349. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53350. * to enhance interoperability with other engines.
  53351. */
  53352. static readonly LIGHTFALLOFF_GLTF: number;
  53353. /**
  53354. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53355. * to enhance interoperability with other materials.
  53356. */
  53357. static readonly LIGHTFALLOFF_STANDARD: number;
  53358. /**
  53359. * Intensity of the direct lights e.g. the four lights available in your scene.
  53360. * This impacts both the direct diffuse and specular highlights.
  53361. */
  53362. protected _directIntensity: number;
  53363. /**
  53364. * Intensity of the emissive part of the material.
  53365. * This helps controlling the emissive effect without modifying the emissive color.
  53366. */
  53367. protected _emissiveIntensity: number;
  53368. /**
  53369. * Intensity of the environment e.g. how much the environment will light the object
  53370. * either through harmonics for rough material or through the refelction for shiny ones.
  53371. */
  53372. protected _environmentIntensity: number;
  53373. /**
  53374. * This is a special control allowing the reduction of the specular highlights coming from the
  53375. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53376. */
  53377. protected _specularIntensity: number;
  53378. /**
  53379. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53380. */
  53381. private _lightingInfos;
  53382. /**
  53383. * Debug Control allowing disabling the bump map on this material.
  53384. */
  53385. protected _disableBumpMap: boolean;
  53386. /**
  53387. * AKA Diffuse Texture in standard nomenclature.
  53388. */
  53389. protected _albedoTexture: Nullable<BaseTexture>;
  53390. /**
  53391. * AKA Occlusion Texture in other nomenclature.
  53392. */
  53393. protected _ambientTexture: Nullable<BaseTexture>;
  53394. /**
  53395. * AKA Occlusion Texture Intensity in other nomenclature.
  53396. */
  53397. protected _ambientTextureStrength: number;
  53398. /**
  53399. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53400. * 1 means it completely occludes it
  53401. * 0 mean it has no impact
  53402. */
  53403. protected _ambientTextureImpactOnAnalyticalLights: number;
  53404. /**
  53405. * Stores the alpha values in a texture.
  53406. */
  53407. protected _opacityTexture: Nullable<BaseTexture>;
  53408. /**
  53409. * Stores the reflection values in a texture.
  53410. */
  53411. protected _reflectionTexture: Nullable<BaseTexture>;
  53412. /**
  53413. * Stores the emissive values in a texture.
  53414. */
  53415. protected _emissiveTexture: Nullable<BaseTexture>;
  53416. /**
  53417. * AKA Specular texture in other nomenclature.
  53418. */
  53419. protected _reflectivityTexture: Nullable<BaseTexture>;
  53420. /**
  53421. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53422. */
  53423. protected _metallicTexture: Nullable<BaseTexture>;
  53424. /**
  53425. * Specifies the metallic scalar of the metallic/roughness workflow.
  53426. * Can also be used to scale the metalness values of the metallic texture.
  53427. */
  53428. protected _metallic: Nullable<number>;
  53429. /**
  53430. * Specifies the roughness scalar of the metallic/roughness workflow.
  53431. * Can also be used to scale the roughness values of the metallic texture.
  53432. */
  53433. protected _roughness: Nullable<number>;
  53434. /**
  53435. * Specifies the an F0 factor to help configuring the material F0.
  53436. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53437. * to 0.5 the previously hard coded value stays the same.
  53438. * Can also be used to scale the F0 values of the metallic texture.
  53439. */
  53440. protected _metallicF0Factor: number;
  53441. /**
  53442. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53443. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53444. * your expectation as it multiplies with the texture data.
  53445. */
  53446. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53447. /**
  53448. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53449. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53450. */
  53451. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53452. /**
  53453. * Stores surface normal data used to displace a mesh in a texture.
  53454. */
  53455. protected _bumpTexture: Nullable<BaseTexture>;
  53456. /**
  53457. * Stores the pre-calculated light information of a mesh in a texture.
  53458. */
  53459. protected _lightmapTexture: Nullable<BaseTexture>;
  53460. /**
  53461. * The color of a material in ambient lighting.
  53462. */
  53463. protected _ambientColor: Color3;
  53464. /**
  53465. * AKA Diffuse Color in other nomenclature.
  53466. */
  53467. protected _albedoColor: Color3;
  53468. /**
  53469. * AKA Specular Color in other nomenclature.
  53470. */
  53471. protected _reflectivityColor: Color3;
  53472. /**
  53473. * The color applied when light is reflected from a material.
  53474. */
  53475. protected _reflectionColor: Color3;
  53476. /**
  53477. * The color applied when light is emitted from a material.
  53478. */
  53479. protected _emissiveColor: Color3;
  53480. /**
  53481. * AKA Glossiness in other nomenclature.
  53482. */
  53483. protected _microSurface: number;
  53484. /**
  53485. * Specifies that the material will use the light map as a show map.
  53486. */
  53487. protected _useLightmapAsShadowmap: boolean;
  53488. /**
  53489. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53490. * makes the reflect vector face the model (under horizon).
  53491. */
  53492. protected _useHorizonOcclusion: boolean;
  53493. /**
  53494. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53495. * too much the area relying on ambient texture to define their ambient occlusion.
  53496. */
  53497. protected _useRadianceOcclusion: boolean;
  53498. /**
  53499. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53500. */
  53501. protected _useAlphaFromAlbedoTexture: boolean;
  53502. /**
  53503. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53504. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53505. */
  53506. protected _useSpecularOverAlpha: boolean;
  53507. /**
  53508. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53509. */
  53510. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53511. /**
  53512. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53513. */
  53514. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53515. /**
  53516. * Specifies if the metallic texture contains the roughness information in its green channel.
  53517. */
  53518. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53519. /**
  53520. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53521. */
  53522. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53523. /**
  53524. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53525. */
  53526. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53527. /**
  53528. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53529. */
  53530. protected _useAmbientInGrayScale: boolean;
  53531. /**
  53532. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53533. * The material will try to infer what glossiness each pixel should be.
  53534. */
  53535. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53536. /**
  53537. * Defines the falloff type used in this material.
  53538. * It by default is Physical.
  53539. */
  53540. protected _lightFalloff: number;
  53541. /**
  53542. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53543. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53544. */
  53545. protected _useRadianceOverAlpha: boolean;
  53546. /**
  53547. * Allows using an object space normal map (instead of tangent space).
  53548. */
  53549. protected _useObjectSpaceNormalMap: boolean;
  53550. /**
  53551. * Allows using the bump map in parallax mode.
  53552. */
  53553. protected _useParallax: boolean;
  53554. /**
  53555. * Allows using the bump map in parallax occlusion mode.
  53556. */
  53557. protected _useParallaxOcclusion: boolean;
  53558. /**
  53559. * Controls the scale bias of the parallax mode.
  53560. */
  53561. protected _parallaxScaleBias: number;
  53562. /**
  53563. * If sets to true, disables all the lights affecting the material.
  53564. */
  53565. protected _disableLighting: boolean;
  53566. /**
  53567. * Number of Simultaneous lights allowed on the material.
  53568. */
  53569. protected _maxSimultaneousLights: number;
  53570. /**
  53571. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53572. */
  53573. protected _invertNormalMapX: boolean;
  53574. /**
  53575. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53576. */
  53577. protected _invertNormalMapY: boolean;
  53578. /**
  53579. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53580. */
  53581. protected _twoSidedLighting: boolean;
  53582. /**
  53583. * Defines the alpha limits in alpha test mode.
  53584. */
  53585. protected _alphaCutOff: number;
  53586. /**
  53587. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53588. */
  53589. protected _forceAlphaTest: boolean;
  53590. /**
  53591. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53592. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53593. */
  53594. protected _useAlphaFresnel: boolean;
  53595. /**
  53596. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53597. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53598. */
  53599. protected _useLinearAlphaFresnel: boolean;
  53600. /**
  53601. * The transparency mode of the material.
  53602. */
  53603. protected _transparencyMode: Nullable<number>;
  53604. /**
  53605. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53606. * from cos thetav and roughness:
  53607. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53608. */
  53609. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53610. /**
  53611. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53612. */
  53613. protected _forceIrradianceInFragment: boolean;
  53614. /**
  53615. * Force normal to face away from face.
  53616. */
  53617. protected _forceNormalForward: boolean;
  53618. /**
  53619. * Enables specular anti aliasing in the PBR shader.
  53620. * It will both interacts on the Geometry for analytical and IBL lighting.
  53621. * It also prefilter the roughness map based on the bump values.
  53622. */
  53623. protected _enableSpecularAntiAliasing: boolean;
  53624. /**
  53625. * Default configuration related to image processing available in the PBR Material.
  53626. */
  53627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53628. /**
  53629. * Keep track of the image processing observer to allow dispose and replace.
  53630. */
  53631. private _imageProcessingObserver;
  53632. /**
  53633. * Attaches a new image processing configuration to the PBR Material.
  53634. * @param configuration
  53635. */
  53636. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53637. /**
  53638. * Stores the available render targets.
  53639. */
  53640. private _renderTargets;
  53641. /**
  53642. * Sets the global ambient color for the material used in lighting calculations.
  53643. */
  53644. private _globalAmbientColor;
  53645. /**
  53646. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53647. */
  53648. private _useLogarithmicDepth;
  53649. /**
  53650. * If set to true, no lighting calculations will be applied.
  53651. */
  53652. private _unlit;
  53653. private _debugMode;
  53654. /**
  53655. * @hidden
  53656. * This is reserved for the inspector.
  53657. * Defines the material debug mode.
  53658. * It helps seeing only some components of the material while troubleshooting.
  53659. */
  53660. debugMode: number;
  53661. /**
  53662. * @hidden
  53663. * This is reserved for the inspector.
  53664. * Specify from where on screen the debug mode should start.
  53665. * The value goes from -1 (full screen) to 1 (not visible)
  53666. * It helps with side by side comparison against the final render
  53667. * This defaults to -1
  53668. */
  53669. private debugLimit;
  53670. /**
  53671. * @hidden
  53672. * This is reserved for the inspector.
  53673. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53674. * You can use the factor to better multiply the final value.
  53675. */
  53676. private debugFactor;
  53677. /**
  53678. * Defines the clear coat layer parameters for the material.
  53679. */
  53680. readonly clearCoat: PBRClearCoatConfiguration;
  53681. /**
  53682. * Defines the anisotropic parameters for the material.
  53683. */
  53684. readonly anisotropy: PBRAnisotropicConfiguration;
  53685. /**
  53686. * Defines the BRDF parameters for the material.
  53687. */
  53688. readonly brdf: PBRBRDFConfiguration;
  53689. /**
  53690. * Defines the Sheen parameters for the material.
  53691. */
  53692. readonly sheen: PBRSheenConfiguration;
  53693. /**
  53694. * Defines the SubSurface parameters for the material.
  53695. */
  53696. readonly subSurface: PBRSubSurfaceConfiguration;
  53697. /**
  53698. * Custom callback helping to override the default shader used in the material.
  53699. */
  53700. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53701. protected _rebuildInParallel: boolean;
  53702. /**
  53703. * Instantiates a new PBRMaterial instance.
  53704. *
  53705. * @param name The material name
  53706. * @param scene The scene the material will be use in.
  53707. */
  53708. constructor(name: string, scene: Scene);
  53709. /**
  53710. * Gets a boolean indicating that current material needs to register RTT
  53711. */
  53712. get hasRenderTargetTextures(): boolean;
  53713. /**
  53714. * Gets the name of the material class.
  53715. */
  53716. getClassName(): string;
  53717. /**
  53718. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53719. */
  53720. get useLogarithmicDepth(): boolean;
  53721. /**
  53722. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53723. */
  53724. set useLogarithmicDepth(value: boolean);
  53725. /**
  53726. * Gets the current transparency mode.
  53727. */
  53728. get transparencyMode(): Nullable<number>;
  53729. /**
  53730. * Sets the transparency mode of the material.
  53731. *
  53732. * | Value | Type | Description |
  53733. * | ----- | ----------------------------------- | ----------- |
  53734. * | 0 | OPAQUE | |
  53735. * | 1 | ALPHATEST | |
  53736. * | 2 | ALPHABLEND | |
  53737. * | 3 | ALPHATESTANDBLEND | |
  53738. *
  53739. */
  53740. set transparencyMode(value: Nullable<number>);
  53741. /**
  53742. * Returns true if alpha blending should be disabled.
  53743. */
  53744. private get _disableAlphaBlending();
  53745. /**
  53746. * Specifies whether or not this material should be rendered in alpha blend mode.
  53747. */
  53748. needAlphaBlending(): boolean;
  53749. /**
  53750. * Specifies if the mesh will require alpha blending.
  53751. * @param mesh - BJS mesh.
  53752. */
  53753. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53754. /**
  53755. * Specifies whether or not this material should be rendered in alpha test mode.
  53756. */
  53757. needAlphaTesting(): boolean;
  53758. /**
  53759. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53760. */
  53761. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53762. /**
  53763. * Gets the texture used for the alpha test.
  53764. */
  53765. getAlphaTestTexture(): Nullable<BaseTexture>;
  53766. /**
  53767. * Specifies that the submesh is ready to be used.
  53768. * @param mesh - BJS mesh.
  53769. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53770. * @param useInstances - Specifies that instances should be used.
  53771. * @returns - boolean indicating that the submesh is ready or not.
  53772. */
  53773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53774. /**
  53775. * Specifies if the material uses metallic roughness workflow.
  53776. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53777. */
  53778. isMetallicWorkflow(): boolean;
  53779. private _prepareEffect;
  53780. private _prepareDefines;
  53781. /**
  53782. * Force shader compilation
  53783. */
  53784. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53785. /**
  53786. * Initializes the uniform buffer layout for the shader.
  53787. */
  53788. buildUniformLayout(): void;
  53789. /**
  53790. * Unbinds the material from the mesh
  53791. */
  53792. unbind(): void;
  53793. /**
  53794. * Binds the submesh data.
  53795. * @param world - The world matrix.
  53796. * @param mesh - The BJS mesh.
  53797. * @param subMesh - A submesh of the BJS mesh.
  53798. */
  53799. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53800. /**
  53801. * Returns the animatable textures.
  53802. * @returns - Array of animatable textures.
  53803. */
  53804. getAnimatables(): IAnimatable[];
  53805. /**
  53806. * Returns the texture used for reflections.
  53807. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53808. */
  53809. private _getReflectionTexture;
  53810. /**
  53811. * Returns an array of the actively used textures.
  53812. * @returns - Array of BaseTextures
  53813. */
  53814. getActiveTextures(): BaseTexture[];
  53815. /**
  53816. * Checks to see if a texture is used in the material.
  53817. * @param texture - Base texture to use.
  53818. * @returns - Boolean specifying if a texture is used in the material.
  53819. */
  53820. hasTexture(texture: BaseTexture): boolean;
  53821. /**
  53822. * Disposes the resources of the material.
  53823. * @param forceDisposeEffect - Forces the disposal of effects.
  53824. * @param forceDisposeTextures - Forces the disposal of all textures.
  53825. */
  53826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53827. }
  53828. }
  53829. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53830. import { Nullable } from "babylonjs/types";
  53831. import { Scene } from "babylonjs/scene";
  53832. import { Color3 } from "babylonjs/Maths/math.color";
  53833. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53834. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53835. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53836. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53837. /**
  53838. * The Physically based material of BJS.
  53839. *
  53840. * This offers the main features of a standard PBR material.
  53841. * For more information, please refer to the documentation :
  53842. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53843. */
  53844. export class PBRMaterial extends PBRBaseMaterial {
  53845. /**
  53846. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53847. */
  53848. static readonly PBRMATERIAL_OPAQUE: number;
  53849. /**
  53850. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53851. */
  53852. static readonly PBRMATERIAL_ALPHATEST: number;
  53853. /**
  53854. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53855. */
  53856. static readonly PBRMATERIAL_ALPHABLEND: number;
  53857. /**
  53858. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53859. * They are also discarded below the alpha cutoff threshold to improve performances.
  53860. */
  53861. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53862. /**
  53863. * Defines the default value of how much AO map is occluding the analytical lights
  53864. * (point spot...).
  53865. */
  53866. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53867. /**
  53868. * Intensity of the direct lights e.g. the four lights available in your scene.
  53869. * This impacts both the direct diffuse and specular highlights.
  53870. */
  53871. directIntensity: number;
  53872. /**
  53873. * Intensity of the emissive part of the material.
  53874. * This helps controlling the emissive effect without modifying the emissive color.
  53875. */
  53876. emissiveIntensity: number;
  53877. /**
  53878. * Intensity of the environment e.g. how much the environment will light the object
  53879. * either through harmonics for rough material or through the refelction for shiny ones.
  53880. */
  53881. environmentIntensity: number;
  53882. /**
  53883. * This is a special control allowing the reduction of the specular highlights coming from the
  53884. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53885. */
  53886. specularIntensity: number;
  53887. /**
  53888. * Debug Control allowing disabling the bump map on this material.
  53889. */
  53890. disableBumpMap: boolean;
  53891. /**
  53892. * AKA Diffuse Texture in standard nomenclature.
  53893. */
  53894. albedoTexture: BaseTexture;
  53895. /**
  53896. * AKA Occlusion Texture in other nomenclature.
  53897. */
  53898. ambientTexture: BaseTexture;
  53899. /**
  53900. * AKA Occlusion Texture Intensity in other nomenclature.
  53901. */
  53902. ambientTextureStrength: number;
  53903. /**
  53904. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53905. * 1 means it completely occludes it
  53906. * 0 mean it has no impact
  53907. */
  53908. ambientTextureImpactOnAnalyticalLights: number;
  53909. /**
  53910. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53911. */
  53912. opacityTexture: BaseTexture;
  53913. /**
  53914. * Stores the reflection values in a texture.
  53915. */
  53916. reflectionTexture: Nullable<BaseTexture>;
  53917. /**
  53918. * Stores the emissive values in a texture.
  53919. */
  53920. emissiveTexture: BaseTexture;
  53921. /**
  53922. * AKA Specular texture in other nomenclature.
  53923. */
  53924. reflectivityTexture: BaseTexture;
  53925. /**
  53926. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53927. */
  53928. metallicTexture: BaseTexture;
  53929. /**
  53930. * Specifies the metallic scalar of the metallic/roughness workflow.
  53931. * Can also be used to scale the metalness values of the metallic texture.
  53932. */
  53933. metallic: Nullable<number>;
  53934. /**
  53935. * Specifies the roughness scalar of the metallic/roughness workflow.
  53936. * Can also be used to scale the roughness values of the metallic texture.
  53937. */
  53938. roughness: Nullable<number>;
  53939. /**
  53940. * Specifies the an F0 factor to help configuring the material F0.
  53941. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53942. * to 0.5 the previously hard coded value stays the same.
  53943. * Can also be used to scale the F0 values of the metallic texture.
  53944. */
  53945. metallicF0Factor: number;
  53946. /**
  53947. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53948. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53949. * your expectation as it multiplies with the texture data.
  53950. */
  53951. useMetallicF0FactorFromMetallicTexture: boolean;
  53952. /**
  53953. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53954. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53955. */
  53956. microSurfaceTexture: BaseTexture;
  53957. /**
  53958. * Stores surface normal data used to displace a mesh in a texture.
  53959. */
  53960. bumpTexture: BaseTexture;
  53961. /**
  53962. * Stores the pre-calculated light information of a mesh in a texture.
  53963. */
  53964. lightmapTexture: BaseTexture;
  53965. /**
  53966. * Stores the refracted light information in a texture.
  53967. */
  53968. get refractionTexture(): Nullable<BaseTexture>;
  53969. set refractionTexture(value: Nullable<BaseTexture>);
  53970. /**
  53971. * The color of a material in ambient lighting.
  53972. */
  53973. ambientColor: Color3;
  53974. /**
  53975. * AKA Diffuse Color in other nomenclature.
  53976. */
  53977. albedoColor: Color3;
  53978. /**
  53979. * AKA Specular Color in other nomenclature.
  53980. */
  53981. reflectivityColor: Color3;
  53982. /**
  53983. * The color reflected from the material.
  53984. */
  53985. reflectionColor: Color3;
  53986. /**
  53987. * The color emitted from the material.
  53988. */
  53989. emissiveColor: Color3;
  53990. /**
  53991. * AKA Glossiness in other nomenclature.
  53992. */
  53993. microSurface: number;
  53994. /**
  53995. * source material index of refraction (IOR)' / 'destination material IOR.
  53996. */
  53997. get indexOfRefraction(): number;
  53998. set indexOfRefraction(value: number);
  53999. /**
  54000. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54001. */
  54002. get invertRefractionY(): boolean;
  54003. set invertRefractionY(value: boolean);
  54004. /**
  54005. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54006. * Materials half opaque for instance using refraction could benefit from this control.
  54007. */
  54008. get linkRefractionWithTransparency(): boolean;
  54009. set linkRefractionWithTransparency(value: boolean);
  54010. /**
  54011. * If true, the light map contains occlusion information instead of lighting info.
  54012. */
  54013. useLightmapAsShadowmap: boolean;
  54014. /**
  54015. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54016. */
  54017. useAlphaFromAlbedoTexture: boolean;
  54018. /**
  54019. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54020. */
  54021. forceAlphaTest: boolean;
  54022. /**
  54023. * Defines the alpha limits in alpha test mode.
  54024. */
  54025. alphaCutOff: number;
  54026. /**
  54027. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54028. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54029. */
  54030. useSpecularOverAlpha: boolean;
  54031. /**
  54032. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54033. */
  54034. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54035. /**
  54036. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54037. */
  54038. useRoughnessFromMetallicTextureAlpha: boolean;
  54039. /**
  54040. * Specifies if the metallic texture contains the roughness information in its green channel.
  54041. */
  54042. useRoughnessFromMetallicTextureGreen: boolean;
  54043. /**
  54044. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54045. */
  54046. useMetallnessFromMetallicTextureBlue: boolean;
  54047. /**
  54048. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54049. */
  54050. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54051. /**
  54052. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54053. */
  54054. useAmbientInGrayScale: boolean;
  54055. /**
  54056. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54057. * The material will try to infer what glossiness each pixel should be.
  54058. */
  54059. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54060. /**
  54061. * BJS is using an harcoded light falloff based on a manually sets up range.
  54062. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54063. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54064. */
  54065. get usePhysicalLightFalloff(): boolean;
  54066. /**
  54067. * BJS is using an harcoded light falloff based on a manually sets up range.
  54068. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54069. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54070. */
  54071. set usePhysicalLightFalloff(value: boolean);
  54072. /**
  54073. * In order to support the falloff compatibility with gltf, a special mode has been added
  54074. * to reproduce the gltf light falloff.
  54075. */
  54076. get useGLTFLightFalloff(): boolean;
  54077. /**
  54078. * In order to support the falloff compatibility with gltf, a special mode has been added
  54079. * to reproduce the gltf light falloff.
  54080. */
  54081. set useGLTFLightFalloff(value: boolean);
  54082. /**
  54083. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54084. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54085. */
  54086. useRadianceOverAlpha: boolean;
  54087. /**
  54088. * Allows using an object space normal map (instead of tangent space).
  54089. */
  54090. useObjectSpaceNormalMap: boolean;
  54091. /**
  54092. * Allows using the bump map in parallax mode.
  54093. */
  54094. useParallax: boolean;
  54095. /**
  54096. * Allows using the bump map in parallax occlusion mode.
  54097. */
  54098. useParallaxOcclusion: boolean;
  54099. /**
  54100. * Controls the scale bias of the parallax mode.
  54101. */
  54102. parallaxScaleBias: number;
  54103. /**
  54104. * If sets to true, disables all the lights affecting the material.
  54105. */
  54106. disableLighting: boolean;
  54107. /**
  54108. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54109. */
  54110. forceIrradianceInFragment: boolean;
  54111. /**
  54112. * Number of Simultaneous lights allowed on the material.
  54113. */
  54114. maxSimultaneousLights: number;
  54115. /**
  54116. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54117. */
  54118. invertNormalMapX: boolean;
  54119. /**
  54120. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54121. */
  54122. invertNormalMapY: boolean;
  54123. /**
  54124. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54125. */
  54126. twoSidedLighting: boolean;
  54127. /**
  54128. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54129. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54130. */
  54131. useAlphaFresnel: boolean;
  54132. /**
  54133. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54134. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54135. */
  54136. useLinearAlphaFresnel: boolean;
  54137. /**
  54138. * Let user defines the brdf lookup texture used for IBL.
  54139. * A default 8bit version is embedded but you could point at :
  54140. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54141. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54142. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54143. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54144. */
  54145. environmentBRDFTexture: Nullable<BaseTexture>;
  54146. /**
  54147. * Force normal to face away from face.
  54148. */
  54149. forceNormalForward: boolean;
  54150. /**
  54151. * Enables specular anti aliasing in the PBR shader.
  54152. * It will both interacts on the Geometry for analytical and IBL lighting.
  54153. * It also prefilter the roughness map based on the bump values.
  54154. */
  54155. enableSpecularAntiAliasing: boolean;
  54156. /**
  54157. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54158. * makes the reflect vector face the model (under horizon).
  54159. */
  54160. useHorizonOcclusion: boolean;
  54161. /**
  54162. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54163. * too much the area relying on ambient texture to define their ambient occlusion.
  54164. */
  54165. useRadianceOcclusion: boolean;
  54166. /**
  54167. * If set to true, no lighting calculations will be applied.
  54168. */
  54169. unlit: boolean;
  54170. /**
  54171. * Gets the image processing configuration used either in this material.
  54172. */
  54173. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54174. /**
  54175. * Sets the Default image processing configuration used either in the this material.
  54176. *
  54177. * If sets to null, the scene one is in use.
  54178. */
  54179. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54180. /**
  54181. * Gets wether the color curves effect is enabled.
  54182. */
  54183. get cameraColorCurvesEnabled(): boolean;
  54184. /**
  54185. * Sets wether the color curves effect is enabled.
  54186. */
  54187. set cameraColorCurvesEnabled(value: boolean);
  54188. /**
  54189. * Gets wether the color grading effect is enabled.
  54190. */
  54191. get cameraColorGradingEnabled(): boolean;
  54192. /**
  54193. * Gets wether the color grading effect is enabled.
  54194. */
  54195. set cameraColorGradingEnabled(value: boolean);
  54196. /**
  54197. * Gets wether tonemapping is enabled or not.
  54198. */
  54199. get cameraToneMappingEnabled(): boolean;
  54200. /**
  54201. * Sets wether tonemapping is enabled or not
  54202. */
  54203. set cameraToneMappingEnabled(value: boolean);
  54204. /**
  54205. * The camera exposure used on this material.
  54206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54207. * This corresponds to a photographic exposure.
  54208. */
  54209. get cameraExposure(): number;
  54210. /**
  54211. * The camera exposure used on this material.
  54212. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54213. * This corresponds to a photographic exposure.
  54214. */
  54215. set cameraExposure(value: number);
  54216. /**
  54217. * Gets The camera contrast used on this material.
  54218. */
  54219. get cameraContrast(): number;
  54220. /**
  54221. * Sets The camera contrast used on this material.
  54222. */
  54223. set cameraContrast(value: number);
  54224. /**
  54225. * Gets the Color Grading 2D Lookup Texture.
  54226. */
  54227. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54228. /**
  54229. * Sets the Color Grading 2D Lookup Texture.
  54230. */
  54231. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54232. /**
  54233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54235. * 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;
  54236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54237. */
  54238. get cameraColorCurves(): Nullable<ColorCurves>;
  54239. /**
  54240. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54241. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54242. * 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;
  54243. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54244. */
  54245. set cameraColorCurves(value: Nullable<ColorCurves>);
  54246. /**
  54247. * Instantiates a new PBRMaterial instance.
  54248. *
  54249. * @param name The material name
  54250. * @param scene The scene the material will be use in.
  54251. */
  54252. constructor(name: string, scene: Scene);
  54253. /**
  54254. * Returns the name of this material class.
  54255. */
  54256. getClassName(): string;
  54257. /**
  54258. * Makes a duplicate of the current material.
  54259. * @param name - name to use for the new material.
  54260. */
  54261. clone(name: string): PBRMaterial;
  54262. /**
  54263. * Serializes this PBR Material.
  54264. * @returns - An object with the serialized material.
  54265. */
  54266. serialize(): any;
  54267. /**
  54268. * Parses a PBR Material from a serialized object.
  54269. * @param source - Serialized object.
  54270. * @param scene - BJS scene instance.
  54271. * @param rootUrl - url for the scene object
  54272. * @returns - PBRMaterial
  54273. */
  54274. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54275. }
  54276. }
  54277. declare module "babylonjs/Misc/dds" {
  54278. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54280. import { Nullable } from "babylonjs/types";
  54281. import { Scene } from "babylonjs/scene";
  54282. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54283. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54284. /**
  54285. * Direct draw surface info
  54286. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54287. */
  54288. export interface DDSInfo {
  54289. /**
  54290. * Width of the texture
  54291. */
  54292. width: number;
  54293. /**
  54294. * Width of the texture
  54295. */
  54296. height: number;
  54297. /**
  54298. * Number of Mipmaps for the texture
  54299. * @see https://en.wikipedia.org/wiki/Mipmap
  54300. */
  54301. mipmapCount: number;
  54302. /**
  54303. * If the textures format is a known fourCC format
  54304. * @see https://www.fourcc.org/
  54305. */
  54306. isFourCC: boolean;
  54307. /**
  54308. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54309. */
  54310. isRGB: boolean;
  54311. /**
  54312. * If the texture is a lumincance format
  54313. */
  54314. isLuminance: boolean;
  54315. /**
  54316. * If this is a cube texture
  54317. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54318. */
  54319. isCube: boolean;
  54320. /**
  54321. * If the texture is a compressed format eg. FOURCC_DXT1
  54322. */
  54323. isCompressed: boolean;
  54324. /**
  54325. * The dxgiFormat of the texture
  54326. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54327. */
  54328. dxgiFormat: number;
  54329. /**
  54330. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54331. */
  54332. textureType: number;
  54333. /**
  54334. * Sphericle polynomial created for the dds texture
  54335. */
  54336. sphericalPolynomial?: SphericalPolynomial;
  54337. }
  54338. /**
  54339. * Class used to provide DDS decompression tools
  54340. */
  54341. export class DDSTools {
  54342. /**
  54343. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54344. */
  54345. static StoreLODInAlphaChannel: boolean;
  54346. /**
  54347. * Gets DDS information from an array buffer
  54348. * @param arrayBuffer defines the array buffer to read data from
  54349. * @returns the DDS information
  54350. */
  54351. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  54352. private static _FloatView;
  54353. private static _Int32View;
  54354. private static _ToHalfFloat;
  54355. private static _FromHalfFloat;
  54356. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54357. private static _GetHalfFloatRGBAArrayBuffer;
  54358. private static _GetFloatRGBAArrayBuffer;
  54359. private static _GetFloatAsUIntRGBAArrayBuffer;
  54360. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54361. private static _GetRGBAArrayBuffer;
  54362. private static _ExtractLongWordOrder;
  54363. private static _GetRGBArrayBuffer;
  54364. private static _GetLuminanceArrayBuffer;
  54365. /**
  54366. * Uploads DDS Levels to a Babylon Texture
  54367. * @hidden
  54368. */
  54369. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54370. }
  54371. module "babylonjs/Engines/thinEngine" {
  54372. interface ThinEngine {
  54373. /**
  54374. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54375. * @param rootUrl defines the url where the file to load is located
  54376. * @param scene defines the current scene
  54377. * @param lodScale defines scale to apply to the mip map selection
  54378. * @param lodOffset defines offset to apply to the mip map selection
  54379. * @param onLoad defines an optional callback raised when the texture is loaded
  54380. * @param onError defines an optional callback raised if there is an issue to load the texture
  54381. * @param format defines the format of the data
  54382. * @param forcedExtension defines the extension to use to pick the right loader
  54383. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54384. * @returns the cube texture as an InternalTexture
  54385. */
  54386. 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;
  54387. }
  54388. }
  54389. }
  54390. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54391. import { Nullable } from "babylonjs/types";
  54392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54393. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54394. /**
  54395. * Implementation of the DDS Texture Loader.
  54396. * @hidden
  54397. */
  54398. export class _DDSTextureLoader implements IInternalTextureLoader {
  54399. /**
  54400. * Defines wether the loader supports cascade loading the different faces.
  54401. */
  54402. readonly supportCascades: boolean;
  54403. /**
  54404. * This returns if the loader support the current file information.
  54405. * @param extension defines the file extension of the file being loaded
  54406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54407. * @param fallback defines the fallback internal texture if any
  54408. * @param isBase64 defines whether the texture is encoded as a base64
  54409. * @param isBuffer defines whether the texture data are stored as a buffer
  54410. * @returns true if the loader can load the specified file
  54411. */
  54412. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54413. /**
  54414. * Transform the url before loading if required.
  54415. * @param rootUrl the url of the texture
  54416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54417. * @returns the transformed texture
  54418. */
  54419. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54420. /**
  54421. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54422. * @param rootUrl the url of the texture
  54423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54424. * @returns the fallback texture
  54425. */
  54426. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54427. /**
  54428. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54429. * @param data contains the texture data
  54430. * @param texture defines the BabylonJS internal texture
  54431. * @param createPolynomials will be true if polynomials have been requested
  54432. * @param onLoad defines the callback to trigger once the texture is ready
  54433. * @param onError defines the callback to trigger in case of error
  54434. */
  54435. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54436. /**
  54437. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54438. * @param data contains the texture data
  54439. * @param texture defines the BabylonJS internal texture
  54440. * @param callback defines the method to call once ready to upload
  54441. */
  54442. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54443. }
  54444. }
  54445. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54446. import { Nullable } from "babylonjs/types";
  54447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54448. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54449. /**
  54450. * Implementation of the ENV Texture Loader.
  54451. * @hidden
  54452. */
  54453. export class _ENVTextureLoader implements IInternalTextureLoader {
  54454. /**
  54455. * Defines wether the loader supports cascade loading the different faces.
  54456. */
  54457. readonly supportCascades: boolean;
  54458. /**
  54459. * This returns if the loader support the current file information.
  54460. * @param extension defines the file extension of the file being loaded
  54461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54462. * @param fallback defines the fallback internal texture if any
  54463. * @param isBase64 defines whether the texture is encoded as a base64
  54464. * @param isBuffer defines whether the texture data are stored as a buffer
  54465. * @returns true if the loader can load the specified file
  54466. */
  54467. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54468. /**
  54469. * Transform the url before loading if required.
  54470. * @param rootUrl the url of the texture
  54471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54472. * @returns the transformed texture
  54473. */
  54474. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54475. /**
  54476. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54477. * @param rootUrl the url of the texture
  54478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54479. * @returns the fallback texture
  54480. */
  54481. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54482. /**
  54483. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54484. * @param data contains the texture data
  54485. * @param texture defines the BabylonJS internal texture
  54486. * @param createPolynomials will be true if polynomials have been requested
  54487. * @param onLoad defines the callback to trigger once the texture is ready
  54488. * @param onError defines the callback to trigger in case of error
  54489. */
  54490. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54491. /**
  54492. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54493. * @param data contains the texture data
  54494. * @param texture defines the BabylonJS internal texture
  54495. * @param callback defines the method to call once ready to upload
  54496. */
  54497. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54498. }
  54499. }
  54500. declare module "babylonjs/Misc/khronosTextureContainer" {
  54501. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54502. /**
  54503. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54504. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54505. */
  54506. export class KhronosTextureContainer {
  54507. /** contents of the KTX container file */
  54508. arrayBuffer: any;
  54509. private static HEADER_LEN;
  54510. private static COMPRESSED_2D;
  54511. private static COMPRESSED_3D;
  54512. private static TEX_2D;
  54513. private static TEX_3D;
  54514. /**
  54515. * Gets the openGL type
  54516. */
  54517. glType: number;
  54518. /**
  54519. * Gets the openGL type size
  54520. */
  54521. glTypeSize: number;
  54522. /**
  54523. * Gets the openGL format
  54524. */
  54525. glFormat: number;
  54526. /**
  54527. * Gets the openGL internal format
  54528. */
  54529. glInternalFormat: number;
  54530. /**
  54531. * Gets the base internal format
  54532. */
  54533. glBaseInternalFormat: number;
  54534. /**
  54535. * Gets image width in pixel
  54536. */
  54537. pixelWidth: number;
  54538. /**
  54539. * Gets image height in pixel
  54540. */
  54541. pixelHeight: number;
  54542. /**
  54543. * Gets image depth in pixels
  54544. */
  54545. pixelDepth: number;
  54546. /**
  54547. * Gets the number of array elements
  54548. */
  54549. numberOfArrayElements: number;
  54550. /**
  54551. * Gets the number of faces
  54552. */
  54553. numberOfFaces: number;
  54554. /**
  54555. * Gets the number of mipmap levels
  54556. */
  54557. numberOfMipmapLevels: number;
  54558. /**
  54559. * Gets the bytes of key value data
  54560. */
  54561. bytesOfKeyValueData: number;
  54562. /**
  54563. * Gets the load type
  54564. */
  54565. loadType: number;
  54566. /**
  54567. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54568. */
  54569. isInvalid: boolean;
  54570. /**
  54571. * Creates a new KhronosTextureContainer
  54572. * @param arrayBuffer contents of the KTX container file
  54573. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54574. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54575. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54576. */
  54577. constructor(
  54578. /** contents of the KTX container file */
  54579. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54580. /**
  54581. * Uploads KTX content to a Babylon Texture.
  54582. * It is assumed that the texture has already been created & is currently bound
  54583. * @hidden
  54584. */
  54585. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54586. private _upload2DCompressedLevels;
  54587. }
  54588. }
  54589. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54590. import { Nullable } from "babylonjs/types";
  54591. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54592. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54593. /**
  54594. * Implementation of the KTX Texture Loader.
  54595. * @hidden
  54596. */
  54597. export class _KTXTextureLoader implements IInternalTextureLoader {
  54598. /**
  54599. * Defines wether the loader supports cascade loading the different faces.
  54600. */
  54601. readonly supportCascades: boolean;
  54602. /**
  54603. * This returns if the loader support the current file information.
  54604. * @param extension defines the file extension of the file being loaded
  54605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54606. * @param fallback defines the fallback internal texture if any
  54607. * @param isBase64 defines whether the texture is encoded as a base64
  54608. * @param isBuffer defines whether the texture data are stored as a buffer
  54609. * @returns true if the loader can load the specified file
  54610. */
  54611. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54612. /**
  54613. * Transform the url before loading if required.
  54614. * @param rootUrl the url of the texture
  54615. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54616. * @returns the transformed texture
  54617. */
  54618. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54619. /**
  54620. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54621. * @param rootUrl the url of the texture
  54622. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54623. * @returns the fallback texture
  54624. */
  54625. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54626. /**
  54627. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54628. * @param data contains the texture data
  54629. * @param texture defines the BabylonJS internal texture
  54630. * @param createPolynomials will be true if polynomials have been requested
  54631. * @param onLoad defines the callback to trigger once the texture is ready
  54632. * @param onError defines the callback to trigger in case of error
  54633. */
  54634. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54635. /**
  54636. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54637. * @param data contains the texture data
  54638. * @param texture defines the BabylonJS internal texture
  54639. * @param callback defines the method to call once ready to upload
  54640. */
  54641. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54642. }
  54643. }
  54644. declare module "babylonjs/Helpers/sceneHelpers" {
  54645. import { Nullable } from "babylonjs/types";
  54646. import { Mesh } from "babylonjs/Meshes/mesh";
  54647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54648. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54649. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54650. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54651. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54652. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54653. import "babylonjs/Meshes/Builders/boxBuilder";
  54654. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  54655. /** @hidden */
  54656. export var _forceSceneHelpersToBundle: boolean;
  54657. module "babylonjs/scene" {
  54658. interface Scene {
  54659. /**
  54660. * Creates a default light for the scene.
  54661. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54662. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54663. */
  54664. createDefaultLight(replace?: boolean): void;
  54665. /**
  54666. * Creates a default camera for the scene.
  54667. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54668. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54669. * @param replace has default false, when true replaces the active camera in the scene
  54670. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54671. */
  54672. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54673. /**
  54674. * Creates a default camera and a default light.
  54675. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54676. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54677. * @param replace has the default false, when true replaces the active camera/light in the scene
  54678. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54679. */
  54680. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54681. /**
  54682. * Creates a new sky box
  54683. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54684. * @param environmentTexture defines the texture to use as environment texture
  54685. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54686. * @param scale defines the overall scale of the skybox
  54687. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54688. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54689. * @returns a new mesh holding the sky box
  54690. */
  54691. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54692. /**
  54693. * Creates a new environment
  54694. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54695. * @param options defines the options you can use to configure the environment
  54696. * @returns the new EnvironmentHelper
  54697. */
  54698. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54699. /**
  54700. * Creates a new VREXperienceHelper
  54701. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54702. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54703. * @returns a new VREXperienceHelper
  54704. */
  54705. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54706. /**
  54707. * Creates a new WebXRDefaultExperience
  54708. * @see http://doc.babylonjs.com/how_to/webxr
  54709. * @param options experience options
  54710. * @returns a promise for a new WebXRDefaultExperience
  54711. */
  54712. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54713. }
  54714. }
  54715. }
  54716. declare module "babylonjs/Helpers/videoDome" {
  54717. import { Scene } from "babylonjs/scene";
  54718. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54719. import { Mesh } from "babylonjs/Meshes/mesh";
  54720. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54721. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54722. import "babylonjs/Meshes/Builders/sphereBuilder";
  54723. /**
  54724. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54725. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54726. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54727. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54728. */
  54729. export class VideoDome extends TransformNode {
  54730. /**
  54731. * Define the video source as a Monoscopic panoramic 360 video.
  54732. */
  54733. static readonly MODE_MONOSCOPIC: number;
  54734. /**
  54735. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54736. */
  54737. static readonly MODE_TOPBOTTOM: number;
  54738. /**
  54739. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54740. */
  54741. static readonly MODE_SIDEBYSIDE: number;
  54742. private _halfDome;
  54743. private _useDirectMapping;
  54744. /**
  54745. * The video texture being displayed on the sphere
  54746. */
  54747. protected _videoTexture: VideoTexture;
  54748. /**
  54749. * Gets the video texture being displayed on the sphere
  54750. */
  54751. get videoTexture(): VideoTexture;
  54752. /**
  54753. * The skybox material
  54754. */
  54755. protected _material: BackgroundMaterial;
  54756. /**
  54757. * The surface used for the skybox
  54758. */
  54759. protected _mesh: Mesh;
  54760. /**
  54761. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54762. */
  54763. private _halfDomeMask;
  54764. /**
  54765. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54766. * Also see the options.resolution property.
  54767. */
  54768. get fovMultiplier(): number;
  54769. set fovMultiplier(value: number);
  54770. private _videoMode;
  54771. /**
  54772. * Gets or set the current video mode for the video. It can be:
  54773. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54774. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54775. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54776. */
  54777. get videoMode(): number;
  54778. set videoMode(value: number);
  54779. /**
  54780. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54781. *
  54782. */
  54783. get halfDome(): boolean;
  54784. /**
  54785. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54786. */
  54787. set halfDome(enabled: boolean);
  54788. /**
  54789. * Oberserver used in Stereoscopic VR Mode.
  54790. */
  54791. private _onBeforeCameraRenderObserver;
  54792. /**
  54793. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54794. * @param name Element's name, child elements will append suffixes for their own names.
  54795. * @param urlsOrVideo defines the url(s) or the video element to use
  54796. * @param options An object containing optional or exposed sub element properties
  54797. */
  54798. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54799. resolution?: number;
  54800. clickToPlay?: boolean;
  54801. autoPlay?: boolean;
  54802. loop?: boolean;
  54803. size?: number;
  54804. poster?: string;
  54805. faceForward?: boolean;
  54806. useDirectMapping?: boolean;
  54807. halfDomeMode?: boolean;
  54808. }, scene: Scene);
  54809. private _changeVideoMode;
  54810. /**
  54811. * Releases resources associated with this node.
  54812. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54813. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54814. */
  54815. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54816. }
  54817. }
  54818. declare module "babylonjs/Helpers/index" {
  54819. export * from "babylonjs/Helpers/environmentHelper";
  54820. export * from "babylonjs/Helpers/photoDome";
  54821. export * from "babylonjs/Helpers/sceneHelpers";
  54822. export * from "babylonjs/Helpers/videoDome";
  54823. }
  54824. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54825. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54826. import { IDisposable } from "babylonjs/scene";
  54827. import { Engine } from "babylonjs/Engines/engine";
  54828. /**
  54829. * This class can be used to get instrumentation data from a Babylon engine
  54830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54831. */
  54832. export class EngineInstrumentation implements IDisposable {
  54833. /**
  54834. * Define the instrumented engine.
  54835. */
  54836. engine: Engine;
  54837. private _captureGPUFrameTime;
  54838. private _gpuFrameTimeToken;
  54839. private _gpuFrameTime;
  54840. private _captureShaderCompilationTime;
  54841. private _shaderCompilationTime;
  54842. private _onBeginFrameObserver;
  54843. private _onEndFrameObserver;
  54844. private _onBeforeShaderCompilationObserver;
  54845. private _onAfterShaderCompilationObserver;
  54846. /**
  54847. * Gets the perf counter used for GPU frame time
  54848. */
  54849. get gpuFrameTimeCounter(): PerfCounter;
  54850. /**
  54851. * Gets the GPU frame time capture status
  54852. */
  54853. get captureGPUFrameTime(): boolean;
  54854. /**
  54855. * Enable or disable the GPU frame time capture
  54856. */
  54857. set captureGPUFrameTime(value: boolean);
  54858. /**
  54859. * Gets the perf counter used for shader compilation time
  54860. */
  54861. get shaderCompilationTimeCounter(): PerfCounter;
  54862. /**
  54863. * Gets the shader compilation time capture status
  54864. */
  54865. get captureShaderCompilationTime(): boolean;
  54866. /**
  54867. * Enable or disable the shader compilation time capture
  54868. */
  54869. set captureShaderCompilationTime(value: boolean);
  54870. /**
  54871. * Instantiates a new engine instrumentation.
  54872. * This class can be used to get instrumentation data from a Babylon engine
  54873. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54874. * @param engine Defines the engine to instrument
  54875. */
  54876. constructor(
  54877. /**
  54878. * Define the instrumented engine.
  54879. */
  54880. engine: Engine);
  54881. /**
  54882. * Dispose and release associated resources.
  54883. */
  54884. dispose(): void;
  54885. }
  54886. }
  54887. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54888. import { Scene, IDisposable } from "babylonjs/scene";
  54889. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54890. /**
  54891. * This class can be used to get instrumentation data from a Babylon engine
  54892. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54893. */
  54894. export class SceneInstrumentation implements IDisposable {
  54895. /**
  54896. * Defines the scene to instrument
  54897. */
  54898. scene: Scene;
  54899. private _captureActiveMeshesEvaluationTime;
  54900. private _activeMeshesEvaluationTime;
  54901. private _captureRenderTargetsRenderTime;
  54902. private _renderTargetsRenderTime;
  54903. private _captureFrameTime;
  54904. private _frameTime;
  54905. private _captureRenderTime;
  54906. private _renderTime;
  54907. private _captureInterFrameTime;
  54908. private _interFrameTime;
  54909. private _captureParticlesRenderTime;
  54910. private _particlesRenderTime;
  54911. private _captureSpritesRenderTime;
  54912. private _spritesRenderTime;
  54913. private _capturePhysicsTime;
  54914. private _physicsTime;
  54915. private _captureAnimationsTime;
  54916. private _animationsTime;
  54917. private _captureCameraRenderTime;
  54918. private _cameraRenderTime;
  54919. private _onBeforeActiveMeshesEvaluationObserver;
  54920. private _onAfterActiveMeshesEvaluationObserver;
  54921. private _onBeforeRenderTargetsRenderObserver;
  54922. private _onAfterRenderTargetsRenderObserver;
  54923. private _onAfterRenderObserver;
  54924. private _onBeforeDrawPhaseObserver;
  54925. private _onAfterDrawPhaseObserver;
  54926. private _onBeforeAnimationsObserver;
  54927. private _onBeforeParticlesRenderingObserver;
  54928. private _onAfterParticlesRenderingObserver;
  54929. private _onBeforeSpritesRenderingObserver;
  54930. private _onAfterSpritesRenderingObserver;
  54931. private _onBeforePhysicsObserver;
  54932. private _onAfterPhysicsObserver;
  54933. private _onAfterAnimationsObserver;
  54934. private _onBeforeCameraRenderObserver;
  54935. private _onAfterCameraRenderObserver;
  54936. /**
  54937. * Gets the perf counter used for active meshes evaluation time
  54938. */
  54939. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54940. /**
  54941. * Gets the active meshes evaluation time capture status
  54942. */
  54943. get captureActiveMeshesEvaluationTime(): boolean;
  54944. /**
  54945. * Enable or disable the active meshes evaluation time capture
  54946. */
  54947. set captureActiveMeshesEvaluationTime(value: boolean);
  54948. /**
  54949. * Gets the perf counter used for render targets render time
  54950. */
  54951. get renderTargetsRenderTimeCounter(): PerfCounter;
  54952. /**
  54953. * Gets the render targets render time capture status
  54954. */
  54955. get captureRenderTargetsRenderTime(): boolean;
  54956. /**
  54957. * Enable or disable the render targets render time capture
  54958. */
  54959. set captureRenderTargetsRenderTime(value: boolean);
  54960. /**
  54961. * Gets the perf counter used for particles render time
  54962. */
  54963. get particlesRenderTimeCounter(): PerfCounter;
  54964. /**
  54965. * Gets the particles render time capture status
  54966. */
  54967. get captureParticlesRenderTime(): boolean;
  54968. /**
  54969. * Enable or disable the particles render time capture
  54970. */
  54971. set captureParticlesRenderTime(value: boolean);
  54972. /**
  54973. * Gets the perf counter used for sprites render time
  54974. */
  54975. get spritesRenderTimeCounter(): PerfCounter;
  54976. /**
  54977. * Gets the sprites render time capture status
  54978. */
  54979. get captureSpritesRenderTime(): boolean;
  54980. /**
  54981. * Enable or disable the sprites render time capture
  54982. */
  54983. set captureSpritesRenderTime(value: boolean);
  54984. /**
  54985. * Gets the perf counter used for physics time
  54986. */
  54987. get physicsTimeCounter(): PerfCounter;
  54988. /**
  54989. * Gets the physics time capture status
  54990. */
  54991. get capturePhysicsTime(): boolean;
  54992. /**
  54993. * Enable or disable the physics time capture
  54994. */
  54995. set capturePhysicsTime(value: boolean);
  54996. /**
  54997. * Gets the perf counter used for animations time
  54998. */
  54999. get animationsTimeCounter(): PerfCounter;
  55000. /**
  55001. * Gets the animations time capture status
  55002. */
  55003. get captureAnimationsTime(): boolean;
  55004. /**
  55005. * Enable or disable the animations time capture
  55006. */
  55007. set captureAnimationsTime(value: boolean);
  55008. /**
  55009. * Gets the perf counter used for frame time capture
  55010. */
  55011. get frameTimeCounter(): PerfCounter;
  55012. /**
  55013. * Gets the frame time capture status
  55014. */
  55015. get captureFrameTime(): boolean;
  55016. /**
  55017. * Enable or disable the frame time capture
  55018. */
  55019. set captureFrameTime(value: boolean);
  55020. /**
  55021. * Gets the perf counter used for inter-frames time capture
  55022. */
  55023. get interFrameTimeCounter(): PerfCounter;
  55024. /**
  55025. * Gets the inter-frames time capture status
  55026. */
  55027. get captureInterFrameTime(): boolean;
  55028. /**
  55029. * Enable or disable the inter-frames time capture
  55030. */
  55031. set captureInterFrameTime(value: boolean);
  55032. /**
  55033. * Gets the perf counter used for render time capture
  55034. */
  55035. get renderTimeCounter(): PerfCounter;
  55036. /**
  55037. * Gets the render time capture status
  55038. */
  55039. get captureRenderTime(): boolean;
  55040. /**
  55041. * Enable or disable the render time capture
  55042. */
  55043. set captureRenderTime(value: boolean);
  55044. /**
  55045. * Gets the perf counter used for camera render time capture
  55046. */
  55047. get cameraRenderTimeCounter(): PerfCounter;
  55048. /**
  55049. * Gets the camera render time capture status
  55050. */
  55051. get captureCameraRenderTime(): boolean;
  55052. /**
  55053. * Enable or disable the camera render time capture
  55054. */
  55055. set captureCameraRenderTime(value: boolean);
  55056. /**
  55057. * Gets the perf counter used for draw calls
  55058. */
  55059. get drawCallsCounter(): PerfCounter;
  55060. /**
  55061. * Instantiates a new scene instrumentation.
  55062. * This class can be used to get instrumentation data from a Babylon engine
  55063. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55064. * @param scene Defines the scene to instrument
  55065. */
  55066. constructor(
  55067. /**
  55068. * Defines the scene to instrument
  55069. */
  55070. scene: Scene);
  55071. /**
  55072. * Dispose and release associated resources.
  55073. */
  55074. dispose(): void;
  55075. }
  55076. }
  55077. declare module "babylonjs/Instrumentation/index" {
  55078. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55079. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55080. export * from "babylonjs/Instrumentation/timeToken";
  55081. }
  55082. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55083. /** @hidden */
  55084. export var glowMapGenerationPixelShader: {
  55085. name: string;
  55086. shader: string;
  55087. };
  55088. }
  55089. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55090. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55091. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55092. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55093. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55094. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55095. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55096. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55097. /** @hidden */
  55098. export var glowMapGenerationVertexShader: {
  55099. name: string;
  55100. shader: string;
  55101. };
  55102. }
  55103. declare module "babylonjs/Layers/effectLayer" {
  55104. import { Observable } from "babylonjs/Misc/observable";
  55105. import { Nullable } from "babylonjs/types";
  55106. import { Camera } from "babylonjs/Cameras/camera";
  55107. import { Scene } from "babylonjs/scene";
  55108. import { ISize } from "babylonjs/Maths/math.size";
  55109. import { Color4 } from "babylonjs/Maths/math.color";
  55110. import { Engine } from "babylonjs/Engines/engine";
  55111. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55113. import { Mesh } from "babylonjs/Meshes/mesh";
  55114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55116. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55117. import { Effect } from "babylonjs/Materials/effect";
  55118. import { Material } from "babylonjs/Materials/material";
  55119. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55120. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55121. /**
  55122. * Effect layer options. This helps customizing the behaviour
  55123. * of the effect layer.
  55124. */
  55125. export interface IEffectLayerOptions {
  55126. /**
  55127. * Multiplication factor apply to the canvas size to compute the render target size
  55128. * used to generated the objects (the smaller the faster).
  55129. */
  55130. mainTextureRatio: number;
  55131. /**
  55132. * Enforces a fixed size texture to ensure effect stability across devices.
  55133. */
  55134. mainTextureFixedSize?: number;
  55135. /**
  55136. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55137. */
  55138. alphaBlendingMode: number;
  55139. /**
  55140. * The camera attached to the layer.
  55141. */
  55142. camera: Nullable<Camera>;
  55143. /**
  55144. * The rendering group to draw the layer in.
  55145. */
  55146. renderingGroupId: number;
  55147. }
  55148. /**
  55149. * The effect layer Helps adding post process effect blended with the main pass.
  55150. *
  55151. * This can be for instance use to generate glow or higlight effects on the scene.
  55152. *
  55153. * The effect layer class can not be used directly and is intented to inherited from to be
  55154. * customized per effects.
  55155. */
  55156. export abstract class EffectLayer {
  55157. private _vertexBuffers;
  55158. private _indexBuffer;
  55159. private _cachedDefines;
  55160. private _effectLayerMapGenerationEffect;
  55161. private _effectLayerOptions;
  55162. private _mergeEffect;
  55163. protected _scene: Scene;
  55164. protected _engine: Engine;
  55165. protected _maxSize: number;
  55166. protected _mainTextureDesiredSize: ISize;
  55167. protected _mainTexture: RenderTargetTexture;
  55168. protected _shouldRender: boolean;
  55169. protected _postProcesses: PostProcess[];
  55170. protected _textures: BaseTexture[];
  55171. protected _emissiveTextureAndColor: {
  55172. texture: Nullable<BaseTexture>;
  55173. color: Color4;
  55174. };
  55175. /**
  55176. * The name of the layer
  55177. */
  55178. name: string;
  55179. /**
  55180. * The clear color of the texture used to generate the glow map.
  55181. */
  55182. neutralColor: Color4;
  55183. /**
  55184. * Specifies wether the highlight layer is enabled or not.
  55185. */
  55186. isEnabled: boolean;
  55187. /**
  55188. * Gets the camera attached to the layer.
  55189. */
  55190. get camera(): Nullable<Camera>;
  55191. /**
  55192. * Gets the rendering group id the layer should render in.
  55193. */
  55194. get renderingGroupId(): number;
  55195. set renderingGroupId(renderingGroupId: number);
  55196. /**
  55197. * An event triggered when the effect layer has been disposed.
  55198. */
  55199. onDisposeObservable: Observable<EffectLayer>;
  55200. /**
  55201. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55202. */
  55203. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55204. /**
  55205. * An event triggered when the generated texture is being merged in the scene.
  55206. */
  55207. onBeforeComposeObservable: Observable<EffectLayer>;
  55208. /**
  55209. * An event triggered when the mesh is rendered into the effect render target.
  55210. */
  55211. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55212. /**
  55213. * An event triggered after the mesh has been rendered into the effect render target.
  55214. */
  55215. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55216. /**
  55217. * An event triggered when the generated texture has been merged in the scene.
  55218. */
  55219. onAfterComposeObservable: Observable<EffectLayer>;
  55220. /**
  55221. * An event triggered when the efffect layer changes its size.
  55222. */
  55223. onSizeChangedObservable: Observable<EffectLayer>;
  55224. /** @hidden */
  55225. static _SceneComponentInitialization: (scene: Scene) => void;
  55226. /**
  55227. * Instantiates a new effect Layer and references it in the scene.
  55228. * @param name The name of the layer
  55229. * @param scene The scene to use the layer in
  55230. */
  55231. constructor(
  55232. /** The Friendly of the effect in the scene */
  55233. name: string, scene: Scene);
  55234. /**
  55235. * Get the effect name of the layer.
  55236. * @return The effect name
  55237. */
  55238. abstract getEffectName(): string;
  55239. /**
  55240. * Checks for the readiness of the element composing the layer.
  55241. * @param subMesh the mesh to check for
  55242. * @param useInstances specify wether or not to use instances to render the mesh
  55243. * @return true if ready otherwise, false
  55244. */
  55245. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55246. /**
  55247. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55248. * @returns true if the effect requires stencil during the main canvas render pass.
  55249. */
  55250. abstract needStencil(): boolean;
  55251. /**
  55252. * Create the merge effect. This is the shader use to blit the information back
  55253. * to the main canvas at the end of the scene rendering.
  55254. * @returns The effect containing the shader used to merge the effect on the main canvas
  55255. */
  55256. protected abstract _createMergeEffect(): Effect;
  55257. /**
  55258. * Creates the render target textures and post processes used in the effect layer.
  55259. */
  55260. protected abstract _createTextureAndPostProcesses(): void;
  55261. /**
  55262. * Implementation specific of rendering the generating effect on the main canvas.
  55263. * @param effect The effect used to render through
  55264. */
  55265. protected abstract _internalRender(effect: Effect): void;
  55266. /**
  55267. * Sets the required values for both the emissive texture and and the main color.
  55268. */
  55269. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55270. /**
  55271. * Free any resources and references associated to a mesh.
  55272. * Internal use
  55273. * @param mesh The mesh to free.
  55274. */
  55275. abstract _disposeMesh(mesh: Mesh): void;
  55276. /**
  55277. * Serializes this layer (Glow or Highlight for example)
  55278. * @returns a serialized layer object
  55279. */
  55280. abstract serialize?(): any;
  55281. /**
  55282. * Initializes the effect layer with the required options.
  55283. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55284. */
  55285. protected _init(options: Partial<IEffectLayerOptions>): void;
  55286. /**
  55287. * Generates the index buffer of the full screen quad blending to the main canvas.
  55288. */
  55289. private _generateIndexBuffer;
  55290. /**
  55291. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55292. */
  55293. private _generateVertexBuffer;
  55294. /**
  55295. * Sets the main texture desired size which is the closest power of two
  55296. * of the engine canvas size.
  55297. */
  55298. private _setMainTextureSize;
  55299. /**
  55300. * Creates the main texture for the effect layer.
  55301. */
  55302. protected _createMainTexture(): void;
  55303. /**
  55304. * Adds specific effects defines.
  55305. * @param defines The defines to add specifics to.
  55306. */
  55307. protected _addCustomEffectDefines(defines: string[]): void;
  55308. /**
  55309. * Checks for the readiness of the element composing the layer.
  55310. * @param subMesh the mesh to check for
  55311. * @param useInstances specify wether or not to use instances to render the mesh
  55312. * @param emissiveTexture the associated emissive texture used to generate the glow
  55313. * @return true if ready otherwise, false
  55314. */
  55315. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55316. /**
  55317. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55318. */
  55319. render(): void;
  55320. /**
  55321. * Determine if a given mesh will be used in the current effect.
  55322. * @param mesh mesh to test
  55323. * @returns true if the mesh will be used
  55324. */
  55325. hasMesh(mesh: AbstractMesh): boolean;
  55326. /**
  55327. * Returns true if the layer contains information to display, otherwise false.
  55328. * @returns true if the glow layer should be rendered
  55329. */
  55330. shouldRender(): boolean;
  55331. /**
  55332. * Returns true if the mesh should render, otherwise false.
  55333. * @param mesh The mesh to render
  55334. * @returns true if it should render otherwise false
  55335. */
  55336. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55337. /**
  55338. * Returns true if the mesh can be rendered, otherwise false.
  55339. * @param mesh The mesh to render
  55340. * @param material The material used on the mesh
  55341. * @returns true if it can be rendered otherwise false
  55342. */
  55343. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55344. /**
  55345. * Returns true if the mesh should render, otherwise false.
  55346. * @param mesh The mesh to render
  55347. * @returns true if it should render otherwise false
  55348. */
  55349. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55350. /**
  55351. * Renders the submesh passed in parameter to the generation map.
  55352. */
  55353. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55354. /**
  55355. * Defines wether the current material of the mesh should be use to render the effect.
  55356. * @param mesh defines the current mesh to render
  55357. */
  55358. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55359. /**
  55360. * Rebuild the required buffers.
  55361. * @hidden Internal use only.
  55362. */
  55363. _rebuild(): void;
  55364. /**
  55365. * Dispose only the render target textures and post process.
  55366. */
  55367. private _disposeTextureAndPostProcesses;
  55368. /**
  55369. * Dispose the highlight layer and free resources.
  55370. */
  55371. dispose(): void;
  55372. /**
  55373. * Gets the class name of the effect layer
  55374. * @returns the string with the class name of the effect layer
  55375. */
  55376. getClassName(): string;
  55377. /**
  55378. * Creates an effect layer from parsed effect layer data
  55379. * @param parsedEffectLayer defines effect layer data
  55380. * @param scene defines the current scene
  55381. * @param rootUrl defines the root URL containing the effect layer information
  55382. * @returns a parsed effect Layer
  55383. */
  55384. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55385. }
  55386. }
  55387. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55388. import { Scene } from "babylonjs/scene";
  55389. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55390. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55391. import { AbstractScene } from "babylonjs/abstractScene";
  55392. module "babylonjs/abstractScene" {
  55393. interface AbstractScene {
  55394. /**
  55395. * The list of effect layers (highlights/glow) added to the scene
  55396. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55397. * @see http://doc.babylonjs.com/how_to/glow_layer
  55398. */
  55399. effectLayers: Array<EffectLayer>;
  55400. /**
  55401. * Removes the given effect layer from this scene.
  55402. * @param toRemove defines the effect layer to remove
  55403. * @returns the index of the removed effect layer
  55404. */
  55405. removeEffectLayer(toRemove: EffectLayer): number;
  55406. /**
  55407. * Adds the given effect layer to this scene
  55408. * @param newEffectLayer defines the effect layer to add
  55409. */
  55410. addEffectLayer(newEffectLayer: EffectLayer): void;
  55411. }
  55412. }
  55413. /**
  55414. * Defines the layer scene component responsible to manage any effect layers
  55415. * in a given scene.
  55416. */
  55417. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55418. /**
  55419. * The component name helpfull to identify the component in the list of scene components.
  55420. */
  55421. readonly name: string;
  55422. /**
  55423. * The scene the component belongs to.
  55424. */
  55425. scene: Scene;
  55426. private _engine;
  55427. private _renderEffects;
  55428. private _needStencil;
  55429. private _previousStencilState;
  55430. /**
  55431. * Creates a new instance of the component for the given scene
  55432. * @param scene Defines the scene to register the component in
  55433. */
  55434. constructor(scene: Scene);
  55435. /**
  55436. * Registers the component in a given scene
  55437. */
  55438. register(): void;
  55439. /**
  55440. * Rebuilds the elements related to this component in case of
  55441. * context lost for instance.
  55442. */
  55443. rebuild(): void;
  55444. /**
  55445. * Serializes the component data to the specified json object
  55446. * @param serializationObject The object to serialize to
  55447. */
  55448. serialize(serializationObject: any): void;
  55449. /**
  55450. * Adds all the elements from the container to the scene
  55451. * @param container the container holding the elements
  55452. */
  55453. addFromContainer(container: AbstractScene): void;
  55454. /**
  55455. * Removes all the elements in the container from the scene
  55456. * @param container contains the elements to remove
  55457. * @param dispose if the removed element should be disposed (default: false)
  55458. */
  55459. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55460. /**
  55461. * Disposes the component and the associated ressources.
  55462. */
  55463. dispose(): void;
  55464. private _isReadyForMesh;
  55465. private _renderMainTexture;
  55466. private _setStencil;
  55467. private _setStencilBack;
  55468. private _draw;
  55469. private _drawCamera;
  55470. private _drawRenderingGroup;
  55471. }
  55472. }
  55473. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55474. /** @hidden */
  55475. export var glowMapMergePixelShader: {
  55476. name: string;
  55477. shader: string;
  55478. };
  55479. }
  55480. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55481. /** @hidden */
  55482. export var glowMapMergeVertexShader: {
  55483. name: string;
  55484. shader: string;
  55485. };
  55486. }
  55487. declare module "babylonjs/Layers/glowLayer" {
  55488. import { Nullable } from "babylonjs/types";
  55489. import { Camera } from "babylonjs/Cameras/camera";
  55490. import { Scene } from "babylonjs/scene";
  55491. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55493. import { Mesh } from "babylonjs/Meshes/mesh";
  55494. import { Texture } from "babylonjs/Materials/Textures/texture";
  55495. import { Effect } from "babylonjs/Materials/effect";
  55496. import { Material } from "babylonjs/Materials/material";
  55497. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55498. import { Color4 } from "babylonjs/Maths/math.color";
  55499. import "babylonjs/Shaders/glowMapMerge.fragment";
  55500. import "babylonjs/Shaders/glowMapMerge.vertex";
  55501. import "babylonjs/Layers/effectLayerSceneComponent";
  55502. module "babylonjs/abstractScene" {
  55503. interface AbstractScene {
  55504. /**
  55505. * Return a the first highlight layer of the scene with a given name.
  55506. * @param name The name of the highlight layer to look for.
  55507. * @return The highlight layer if found otherwise null.
  55508. */
  55509. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55510. }
  55511. }
  55512. /**
  55513. * Glow layer options. This helps customizing the behaviour
  55514. * of the glow layer.
  55515. */
  55516. export interface IGlowLayerOptions {
  55517. /**
  55518. * Multiplication factor apply to the canvas size to compute the render target size
  55519. * used to generated the glowing objects (the smaller the faster).
  55520. */
  55521. mainTextureRatio: number;
  55522. /**
  55523. * Enforces a fixed size texture to ensure resize independant blur.
  55524. */
  55525. mainTextureFixedSize?: number;
  55526. /**
  55527. * How big is the kernel of the blur texture.
  55528. */
  55529. blurKernelSize: number;
  55530. /**
  55531. * The camera attached to the layer.
  55532. */
  55533. camera: Nullable<Camera>;
  55534. /**
  55535. * Enable MSAA by chosing the number of samples.
  55536. */
  55537. mainTextureSamples?: number;
  55538. /**
  55539. * The rendering group to draw the layer in.
  55540. */
  55541. renderingGroupId: number;
  55542. }
  55543. /**
  55544. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55545. *
  55546. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55547. *
  55548. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55549. */
  55550. export class GlowLayer extends EffectLayer {
  55551. /**
  55552. * Effect Name of the layer.
  55553. */
  55554. static readonly EffectName: string;
  55555. /**
  55556. * The default blur kernel size used for the glow.
  55557. */
  55558. static DefaultBlurKernelSize: number;
  55559. /**
  55560. * The default texture size ratio used for the glow.
  55561. */
  55562. static DefaultTextureRatio: number;
  55563. /**
  55564. * Sets the kernel size of the blur.
  55565. */
  55566. set blurKernelSize(value: number);
  55567. /**
  55568. * Gets the kernel size of the blur.
  55569. */
  55570. get blurKernelSize(): number;
  55571. /**
  55572. * Sets the glow intensity.
  55573. */
  55574. set intensity(value: number);
  55575. /**
  55576. * Gets the glow intensity.
  55577. */
  55578. get intensity(): number;
  55579. private _options;
  55580. private _intensity;
  55581. private _horizontalBlurPostprocess1;
  55582. private _verticalBlurPostprocess1;
  55583. private _horizontalBlurPostprocess2;
  55584. private _verticalBlurPostprocess2;
  55585. private _blurTexture1;
  55586. private _blurTexture2;
  55587. private _postProcesses1;
  55588. private _postProcesses2;
  55589. private _includedOnlyMeshes;
  55590. private _excludedMeshes;
  55591. private _meshesUsingTheirOwnMaterials;
  55592. /**
  55593. * Callback used to let the user override the color selection on a per mesh basis
  55594. */
  55595. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55596. /**
  55597. * Callback used to let the user override the texture selection on a per mesh basis
  55598. */
  55599. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55600. /**
  55601. * Instantiates a new glow Layer and references it to the scene.
  55602. * @param name The name of the layer
  55603. * @param scene The scene to use the layer in
  55604. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55605. */
  55606. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55607. /**
  55608. * Get the effect name of the layer.
  55609. * @return The effect name
  55610. */
  55611. getEffectName(): string;
  55612. /**
  55613. * Create the merge effect. This is the shader use to blit the information back
  55614. * to the main canvas at the end of the scene rendering.
  55615. */
  55616. protected _createMergeEffect(): Effect;
  55617. /**
  55618. * Creates the render target textures and post processes used in the glow layer.
  55619. */
  55620. protected _createTextureAndPostProcesses(): void;
  55621. /**
  55622. * Checks for the readiness of the element composing the layer.
  55623. * @param subMesh the mesh to check for
  55624. * @param useInstances specify wether or not to use instances to render the mesh
  55625. * @param emissiveTexture the associated emissive texture used to generate the glow
  55626. * @return true if ready otherwise, false
  55627. */
  55628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55629. /**
  55630. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55631. */
  55632. needStencil(): boolean;
  55633. /**
  55634. * Returns true if the mesh can be rendered, otherwise false.
  55635. * @param mesh The mesh to render
  55636. * @param material The material used on the mesh
  55637. * @returns true if it can be rendered otherwise false
  55638. */
  55639. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55640. /**
  55641. * Implementation specific of rendering the generating effect on the main canvas.
  55642. * @param effect The effect used to render through
  55643. */
  55644. protected _internalRender(effect: Effect): void;
  55645. /**
  55646. * Sets the required values for both the emissive texture and and the main color.
  55647. */
  55648. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55649. /**
  55650. * Returns true if the mesh should render, otherwise false.
  55651. * @param mesh The mesh to render
  55652. * @returns true if it should render otherwise false
  55653. */
  55654. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55655. /**
  55656. * Adds specific effects defines.
  55657. * @param defines The defines to add specifics to.
  55658. */
  55659. protected _addCustomEffectDefines(defines: string[]): void;
  55660. /**
  55661. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55662. * @param mesh The mesh to exclude from the glow layer
  55663. */
  55664. addExcludedMesh(mesh: Mesh): void;
  55665. /**
  55666. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55667. * @param mesh The mesh to remove
  55668. */
  55669. removeExcludedMesh(mesh: Mesh): void;
  55670. /**
  55671. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55672. * @param mesh The mesh to include in the glow layer
  55673. */
  55674. addIncludedOnlyMesh(mesh: Mesh): void;
  55675. /**
  55676. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55677. * @param mesh The mesh to remove
  55678. */
  55679. removeIncludedOnlyMesh(mesh: Mesh): void;
  55680. /**
  55681. * Determine if a given mesh will be used in the glow layer
  55682. * @param mesh The mesh to test
  55683. * @returns true if the mesh will be highlighted by the current glow layer
  55684. */
  55685. hasMesh(mesh: AbstractMesh): boolean;
  55686. /**
  55687. * Defines wether the current material of the mesh should be use to render the effect.
  55688. * @param mesh defines the current mesh to render
  55689. */
  55690. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55691. /**
  55692. * Add a mesh to be rendered through its own material and not with emissive only.
  55693. * @param mesh The mesh for which we need to use its material
  55694. */
  55695. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55696. /**
  55697. * Remove a mesh from being rendered through its own material and not with emissive only.
  55698. * @param mesh The mesh for which we need to not use its material
  55699. */
  55700. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55701. /**
  55702. * Free any resources and references associated to a mesh.
  55703. * Internal use
  55704. * @param mesh The mesh to free.
  55705. * @hidden
  55706. */
  55707. _disposeMesh(mesh: Mesh): void;
  55708. /**
  55709. * Gets the class name of the effect layer
  55710. * @returns the string with the class name of the effect layer
  55711. */
  55712. getClassName(): string;
  55713. /**
  55714. * Serializes this glow layer
  55715. * @returns a serialized glow layer object
  55716. */
  55717. serialize(): any;
  55718. /**
  55719. * Creates a Glow Layer from parsed glow layer data
  55720. * @param parsedGlowLayer defines glow layer data
  55721. * @param scene defines the current scene
  55722. * @param rootUrl defines the root URL containing the glow layer information
  55723. * @returns a parsed Glow Layer
  55724. */
  55725. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55726. }
  55727. }
  55728. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55729. /** @hidden */
  55730. export var glowBlurPostProcessPixelShader: {
  55731. name: string;
  55732. shader: string;
  55733. };
  55734. }
  55735. declare module "babylonjs/Layers/highlightLayer" {
  55736. import { Observable } from "babylonjs/Misc/observable";
  55737. import { Nullable } from "babylonjs/types";
  55738. import { Camera } from "babylonjs/Cameras/camera";
  55739. import { Scene } from "babylonjs/scene";
  55740. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55742. import { Mesh } from "babylonjs/Meshes/mesh";
  55743. import { Effect } from "babylonjs/Materials/effect";
  55744. import { Material } from "babylonjs/Materials/material";
  55745. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55746. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55747. import "babylonjs/Shaders/glowMapMerge.fragment";
  55748. import "babylonjs/Shaders/glowMapMerge.vertex";
  55749. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55750. module "babylonjs/abstractScene" {
  55751. interface AbstractScene {
  55752. /**
  55753. * Return a the first highlight layer of the scene with a given name.
  55754. * @param name The name of the highlight layer to look for.
  55755. * @return The highlight layer if found otherwise null.
  55756. */
  55757. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55758. }
  55759. }
  55760. /**
  55761. * Highlight layer options. This helps customizing the behaviour
  55762. * of the highlight layer.
  55763. */
  55764. export interface IHighlightLayerOptions {
  55765. /**
  55766. * Multiplication factor apply to the canvas size to compute the render target size
  55767. * used to generated the glowing objects (the smaller the faster).
  55768. */
  55769. mainTextureRatio: number;
  55770. /**
  55771. * Enforces a fixed size texture to ensure resize independant blur.
  55772. */
  55773. mainTextureFixedSize?: number;
  55774. /**
  55775. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55776. * of the picture to blur (the smaller the faster).
  55777. */
  55778. blurTextureSizeRatio: number;
  55779. /**
  55780. * How big in texel of the blur texture is the vertical blur.
  55781. */
  55782. blurVerticalSize: number;
  55783. /**
  55784. * How big in texel of the blur texture is the horizontal blur.
  55785. */
  55786. blurHorizontalSize: number;
  55787. /**
  55788. * Alpha blending mode used to apply the blur. Default is combine.
  55789. */
  55790. alphaBlendingMode: number;
  55791. /**
  55792. * The camera attached to the layer.
  55793. */
  55794. camera: Nullable<Camera>;
  55795. /**
  55796. * Should we display highlight as a solid stroke?
  55797. */
  55798. isStroke?: boolean;
  55799. /**
  55800. * The rendering group to draw the layer in.
  55801. */
  55802. renderingGroupId: number;
  55803. }
  55804. /**
  55805. * The highlight layer Helps adding a glow effect around a mesh.
  55806. *
  55807. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55808. * glowy meshes to your scene.
  55809. *
  55810. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55811. */
  55812. export class HighlightLayer extends EffectLayer {
  55813. name: string;
  55814. /**
  55815. * Effect Name of the highlight layer.
  55816. */
  55817. static readonly EffectName: string;
  55818. /**
  55819. * The neutral color used during the preparation of the glow effect.
  55820. * This is black by default as the blend operation is a blend operation.
  55821. */
  55822. static NeutralColor: Color4;
  55823. /**
  55824. * Stencil value used for glowing meshes.
  55825. */
  55826. static GlowingMeshStencilReference: number;
  55827. /**
  55828. * Stencil value used for the other meshes in the scene.
  55829. */
  55830. static NormalMeshStencilReference: number;
  55831. /**
  55832. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55833. */
  55834. innerGlow: boolean;
  55835. /**
  55836. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55837. */
  55838. outerGlow: boolean;
  55839. /**
  55840. * Specifies the horizontal size of the blur.
  55841. */
  55842. set blurHorizontalSize(value: number);
  55843. /**
  55844. * Specifies the vertical size of the blur.
  55845. */
  55846. set blurVerticalSize(value: number);
  55847. /**
  55848. * Gets the horizontal size of the blur.
  55849. */
  55850. get blurHorizontalSize(): number;
  55851. /**
  55852. * Gets the vertical size of the blur.
  55853. */
  55854. get blurVerticalSize(): number;
  55855. /**
  55856. * An event triggered when the highlight layer is being blurred.
  55857. */
  55858. onBeforeBlurObservable: Observable<HighlightLayer>;
  55859. /**
  55860. * An event triggered when the highlight layer has been blurred.
  55861. */
  55862. onAfterBlurObservable: Observable<HighlightLayer>;
  55863. private _instanceGlowingMeshStencilReference;
  55864. private _options;
  55865. private _downSamplePostprocess;
  55866. private _horizontalBlurPostprocess;
  55867. private _verticalBlurPostprocess;
  55868. private _blurTexture;
  55869. private _meshes;
  55870. private _excludedMeshes;
  55871. /**
  55872. * Instantiates a new highlight Layer and references it to the scene..
  55873. * @param name The name of the layer
  55874. * @param scene The scene to use the layer in
  55875. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55876. */
  55877. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55878. /**
  55879. * Get the effect name of the layer.
  55880. * @return The effect name
  55881. */
  55882. getEffectName(): string;
  55883. /**
  55884. * Create the merge effect. This is the shader use to blit the information back
  55885. * to the main canvas at the end of the scene rendering.
  55886. */
  55887. protected _createMergeEffect(): Effect;
  55888. /**
  55889. * Creates the render target textures and post processes used in the highlight layer.
  55890. */
  55891. protected _createTextureAndPostProcesses(): void;
  55892. /**
  55893. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55894. */
  55895. needStencil(): boolean;
  55896. /**
  55897. * Checks for the readiness of the element composing the layer.
  55898. * @param subMesh the mesh to check for
  55899. * @param useInstances specify wether or not to use instances to render the mesh
  55900. * @param emissiveTexture the associated emissive texture used to generate the glow
  55901. * @return true if ready otherwise, false
  55902. */
  55903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55904. /**
  55905. * Implementation specific of rendering the generating effect on the main canvas.
  55906. * @param effect The effect used to render through
  55907. */
  55908. protected _internalRender(effect: Effect): void;
  55909. /**
  55910. * Returns true if the layer contains information to display, otherwise false.
  55911. */
  55912. shouldRender(): boolean;
  55913. /**
  55914. * Returns true if the mesh should render, otherwise false.
  55915. * @param mesh The mesh to render
  55916. * @returns true if it should render otherwise false
  55917. */
  55918. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55919. /**
  55920. * Sets the required values for both the emissive texture and and the main color.
  55921. */
  55922. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55923. /**
  55924. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55925. * @param mesh The mesh to exclude from the highlight layer
  55926. */
  55927. addExcludedMesh(mesh: Mesh): void;
  55928. /**
  55929. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55930. * @param mesh The mesh to highlight
  55931. */
  55932. removeExcludedMesh(mesh: Mesh): void;
  55933. /**
  55934. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55935. * @param mesh mesh to test
  55936. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55937. */
  55938. hasMesh(mesh: AbstractMesh): boolean;
  55939. /**
  55940. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55941. * @param mesh The mesh to highlight
  55942. * @param color The color of the highlight
  55943. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55944. */
  55945. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55946. /**
  55947. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55948. * @param mesh The mesh to highlight
  55949. */
  55950. removeMesh(mesh: Mesh): void;
  55951. /**
  55952. * Force the stencil to the normal expected value for none glowing parts
  55953. */
  55954. private _defaultStencilReference;
  55955. /**
  55956. * Free any resources and references associated to a mesh.
  55957. * Internal use
  55958. * @param mesh The mesh to free.
  55959. * @hidden
  55960. */
  55961. _disposeMesh(mesh: Mesh): void;
  55962. /**
  55963. * Dispose the highlight layer and free resources.
  55964. */
  55965. dispose(): void;
  55966. /**
  55967. * Gets the class name of the effect layer
  55968. * @returns the string with the class name of the effect layer
  55969. */
  55970. getClassName(): string;
  55971. /**
  55972. * Serializes this Highlight layer
  55973. * @returns a serialized Highlight layer object
  55974. */
  55975. serialize(): any;
  55976. /**
  55977. * Creates a Highlight layer from parsed Highlight layer data
  55978. * @param parsedHightlightLayer defines the Highlight layer data
  55979. * @param scene defines the current scene
  55980. * @param rootUrl defines the root URL containing the Highlight layer information
  55981. * @returns a parsed Highlight layer
  55982. */
  55983. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55984. }
  55985. }
  55986. declare module "babylonjs/Layers/layerSceneComponent" {
  55987. import { Scene } from "babylonjs/scene";
  55988. import { ISceneComponent } from "babylonjs/sceneComponent";
  55989. import { Layer } from "babylonjs/Layers/layer";
  55990. import { AbstractScene } from "babylonjs/abstractScene";
  55991. module "babylonjs/abstractScene" {
  55992. interface AbstractScene {
  55993. /**
  55994. * The list of layers (background and foreground) of the scene
  55995. */
  55996. layers: Array<Layer>;
  55997. }
  55998. }
  55999. /**
  56000. * Defines the layer scene component responsible to manage any layers
  56001. * in a given scene.
  56002. */
  56003. export class LayerSceneComponent implements ISceneComponent {
  56004. /**
  56005. * The component name helpfull to identify the component in the list of scene components.
  56006. */
  56007. readonly name: string;
  56008. /**
  56009. * The scene the component belongs to.
  56010. */
  56011. scene: Scene;
  56012. private _engine;
  56013. /**
  56014. * Creates a new instance of the component for the given scene
  56015. * @param scene Defines the scene to register the component in
  56016. */
  56017. constructor(scene: Scene);
  56018. /**
  56019. * Registers the component in a given scene
  56020. */
  56021. register(): void;
  56022. /**
  56023. * Rebuilds the elements related to this component in case of
  56024. * context lost for instance.
  56025. */
  56026. rebuild(): void;
  56027. /**
  56028. * Disposes the component and the associated ressources.
  56029. */
  56030. dispose(): void;
  56031. private _draw;
  56032. private _drawCameraPredicate;
  56033. private _drawCameraBackground;
  56034. private _drawCameraForeground;
  56035. private _drawRenderTargetPredicate;
  56036. private _drawRenderTargetBackground;
  56037. private _drawRenderTargetForeground;
  56038. /**
  56039. * Adds all the elements from the container to the scene
  56040. * @param container the container holding the elements
  56041. */
  56042. addFromContainer(container: AbstractScene): void;
  56043. /**
  56044. * Removes all the elements in the container from the scene
  56045. * @param container contains the elements to remove
  56046. * @param dispose if the removed element should be disposed (default: false)
  56047. */
  56048. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56049. }
  56050. }
  56051. declare module "babylonjs/Shaders/layer.fragment" {
  56052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56053. /** @hidden */
  56054. export var layerPixelShader: {
  56055. name: string;
  56056. shader: string;
  56057. };
  56058. }
  56059. declare module "babylonjs/Shaders/layer.vertex" {
  56060. /** @hidden */
  56061. export var layerVertexShader: {
  56062. name: string;
  56063. shader: string;
  56064. };
  56065. }
  56066. declare module "babylonjs/Layers/layer" {
  56067. import { Observable } from "babylonjs/Misc/observable";
  56068. import { Nullable } from "babylonjs/types";
  56069. import { Scene } from "babylonjs/scene";
  56070. import { Vector2 } from "babylonjs/Maths/math.vector";
  56071. import { Color4 } from "babylonjs/Maths/math.color";
  56072. import { Texture } from "babylonjs/Materials/Textures/texture";
  56073. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56074. import "babylonjs/Shaders/layer.fragment";
  56075. import "babylonjs/Shaders/layer.vertex";
  56076. /**
  56077. * This represents a full screen 2d layer.
  56078. * This can be useful to display a picture in the background of your scene for instance.
  56079. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56080. */
  56081. export class Layer {
  56082. /**
  56083. * Define the name of the layer.
  56084. */
  56085. name: string;
  56086. /**
  56087. * Define the texture the layer should display.
  56088. */
  56089. texture: Nullable<Texture>;
  56090. /**
  56091. * Is the layer in background or foreground.
  56092. */
  56093. isBackground: boolean;
  56094. /**
  56095. * Define the color of the layer (instead of texture).
  56096. */
  56097. color: Color4;
  56098. /**
  56099. * Define the scale of the layer in order to zoom in out of the texture.
  56100. */
  56101. scale: Vector2;
  56102. /**
  56103. * Define an offset for the layer in order to shift the texture.
  56104. */
  56105. offset: Vector2;
  56106. /**
  56107. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56108. */
  56109. alphaBlendingMode: number;
  56110. /**
  56111. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56112. * Alpha test will not mix with the background color in case of transparency.
  56113. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56114. */
  56115. alphaTest: boolean;
  56116. /**
  56117. * Define a mask to restrict the layer to only some of the scene cameras.
  56118. */
  56119. layerMask: number;
  56120. /**
  56121. * Define the list of render target the layer is visible into.
  56122. */
  56123. renderTargetTextures: RenderTargetTexture[];
  56124. /**
  56125. * Define if the layer is only used in renderTarget or if it also
  56126. * renders in the main frame buffer of the canvas.
  56127. */
  56128. renderOnlyInRenderTargetTextures: boolean;
  56129. private _scene;
  56130. private _vertexBuffers;
  56131. private _indexBuffer;
  56132. private _effect;
  56133. private _previousDefines;
  56134. /**
  56135. * An event triggered when the layer is disposed.
  56136. */
  56137. onDisposeObservable: Observable<Layer>;
  56138. private _onDisposeObserver;
  56139. /**
  56140. * Back compatibility with callback before the onDisposeObservable existed.
  56141. * The set callback will be triggered when the layer has been disposed.
  56142. */
  56143. set onDispose(callback: () => void);
  56144. /**
  56145. * An event triggered before rendering the scene
  56146. */
  56147. onBeforeRenderObservable: Observable<Layer>;
  56148. private _onBeforeRenderObserver;
  56149. /**
  56150. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56151. * The set callback will be triggered just before rendering the layer.
  56152. */
  56153. set onBeforeRender(callback: () => void);
  56154. /**
  56155. * An event triggered after rendering the scene
  56156. */
  56157. onAfterRenderObservable: Observable<Layer>;
  56158. private _onAfterRenderObserver;
  56159. /**
  56160. * Back compatibility with callback before the onAfterRenderObservable existed.
  56161. * The set callback will be triggered just after rendering the layer.
  56162. */
  56163. set onAfterRender(callback: () => void);
  56164. /**
  56165. * Instantiates a new layer.
  56166. * This represents a full screen 2d layer.
  56167. * This can be useful to display a picture in the background of your scene for instance.
  56168. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56169. * @param name Define the name of the layer in the scene
  56170. * @param imgUrl Define the url of the texture to display in the layer
  56171. * @param scene Define the scene the layer belongs to
  56172. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56173. * @param color Defines a color for the layer
  56174. */
  56175. constructor(
  56176. /**
  56177. * Define the name of the layer.
  56178. */
  56179. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56180. private _createIndexBuffer;
  56181. /** @hidden */
  56182. _rebuild(): void;
  56183. /**
  56184. * Renders the layer in the scene.
  56185. */
  56186. render(): void;
  56187. /**
  56188. * Disposes and releases the associated ressources.
  56189. */
  56190. dispose(): void;
  56191. }
  56192. }
  56193. declare module "babylonjs/Layers/index" {
  56194. export * from "babylonjs/Layers/effectLayer";
  56195. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56196. export * from "babylonjs/Layers/glowLayer";
  56197. export * from "babylonjs/Layers/highlightLayer";
  56198. export * from "babylonjs/Layers/layer";
  56199. export * from "babylonjs/Layers/layerSceneComponent";
  56200. }
  56201. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56202. /** @hidden */
  56203. export var lensFlarePixelShader: {
  56204. name: string;
  56205. shader: string;
  56206. };
  56207. }
  56208. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56209. /** @hidden */
  56210. export var lensFlareVertexShader: {
  56211. name: string;
  56212. shader: string;
  56213. };
  56214. }
  56215. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56216. import { Scene } from "babylonjs/scene";
  56217. import { Vector3 } from "babylonjs/Maths/math.vector";
  56218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56219. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56220. import "babylonjs/Shaders/lensFlare.fragment";
  56221. import "babylonjs/Shaders/lensFlare.vertex";
  56222. import { Viewport } from "babylonjs/Maths/math.viewport";
  56223. /**
  56224. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56225. * It is usually composed of several `lensFlare`.
  56226. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56227. */
  56228. export class LensFlareSystem {
  56229. /**
  56230. * Define the name of the lens flare system
  56231. */
  56232. name: string;
  56233. /**
  56234. * List of lens flares used in this system.
  56235. */
  56236. lensFlares: LensFlare[];
  56237. /**
  56238. * Define a limit from the border the lens flare can be visible.
  56239. */
  56240. borderLimit: number;
  56241. /**
  56242. * Define a viewport border we do not want to see the lens flare in.
  56243. */
  56244. viewportBorder: number;
  56245. /**
  56246. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56247. */
  56248. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56249. /**
  56250. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56251. */
  56252. layerMask: number;
  56253. /**
  56254. * Define the id of the lens flare system in the scene.
  56255. * (equal to name by default)
  56256. */
  56257. id: string;
  56258. private _scene;
  56259. private _emitter;
  56260. private _vertexBuffers;
  56261. private _indexBuffer;
  56262. private _effect;
  56263. private _positionX;
  56264. private _positionY;
  56265. private _isEnabled;
  56266. /** @hidden */
  56267. static _SceneComponentInitialization: (scene: Scene) => void;
  56268. /**
  56269. * Instantiates a lens flare system.
  56270. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56271. * It is usually composed of several `lensFlare`.
  56272. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56273. * @param name Define the name of the lens flare system in the scene
  56274. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56275. * @param scene Define the scene the lens flare system belongs to
  56276. */
  56277. constructor(
  56278. /**
  56279. * Define the name of the lens flare system
  56280. */
  56281. name: string, emitter: any, scene: Scene);
  56282. /**
  56283. * Define if the lens flare system is enabled.
  56284. */
  56285. get isEnabled(): boolean;
  56286. set isEnabled(value: boolean);
  56287. /**
  56288. * Get the scene the effects belongs to.
  56289. * @returns the scene holding the lens flare system
  56290. */
  56291. getScene(): Scene;
  56292. /**
  56293. * Get the emitter of the lens flare system.
  56294. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56295. * @returns the emitter of the lens flare system
  56296. */
  56297. getEmitter(): any;
  56298. /**
  56299. * Set the emitter of the lens flare system.
  56300. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56301. * @param newEmitter Define the new emitter of the system
  56302. */
  56303. setEmitter(newEmitter: any): void;
  56304. /**
  56305. * Get the lens flare system emitter position.
  56306. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56307. * @returns the position
  56308. */
  56309. getEmitterPosition(): Vector3;
  56310. /**
  56311. * @hidden
  56312. */
  56313. computeEffectivePosition(globalViewport: Viewport): boolean;
  56314. /** @hidden */
  56315. _isVisible(): boolean;
  56316. /**
  56317. * @hidden
  56318. */
  56319. render(): boolean;
  56320. /**
  56321. * Dispose and release the lens flare with its associated resources.
  56322. */
  56323. dispose(): void;
  56324. /**
  56325. * Parse a lens flare system from a JSON repressentation
  56326. * @param parsedLensFlareSystem Define the JSON to parse
  56327. * @param scene Define the scene the parsed system should be instantiated in
  56328. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56329. * @returns the parsed system
  56330. */
  56331. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56332. /**
  56333. * Serialize the current Lens Flare System into a JSON representation.
  56334. * @returns the serialized JSON
  56335. */
  56336. serialize(): any;
  56337. }
  56338. }
  56339. declare module "babylonjs/LensFlares/lensFlare" {
  56340. import { Nullable } from "babylonjs/types";
  56341. import { Color3 } from "babylonjs/Maths/math.color";
  56342. import { Texture } from "babylonjs/Materials/Textures/texture";
  56343. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56344. /**
  56345. * This represents one of the lens effect in a `lensFlareSystem`.
  56346. * It controls one of the indiviual texture used in the effect.
  56347. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56348. */
  56349. export class LensFlare {
  56350. /**
  56351. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56352. */
  56353. size: number;
  56354. /**
  56355. * 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.
  56356. */
  56357. position: number;
  56358. /**
  56359. * Define the lens color.
  56360. */
  56361. color: Color3;
  56362. /**
  56363. * Define the lens texture.
  56364. */
  56365. texture: Nullable<Texture>;
  56366. /**
  56367. * Define the alpha mode to render this particular lens.
  56368. */
  56369. alphaMode: number;
  56370. private _system;
  56371. /**
  56372. * Creates a new Lens Flare.
  56373. * This represents one of the lens effect in a `lensFlareSystem`.
  56374. * It controls one of the indiviual texture used in the effect.
  56375. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56376. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56377. * @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.
  56378. * @param color Define the lens color
  56379. * @param imgUrl Define the lens texture url
  56380. * @param system Define the `lensFlareSystem` this flare is part of
  56381. * @returns The newly created Lens Flare
  56382. */
  56383. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56384. /**
  56385. * Instantiates a new Lens Flare.
  56386. * This represents one of the lens effect in a `lensFlareSystem`.
  56387. * It controls one of the indiviual texture used in the effect.
  56388. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56389. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56390. * @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.
  56391. * @param color Define the lens color
  56392. * @param imgUrl Define the lens texture url
  56393. * @param system Define the `lensFlareSystem` this flare is part of
  56394. */
  56395. constructor(
  56396. /**
  56397. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56398. */
  56399. size: number,
  56400. /**
  56401. * 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.
  56402. */
  56403. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56404. /**
  56405. * Dispose and release the lens flare with its associated resources.
  56406. */
  56407. dispose(): void;
  56408. }
  56409. }
  56410. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56411. import { Nullable } from "babylonjs/types";
  56412. import { Scene } from "babylonjs/scene";
  56413. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56414. import { AbstractScene } from "babylonjs/abstractScene";
  56415. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56416. module "babylonjs/abstractScene" {
  56417. interface AbstractScene {
  56418. /**
  56419. * The list of lens flare system added to the scene
  56420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56421. */
  56422. lensFlareSystems: Array<LensFlareSystem>;
  56423. /**
  56424. * Removes the given lens flare system from this scene.
  56425. * @param toRemove The lens flare system to remove
  56426. * @returns The index of the removed lens flare system
  56427. */
  56428. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56429. /**
  56430. * Adds the given lens flare system to this scene
  56431. * @param newLensFlareSystem The lens flare system to add
  56432. */
  56433. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56434. /**
  56435. * Gets a lens flare system using its name
  56436. * @param name defines the name to look for
  56437. * @returns the lens flare system or null if not found
  56438. */
  56439. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56440. /**
  56441. * Gets a lens flare system using its id
  56442. * @param id defines the id to look for
  56443. * @returns the lens flare system or null if not found
  56444. */
  56445. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56446. }
  56447. }
  56448. /**
  56449. * Defines the lens flare scene component responsible to manage any lens flares
  56450. * in a given scene.
  56451. */
  56452. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56453. /**
  56454. * The component name helpfull to identify the component in the list of scene components.
  56455. */
  56456. readonly name: string;
  56457. /**
  56458. * The scene the component belongs to.
  56459. */
  56460. scene: Scene;
  56461. /**
  56462. * Creates a new instance of the component for the given scene
  56463. * @param scene Defines the scene to register the component in
  56464. */
  56465. constructor(scene: Scene);
  56466. /**
  56467. * Registers the component in a given scene
  56468. */
  56469. register(): void;
  56470. /**
  56471. * Rebuilds the elements related to this component in case of
  56472. * context lost for instance.
  56473. */
  56474. rebuild(): void;
  56475. /**
  56476. * Adds all the elements from the container to the scene
  56477. * @param container the container holding the elements
  56478. */
  56479. addFromContainer(container: AbstractScene): void;
  56480. /**
  56481. * Removes all the elements in the container from the scene
  56482. * @param container contains the elements to remove
  56483. * @param dispose if the removed element should be disposed (default: false)
  56484. */
  56485. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56486. /**
  56487. * Serializes the component data to the specified json object
  56488. * @param serializationObject The object to serialize to
  56489. */
  56490. serialize(serializationObject: any): void;
  56491. /**
  56492. * Disposes the component and the associated ressources.
  56493. */
  56494. dispose(): void;
  56495. private _draw;
  56496. }
  56497. }
  56498. declare module "babylonjs/LensFlares/index" {
  56499. export * from "babylonjs/LensFlares/lensFlare";
  56500. export * from "babylonjs/LensFlares/lensFlareSystem";
  56501. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56502. }
  56503. declare module "babylonjs/Shaders/depth.fragment" {
  56504. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56505. /** @hidden */
  56506. export var depthPixelShader: {
  56507. name: string;
  56508. shader: string;
  56509. };
  56510. }
  56511. declare module "babylonjs/Shaders/depth.vertex" {
  56512. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56515. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56517. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56518. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56519. /** @hidden */
  56520. export var depthVertexShader: {
  56521. name: string;
  56522. shader: string;
  56523. };
  56524. }
  56525. declare module "babylonjs/Rendering/depthRenderer" {
  56526. import { Nullable } from "babylonjs/types";
  56527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56528. import { Scene } from "babylonjs/scene";
  56529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56530. import { Camera } from "babylonjs/Cameras/camera";
  56531. import "babylonjs/Shaders/depth.fragment";
  56532. import "babylonjs/Shaders/depth.vertex";
  56533. /**
  56534. * This represents a depth renderer in Babylon.
  56535. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56536. */
  56537. export class DepthRenderer {
  56538. private _scene;
  56539. private _depthMap;
  56540. private _effect;
  56541. private readonly _storeNonLinearDepth;
  56542. private readonly _clearColor;
  56543. /** Get if the depth renderer is using packed depth or not */
  56544. readonly isPacked: boolean;
  56545. private _cachedDefines;
  56546. private _camera;
  56547. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56548. enabled: boolean;
  56549. /**
  56550. * Specifiess that the depth renderer will only be used within
  56551. * the camera it is created for.
  56552. * This can help forcing its rendering during the camera processing.
  56553. */
  56554. useOnlyInActiveCamera: boolean;
  56555. /** @hidden */
  56556. static _SceneComponentInitialization: (scene: Scene) => void;
  56557. /**
  56558. * Instantiates a depth renderer
  56559. * @param scene The scene the renderer belongs to
  56560. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56561. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56562. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56563. */
  56564. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56565. /**
  56566. * Creates the depth rendering effect and checks if the effect is ready.
  56567. * @param subMesh The submesh to be used to render the depth map of
  56568. * @param useInstances If multiple world instances should be used
  56569. * @returns if the depth renderer is ready to render the depth map
  56570. */
  56571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56572. /**
  56573. * Gets the texture which the depth map will be written to.
  56574. * @returns The depth map texture
  56575. */
  56576. getDepthMap(): RenderTargetTexture;
  56577. /**
  56578. * Disposes of the depth renderer.
  56579. */
  56580. dispose(): void;
  56581. }
  56582. }
  56583. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56584. /** @hidden */
  56585. export var minmaxReduxPixelShader: {
  56586. name: string;
  56587. shader: string;
  56588. };
  56589. }
  56590. declare module "babylonjs/Misc/minMaxReducer" {
  56591. import { Nullable } from "babylonjs/types";
  56592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56593. import { Camera } from "babylonjs/Cameras/camera";
  56594. import { Observer } from "babylonjs/Misc/observable";
  56595. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56596. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56597. import { Observable } from "babylonjs/Misc/observable";
  56598. import "babylonjs/Shaders/minmaxRedux.fragment";
  56599. /**
  56600. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56601. * and maximum values from all values of the texture.
  56602. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56603. * The source values are read from the red channel of the texture.
  56604. */
  56605. export class MinMaxReducer {
  56606. /**
  56607. * Observable triggered when the computation has been performed
  56608. */
  56609. onAfterReductionPerformed: Observable<{
  56610. min: number;
  56611. max: number;
  56612. }>;
  56613. protected _camera: Camera;
  56614. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56615. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56616. protected _postProcessManager: PostProcessManager;
  56617. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56618. protected _forceFullscreenViewport: boolean;
  56619. /**
  56620. * Creates a min/max reducer
  56621. * @param camera The camera to use for the post processes
  56622. */
  56623. constructor(camera: Camera);
  56624. /**
  56625. * Gets the texture used to read the values from.
  56626. */
  56627. get sourceTexture(): Nullable<RenderTargetTexture>;
  56628. /**
  56629. * Sets the source texture to read the values from.
  56630. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56631. * because in such textures '1' value must not be taken into account to compute the maximum
  56632. * as this value is used to clear the texture.
  56633. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56634. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56635. * @param depthRedux Indicates if the texture is a depth texture or not
  56636. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56637. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56638. */
  56639. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56640. /**
  56641. * Defines the refresh rate of the computation.
  56642. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56643. */
  56644. get refreshRate(): number;
  56645. set refreshRate(value: number);
  56646. protected _activated: boolean;
  56647. /**
  56648. * Gets the activation status of the reducer
  56649. */
  56650. get activated(): boolean;
  56651. /**
  56652. * Activates the reduction computation.
  56653. * When activated, the observers registered in onAfterReductionPerformed are
  56654. * called after the compuation is performed
  56655. */
  56656. activate(): void;
  56657. /**
  56658. * Deactivates the reduction computation.
  56659. */
  56660. deactivate(): void;
  56661. /**
  56662. * Disposes the min/max reducer
  56663. * @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.
  56664. */
  56665. dispose(disposeAll?: boolean): void;
  56666. }
  56667. }
  56668. declare module "babylonjs/Misc/depthReducer" {
  56669. import { Nullable } from "babylonjs/types";
  56670. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56671. import { Camera } from "babylonjs/Cameras/camera";
  56672. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56673. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56674. /**
  56675. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56676. */
  56677. export class DepthReducer extends MinMaxReducer {
  56678. private _depthRenderer;
  56679. private _depthRendererId;
  56680. /**
  56681. * Gets the depth renderer used for the computation.
  56682. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56683. */
  56684. get depthRenderer(): Nullable<DepthRenderer>;
  56685. /**
  56686. * Creates a depth reducer
  56687. * @param camera The camera used to render the depth texture
  56688. */
  56689. constructor(camera: Camera);
  56690. /**
  56691. * Sets the depth renderer to use to generate the depth map
  56692. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56693. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56694. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56695. */
  56696. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56697. /** @hidden */
  56698. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56699. /**
  56700. * Activates the reduction computation.
  56701. * When activated, the observers registered in onAfterReductionPerformed are
  56702. * called after the compuation is performed
  56703. */
  56704. activate(): void;
  56705. /**
  56706. * Deactivates the reduction computation.
  56707. */
  56708. deactivate(): void;
  56709. /**
  56710. * Disposes the depth reducer
  56711. * @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.
  56712. */
  56713. dispose(disposeAll?: boolean): void;
  56714. }
  56715. }
  56716. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56717. import { Nullable } from "babylonjs/types";
  56718. import { Scene } from "babylonjs/scene";
  56719. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56720. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56722. import { Mesh } from "babylonjs/Meshes/mesh";
  56723. import { Effect } from "babylonjs/Materials/effect";
  56724. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56725. import "babylonjs/Shaders/shadowMap.fragment";
  56726. import "babylonjs/Shaders/shadowMap.vertex";
  56727. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56728. import { Observable } from "babylonjs/Misc/observable";
  56729. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56730. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56731. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56732. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56733. /**
  56734. * A CSM implementation allowing casting shadows on large scenes.
  56735. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56736. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56737. */
  56738. export class CascadedShadowGenerator implements IShadowGenerator {
  56739. private static readonly frustumCornersNDCSpace;
  56740. /**
  56741. * Name of the CSM class
  56742. */
  56743. static readonly CLASSNAME: string;
  56744. /**
  56745. * Defines the default number of cascades used by the CSM.
  56746. */
  56747. static readonly DEFAULT_CASCADES_COUNT: number;
  56748. /**
  56749. * Defines the minimum number of cascades used by the CSM.
  56750. */
  56751. static readonly MIN_CASCADES_COUNT: number;
  56752. /**
  56753. * Defines the maximum number of cascades used by the CSM.
  56754. */
  56755. static readonly MAX_CASCADES_COUNT: number;
  56756. /**
  56757. * Shadow generator mode None: no filtering applied.
  56758. */
  56759. static readonly FILTER_NONE: number;
  56760. /**
  56761. * Shadow generator mode PCF: Percentage Closer Filtering
  56762. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  56763. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  56764. */
  56765. static readonly FILTER_PCF: number;
  56766. /**
  56767. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  56768. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  56769. * Contact Hardening
  56770. */
  56771. static readonly FILTER_PCSS: number;
  56772. /**
  56773. * Reserved for PCF and PCSS
  56774. * Highest Quality.
  56775. *
  56776. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  56777. *
  56778. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  56779. */
  56780. static readonly QUALITY_HIGH: number;
  56781. /**
  56782. * Reserved for PCF and PCSS
  56783. * Good tradeoff for quality/perf cross devices
  56784. *
  56785. * Execute PCF on a 3*3 kernel.
  56786. *
  56787. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  56788. */
  56789. static readonly QUALITY_MEDIUM: number;
  56790. /**
  56791. * Reserved for PCF and PCSS
  56792. * The lowest quality but the fastest.
  56793. *
  56794. * Execute PCF on a 1*1 kernel.
  56795. *
  56796. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  56797. */
  56798. static readonly QUALITY_LOW: number;
  56799. private static readonly _CLEARONE;
  56800. /**
  56801. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  56802. */
  56803. onBeforeShadowMapRenderObservable: Observable<Effect>;
  56804. /**
  56805. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  56806. */
  56807. onAfterShadowMapRenderObservable: Observable<Effect>;
  56808. /**
  56809. * Observable triggered before a mesh is rendered in the shadow map.
  56810. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  56811. */
  56812. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  56813. /**
  56814. * Observable triggered after a mesh is rendered in the shadow map.
  56815. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  56816. */
  56817. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  56818. private _bias;
  56819. /**
  56820. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  56821. */
  56822. get bias(): number;
  56823. /**
  56824. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  56825. */
  56826. set bias(bias: number);
  56827. private _normalBias;
  56828. /**
  56829. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  56830. */
  56831. get normalBias(): number;
  56832. /**
  56833. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  56834. */
  56835. set normalBias(normalBias: number);
  56836. private _filter;
  56837. /**
  56838. * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
  56839. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  56840. */
  56841. get filter(): number;
  56842. /**
  56843. * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
  56844. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  56845. */
  56846. set filter(value: number);
  56847. /**
  56848. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  56849. */
  56850. get usePercentageCloserFiltering(): boolean;
  56851. /**
  56852. * Sets the current filter to "PCF" (percentage closer filtering).
  56853. */
  56854. set usePercentageCloserFiltering(value: boolean);
  56855. private _filteringQuality;
  56856. /**
  56857. * Gets the PCF or PCSS Quality.
  56858. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  56859. */
  56860. get filteringQuality(): number;
  56861. /**
  56862. * Sets the PCF or PCSS Quality.
  56863. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  56864. */
  56865. set filteringQuality(filteringQuality: number);
  56866. /**
  56867. * Gets if the current filter is set to "PCSS" (contact hardening).
  56868. */
  56869. get useContactHardeningShadow(): boolean;
  56870. /**
  56871. * Sets the current filter to "PCSS" (contact hardening).
  56872. */
  56873. set useContactHardeningShadow(value: boolean);
  56874. private _contactHardeningLightSizeUVRatio;
  56875. /**
  56876. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  56877. * Using a ratio helps keeping shape stability independently of the map size.
  56878. *
  56879. * It does not account for the light projection as it was having too much
  56880. * instability during the light setup or during light position changes.
  56881. *
  56882. * Only valid if useContactHardeningShadow is true.
  56883. */
  56884. get contactHardeningLightSizeUVRatio(): number;
  56885. /**
  56886. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  56887. * Using a ratio helps keeping shape stability independently of the map size.
  56888. *
  56889. * It does not account for the light projection as it was having too much
  56890. * instability during the light setup or during light position changes.
  56891. *
  56892. * Only valid if useContactHardeningShadow is true.
  56893. */
  56894. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  56895. private _darkness;
  56896. /** Gets or sets the actual darkness of a shadow */
  56897. get darkness(): number;
  56898. set darkness(value: number);
  56899. /**
  56900. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  56901. * 0 means strongest and 1 would means no shadow.
  56902. * @returns the darkness.
  56903. */
  56904. getDarkness(): number;
  56905. /**
  56906. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  56907. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  56908. * @returns the shadow generator allowing fluent coding.
  56909. */
  56910. setDarkness(darkness: number): CascadedShadowGenerator;
  56911. /**
  56912. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56913. */
  56914. penumbraDarkness: number;
  56915. private _transparencyShadow;
  56916. /** Gets or sets the ability to have transparent shadow */
  56917. get transparencyShadow(): boolean;
  56918. set transparencyShadow(value: boolean);
  56919. /**
  56920. * Sets the ability to have transparent shadow (boolean).
  56921. * @param transparent True if transparent else False
  56922. * @returns the shadow generator allowing fluent coding
  56923. */
  56924. setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
  56925. private _numCascades;
  56926. /**
  56927. * Gets or set the number of cascades used by the CSM.
  56928. */
  56929. get numCascades(): number;
  56930. set numCascades(value: number);
  56931. /**
  56932. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56933. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56934. */
  56935. stabilizeCascades: boolean;
  56936. private _shadowMap;
  56937. /**
  56938. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  56939. * @returns The render target texture if present otherwise, null
  56940. */
  56941. getShadowMap(): Nullable<RenderTargetTexture>;
  56942. protected _freezeShadowCastersBoundingInfo: boolean;
  56943. private _freezeShadowCastersBoundingInfoObservable;
  56944. /**
  56945. * Enables or disables the shadow casters bounding info computation.
  56946. * If your shadow casters don't move, you can disable this feature.
  56947. * If it is enabled, the bounding box computation is done every frame.
  56948. */
  56949. get freezeShadowCastersBoundingInfo(): boolean;
  56950. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56951. private _scbiMin;
  56952. private _scbiMax;
  56953. protected _computeShadowCastersBoundingInfo(): void;
  56954. protected _shadowCastersBoundingInfo: BoundingInfo;
  56955. /**
  56956. * Gets or sets the shadow casters bounding info.
  56957. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56958. * so that the system won't overwrite the bounds you provide
  56959. */
  56960. get shadowCastersBoundingInfo(): BoundingInfo;
  56961. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56962. protected _breaksAreDirty: boolean;
  56963. protected _minDistance: number;
  56964. protected _maxDistance: number;
  56965. /**
  56966. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56967. *
  56968. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56969. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56970. * @param min minimal distance for the breaks (default to 0.)
  56971. * @param max maximal distance for the breaks (default to 1.)
  56972. */
  56973. setMinMaxDistance(min: number, max: number): void;
  56974. /** Gets the minimal distance used in the cascade break computation */
  56975. get minDistance(): number;
  56976. /** Gets the maximal distance used in the cascade break computation */
  56977. get maxDistance(): number;
  56978. /**
  56979. * Gets the class name of that object
  56980. * @returns "ShadowGenerator"
  56981. */
  56982. getClassName(): string;
  56983. /**
  56984. * Helper function to add a mesh and its descendants to the list of shadow casters.
  56985. * @param mesh Mesh to add
  56986. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  56987. * @returns the Shadow Generator itself
  56988. */
  56989. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  56990. /**
  56991. * Helper function to remove a mesh and its descendants from the list of shadow casters
  56992. * @param mesh Mesh to remove
  56993. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  56994. * @returns the Shadow Generator itself
  56995. */
  56996. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  56997. /**
  56998. * Controls the extent to which the shadows fade out at the edge of the frustum
  56999. */
  57000. frustumEdgeFalloff: number;
  57001. private _light;
  57002. /**
  57003. * Returns the associated light object.
  57004. * @returns the light generating the shadow
  57005. */
  57006. getLight(): DirectionalLight;
  57007. /**
  57008. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  57009. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  57010. * It might on the other hand introduce peter panning.
  57011. */
  57012. forceBackFacesOnly: boolean;
  57013. private _cascadeMinExtents;
  57014. private _cascadeMaxExtents;
  57015. /**
  57016. * Gets a cascade minimum extents
  57017. * @param cascadeIndex index of the cascade
  57018. * @returns the minimum cascade extents
  57019. */
  57020. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57021. /**
  57022. * Gets a cascade maximum extents
  57023. * @param cascadeIndex index of the cascade
  57024. * @returns the maximum cascade extents
  57025. */
  57026. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57027. private _scene;
  57028. private _lightDirection;
  57029. private _effect;
  57030. private _cascades;
  57031. private _cachedDirection;
  57032. private _cachedDefines;
  57033. private _mapSize;
  57034. private _currentLayer;
  57035. private _textureType;
  57036. private _defaultTextureMatrix;
  57037. private _storedUniqueId;
  57038. private _viewSpaceFrustumsZ;
  57039. private _viewMatrices;
  57040. private _projectionMatrices;
  57041. private _transformMatrices;
  57042. private _transformMatricesAsArray;
  57043. private _frustumLengths;
  57044. private _lightSizeUVCorrection;
  57045. private _depthCorrection;
  57046. private _frustumCornersWorldSpace;
  57047. private _frustumCenter;
  57048. private _shadowCameraPos;
  57049. private _shadowMaxZ;
  57050. /**
  57051. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57052. * It defaults to camera.maxZ
  57053. */
  57054. get shadowMaxZ(): number;
  57055. /**
  57056. * Sets the shadow max z distance.
  57057. */
  57058. set shadowMaxZ(value: number);
  57059. protected _debug: boolean;
  57060. /**
  57061. * Gets or sets the debug flag.
  57062. * When enabled, the cascades are materialized by different colors on the screen.
  57063. */
  57064. get debug(): boolean;
  57065. set debug(dbg: boolean);
  57066. private _depthClamp;
  57067. /**
  57068. * Gets or sets the depth clamping value.
  57069. *
  57070. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57071. * to account for the shadow casters far away.
  57072. *
  57073. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57074. */
  57075. get depthClamp(): boolean;
  57076. set depthClamp(value: boolean);
  57077. private _cascadeBlendPercentage;
  57078. /**
  57079. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57080. * It defaults to 0.1 (10% blending).
  57081. */
  57082. get cascadeBlendPercentage(): number;
  57083. set cascadeBlendPercentage(value: number);
  57084. private _lambda;
  57085. /**
  57086. * Gets or set the lambda parameter.
  57087. * This parameter is used to split the camera frustum and create the cascades.
  57088. * 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.
  57089. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57090. */
  57091. get lambda(): number;
  57092. set lambda(value: number);
  57093. /**
  57094. * Gets the view matrix corresponding to a given cascade
  57095. * @param cascadeNum cascade to retrieve the view matrix from
  57096. * @returns the cascade view matrix
  57097. */
  57098. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57099. /**
  57100. * Gets the projection matrix corresponding to a given cascade
  57101. * @param cascadeNum cascade to retrieve the projection matrix from
  57102. * @returns the cascade projection matrix
  57103. */
  57104. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57105. private _depthRenderer;
  57106. /**
  57107. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57108. *
  57109. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57110. *
  57111. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57112. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57113. * @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
  57114. */
  57115. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57116. private _depthReducer;
  57117. private _autoCalcDepthBounds;
  57118. /**
  57119. * Gets or sets the autoCalcDepthBounds property.
  57120. *
  57121. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57122. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57123. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57124. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57125. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57126. */
  57127. get autoCalcDepthBounds(): boolean;
  57128. set autoCalcDepthBounds(value: boolean);
  57129. /**
  57130. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57131. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57132. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57133. * for setting the refresh rate on the renderer yourself!
  57134. */
  57135. get autoCalcDepthBoundsRefreshRate(): number;
  57136. set autoCalcDepthBoundsRefreshRate(value: number);
  57137. /**
  57138. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57139. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57140. * you change the camera near/far planes!
  57141. */
  57142. splitFrustum(): void;
  57143. private _splitFrustum;
  57144. /**
  57145. * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
  57146. * (eq to view projection * shadow projection matrices)
  57147. * @param cascadeIndex index number of the cascaded shadow map
  57148. * @returns The transform matrix used to create the CSM shadow map
  57149. */
  57150. getCSMTransformMatrix(cascadeIndex: number): Matrix;
  57151. private _computeMatrices;
  57152. private _computeFrustumInWorldSpace;
  57153. private _computeCascadeFrustum;
  57154. /** @hidden */
  57155. static _SceneComponentInitialization: (scene: Scene) => void;
  57156. /**
  57157. * Creates a Cascaded Shadow Generator object.
  57158. * A ShadowGenerator is the required tool to use the shadows.
  57159. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57160. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57161. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57162. * @param light The directional light object generating the shadows.
  57163. * @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.
  57164. */
  57165. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57166. private _initializeGenerator;
  57167. private _initializeShadowMap;
  57168. private _renderForShadowMap;
  57169. private _renderSubMeshForShadowMap;
  57170. private _applyFilterValues;
  57171. /**
  57172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  57173. * @param onCompiled Callback triggered at the and of the effects compilation
  57174. * @param options Sets of optional options forcing the compilation with different modes
  57175. */
  57176. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  57177. useInstances: boolean;
  57178. }>): void;
  57179. /**
  57180. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  57181. * @param options Sets of optional options forcing the compilation with different modes
  57182. * @returns A promise that resolves when the compilation completes
  57183. */
  57184. forceCompilationAsync(options?: Partial<{
  57185. useInstances: boolean;
  57186. }>): Promise<void>;
  57187. /**
  57188. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  57189. * @param subMesh The submesh we want to render in the shadow map
  57190. * @param useInstances Defines wether will draw in the map using instances
  57191. * @returns true if ready otherwise, false
  57192. */
  57193. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57194. /**
  57195. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57196. * @param defines Defines of the material we want to update
  57197. * @param lightIndex Index of the light in the enabled light list of the material
  57198. */
  57199. prepareDefines(defines: any, lightIndex: number): void;
  57200. /**
  57201. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57202. * defined in the generator but impacting the effect).
  57203. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57204. * @param effect The effect we are binfing the information for
  57205. */
  57206. bindShadowLight(lightIndex: string, effect: Effect): void;
  57207. /**
  57208. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57209. * (eq to view projection * shadow projection matrices)
  57210. * @returns The transform matrix used to create the shadow map
  57211. */
  57212. getTransformMatrix(): Matrix;
  57213. /**
  57214. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  57215. * Cube and 2D textures for instance.
  57216. */
  57217. recreateShadowMap(): void;
  57218. private _disposeRTT;
  57219. /**
  57220. * Disposes the ShadowGenerator.
  57221. * Returns nothing.
  57222. */
  57223. dispose(): void;
  57224. /**
  57225. * Serializes the shadow generator setup to a json object.
  57226. * @returns The serialized JSON object
  57227. */
  57228. serialize(): any;
  57229. /**
  57230. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57231. * @param parsedShadowGenerator The JSON object to parse
  57232. * @param scene The scene to create the shadow map for
  57233. * @returns The parsed shadow generator
  57234. */
  57235. static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
  57236. }
  57237. }
  57238. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57239. import { Scene } from "babylonjs/scene";
  57240. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57241. import { AbstractScene } from "babylonjs/abstractScene";
  57242. /**
  57243. * Defines the shadow generator component responsible to manage any shadow generators
  57244. * in a given scene.
  57245. */
  57246. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57247. /**
  57248. * The component name helpfull to identify the component in the list of scene components.
  57249. */
  57250. readonly name: string;
  57251. /**
  57252. * The scene the component belongs to.
  57253. */
  57254. scene: Scene;
  57255. /**
  57256. * Creates a new instance of the component for the given scene
  57257. * @param scene Defines the scene to register the component in
  57258. */
  57259. constructor(scene: Scene);
  57260. /**
  57261. * Registers the component in a given scene
  57262. */
  57263. register(): void;
  57264. /**
  57265. * Rebuilds the elements related to this component in case of
  57266. * context lost for instance.
  57267. */
  57268. rebuild(): void;
  57269. /**
  57270. * Serializes the component data to the specified json object
  57271. * @param serializationObject The object to serialize to
  57272. */
  57273. serialize(serializationObject: any): void;
  57274. /**
  57275. * Adds all the elements from the container to the scene
  57276. * @param container the container holding the elements
  57277. */
  57278. addFromContainer(container: AbstractScene): void;
  57279. /**
  57280. * Removes all the elements in the container from the scene
  57281. * @param container contains the elements to remove
  57282. * @param dispose if the removed element should be disposed (default: false)
  57283. */
  57284. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57285. /**
  57286. * Rebuilds the elements related to this component in case of
  57287. * context lost for instance.
  57288. */
  57289. dispose(): void;
  57290. private _gatherRenderTargets;
  57291. }
  57292. }
  57293. declare module "babylonjs/Lights/Shadows/index" {
  57294. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57295. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57296. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57297. }
  57298. declare module "babylonjs/Lights/pointLight" {
  57299. import { Scene } from "babylonjs/scene";
  57300. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57302. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57303. import { Effect } from "babylonjs/Materials/effect";
  57304. /**
  57305. * A point light is a light defined by an unique point in world space.
  57306. * The light is emitted in every direction from this point.
  57307. * A good example of a point light is a standard light bulb.
  57308. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57309. */
  57310. export class PointLight extends ShadowLight {
  57311. private _shadowAngle;
  57312. /**
  57313. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57314. * This specifies what angle the shadow will use to be created.
  57315. *
  57316. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57317. */
  57318. get shadowAngle(): number;
  57319. /**
  57320. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57321. * This specifies what angle the shadow will use to be created.
  57322. *
  57323. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57324. */
  57325. set shadowAngle(value: number);
  57326. /**
  57327. * Gets the direction if it has been set.
  57328. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57329. */
  57330. get direction(): Vector3;
  57331. /**
  57332. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57333. */
  57334. set direction(value: Vector3);
  57335. /**
  57336. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57337. * A PointLight emits the light in every direction.
  57338. * It can cast shadows.
  57339. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57340. * ```javascript
  57341. * var pointLight = new PointLight("pl", camera.position, scene);
  57342. * ```
  57343. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57344. * @param name The light friendly name
  57345. * @param position The position of the point light in the scene
  57346. * @param scene The scene the lights belongs to
  57347. */
  57348. constructor(name: string, position: Vector3, scene: Scene);
  57349. /**
  57350. * Returns the string "PointLight"
  57351. * @returns the class name
  57352. */
  57353. getClassName(): string;
  57354. /**
  57355. * Returns the integer 0.
  57356. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57357. */
  57358. getTypeID(): number;
  57359. /**
  57360. * Specifies wether or not the shadowmap should be a cube texture.
  57361. * @returns true if the shadowmap needs to be a cube texture.
  57362. */
  57363. needCube(): boolean;
  57364. /**
  57365. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57366. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57367. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57368. */
  57369. getShadowDirection(faceIndex?: number): Vector3;
  57370. /**
  57371. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57372. * - fov = PI / 2
  57373. * - aspect ratio : 1.0
  57374. * - z-near and far equal to the active camera minZ and maxZ.
  57375. * Returns the PointLight.
  57376. */
  57377. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57378. protected _buildUniformLayout(): void;
  57379. /**
  57380. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57381. * @param effect The effect to update
  57382. * @param lightIndex The index of the light in the effect to update
  57383. * @returns The point light
  57384. */
  57385. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57386. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57387. /**
  57388. * Prepares the list of defines specific to the light type.
  57389. * @param defines the list of defines
  57390. * @param lightIndex defines the index of the light for the effect
  57391. */
  57392. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57393. }
  57394. }
  57395. declare module "babylonjs/Lights/index" {
  57396. export * from "babylonjs/Lights/light";
  57397. export * from "babylonjs/Lights/shadowLight";
  57398. export * from "babylonjs/Lights/Shadows/index";
  57399. export * from "babylonjs/Lights/directionalLight";
  57400. export * from "babylonjs/Lights/hemisphericLight";
  57401. export * from "babylonjs/Lights/pointLight";
  57402. export * from "babylonjs/Lights/spotLight";
  57403. }
  57404. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57405. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57406. /**
  57407. * Header information of HDR texture files.
  57408. */
  57409. export interface HDRInfo {
  57410. /**
  57411. * The height of the texture in pixels.
  57412. */
  57413. height: number;
  57414. /**
  57415. * The width of the texture in pixels.
  57416. */
  57417. width: number;
  57418. /**
  57419. * The index of the beginning of the data in the binary file.
  57420. */
  57421. dataPosition: number;
  57422. }
  57423. /**
  57424. * This groups tools to convert HDR texture to native colors array.
  57425. */
  57426. export class HDRTools {
  57427. private static Ldexp;
  57428. private static Rgbe2float;
  57429. private static readStringLine;
  57430. /**
  57431. * Reads header information from an RGBE texture stored in a native array.
  57432. * More information on this format are available here:
  57433. * https://en.wikipedia.org/wiki/RGBE_image_format
  57434. *
  57435. * @param uint8array The binary file stored in native array.
  57436. * @return The header information.
  57437. */
  57438. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57439. /**
  57440. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57441. * This RGBE texture needs to store the information as a panorama.
  57442. *
  57443. * More information on this format are available here:
  57444. * https://en.wikipedia.org/wiki/RGBE_image_format
  57445. *
  57446. * @param buffer The binary file stored in an array buffer.
  57447. * @param size The expected size of the extracted cubemap.
  57448. * @return The Cube Map information.
  57449. */
  57450. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57451. /**
  57452. * Returns the pixels data extracted from an RGBE texture.
  57453. * This pixels will be stored left to right up to down in the R G B order in one array.
  57454. *
  57455. * More information on this format are available here:
  57456. * https://en.wikipedia.org/wiki/RGBE_image_format
  57457. *
  57458. * @param uint8array The binary file stored in an array buffer.
  57459. * @param hdrInfo The header information of the file.
  57460. * @return The pixels data in RGB right to left up to down order.
  57461. */
  57462. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57463. private static RGBE_ReadPixels_RLE;
  57464. }
  57465. }
  57466. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57467. import { Nullable } from "babylonjs/types";
  57468. import { Scene } from "babylonjs/scene";
  57469. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57471. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57472. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57473. /**
  57474. * This represents a texture coming from an HDR input.
  57475. *
  57476. * The only supported format is currently panorama picture stored in RGBE format.
  57477. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57478. */
  57479. export class HDRCubeTexture extends BaseTexture {
  57480. private static _facesMapping;
  57481. private _generateHarmonics;
  57482. private _noMipmap;
  57483. private _textureMatrix;
  57484. private _size;
  57485. private _onLoad;
  57486. private _onError;
  57487. /**
  57488. * The texture URL.
  57489. */
  57490. url: string;
  57491. /**
  57492. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57493. */
  57494. coordinatesMode: number;
  57495. protected _isBlocking: boolean;
  57496. /**
  57497. * Sets wether or not the texture is blocking during loading.
  57498. */
  57499. set isBlocking(value: boolean);
  57500. /**
  57501. * Gets wether or not the texture is blocking during loading.
  57502. */
  57503. get isBlocking(): boolean;
  57504. protected _rotationY: number;
  57505. /**
  57506. * Sets texture matrix rotation angle around Y axis in radians.
  57507. */
  57508. set rotationY(value: number);
  57509. /**
  57510. * Gets texture matrix rotation angle around Y axis radians.
  57511. */
  57512. get rotationY(): number;
  57513. /**
  57514. * Gets or sets the center of the bounding box associated with the cube texture
  57515. * It must define where the camera used to render the texture was set
  57516. */
  57517. boundingBoxPosition: Vector3;
  57518. private _boundingBoxSize;
  57519. /**
  57520. * Gets or sets the size of the bounding box associated with the cube texture
  57521. * When defined, the cubemap will switch to local mode
  57522. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57523. * @example https://www.babylonjs-playground.com/#RNASML
  57524. */
  57525. set boundingBoxSize(value: Vector3);
  57526. get boundingBoxSize(): Vector3;
  57527. /**
  57528. * Instantiates an HDRTexture from the following parameters.
  57529. *
  57530. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57531. * @param scene The scene the texture will be used in
  57532. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57533. * @param noMipmap Forces to not generate the mipmap if true
  57534. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57535. * @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)
  57536. * @param reserved Reserved flag for internal use.
  57537. */
  57538. 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>);
  57539. /**
  57540. * Get the current class name of the texture useful for serialization or dynamic coding.
  57541. * @returns "HDRCubeTexture"
  57542. */
  57543. getClassName(): string;
  57544. /**
  57545. * Occurs when the file is raw .hdr file.
  57546. */
  57547. private loadTexture;
  57548. clone(): HDRCubeTexture;
  57549. delayLoad(): void;
  57550. /**
  57551. * Get the texture reflection matrix used to rotate/transform the reflection.
  57552. * @returns the reflection matrix
  57553. */
  57554. getReflectionTextureMatrix(): Matrix;
  57555. /**
  57556. * Set the texture reflection matrix used to rotate/transform the reflection.
  57557. * @param value Define the reflection matrix to set
  57558. */
  57559. setReflectionTextureMatrix(value: Matrix): void;
  57560. /**
  57561. * Parses a JSON representation of an HDR Texture in order to create the texture
  57562. * @param parsedTexture Define the JSON representation
  57563. * @param scene Define the scene the texture should be created in
  57564. * @param rootUrl Define the root url in case we need to load relative dependencies
  57565. * @returns the newly created texture after parsing
  57566. */
  57567. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57568. serialize(): any;
  57569. }
  57570. }
  57571. declare module "babylonjs/Physics/physicsEngine" {
  57572. import { Nullable } from "babylonjs/types";
  57573. import { Vector3 } from "babylonjs/Maths/math.vector";
  57574. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57575. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57576. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57577. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57578. /**
  57579. * Class used to control physics engine
  57580. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57581. */
  57582. export class PhysicsEngine implements IPhysicsEngine {
  57583. private _physicsPlugin;
  57584. /**
  57585. * Global value used to control the smallest number supported by the simulation
  57586. */
  57587. static Epsilon: number;
  57588. private _impostors;
  57589. private _joints;
  57590. private _subTimeStep;
  57591. /**
  57592. * Gets the gravity vector used by the simulation
  57593. */
  57594. gravity: Vector3;
  57595. /**
  57596. * Factory used to create the default physics plugin.
  57597. * @returns The default physics plugin
  57598. */
  57599. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57600. /**
  57601. * Creates a new Physics Engine
  57602. * @param gravity defines the gravity vector used by the simulation
  57603. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57604. */
  57605. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57606. /**
  57607. * Sets the gravity vector used by the simulation
  57608. * @param gravity defines the gravity vector to use
  57609. */
  57610. setGravity(gravity: Vector3): void;
  57611. /**
  57612. * Set the time step of the physics engine.
  57613. * Default is 1/60.
  57614. * To slow it down, enter 1/600 for example.
  57615. * To speed it up, 1/30
  57616. * @param newTimeStep defines the new timestep to apply to this world.
  57617. */
  57618. setTimeStep(newTimeStep?: number): void;
  57619. /**
  57620. * Get the time step of the physics engine.
  57621. * @returns the current time step
  57622. */
  57623. getTimeStep(): number;
  57624. /**
  57625. * Set the sub time step of the physics engine.
  57626. * Default is 0 meaning there is no sub steps
  57627. * To increase physics resolution precision, set a small value (like 1 ms)
  57628. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57629. */
  57630. setSubTimeStep(subTimeStep?: number): void;
  57631. /**
  57632. * Get the sub time step of the physics engine.
  57633. * @returns the current sub time step
  57634. */
  57635. getSubTimeStep(): number;
  57636. /**
  57637. * Release all resources
  57638. */
  57639. dispose(): void;
  57640. /**
  57641. * Gets the name of the current physics plugin
  57642. * @returns the name of the plugin
  57643. */
  57644. getPhysicsPluginName(): string;
  57645. /**
  57646. * Adding a new impostor for the impostor tracking.
  57647. * This will be done by the impostor itself.
  57648. * @param impostor the impostor to add
  57649. */
  57650. addImpostor(impostor: PhysicsImpostor): void;
  57651. /**
  57652. * Remove an impostor from the engine.
  57653. * This impostor and its mesh will not longer be updated by the physics engine.
  57654. * @param impostor the impostor to remove
  57655. */
  57656. removeImpostor(impostor: PhysicsImpostor): void;
  57657. /**
  57658. * Add a joint to the physics engine
  57659. * @param mainImpostor defines the main impostor to which the joint is added.
  57660. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57661. * @param joint defines the joint that will connect both impostors.
  57662. */
  57663. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57664. /**
  57665. * Removes a joint from the simulation
  57666. * @param mainImpostor defines the impostor used with the joint
  57667. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57668. * @param joint defines the joint to remove
  57669. */
  57670. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57671. /**
  57672. * Called by the scene. No need to call it.
  57673. * @param delta defines the timespam between frames
  57674. */
  57675. _step(delta: number): void;
  57676. /**
  57677. * Gets the current plugin used to run the simulation
  57678. * @returns current plugin
  57679. */
  57680. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57681. /**
  57682. * Gets the list of physic impostors
  57683. * @returns an array of PhysicsImpostor
  57684. */
  57685. getImpostors(): Array<PhysicsImpostor>;
  57686. /**
  57687. * Gets the impostor for a physics enabled object
  57688. * @param object defines the object impersonated by the impostor
  57689. * @returns the PhysicsImpostor or null if not found
  57690. */
  57691. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57692. /**
  57693. * Gets the impostor for a physics body object
  57694. * @param body defines physics body used by the impostor
  57695. * @returns the PhysicsImpostor or null if not found
  57696. */
  57697. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57698. /**
  57699. * Does a raycast in the physics world
  57700. * @param from when should the ray start?
  57701. * @param to when should the ray end?
  57702. * @returns PhysicsRaycastResult
  57703. */
  57704. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57705. }
  57706. }
  57707. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57708. import { Nullable } from "babylonjs/types";
  57709. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57711. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57712. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57713. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57714. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57715. /** @hidden */
  57716. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57717. private _useDeltaForWorldStep;
  57718. world: any;
  57719. name: string;
  57720. private _physicsMaterials;
  57721. private _fixedTimeStep;
  57722. private _cannonRaycastResult;
  57723. private _raycastResult;
  57724. private _physicsBodysToRemoveAfterStep;
  57725. BJSCANNON: any;
  57726. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57727. setGravity(gravity: Vector3): void;
  57728. setTimeStep(timeStep: number): void;
  57729. getTimeStep(): number;
  57730. executeStep(delta: number): void;
  57731. private _removeMarkedPhysicsBodiesFromWorld;
  57732. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57733. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57734. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57735. private _processChildMeshes;
  57736. removePhysicsBody(impostor: PhysicsImpostor): void;
  57737. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57738. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57739. private _addMaterial;
  57740. private _checkWithEpsilon;
  57741. private _createShape;
  57742. private _createHeightmap;
  57743. private _minus90X;
  57744. private _plus90X;
  57745. private _tmpPosition;
  57746. private _tmpDeltaPosition;
  57747. private _tmpUnityRotation;
  57748. private _updatePhysicsBodyTransformation;
  57749. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57751. isSupported(): boolean;
  57752. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57753. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57754. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57755. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57756. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57757. getBodyMass(impostor: PhysicsImpostor): number;
  57758. getBodyFriction(impostor: PhysicsImpostor): number;
  57759. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57760. getBodyRestitution(impostor: PhysicsImpostor): number;
  57761. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57762. sleepBody(impostor: PhysicsImpostor): void;
  57763. wakeUpBody(impostor: PhysicsImpostor): void;
  57764. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57765. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57766. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57767. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57768. getRadius(impostor: PhysicsImpostor): number;
  57769. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57770. dispose(): void;
  57771. private _extendNamespace;
  57772. /**
  57773. * Does a raycast in the physics world
  57774. * @param from when should the ray start?
  57775. * @param to when should the ray end?
  57776. * @returns PhysicsRaycastResult
  57777. */
  57778. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57779. }
  57780. }
  57781. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57782. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57783. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57784. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57786. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57787. import { Nullable } from "babylonjs/types";
  57788. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57789. /** @hidden */
  57790. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57791. world: any;
  57792. name: string;
  57793. BJSOIMO: any;
  57794. private _raycastResult;
  57795. constructor(iterations?: number, oimoInjection?: any);
  57796. setGravity(gravity: Vector3): void;
  57797. setTimeStep(timeStep: number): void;
  57798. getTimeStep(): number;
  57799. private _tmpImpostorsArray;
  57800. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57801. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57802. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57803. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57804. private _tmpPositionVector;
  57805. removePhysicsBody(impostor: PhysicsImpostor): void;
  57806. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57807. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57808. isSupported(): boolean;
  57809. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57810. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57811. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57812. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57813. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57814. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57815. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57816. getBodyMass(impostor: PhysicsImpostor): number;
  57817. getBodyFriction(impostor: PhysicsImpostor): number;
  57818. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57819. getBodyRestitution(impostor: PhysicsImpostor): number;
  57820. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57821. sleepBody(impostor: PhysicsImpostor): void;
  57822. wakeUpBody(impostor: PhysicsImpostor): void;
  57823. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57824. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57825. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57826. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57827. getRadius(impostor: PhysicsImpostor): number;
  57828. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57829. dispose(): void;
  57830. /**
  57831. * Does a raycast in the physics world
  57832. * @param from when should the ray start?
  57833. * @param to when should the ray end?
  57834. * @returns PhysicsRaycastResult
  57835. */
  57836. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57837. }
  57838. }
  57839. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57840. import { Nullable } from "babylonjs/types";
  57841. import { Scene } from "babylonjs/scene";
  57842. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57843. import { Color4 } from "babylonjs/Maths/math.color";
  57844. import { Mesh } from "babylonjs/Meshes/mesh";
  57845. /**
  57846. * Class containing static functions to help procedurally build meshes
  57847. */
  57848. export class RibbonBuilder {
  57849. /**
  57850. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57851. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57852. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57853. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57854. * * 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
  57855. * * 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
  57856. * * 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
  57857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57859. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57860. * * 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
  57861. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57862. * * 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
  57863. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57865. * @param name defines the name of the mesh
  57866. * @param options defines the options used to create the mesh
  57867. * @param scene defines the hosting scene
  57868. * @returns the ribbon mesh
  57869. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57871. */
  57872. static CreateRibbon(name: string, options: {
  57873. pathArray: Vector3[][];
  57874. closeArray?: boolean;
  57875. closePath?: boolean;
  57876. offset?: number;
  57877. updatable?: boolean;
  57878. sideOrientation?: number;
  57879. frontUVs?: Vector4;
  57880. backUVs?: Vector4;
  57881. instance?: Mesh;
  57882. invertUV?: boolean;
  57883. uvs?: Vector2[];
  57884. colors?: Color4[];
  57885. }, scene?: Nullable<Scene>): Mesh;
  57886. }
  57887. }
  57888. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57889. import { Nullable } from "babylonjs/types";
  57890. import { Scene } from "babylonjs/scene";
  57891. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57892. import { Mesh } from "babylonjs/Meshes/mesh";
  57893. /**
  57894. * Class containing static functions to help procedurally build meshes
  57895. */
  57896. export class ShapeBuilder {
  57897. /**
  57898. * 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.
  57899. * * 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.
  57900. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57901. * * 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.
  57902. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57903. * * 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
  57904. * * 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
  57905. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57910. * @param name defines the name of the mesh
  57911. * @param options defines the options used to create the mesh
  57912. * @param scene defines the hosting scene
  57913. * @returns the extruded shape mesh
  57914. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57916. */
  57917. static ExtrudeShape(name: string, options: {
  57918. shape: Vector3[];
  57919. path: Vector3[];
  57920. scale?: number;
  57921. rotation?: number;
  57922. cap?: number;
  57923. updatable?: boolean;
  57924. sideOrientation?: number;
  57925. frontUVs?: Vector4;
  57926. backUVs?: Vector4;
  57927. instance?: Mesh;
  57928. invertUV?: boolean;
  57929. }, scene?: Nullable<Scene>): Mesh;
  57930. /**
  57931. * Creates an custom extruded shape mesh.
  57932. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57933. * * 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.
  57934. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57935. * * 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
  57936. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57937. * * 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
  57938. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57939. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57940. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57941. * * 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
  57942. * * 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
  57943. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57946. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57948. * @param name defines the name of the mesh
  57949. * @param options defines the options used to create the mesh
  57950. * @param scene defines the hosting scene
  57951. * @returns the custom extruded shape mesh
  57952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57953. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57955. */
  57956. static ExtrudeShapeCustom(name: string, options: {
  57957. shape: Vector3[];
  57958. path: Vector3[];
  57959. scaleFunction?: any;
  57960. rotationFunction?: any;
  57961. ribbonCloseArray?: boolean;
  57962. ribbonClosePath?: boolean;
  57963. cap?: number;
  57964. updatable?: boolean;
  57965. sideOrientation?: number;
  57966. frontUVs?: Vector4;
  57967. backUVs?: Vector4;
  57968. instance?: Mesh;
  57969. invertUV?: boolean;
  57970. }, scene?: Nullable<Scene>): Mesh;
  57971. private static _ExtrudeShapeGeneric;
  57972. }
  57973. }
  57974. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57975. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57976. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57977. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57978. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57979. import { Nullable } from "babylonjs/types";
  57980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57981. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57982. /**
  57983. * AmmoJS Physics plugin
  57984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57985. * @see https://github.com/kripken/ammo.js/
  57986. */
  57987. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57988. private _useDeltaForWorldStep;
  57989. /**
  57990. * Reference to the Ammo library
  57991. */
  57992. bjsAMMO: any;
  57993. /**
  57994. * Created ammoJS world which physics bodies are added to
  57995. */
  57996. world: any;
  57997. /**
  57998. * Name of the plugin
  57999. */
  58000. name: string;
  58001. private _timeStep;
  58002. private _fixedTimeStep;
  58003. private _maxSteps;
  58004. private _tmpQuaternion;
  58005. private _tmpAmmoTransform;
  58006. private _tmpAmmoQuaternion;
  58007. private _tmpAmmoConcreteContactResultCallback;
  58008. private _collisionConfiguration;
  58009. private _dispatcher;
  58010. private _overlappingPairCache;
  58011. private _solver;
  58012. private _softBodySolver;
  58013. private _tmpAmmoVectorA;
  58014. private _tmpAmmoVectorB;
  58015. private _tmpAmmoVectorC;
  58016. private _tmpAmmoVectorD;
  58017. private _tmpContactCallbackResult;
  58018. private _tmpAmmoVectorRCA;
  58019. private _tmpAmmoVectorRCB;
  58020. private _raycastResult;
  58021. private static readonly DISABLE_COLLISION_FLAG;
  58022. private static readonly KINEMATIC_FLAG;
  58023. private static readonly DISABLE_DEACTIVATION_FLAG;
  58024. /**
  58025. * Initializes the ammoJS plugin
  58026. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58027. * @param ammoInjection can be used to inject your own ammo reference
  58028. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58029. */
  58030. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58031. /**
  58032. * Sets the gravity of the physics world (m/(s^2))
  58033. * @param gravity Gravity to set
  58034. */
  58035. setGravity(gravity: Vector3): void;
  58036. /**
  58037. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58038. * @param timeStep timestep to use in seconds
  58039. */
  58040. setTimeStep(timeStep: number): void;
  58041. /**
  58042. * 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)
  58043. * @param fixedTimeStep fixedTimeStep to use in seconds
  58044. */
  58045. setFixedTimeStep(fixedTimeStep: number): void;
  58046. /**
  58047. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58048. * @param maxSteps the maximum number of steps by the physics engine per frame
  58049. */
  58050. setMaxSteps(maxSteps: number): void;
  58051. /**
  58052. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58053. * @returns the current timestep in seconds
  58054. */
  58055. getTimeStep(): number;
  58056. /**
  58057. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58058. */
  58059. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58060. private _isImpostorInContact;
  58061. private _isImpostorPairInContact;
  58062. private _stepSimulation;
  58063. /**
  58064. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58065. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58066. * After the step the babylon meshes are set to the position of the physics imposters
  58067. * @param delta amount of time to step forward
  58068. * @param impostors array of imposters to update before/after the step
  58069. */
  58070. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58071. /**
  58072. * Update babylon mesh to match physics world object
  58073. * @param impostor imposter to match
  58074. */
  58075. private _afterSoftStep;
  58076. /**
  58077. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58078. * @param impostor imposter to match
  58079. */
  58080. private _ropeStep;
  58081. /**
  58082. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58083. * @param impostor imposter to match
  58084. */
  58085. private _softbodyOrClothStep;
  58086. private _tmpVector;
  58087. private _tmpMatrix;
  58088. /**
  58089. * Applies an impulse on the imposter
  58090. * @param impostor imposter to apply impulse to
  58091. * @param force amount of force to be applied to the imposter
  58092. * @param contactPoint the location to apply the impulse on the imposter
  58093. */
  58094. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58095. /**
  58096. * Applies a force on the imposter
  58097. * @param impostor imposter to apply force
  58098. * @param force amount of force to be applied to the imposter
  58099. * @param contactPoint the location to apply the force on the imposter
  58100. */
  58101. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58102. /**
  58103. * Creates a physics body using the plugin
  58104. * @param impostor the imposter to create the physics body on
  58105. */
  58106. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58107. /**
  58108. * Removes the physics body from the imposter and disposes of the body's memory
  58109. * @param impostor imposter to remove the physics body from
  58110. */
  58111. removePhysicsBody(impostor: PhysicsImpostor): void;
  58112. /**
  58113. * Generates a joint
  58114. * @param impostorJoint the imposter joint to create the joint with
  58115. */
  58116. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58117. /**
  58118. * Removes a joint
  58119. * @param impostorJoint the imposter joint to remove the joint from
  58120. */
  58121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58122. private _addMeshVerts;
  58123. /**
  58124. * Initialise the soft body vertices to match its object's (mesh) vertices
  58125. * Softbody vertices (nodes) are in world space and to match this
  58126. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58127. * @param impostor to create the softbody for
  58128. */
  58129. private _softVertexData;
  58130. /**
  58131. * Create an impostor's soft body
  58132. * @param impostor to create the softbody for
  58133. */
  58134. private _createSoftbody;
  58135. /**
  58136. * Create cloth for an impostor
  58137. * @param impostor to create the softbody for
  58138. */
  58139. private _createCloth;
  58140. /**
  58141. * Create rope for an impostor
  58142. * @param impostor to create the softbody for
  58143. */
  58144. private _createRope;
  58145. /**
  58146. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58147. * @param impostor to create the custom physics shape for
  58148. */
  58149. private _createCustom;
  58150. private _addHullVerts;
  58151. private _createShape;
  58152. /**
  58153. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58154. * @param impostor imposter containing the physics body and babylon object
  58155. */
  58156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58157. /**
  58158. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58159. * @param impostor imposter containing the physics body and babylon object
  58160. * @param newPosition new position
  58161. * @param newRotation new rotation
  58162. */
  58163. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58164. /**
  58165. * If this plugin is supported
  58166. * @returns true if its supported
  58167. */
  58168. isSupported(): boolean;
  58169. /**
  58170. * Sets the linear velocity of the physics body
  58171. * @param impostor imposter to set the velocity on
  58172. * @param velocity velocity to set
  58173. */
  58174. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58175. /**
  58176. * Sets the angular velocity of the physics body
  58177. * @param impostor imposter to set the velocity on
  58178. * @param velocity velocity to set
  58179. */
  58180. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58181. /**
  58182. * gets the linear velocity
  58183. * @param impostor imposter to get linear velocity from
  58184. * @returns linear velocity
  58185. */
  58186. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58187. /**
  58188. * gets the angular velocity
  58189. * @param impostor imposter to get angular velocity from
  58190. * @returns angular velocity
  58191. */
  58192. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58193. /**
  58194. * Sets the mass of physics body
  58195. * @param impostor imposter to set the mass on
  58196. * @param mass mass to set
  58197. */
  58198. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58199. /**
  58200. * Gets the mass of the physics body
  58201. * @param impostor imposter to get the mass from
  58202. * @returns mass
  58203. */
  58204. getBodyMass(impostor: PhysicsImpostor): number;
  58205. /**
  58206. * Gets friction of the impostor
  58207. * @param impostor impostor to get friction from
  58208. * @returns friction value
  58209. */
  58210. getBodyFriction(impostor: PhysicsImpostor): number;
  58211. /**
  58212. * Sets friction of the impostor
  58213. * @param impostor impostor to set friction on
  58214. * @param friction friction value
  58215. */
  58216. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58217. /**
  58218. * Gets restitution of the impostor
  58219. * @param impostor impostor to get restitution from
  58220. * @returns restitution value
  58221. */
  58222. getBodyRestitution(impostor: PhysicsImpostor): number;
  58223. /**
  58224. * Sets resitution of the impostor
  58225. * @param impostor impostor to set resitution on
  58226. * @param restitution resitution value
  58227. */
  58228. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58229. /**
  58230. * Gets pressure inside the impostor
  58231. * @param impostor impostor to get pressure from
  58232. * @returns pressure value
  58233. */
  58234. getBodyPressure(impostor: PhysicsImpostor): number;
  58235. /**
  58236. * Sets pressure inside a soft body impostor
  58237. * Cloth and rope must remain 0 pressure
  58238. * @param impostor impostor to set pressure on
  58239. * @param pressure pressure value
  58240. */
  58241. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58242. /**
  58243. * Gets stiffness of the impostor
  58244. * @param impostor impostor to get stiffness from
  58245. * @returns pressure value
  58246. */
  58247. getBodyStiffness(impostor: PhysicsImpostor): number;
  58248. /**
  58249. * Sets stiffness of the impostor
  58250. * @param impostor impostor to set stiffness on
  58251. * @param stiffness stiffness value from 0 to 1
  58252. */
  58253. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58254. /**
  58255. * Gets velocityIterations of the impostor
  58256. * @param impostor impostor to get velocity iterations from
  58257. * @returns velocityIterations value
  58258. */
  58259. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58260. /**
  58261. * Sets velocityIterations of the impostor
  58262. * @param impostor impostor to set velocity iterations on
  58263. * @param velocityIterations velocityIterations value
  58264. */
  58265. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58266. /**
  58267. * Gets positionIterations of the impostor
  58268. * @param impostor impostor to get position iterations from
  58269. * @returns positionIterations value
  58270. */
  58271. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58272. /**
  58273. * Sets positionIterations of the impostor
  58274. * @param impostor impostor to set position on
  58275. * @param positionIterations positionIterations value
  58276. */
  58277. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58278. /**
  58279. * Append an anchor to a cloth object
  58280. * @param impostor is the cloth impostor to add anchor to
  58281. * @param otherImpostor is the rigid impostor to anchor to
  58282. * @param width ratio across width from 0 to 1
  58283. * @param height ratio up height from 0 to 1
  58284. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58285. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58286. */
  58287. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58288. /**
  58289. * Append an hook to a rope object
  58290. * @param impostor is the rope impostor to add hook to
  58291. * @param otherImpostor is the rigid impostor to hook to
  58292. * @param length ratio along the rope from 0 to 1
  58293. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58294. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58295. */
  58296. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58297. /**
  58298. * Sleeps the physics body and stops it from being active
  58299. * @param impostor impostor to sleep
  58300. */
  58301. sleepBody(impostor: PhysicsImpostor): void;
  58302. /**
  58303. * Activates the physics body
  58304. * @param impostor impostor to activate
  58305. */
  58306. wakeUpBody(impostor: PhysicsImpostor): void;
  58307. /**
  58308. * Updates the distance parameters of the joint
  58309. * @param joint joint to update
  58310. * @param maxDistance maximum distance of the joint
  58311. * @param minDistance minimum distance of the joint
  58312. */
  58313. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58314. /**
  58315. * Sets a motor on the joint
  58316. * @param joint joint to set motor on
  58317. * @param speed speed of the motor
  58318. * @param maxForce maximum force of the motor
  58319. * @param motorIndex index of the motor
  58320. */
  58321. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58322. /**
  58323. * Sets the motors limit
  58324. * @param joint joint to set limit on
  58325. * @param upperLimit upper limit
  58326. * @param lowerLimit lower limit
  58327. */
  58328. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58329. /**
  58330. * Syncs the position and rotation of a mesh with the impostor
  58331. * @param mesh mesh to sync
  58332. * @param impostor impostor to update the mesh with
  58333. */
  58334. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58335. /**
  58336. * Gets the radius of the impostor
  58337. * @param impostor impostor to get radius from
  58338. * @returns the radius
  58339. */
  58340. getRadius(impostor: PhysicsImpostor): number;
  58341. /**
  58342. * Gets the box size of the impostor
  58343. * @param impostor impostor to get box size from
  58344. * @param result the resulting box size
  58345. */
  58346. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58347. /**
  58348. * Disposes of the impostor
  58349. */
  58350. dispose(): void;
  58351. /**
  58352. * Does a raycast in the physics world
  58353. * @param from when should the ray start?
  58354. * @param to when should the ray end?
  58355. * @returns PhysicsRaycastResult
  58356. */
  58357. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58358. }
  58359. }
  58360. declare module "babylonjs/Probes/reflectionProbe" {
  58361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58362. import { Vector3 } from "babylonjs/Maths/math.vector";
  58363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58364. import { Nullable } from "babylonjs/types";
  58365. import { Scene } from "babylonjs/scene";
  58366. module "babylonjs/abstractScene" {
  58367. interface AbstractScene {
  58368. /**
  58369. * The list of reflection probes added to the scene
  58370. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58371. */
  58372. reflectionProbes: Array<ReflectionProbe>;
  58373. /**
  58374. * Removes the given reflection probe from this scene.
  58375. * @param toRemove The reflection probe to remove
  58376. * @returns The index of the removed reflection probe
  58377. */
  58378. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58379. /**
  58380. * Adds the given reflection probe to this scene.
  58381. * @param newReflectionProbe The reflection probe to add
  58382. */
  58383. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58384. }
  58385. }
  58386. /**
  58387. * Class used to generate realtime reflection / refraction cube textures
  58388. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58389. */
  58390. export class ReflectionProbe {
  58391. /** defines the name of the probe */
  58392. name: string;
  58393. private _scene;
  58394. private _renderTargetTexture;
  58395. private _projectionMatrix;
  58396. private _viewMatrix;
  58397. private _target;
  58398. private _add;
  58399. private _attachedMesh;
  58400. private _invertYAxis;
  58401. /** Gets or sets probe position (center of the cube map) */
  58402. position: Vector3;
  58403. /**
  58404. * Creates a new reflection probe
  58405. * @param name defines the name of the probe
  58406. * @param size defines the texture resolution (for each face)
  58407. * @param scene defines the hosting scene
  58408. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58409. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58410. */
  58411. constructor(
  58412. /** defines the name of the probe */
  58413. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58414. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58415. get samples(): number;
  58416. set samples(value: number);
  58417. /** Gets or sets the refresh rate to use (on every frame by default) */
  58418. get refreshRate(): number;
  58419. set refreshRate(value: number);
  58420. /**
  58421. * Gets the hosting scene
  58422. * @returns a Scene
  58423. */
  58424. getScene(): Scene;
  58425. /** Gets the internal CubeTexture used to render to */
  58426. get cubeTexture(): RenderTargetTexture;
  58427. /** Gets the list of meshes to render */
  58428. get renderList(): Nullable<AbstractMesh[]>;
  58429. /**
  58430. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58431. * @param mesh defines the mesh to attach to
  58432. */
  58433. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58434. /**
  58435. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58436. * @param renderingGroupId The rendering group id corresponding to its index
  58437. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58438. */
  58439. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58440. /**
  58441. * Clean all associated resources
  58442. */
  58443. dispose(): void;
  58444. /**
  58445. * Converts the reflection probe information to a readable string for debug purpose.
  58446. * @param fullDetails Supports for multiple levels of logging within scene loading
  58447. * @returns the human readable reflection probe info
  58448. */
  58449. toString(fullDetails?: boolean): string;
  58450. /**
  58451. * Get the class name of the relfection probe.
  58452. * @returns "ReflectionProbe"
  58453. */
  58454. getClassName(): string;
  58455. /**
  58456. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58457. * @returns The JSON representation of the texture
  58458. */
  58459. serialize(): any;
  58460. /**
  58461. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58462. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58463. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58464. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58465. * @returns The parsed reflection probe if successful
  58466. */
  58467. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58468. }
  58469. }
  58470. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58471. /** @hidden */
  58472. export var _BabylonLoaderRegistered: boolean;
  58473. /**
  58474. * Helps setting up some configuration for the babylon file loader.
  58475. */
  58476. export class BabylonFileLoaderConfiguration {
  58477. /**
  58478. * The loader does not allow injecting custom physix engine into the plugins.
  58479. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58480. * So you could set this variable to your engine import to make it work.
  58481. */
  58482. static LoaderInjectedPhysicsEngine: any;
  58483. }
  58484. }
  58485. declare module "babylonjs/Loading/Plugins/index" {
  58486. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58487. }
  58488. declare module "babylonjs/Loading/index" {
  58489. export * from "babylonjs/Loading/loadingScreen";
  58490. export * from "babylonjs/Loading/Plugins/index";
  58491. export * from "babylonjs/Loading/sceneLoader";
  58492. export * from "babylonjs/Loading/sceneLoaderFlags";
  58493. }
  58494. declare module "babylonjs/Materials/Background/index" {
  58495. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58496. }
  58497. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58498. import { Scene } from "babylonjs/scene";
  58499. import { Color3 } from "babylonjs/Maths/math.color";
  58500. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58502. /**
  58503. * The Physically based simple base material of BJS.
  58504. *
  58505. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58506. * It is used as the base class for both the specGloss and metalRough conventions.
  58507. */
  58508. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58509. /**
  58510. * Number of Simultaneous lights allowed on the material.
  58511. */
  58512. maxSimultaneousLights: number;
  58513. /**
  58514. * If sets to true, disables all the lights affecting the material.
  58515. */
  58516. disableLighting: boolean;
  58517. /**
  58518. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58519. */
  58520. environmentTexture: BaseTexture;
  58521. /**
  58522. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58523. */
  58524. invertNormalMapX: boolean;
  58525. /**
  58526. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58527. */
  58528. invertNormalMapY: boolean;
  58529. /**
  58530. * Normal map used in the model.
  58531. */
  58532. normalTexture: BaseTexture;
  58533. /**
  58534. * Emissivie color used to self-illuminate the model.
  58535. */
  58536. emissiveColor: Color3;
  58537. /**
  58538. * Emissivie texture used to self-illuminate the model.
  58539. */
  58540. emissiveTexture: BaseTexture;
  58541. /**
  58542. * Occlusion Channel Strenght.
  58543. */
  58544. occlusionStrength: number;
  58545. /**
  58546. * Occlusion Texture of the material (adding extra occlusion effects).
  58547. */
  58548. occlusionTexture: BaseTexture;
  58549. /**
  58550. * Defines the alpha limits in alpha test mode.
  58551. */
  58552. alphaCutOff: number;
  58553. /**
  58554. * Gets the current double sided mode.
  58555. */
  58556. get doubleSided(): boolean;
  58557. /**
  58558. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58559. */
  58560. set doubleSided(value: boolean);
  58561. /**
  58562. * Stores the pre-calculated light information of a mesh in a texture.
  58563. */
  58564. lightmapTexture: BaseTexture;
  58565. /**
  58566. * If true, the light map contains occlusion information instead of lighting info.
  58567. */
  58568. useLightmapAsShadowmap: boolean;
  58569. /**
  58570. * Instantiates a new PBRMaterial instance.
  58571. *
  58572. * @param name The material name
  58573. * @param scene The scene the material will be use in.
  58574. */
  58575. constructor(name: string, scene: Scene);
  58576. getClassName(): string;
  58577. }
  58578. }
  58579. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58580. import { Scene } from "babylonjs/scene";
  58581. import { Color3 } from "babylonjs/Maths/math.color";
  58582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58583. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58584. /**
  58585. * The PBR material of BJS following the metal roughness convention.
  58586. *
  58587. * This fits to the PBR convention in the GLTF definition:
  58588. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58589. */
  58590. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58591. /**
  58592. * The base color has two different interpretations depending on the value of metalness.
  58593. * When the material is a metal, the base color is the specific measured reflectance value
  58594. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58595. * of the material.
  58596. */
  58597. baseColor: Color3;
  58598. /**
  58599. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58600. * well as opacity information in the alpha channel.
  58601. */
  58602. baseTexture: BaseTexture;
  58603. /**
  58604. * Specifies the metallic scalar value of the material.
  58605. * Can also be used to scale the metalness values of the metallic texture.
  58606. */
  58607. metallic: number;
  58608. /**
  58609. * Specifies the roughness scalar value of the material.
  58610. * Can also be used to scale the roughness values of the metallic texture.
  58611. */
  58612. roughness: number;
  58613. /**
  58614. * Texture containing both the metallic value in the B channel and the
  58615. * roughness value in the G channel to keep better precision.
  58616. */
  58617. metallicRoughnessTexture: BaseTexture;
  58618. /**
  58619. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58620. *
  58621. * @param name The material name
  58622. * @param scene The scene the material will be use in.
  58623. */
  58624. constructor(name: string, scene: Scene);
  58625. /**
  58626. * Return the currrent class name of the material.
  58627. */
  58628. getClassName(): string;
  58629. /**
  58630. * Makes a duplicate of the current material.
  58631. * @param name - name to use for the new material.
  58632. */
  58633. clone(name: string): PBRMetallicRoughnessMaterial;
  58634. /**
  58635. * Serialize the material to a parsable JSON object.
  58636. */
  58637. serialize(): any;
  58638. /**
  58639. * Parses a JSON object correponding to the serialize function.
  58640. */
  58641. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58642. }
  58643. }
  58644. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58645. import { Scene } from "babylonjs/scene";
  58646. import { Color3 } from "babylonjs/Maths/math.color";
  58647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58648. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58649. /**
  58650. * The PBR material of BJS following the specular glossiness convention.
  58651. *
  58652. * This fits to the PBR convention in the GLTF definition:
  58653. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58654. */
  58655. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58656. /**
  58657. * Specifies the diffuse color of the material.
  58658. */
  58659. diffuseColor: Color3;
  58660. /**
  58661. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58662. * channel.
  58663. */
  58664. diffuseTexture: BaseTexture;
  58665. /**
  58666. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58667. */
  58668. specularColor: Color3;
  58669. /**
  58670. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58671. */
  58672. glossiness: number;
  58673. /**
  58674. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58675. */
  58676. specularGlossinessTexture: BaseTexture;
  58677. /**
  58678. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58679. *
  58680. * @param name The material name
  58681. * @param scene The scene the material will be use in.
  58682. */
  58683. constructor(name: string, scene: Scene);
  58684. /**
  58685. * Return the currrent class name of the material.
  58686. */
  58687. getClassName(): string;
  58688. /**
  58689. * Makes a duplicate of the current material.
  58690. * @param name - name to use for the new material.
  58691. */
  58692. clone(name: string): PBRSpecularGlossinessMaterial;
  58693. /**
  58694. * Serialize the material to a parsable JSON object.
  58695. */
  58696. serialize(): any;
  58697. /**
  58698. * Parses a JSON object correponding to the serialize function.
  58699. */
  58700. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58701. }
  58702. }
  58703. declare module "babylonjs/Materials/PBR/index" {
  58704. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58705. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58706. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58707. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58708. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58709. }
  58710. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58711. import { Nullable } from "babylonjs/types";
  58712. import { Scene } from "babylonjs/scene";
  58713. import { Matrix } from "babylonjs/Maths/math.vector";
  58714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58715. /**
  58716. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58717. * It can help converting any input color in a desired output one. This can then be used to create effects
  58718. * from sepia, black and white to sixties or futuristic rendering...
  58719. *
  58720. * The only supported format is currently 3dl.
  58721. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58722. */
  58723. export class ColorGradingTexture extends BaseTexture {
  58724. /**
  58725. * The current texture matrix. (will always be identity in color grading texture)
  58726. */
  58727. private _textureMatrix;
  58728. /**
  58729. * The texture URL.
  58730. */
  58731. url: string;
  58732. /**
  58733. * Empty line regex stored for GC.
  58734. */
  58735. private static _noneEmptyLineRegex;
  58736. private _engine;
  58737. /**
  58738. * Instantiates a ColorGradingTexture from the following parameters.
  58739. *
  58740. * @param url The location of the color gradind data (currently only supporting 3dl)
  58741. * @param scene The scene the texture will be used in
  58742. */
  58743. constructor(url: string, scene: Scene);
  58744. /**
  58745. * Returns the texture matrix used in most of the material.
  58746. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58747. */
  58748. getTextureMatrix(): Matrix;
  58749. /**
  58750. * Occurs when the file being loaded is a .3dl LUT file.
  58751. */
  58752. private load3dlTexture;
  58753. /**
  58754. * Starts the loading process of the texture.
  58755. */
  58756. private loadTexture;
  58757. /**
  58758. * Clones the color gradind texture.
  58759. */
  58760. clone(): ColorGradingTexture;
  58761. /**
  58762. * Called during delayed load for textures.
  58763. */
  58764. delayLoad(): void;
  58765. /**
  58766. * Parses a color grading texture serialized by Babylon.
  58767. * @param parsedTexture The texture information being parsedTexture
  58768. * @param scene The scene to load the texture in
  58769. * @param rootUrl The root url of the data assets to load
  58770. * @return A color gradind texture
  58771. */
  58772. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58773. /**
  58774. * Serializes the LUT texture to json format.
  58775. */
  58776. serialize(): any;
  58777. }
  58778. }
  58779. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58781. import { Scene } from "babylonjs/scene";
  58782. import { Nullable } from "babylonjs/types";
  58783. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58784. /**
  58785. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58786. */
  58787. export class EquiRectangularCubeTexture extends BaseTexture {
  58788. /** The six faces of the cube. */
  58789. private static _FacesMapping;
  58790. private _noMipmap;
  58791. private _onLoad;
  58792. private _onError;
  58793. /** The size of the cubemap. */
  58794. private _size;
  58795. /** The buffer of the image. */
  58796. private _buffer;
  58797. /** The width of the input image. */
  58798. private _width;
  58799. /** The height of the input image. */
  58800. private _height;
  58801. /** The URL to the image. */
  58802. url: string;
  58803. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58804. coordinatesMode: number;
  58805. /**
  58806. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58807. * @param url The location of the image
  58808. * @param scene The scene the texture will be used in
  58809. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58810. * @param noMipmap Forces to not generate the mipmap if true
  58811. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58812. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58813. * @param onLoad — defines a callback called when texture is loaded
  58814. * @param onError — defines a callback called if there is an error
  58815. */
  58816. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58817. /**
  58818. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58819. */
  58820. private loadImage;
  58821. /**
  58822. * Convert the image buffer into a cubemap and create a CubeTexture.
  58823. */
  58824. private loadTexture;
  58825. /**
  58826. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58827. * @param buffer The ArrayBuffer that should be converted.
  58828. * @returns The buffer as Float32Array.
  58829. */
  58830. private getFloat32ArrayFromArrayBuffer;
  58831. /**
  58832. * Get the current class name of the texture useful for serialization or dynamic coding.
  58833. * @returns "EquiRectangularCubeTexture"
  58834. */
  58835. getClassName(): string;
  58836. /**
  58837. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58838. * @returns A clone of the current EquiRectangularCubeTexture.
  58839. */
  58840. clone(): EquiRectangularCubeTexture;
  58841. }
  58842. }
  58843. declare module "babylonjs/Misc/tga" {
  58844. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58845. /**
  58846. * Based on jsTGALoader - Javascript loader for TGA file
  58847. * By Vincent Thibault
  58848. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58849. */
  58850. export class TGATools {
  58851. private static _TYPE_INDEXED;
  58852. private static _TYPE_RGB;
  58853. private static _TYPE_GREY;
  58854. private static _TYPE_RLE_INDEXED;
  58855. private static _TYPE_RLE_RGB;
  58856. private static _TYPE_RLE_GREY;
  58857. private static _ORIGIN_MASK;
  58858. private static _ORIGIN_SHIFT;
  58859. private static _ORIGIN_BL;
  58860. private static _ORIGIN_BR;
  58861. private static _ORIGIN_UL;
  58862. private static _ORIGIN_UR;
  58863. /**
  58864. * Gets the header of a TGA file
  58865. * @param data defines the TGA data
  58866. * @returns the header
  58867. */
  58868. static GetTGAHeader(data: Uint8Array): any;
  58869. /**
  58870. * Uploads TGA content to a Babylon Texture
  58871. * @hidden
  58872. */
  58873. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58874. /** @hidden */
  58875. 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;
  58876. /** @hidden */
  58877. 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;
  58878. /** @hidden */
  58879. 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;
  58880. /** @hidden */
  58881. 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;
  58882. /** @hidden */
  58883. 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;
  58884. /** @hidden */
  58885. 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;
  58886. }
  58887. }
  58888. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58889. import { Nullable } from "babylonjs/types";
  58890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58891. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58892. /**
  58893. * Implementation of the TGA Texture Loader.
  58894. * @hidden
  58895. */
  58896. export class _TGATextureLoader implements IInternalTextureLoader {
  58897. /**
  58898. * Defines wether the loader supports cascade loading the different faces.
  58899. */
  58900. readonly supportCascades: boolean;
  58901. /**
  58902. * This returns if the loader support the current file information.
  58903. * @param extension defines the file extension of the file being loaded
  58904. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58905. * @param fallback defines the fallback internal texture if any
  58906. * @param isBase64 defines whether the texture is encoded as a base64
  58907. * @param isBuffer defines whether the texture data are stored as a buffer
  58908. * @returns true if the loader can load the specified file
  58909. */
  58910. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58911. /**
  58912. * Transform the url before loading if required.
  58913. * @param rootUrl the url of the texture
  58914. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58915. * @returns the transformed texture
  58916. */
  58917. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58918. /**
  58919. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58920. * @param rootUrl the url of the texture
  58921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58922. * @returns the fallback texture
  58923. */
  58924. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58925. /**
  58926. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58927. * @param data contains the texture data
  58928. * @param texture defines the BabylonJS internal texture
  58929. * @param createPolynomials will be true if polynomials have been requested
  58930. * @param onLoad defines the callback to trigger once the texture is ready
  58931. * @param onError defines the callback to trigger in case of error
  58932. */
  58933. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58934. /**
  58935. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58936. * @param data contains the texture data
  58937. * @param texture defines the BabylonJS internal texture
  58938. * @param callback defines the method to call once ready to upload
  58939. */
  58940. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58941. }
  58942. }
  58943. declare module "babylonjs/Misc/basis" {
  58944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58945. /**
  58946. * Info about the .basis files
  58947. */
  58948. class BasisFileInfo {
  58949. /**
  58950. * If the file has alpha
  58951. */
  58952. hasAlpha: boolean;
  58953. /**
  58954. * Info about each image of the basis file
  58955. */
  58956. images: Array<{
  58957. levels: Array<{
  58958. width: number;
  58959. height: number;
  58960. transcodedPixels: ArrayBufferView;
  58961. }>;
  58962. }>;
  58963. }
  58964. /**
  58965. * Result of transcoding a basis file
  58966. */
  58967. class TranscodeResult {
  58968. /**
  58969. * Info about the .basis file
  58970. */
  58971. fileInfo: BasisFileInfo;
  58972. /**
  58973. * Format to use when loading the file
  58974. */
  58975. format: number;
  58976. }
  58977. /**
  58978. * Configuration options for the Basis transcoder
  58979. */
  58980. export class BasisTranscodeConfiguration {
  58981. /**
  58982. * Supported compression formats used to determine the supported output format of the transcoder
  58983. */
  58984. supportedCompressionFormats?: {
  58985. /**
  58986. * etc1 compression format
  58987. */
  58988. etc1?: boolean;
  58989. /**
  58990. * s3tc compression format
  58991. */
  58992. s3tc?: boolean;
  58993. /**
  58994. * pvrtc compression format
  58995. */
  58996. pvrtc?: boolean;
  58997. /**
  58998. * etc2 compression format
  58999. */
  59000. etc2?: boolean;
  59001. };
  59002. /**
  59003. * If mipmap levels should be loaded for transcoded images (Default: true)
  59004. */
  59005. loadMipmapLevels?: boolean;
  59006. /**
  59007. * Index of a single image to load (Default: all images)
  59008. */
  59009. loadSingleImage?: number;
  59010. }
  59011. /**
  59012. * Used to load .Basis files
  59013. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59014. */
  59015. export class BasisTools {
  59016. private static _IgnoreSupportedFormats;
  59017. /**
  59018. * URL to use when loading the basis transcoder
  59019. */
  59020. static JSModuleURL: string;
  59021. /**
  59022. * URL to use when loading the wasm module for the transcoder
  59023. */
  59024. static WasmModuleURL: string;
  59025. /**
  59026. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59027. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59028. * @returns internal format corresponding to the Basis format
  59029. */
  59030. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59031. private static _WorkerPromise;
  59032. private static _Worker;
  59033. private static _actionId;
  59034. private static _CreateWorkerAsync;
  59035. /**
  59036. * Transcodes a loaded image file to compressed pixel data
  59037. * @param imageData image data to transcode
  59038. * @param config configuration options for the transcoding
  59039. * @returns a promise resulting in the transcoded image
  59040. */
  59041. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59042. /**
  59043. * Loads a texture from the transcode result
  59044. * @param texture texture load to
  59045. * @param transcodeResult the result of transcoding the basis file to load from
  59046. */
  59047. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59048. }
  59049. }
  59050. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59051. import { Nullable } from "babylonjs/types";
  59052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59053. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59054. /**
  59055. * Loader for .basis file format
  59056. */
  59057. export class _BasisTextureLoader implements IInternalTextureLoader {
  59058. /**
  59059. * Defines whether the loader supports cascade loading the different faces.
  59060. */
  59061. readonly supportCascades: boolean;
  59062. /**
  59063. * This returns if the loader support the current file information.
  59064. * @param extension defines the file extension of the file being loaded
  59065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  59066. * @param fallback defines the fallback internal texture if any
  59067. * @param isBase64 defines whether the texture is encoded as a base64
  59068. * @param isBuffer defines whether the texture data are stored as a buffer
  59069. * @returns true if the loader can load the specified file
  59070. */
  59071. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  59072. /**
  59073. * Transform the url before loading if required.
  59074. * @param rootUrl the url of the texture
  59075. * @param textureFormatInUse defines the current compressed format in use iun the engine
  59076. * @returns the transformed texture
  59077. */
  59078. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  59079. /**
  59080. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  59081. * @param rootUrl the url of the texture
  59082. * @param textureFormatInUse defines the current compressed format in use iun the engine
  59083. * @returns the fallback texture
  59084. */
  59085. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  59086. /**
  59087. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  59088. * @param data contains the texture data
  59089. * @param texture defines the BabylonJS internal texture
  59090. * @param createPolynomials will be true if polynomials have been requested
  59091. * @param onLoad defines the callback to trigger once the texture is ready
  59092. * @param onError defines the callback to trigger in case of error
  59093. */
  59094. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59095. /**
  59096. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  59097. * @param data contains the texture data
  59098. * @param texture defines the BabylonJS internal texture
  59099. * @param callback defines the method to call once ready to upload
  59100. */
  59101. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59102. }
  59103. }
  59104. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59105. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59106. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59107. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59108. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59109. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59110. }
  59111. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59112. import { Scene } from "babylonjs/scene";
  59113. import { Texture } from "babylonjs/Materials/Textures/texture";
  59114. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59115. /**
  59116. * 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.
  59117. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59118. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59119. */
  59120. export class CustomProceduralTexture extends ProceduralTexture {
  59121. private _animate;
  59122. private _time;
  59123. private _config;
  59124. private _texturePath;
  59125. /**
  59126. * Instantiates a new Custom Procedural Texture.
  59127. * 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.
  59128. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59129. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59130. * @param name Define the name of the texture
  59131. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59132. * @param size Define the size of the texture to create
  59133. * @param scene Define the scene the texture belongs to
  59134. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59135. * @param generateMipMaps Define if the texture should creates mip maps or not
  59136. */
  59137. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59138. private _loadJson;
  59139. /**
  59140. * Is the texture ready to be used ? (rendered at least once)
  59141. * @returns true if ready, otherwise, false.
  59142. */
  59143. isReady(): boolean;
  59144. /**
  59145. * Render the texture to its associated render target.
  59146. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59147. */
  59148. render(useCameraPostProcess?: boolean): void;
  59149. /**
  59150. * Update the list of dependant textures samplers in the shader.
  59151. */
  59152. updateTextures(): void;
  59153. /**
  59154. * Update the uniform values of the procedural texture in the shader.
  59155. */
  59156. updateShaderUniforms(): void;
  59157. /**
  59158. * Define if the texture animates or not.
  59159. */
  59160. get animate(): boolean;
  59161. set animate(value: boolean);
  59162. }
  59163. }
  59164. declare module "babylonjs/Shaders/noise.fragment" {
  59165. /** @hidden */
  59166. export var noisePixelShader: {
  59167. name: string;
  59168. shader: string;
  59169. };
  59170. }
  59171. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59172. import { Nullable } from "babylonjs/types";
  59173. import { Scene } from "babylonjs/scene";
  59174. import { Texture } from "babylonjs/Materials/Textures/texture";
  59175. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59176. import "babylonjs/Shaders/noise.fragment";
  59177. /**
  59178. * Class used to generate noise procedural textures
  59179. */
  59180. export class NoiseProceduralTexture extends ProceduralTexture {
  59181. private _time;
  59182. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59183. brightness: number;
  59184. /** Defines the number of octaves to process */
  59185. octaves: number;
  59186. /** Defines the level of persistence (0.8 by default) */
  59187. persistence: number;
  59188. /** Gets or sets animation speed factor (default is 1) */
  59189. animationSpeedFactor: number;
  59190. /**
  59191. * Creates a new NoiseProceduralTexture
  59192. * @param name defines the name fo the texture
  59193. * @param size defines the size of the texture (default is 256)
  59194. * @param scene defines the hosting scene
  59195. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59196. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59197. */
  59198. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59199. private _updateShaderUniforms;
  59200. protected _getDefines(): string;
  59201. /** Generate the current state of the procedural texture */
  59202. render(useCameraPostProcess?: boolean): void;
  59203. /**
  59204. * Serializes this noise procedural texture
  59205. * @returns a serialized noise procedural texture object
  59206. */
  59207. serialize(): any;
  59208. /**
  59209. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59210. * @param parsedTexture defines parsed texture data
  59211. * @param scene defines the current scene
  59212. * @param rootUrl defines the root URL containing noise procedural texture information
  59213. * @returns a parsed NoiseProceduralTexture
  59214. */
  59215. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59216. }
  59217. }
  59218. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59219. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59220. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59221. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59222. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59223. }
  59224. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59225. import { Nullable } from "babylonjs/types";
  59226. import { Scene } from "babylonjs/scene";
  59227. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59229. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59230. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59231. /**
  59232. * Raw cube texture where the raw buffers are passed in
  59233. */
  59234. export class RawCubeTexture extends CubeTexture {
  59235. /**
  59236. * Creates a cube texture where the raw buffers are passed in.
  59237. * @param scene defines the scene the texture is attached to
  59238. * @param data defines the array of data to use to create each face
  59239. * @param size defines the size of the textures
  59240. * @param format defines the format of the data
  59241. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59242. * @param generateMipMaps defines if the engine should generate the mip levels
  59243. * @param invertY defines if data must be stored with Y axis inverted
  59244. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59245. * @param compression defines the compression used (null by default)
  59246. */
  59247. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59248. /**
  59249. * Updates the raw cube texture.
  59250. * @param data defines the data to store
  59251. * @param format defines the data format
  59252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59253. * @param invertY defines if data must be stored with Y axis inverted
  59254. * @param compression defines the compression used (null by default)
  59255. * @param level defines which level of the texture to update
  59256. */
  59257. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59258. /**
  59259. * Updates a raw cube texture with RGBD encoded data.
  59260. * @param data defines the array of data [mipmap][face] to use to create each face
  59261. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59262. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59263. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59264. * @returns a promsie that resolves when the operation is complete
  59265. */
  59266. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59267. /**
  59268. * Clones the raw cube texture.
  59269. * @return a new cube texture
  59270. */
  59271. clone(): CubeTexture;
  59272. /** @hidden */
  59273. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59274. }
  59275. }
  59276. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59277. import { Scene } from "babylonjs/scene";
  59278. import { Texture } from "babylonjs/Materials/Textures/texture";
  59279. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59280. /**
  59281. * Class used to store 3D textures containing user data
  59282. */
  59283. export class RawTexture3D extends Texture {
  59284. /** Gets or sets the texture format to use */
  59285. format: number;
  59286. private _engine;
  59287. /**
  59288. * Create a new RawTexture3D
  59289. * @param data defines the data of the texture
  59290. * @param width defines the width of the texture
  59291. * @param height defines the height of the texture
  59292. * @param depth defines the depth of the texture
  59293. * @param format defines the texture format to use
  59294. * @param scene defines the hosting scene
  59295. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59296. * @param invertY defines if texture must be stored with Y axis inverted
  59297. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59298. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59299. */
  59300. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59301. /** Gets or sets the texture format to use */
  59302. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59303. /**
  59304. * Update the texture with new data
  59305. * @param data defines the data to store in the texture
  59306. */
  59307. update(data: ArrayBufferView): void;
  59308. }
  59309. }
  59310. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59311. import { Scene } from "babylonjs/scene";
  59312. import { Texture } from "babylonjs/Materials/Textures/texture";
  59313. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59314. /**
  59315. * Class used to store 2D array textures containing user data
  59316. */
  59317. export class RawTexture2DArray extends Texture {
  59318. /** Gets or sets the texture format to use */
  59319. format: number;
  59320. private _engine;
  59321. /**
  59322. * Create a new RawTexture2DArray
  59323. * @param data defines the data of the texture
  59324. * @param width defines the width of the texture
  59325. * @param height defines the height of the texture
  59326. * @param depth defines the number of layers of the texture
  59327. * @param format defines the texture format to use
  59328. * @param scene defines the hosting scene
  59329. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59330. * @param invertY defines if texture must be stored with Y axis inverted
  59331. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59332. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59333. */
  59334. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59335. /** Gets or sets the texture format to use */
  59336. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59337. /**
  59338. * Update the texture with new data
  59339. * @param data defines the data to store in the texture
  59340. */
  59341. update(data: ArrayBufferView): void;
  59342. }
  59343. }
  59344. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59345. import { Scene } from "babylonjs/scene";
  59346. import { Plane } from "babylonjs/Maths/math.plane";
  59347. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59348. /**
  59349. * Creates a refraction texture used by refraction channel of the standard material.
  59350. * It is like a mirror but to see through a material.
  59351. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59352. */
  59353. export class RefractionTexture extends RenderTargetTexture {
  59354. /**
  59355. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59356. * 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.
  59357. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59358. */
  59359. refractionPlane: Plane;
  59360. /**
  59361. * Define how deep under the surface we should see.
  59362. */
  59363. depth: number;
  59364. /**
  59365. * Creates a refraction texture used by refraction channel of the standard material.
  59366. * It is like a mirror but to see through a material.
  59367. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59368. * @param name Define the texture name
  59369. * @param size Define the size of the underlying texture
  59370. * @param scene Define the scene the refraction belongs to
  59371. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59372. */
  59373. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59374. /**
  59375. * Clone the refraction texture.
  59376. * @returns the cloned texture
  59377. */
  59378. clone(): RefractionTexture;
  59379. /**
  59380. * Serialize the texture to a JSON representation you could use in Parse later on
  59381. * @returns the serialized JSON representation
  59382. */
  59383. serialize(): any;
  59384. }
  59385. }
  59386. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59387. import { Nullable } from "babylonjs/types";
  59388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59389. import { Matrix } from "babylonjs/Maths/math.vector";
  59390. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59391. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59392. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59393. import { Scene } from "babylonjs/scene";
  59394. /**
  59395. * Defines the options related to the creation of an HtmlElementTexture
  59396. */
  59397. export interface IHtmlElementTextureOptions {
  59398. /**
  59399. * Defines wether mip maps should be created or not.
  59400. */
  59401. generateMipMaps?: boolean;
  59402. /**
  59403. * Defines the sampling mode of the texture.
  59404. */
  59405. samplingMode?: number;
  59406. /**
  59407. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59408. */
  59409. engine: Nullable<ThinEngine>;
  59410. /**
  59411. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59412. */
  59413. scene: Nullable<Scene>;
  59414. }
  59415. /**
  59416. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59417. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59418. * is automatically managed.
  59419. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59420. * in your application.
  59421. *
  59422. * As the update is not automatic, you need to call them manually.
  59423. */
  59424. export class HtmlElementTexture extends BaseTexture {
  59425. /**
  59426. * The texture URL.
  59427. */
  59428. element: HTMLVideoElement | HTMLCanvasElement;
  59429. private static readonly DefaultOptions;
  59430. private _textureMatrix;
  59431. private _engine;
  59432. private _isVideo;
  59433. private _generateMipMaps;
  59434. private _samplingMode;
  59435. /**
  59436. * Instantiates a HtmlElementTexture from the following parameters.
  59437. *
  59438. * @param name Defines the name of the texture
  59439. * @param element Defines the video or canvas the texture is filled with
  59440. * @param options Defines the other none mandatory texture creation options
  59441. */
  59442. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59443. private _createInternalTexture;
  59444. /**
  59445. * Returns the texture matrix used in most of the material.
  59446. */
  59447. getTextureMatrix(): Matrix;
  59448. /**
  59449. * Updates the content of the texture.
  59450. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59451. */
  59452. update(invertY?: Nullable<boolean>): void;
  59453. }
  59454. }
  59455. declare module "babylonjs/Materials/Textures/index" {
  59456. export * from "babylonjs/Materials/Textures/baseTexture";
  59457. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59458. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59459. export * from "babylonjs/Materials/Textures/cubeTexture";
  59460. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59461. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59462. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59463. export * from "babylonjs/Materials/Textures/internalTexture";
  59464. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59465. export * from "babylonjs/Materials/Textures/Loaders/index";
  59466. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59467. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59468. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59469. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59470. export * from "babylonjs/Materials/Textures/rawTexture";
  59471. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59472. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59473. export * from "babylonjs/Materials/Textures/refractionTexture";
  59474. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59475. export * from "babylonjs/Materials/Textures/texture";
  59476. export * from "babylonjs/Materials/Textures/videoTexture";
  59477. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59478. }
  59479. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59480. /**
  59481. * Enum used to define the target of a block
  59482. */
  59483. export enum NodeMaterialBlockTargets {
  59484. /** Vertex shader */
  59485. Vertex = 1,
  59486. /** Fragment shader */
  59487. Fragment = 2,
  59488. /** Neutral */
  59489. Neutral = 4,
  59490. /** Vertex and Fragment */
  59491. VertexAndFragment = 3
  59492. }
  59493. }
  59494. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59495. /**
  59496. * Defines the kind of connection point for node based material
  59497. */
  59498. export enum NodeMaterialBlockConnectionPointTypes {
  59499. /** Float */
  59500. Float = 1,
  59501. /** Int */
  59502. Int = 2,
  59503. /** Vector2 */
  59504. Vector2 = 4,
  59505. /** Vector3 */
  59506. Vector3 = 8,
  59507. /** Vector4 */
  59508. Vector4 = 16,
  59509. /** Color3 */
  59510. Color3 = 32,
  59511. /** Color4 */
  59512. Color4 = 64,
  59513. /** Matrix */
  59514. Matrix = 128,
  59515. /** Detect type based on connection */
  59516. AutoDetect = 1024,
  59517. /** Output type that will be defined by input type */
  59518. BasedOnInput = 2048
  59519. }
  59520. }
  59521. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59522. /**
  59523. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59524. */
  59525. export enum NodeMaterialBlockConnectionPointMode {
  59526. /** Value is an uniform */
  59527. Uniform = 0,
  59528. /** Value is a mesh attribute */
  59529. Attribute = 1,
  59530. /** Value is a varying between vertex and fragment shaders */
  59531. Varying = 2,
  59532. /** Mode is undefined */
  59533. Undefined = 3
  59534. }
  59535. }
  59536. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59537. /**
  59538. * Enum used to define system values e.g. values automatically provided by the system
  59539. */
  59540. export enum NodeMaterialSystemValues {
  59541. /** World */
  59542. World = 1,
  59543. /** View */
  59544. View = 2,
  59545. /** Projection */
  59546. Projection = 3,
  59547. /** ViewProjection */
  59548. ViewProjection = 4,
  59549. /** WorldView */
  59550. WorldView = 5,
  59551. /** WorldViewProjection */
  59552. WorldViewProjection = 6,
  59553. /** CameraPosition */
  59554. CameraPosition = 7,
  59555. /** Fog Color */
  59556. FogColor = 8,
  59557. /** Delta time */
  59558. DeltaTime = 9
  59559. }
  59560. }
  59561. declare module "babylonjs/Materials/Node/Enums/index" {
  59562. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59563. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59564. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59565. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59566. }
  59567. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59569. /**
  59570. * Root class for all node material optimizers
  59571. */
  59572. export class NodeMaterialOptimizer {
  59573. /**
  59574. * Function used to optimize a NodeMaterial graph
  59575. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59576. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59577. */
  59578. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59579. }
  59580. }
  59581. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59585. import { Scene } from "babylonjs/scene";
  59586. /**
  59587. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59588. */
  59589. export class TransformBlock extends NodeMaterialBlock {
  59590. /**
  59591. * Defines the value to use to complement W value to transform it to a Vector4
  59592. */
  59593. complementW: number;
  59594. /**
  59595. * Defines the value to use to complement z value to transform it to a Vector4
  59596. */
  59597. complementZ: number;
  59598. /**
  59599. * Creates a new TransformBlock
  59600. * @param name defines the block name
  59601. */
  59602. constructor(name: string);
  59603. /**
  59604. * Gets the current class name
  59605. * @returns the class name
  59606. */
  59607. getClassName(): string;
  59608. /**
  59609. * Gets the vector input
  59610. */
  59611. get vector(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the output component
  59614. */
  59615. get output(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the matrix transform input
  59618. */
  59619. get transform(): NodeMaterialConnectionPoint;
  59620. protected _buildBlock(state: NodeMaterialBuildState): this;
  59621. serialize(): any;
  59622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59623. protected _dumpPropertiesCode(): string;
  59624. }
  59625. }
  59626. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59630. /**
  59631. * Block used to output the vertex position
  59632. */
  59633. export class VertexOutputBlock extends NodeMaterialBlock {
  59634. /**
  59635. * Creates a new VertexOutputBlock
  59636. * @param name defines the block name
  59637. */
  59638. constructor(name: string);
  59639. /**
  59640. * Gets the current class name
  59641. * @returns the class name
  59642. */
  59643. getClassName(): string;
  59644. /**
  59645. * Gets the vector input component
  59646. */
  59647. get vector(): NodeMaterialConnectionPoint;
  59648. protected _buildBlock(state: NodeMaterialBuildState): this;
  59649. }
  59650. }
  59651. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59655. /**
  59656. * Block used to output the final color
  59657. */
  59658. export class FragmentOutputBlock extends NodeMaterialBlock {
  59659. /**
  59660. * Create a new FragmentOutputBlock
  59661. * @param name defines the block name
  59662. */
  59663. constructor(name: string);
  59664. /**
  59665. * Gets the current class name
  59666. * @returns the class name
  59667. */
  59668. getClassName(): string;
  59669. /**
  59670. * Gets the rgba input component
  59671. */
  59672. get rgba(): NodeMaterialConnectionPoint;
  59673. /**
  59674. * Gets the rgb input component
  59675. */
  59676. get rgb(): NodeMaterialConnectionPoint;
  59677. /**
  59678. * Gets the a input component
  59679. */
  59680. get a(): NodeMaterialConnectionPoint;
  59681. protected _buildBlock(state: NodeMaterialBuildState): this;
  59682. }
  59683. }
  59684. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59690. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59691. import { Effect } from "babylonjs/Materials/effect";
  59692. import { Mesh } from "babylonjs/Meshes/mesh";
  59693. import { Nullable } from "babylonjs/types";
  59694. import { Scene } from "babylonjs/scene";
  59695. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59696. /**
  59697. * Block used to read a reflection texture from a sampler
  59698. */
  59699. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59700. private _define3DName;
  59701. private _defineCubicName;
  59702. private _defineExplicitName;
  59703. private _defineProjectionName;
  59704. private _defineLocalCubicName;
  59705. private _defineSphericalName;
  59706. private _definePlanarName;
  59707. private _defineEquirectangularName;
  59708. private _defineMirroredEquirectangularFixedName;
  59709. private _defineEquirectangularFixedName;
  59710. private _defineSkyboxName;
  59711. private _cubeSamplerName;
  59712. private _2DSamplerName;
  59713. private _positionUVWName;
  59714. private _directionWName;
  59715. private _reflectionCoordsName;
  59716. private _reflection2DCoordsName;
  59717. private _reflectionColorName;
  59718. private _reflectionMatrixName;
  59719. /**
  59720. * Gets or sets the texture associated with the node
  59721. */
  59722. texture: Nullable<BaseTexture>;
  59723. /**
  59724. * Create a new TextureBlock
  59725. * @param name defines the block name
  59726. */
  59727. constructor(name: string);
  59728. /**
  59729. * Gets the current class name
  59730. * @returns the class name
  59731. */
  59732. getClassName(): string;
  59733. /**
  59734. * Gets the world position input component
  59735. */
  59736. get position(): NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the world position input component
  59739. */
  59740. get worldPosition(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the world normal input component
  59743. */
  59744. get worldNormal(): NodeMaterialConnectionPoint;
  59745. /**
  59746. * Gets the world input component
  59747. */
  59748. get world(): NodeMaterialConnectionPoint;
  59749. /**
  59750. * Gets the camera (or eye) position component
  59751. */
  59752. get cameraPosition(): NodeMaterialConnectionPoint;
  59753. /**
  59754. * Gets the view input component
  59755. */
  59756. get view(): NodeMaterialConnectionPoint;
  59757. /**
  59758. * Gets the rgb output component
  59759. */
  59760. get rgb(): NodeMaterialConnectionPoint;
  59761. /**
  59762. * Gets the r output component
  59763. */
  59764. get r(): NodeMaterialConnectionPoint;
  59765. /**
  59766. * Gets the g output component
  59767. */
  59768. get g(): NodeMaterialConnectionPoint;
  59769. /**
  59770. * Gets the b output component
  59771. */
  59772. get b(): NodeMaterialConnectionPoint;
  59773. autoConfigure(material: NodeMaterial): void;
  59774. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59775. isReady(): boolean;
  59776. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59777. private _injectVertexCode;
  59778. private _writeOutput;
  59779. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59780. protected _dumpPropertiesCode(): string;
  59781. serialize(): any;
  59782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59783. }
  59784. }
  59785. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59787. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59788. import { Scene } from "babylonjs/scene";
  59789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59790. import { Matrix } from "babylonjs/Maths/math.vector";
  59791. import { Mesh } from "babylonjs/Meshes/mesh";
  59792. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59793. import { Observable } from "babylonjs/Misc/observable";
  59794. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59795. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59796. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59797. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59798. import { Nullable } from "babylonjs/types";
  59799. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59800. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59801. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59802. /**
  59803. * Interface used to configure the node material editor
  59804. */
  59805. export interface INodeMaterialEditorOptions {
  59806. /** Define the URl to load node editor script */
  59807. editorURL?: string;
  59808. }
  59809. /** @hidden */
  59810. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59811. NORMAL: boolean;
  59812. TANGENT: boolean;
  59813. UV1: boolean;
  59814. /** BONES */
  59815. NUM_BONE_INFLUENCERS: number;
  59816. BonesPerMesh: number;
  59817. BONETEXTURE: boolean;
  59818. /** MORPH TARGETS */
  59819. MORPHTARGETS: boolean;
  59820. MORPHTARGETS_NORMAL: boolean;
  59821. MORPHTARGETS_TANGENT: boolean;
  59822. MORPHTARGETS_UV: boolean;
  59823. NUM_MORPH_INFLUENCERS: number;
  59824. /** IMAGE PROCESSING */
  59825. IMAGEPROCESSING: boolean;
  59826. VIGNETTE: boolean;
  59827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59828. VIGNETTEBLENDMODEOPAQUE: boolean;
  59829. TONEMAPPING: boolean;
  59830. TONEMAPPING_ACES: boolean;
  59831. CONTRAST: boolean;
  59832. EXPOSURE: boolean;
  59833. COLORCURVES: boolean;
  59834. COLORGRADING: boolean;
  59835. COLORGRADING3D: boolean;
  59836. SAMPLER3DGREENDEPTH: boolean;
  59837. SAMPLER3DBGRMAP: boolean;
  59838. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59839. /** MISC. */
  59840. BUMPDIRECTUV: number;
  59841. constructor();
  59842. setValue(name: string, value: boolean): void;
  59843. }
  59844. /**
  59845. * Class used to configure NodeMaterial
  59846. */
  59847. export interface INodeMaterialOptions {
  59848. /**
  59849. * Defines if blocks should emit comments
  59850. */
  59851. emitComments: boolean;
  59852. }
  59853. /**
  59854. * Class used to create a node based material built by assembling shader blocks
  59855. */
  59856. export class NodeMaterial extends PushMaterial {
  59857. private static _BuildIdGenerator;
  59858. private _options;
  59859. private _vertexCompilationState;
  59860. private _fragmentCompilationState;
  59861. private _sharedData;
  59862. private _buildId;
  59863. private _buildWasSuccessful;
  59864. private _cachedWorldViewMatrix;
  59865. private _cachedWorldViewProjectionMatrix;
  59866. private _optimizers;
  59867. private _animationFrame;
  59868. /** Define the Url to load node editor script */
  59869. static EditorURL: string;
  59870. /** Define the Url to load snippets */
  59871. static SnippetUrl: string;
  59872. private BJSNODEMATERIALEDITOR;
  59873. /** Get the inspector from bundle or global */
  59874. private _getGlobalNodeMaterialEditor;
  59875. /**
  59876. * Gets or sets data used by visual editor
  59877. * @see https://nme.babylonjs.com
  59878. */
  59879. editorData: any;
  59880. /**
  59881. * 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)
  59882. */
  59883. ignoreAlpha: boolean;
  59884. /**
  59885. * Defines the maximum number of lights that can be used in the material
  59886. */
  59887. maxSimultaneousLights: number;
  59888. /**
  59889. * Observable raised when the material is built
  59890. */
  59891. onBuildObservable: Observable<NodeMaterial>;
  59892. /**
  59893. * Gets or sets the root nodes of the material vertex shader
  59894. */
  59895. _vertexOutputNodes: NodeMaterialBlock[];
  59896. /**
  59897. * Gets or sets the root nodes of the material fragment (pixel) shader
  59898. */
  59899. _fragmentOutputNodes: NodeMaterialBlock[];
  59900. /** Gets or sets options to control the node material overall behavior */
  59901. get options(): INodeMaterialOptions;
  59902. set options(options: INodeMaterialOptions);
  59903. /**
  59904. * Default configuration related to image processing available in the standard Material.
  59905. */
  59906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59907. /**
  59908. * Gets the image processing configuration used either in this material.
  59909. */
  59910. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59911. /**
  59912. * Sets the Default image processing configuration used either in the this material.
  59913. *
  59914. * If sets to null, the scene one is in use.
  59915. */
  59916. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59917. /**
  59918. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59919. */
  59920. attachedBlocks: NodeMaterialBlock[];
  59921. /**
  59922. * Create a new node based material
  59923. * @param name defines the material name
  59924. * @param scene defines the hosting scene
  59925. * @param options defines creation option
  59926. */
  59927. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59928. /**
  59929. * Gets the current class name of the material e.g. "NodeMaterial"
  59930. * @returns the class name
  59931. */
  59932. getClassName(): string;
  59933. /**
  59934. * Keep track of the image processing observer to allow dispose and replace.
  59935. */
  59936. private _imageProcessingObserver;
  59937. /**
  59938. * Attaches a new image processing configuration to the Standard Material.
  59939. * @param configuration
  59940. */
  59941. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59942. /**
  59943. * Get a block by its name
  59944. * @param name defines the name of the block to retrieve
  59945. * @returns the required block or null if not found
  59946. */
  59947. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59948. /**
  59949. * Get a block by its name
  59950. * @param predicate defines the predicate used to find the good candidate
  59951. * @returns the required block or null if not found
  59952. */
  59953. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59954. /**
  59955. * Get an input block by its name
  59956. * @param predicate defines the predicate used to find the good candidate
  59957. * @returns the required input block or null if not found
  59958. */
  59959. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59960. /**
  59961. * Gets the list of input blocks attached to this material
  59962. * @returns an array of InputBlocks
  59963. */
  59964. getInputBlocks(): InputBlock[];
  59965. /**
  59966. * Adds a new optimizer to the list of optimizers
  59967. * @param optimizer defines the optimizers to add
  59968. * @returns the current material
  59969. */
  59970. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59971. /**
  59972. * Remove an optimizer from the list of optimizers
  59973. * @param optimizer defines the optimizers to remove
  59974. * @returns the current material
  59975. */
  59976. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59977. /**
  59978. * Add a new block to the list of output nodes
  59979. * @param node defines the node to add
  59980. * @returns the current material
  59981. */
  59982. addOutputNode(node: NodeMaterialBlock): this;
  59983. /**
  59984. * Remove a block from the list of root nodes
  59985. * @param node defines the node to remove
  59986. * @returns the current material
  59987. */
  59988. removeOutputNode(node: NodeMaterialBlock): this;
  59989. private _addVertexOutputNode;
  59990. private _removeVertexOutputNode;
  59991. private _addFragmentOutputNode;
  59992. private _removeFragmentOutputNode;
  59993. /**
  59994. * Specifies if the material will require alpha blending
  59995. * @returns a boolean specifying if alpha blending is needed
  59996. */
  59997. needAlphaBlending(): boolean;
  59998. /**
  59999. * Specifies if this material should be rendered in alpha test mode
  60000. * @returns a boolean specifying if an alpha test is needed.
  60001. */
  60002. needAlphaTesting(): boolean;
  60003. private _initializeBlock;
  60004. private _resetDualBlocks;
  60005. /**
  60006. * Remove a block from the current node material
  60007. * @param block defines the block to remove
  60008. */
  60009. removeBlock(block: NodeMaterialBlock): void;
  60010. /**
  60011. * Build the material and generates the inner effect
  60012. * @param verbose defines if the build should log activity
  60013. */
  60014. build(verbose?: boolean): void;
  60015. /**
  60016. * Runs an otpimization phase to try to improve the shader code
  60017. */
  60018. optimize(): void;
  60019. private _prepareDefinesForAttributes;
  60020. /**
  60021. * Get if the submesh is ready to be used and all its information available.
  60022. * Child classes can use it to update shaders
  60023. * @param mesh defines the mesh to check
  60024. * @param subMesh defines which submesh to check
  60025. * @param useInstances specifies that instances should be used
  60026. * @returns a boolean indicating that the submesh is ready or not
  60027. */
  60028. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60029. /**
  60030. * Get a string representing the shaders built by the current node graph
  60031. */
  60032. get compiledShaders(): string;
  60033. /**
  60034. * Binds the world matrix to the material
  60035. * @param world defines the world transformation matrix
  60036. */
  60037. bindOnlyWorldMatrix(world: Matrix): void;
  60038. /**
  60039. * Binds the submesh to this material by preparing the effect and shader to draw
  60040. * @param world defines the world transformation matrix
  60041. * @param mesh defines the mesh containing the submesh
  60042. * @param subMesh defines the submesh to bind the material to
  60043. */
  60044. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60045. /**
  60046. * Gets the active textures from the material
  60047. * @returns an array of textures
  60048. */
  60049. getActiveTextures(): BaseTexture[];
  60050. /**
  60051. * Gets the list of texture blocks
  60052. * @returns an array of texture blocks
  60053. */
  60054. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60055. /**
  60056. * Specifies if the material uses a texture
  60057. * @param texture defines the texture to check against the material
  60058. * @returns a boolean specifying if the material uses the texture
  60059. */
  60060. hasTexture(texture: BaseTexture): boolean;
  60061. /**
  60062. * Disposes the material
  60063. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60064. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60065. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60066. */
  60067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60068. /** Creates the node editor window. */
  60069. private _createNodeEditor;
  60070. /**
  60071. * Launch the node material editor
  60072. * @param config Define the configuration of the editor
  60073. * @return a promise fulfilled when the node editor is visible
  60074. */
  60075. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60076. /**
  60077. * Clear the current material
  60078. */
  60079. clear(): void;
  60080. /**
  60081. * Clear the current material and set it to a default state
  60082. */
  60083. setToDefault(): void;
  60084. /**
  60085. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60086. * @param url defines the url to load from
  60087. * @returns a promise that will fullfil when the material is fully loaded
  60088. */
  60089. loadAsync(url: string): Promise<void>;
  60090. private _gatherBlocks;
  60091. /**
  60092. * Generate a string containing the code declaration required to create an equivalent of this material
  60093. * @returns a string
  60094. */
  60095. generateCode(): string;
  60096. /**
  60097. * Serializes this material in a JSON representation
  60098. * @returns the serialized material object
  60099. */
  60100. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60101. private _restoreConnections;
  60102. /**
  60103. * Clear the current graph and load a new one from a serialization object
  60104. * @param source defines the JSON representation of the material
  60105. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60106. */
  60107. loadFromSerialization(source: any, rootUrl?: string): void;
  60108. /**
  60109. * Creates a node material from parsed material data
  60110. * @param source defines the JSON representation of the material
  60111. * @param scene defines the hosting scene
  60112. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60113. * @returns a new node material
  60114. */
  60115. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60116. /**
  60117. * Creates a node material from a snippet saved by the node material editor
  60118. * @param snippetId defines the snippet to load
  60119. * @param scene defines the hosting scene
  60120. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60121. * @returns a promise that will resolve to the new node material
  60122. */
  60123. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  60124. /**
  60125. * Creates a new node material set to default basic configuration
  60126. * @param name defines the name of the material
  60127. * @param scene defines the hosting scene
  60128. * @returns a new NodeMaterial
  60129. */
  60130. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60131. }
  60132. }
  60133. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60136. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60139. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60140. import { Effect } from "babylonjs/Materials/effect";
  60141. import { Mesh } from "babylonjs/Meshes/mesh";
  60142. import { Nullable } from "babylonjs/types";
  60143. import { Texture } from "babylonjs/Materials/Textures/texture";
  60144. import { Scene } from "babylonjs/scene";
  60145. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60146. /**
  60147. * Block used to read a texture from a sampler
  60148. */
  60149. export class TextureBlock extends NodeMaterialBlock {
  60150. private _defineName;
  60151. private _linearDefineName;
  60152. private _tempTextureRead;
  60153. private _samplerName;
  60154. private _transformedUVName;
  60155. private _textureTransformName;
  60156. private _textureInfoName;
  60157. private _mainUVName;
  60158. private _mainUVDefineName;
  60159. /**
  60160. * Gets or sets the texture associated with the node
  60161. */
  60162. texture: Nullable<Texture>;
  60163. /**
  60164. * Create a new TextureBlock
  60165. * @param name defines the block name
  60166. */
  60167. constructor(name: string);
  60168. /**
  60169. * Gets the current class name
  60170. * @returns the class name
  60171. */
  60172. getClassName(): string;
  60173. /**
  60174. * Gets the uv input component
  60175. */
  60176. get uv(): NodeMaterialConnectionPoint;
  60177. /**
  60178. * Gets the rgba output component
  60179. */
  60180. get rgba(): NodeMaterialConnectionPoint;
  60181. /**
  60182. * Gets the rgb output component
  60183. */
  60184. get rgb(): NodeMaterialConnectionPoint;
  60185. /**
  60186. * Gets the r output component
  60187. */
  60188. get r(): NodeMaterialConnectionPoint;
  60189. /**
  60190. * Gets the g output component
  60191. */
  60192. get g(): NodeMaterialConnectionPoint;
  60193. /**
  60194. * Gets the b output component
  60195. */
  60196. get b(): NodeMaterialConnectionPoint;
  60197. /**
  60198. * Gets the a output component
  60199. */
  60200. get a(): NodeMaterialConnectionPoint;
  60201. get target(): NodeMaterialBlockTargets;
  60202. autoConfigure(material: NodeMaterial): void;
  60203. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60205. isReady(): boolean;
  60206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60207. private get _isMixed();
  60208. private _injectVertexCode;
  60209. private _writeTextureRead;
  60210. private _writeOutput;
  60211. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60212. protected _dumpPropertiesCode(): string;
  60213. serialize(): any;
  60214. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60215. }
  60216. }
  60217. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60220. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60221. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60222. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60223. import { Scene } from "babylonjs/scene";
  60224. /**
  60225. * Class used to store shared data between 2 NodeMaterialBuildState
  60226. */
  60227. export class NodeMaterialBuildStateSharedData {
  60228. /**
  60229. * Gets the list of emitted varyings
  60230. */
  60231. temps: string[];
  60232. /**
  60233. * Gets the list of emitted varyings
  60234. */
  60235. varyings: string[];
  60236. /**
  60237. * Gets the varying declaration string
  60238. */
  60239. varyingDeclaration: string;
  60240. /**
  60241. * Input blocks
  60242. */
  60243. inputBlocks: InputBlock[];
  60244. /**
  60245. * Input blocks
  60246. */
  60247. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60248. /**
  60249. * Bindable blocks (Blocks that need to set data to the effect)
  60250. */
  60251. bindableBlocks: NodeMaterialBlock[];
  60252. /**
  60253. * List of blocks that can provide a compilation fallback
  60254. */
  60255. blocksWithFallbacks: NodeMaterialBlock[];
  60256. /**
  60257. * List of blocks that can provide a define update
  60258. */
  60259. blocksWithDefines: NodeMaterialBlock[];
  60260. /**
  60261. * List of blocks that can provide a repeatable content
  60262. */
  60263. repeatableContentBlocks: NodeMaterialBlock[];
  60264. /**
  60265. * List of blocks that can provide a dynamic list of uniforms
  60266. */
  60267. dynamicUniformBlocks: NodeMaterialBlock[];
  60268. /**
  60269. * List of blocks that can block the isReady function for the material
  60270. */
  60271. blockingBlocks: NodeMaterialBlock[];
  60272. /**
  60273. * Gets the list of animated inputs
  60274. */
  60275. animatedInputs: InputBlock[];
  60276. /**
  60277. * Build Id used to avoid multiple recompilations
  60278. */
  60279. buildId: number;
  60280. /** List of emitted variables */
  60281. variableNames: {
  60282. [key: string]: number;
  60283. };
  60284. /** List of emitted defines */
  60285. defineNames: {
  60286. [key: string]: number;
  60287. };
  60288. /** Should emit comments? */
  60289. emitComments: boolean;
  60290. /** Emit build activity */
  60291. verbose: boolean;
  60292. /** Gets or sets the hosting scene */
  60293. scene: Scene;
  60294. /**
  60295. * Gets the compilation hints emitted at compilation time
  60296. */
  60297. hints: {
  60298. needWorldViewMatrix: boolean;
  60299. needWorldViewProjectionMatrix: boolean;
  60300. needAlphaBlending: boolean;
  60301. needAlphaTesting: boolean;
  60302. };
  60303. /**
  60304. * List of compilation checks
  60305. */
  60306. checks: {
  60307. emitVertex: boolean;
  60308. emitFragment: boolean;
  60309. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60310. };
  60311. /** Creates a new shared data */
  60312. constructor();
  60313. /**
  60314. * Emits console errors and exceptions if there is a failing check
  60315. */
  60316. emitErrors(): void;
  60317. }
  60318. }
  60319. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60320. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60321. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60322. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60323. /**
  60324. * Class used to store node based material build state
  60325. */
  60326. export class NodeMaterialBuildState {
  60327. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60328. supportUniformBuffers: boolean;
  60329. /**
  60330. * Gets the list of emitted attributes
  60331. */
  60332. attributes: string[];
  60333. /**
  60334. * Gets the list of emitted uniforms
  60335. */
  60336. uniforms: string[];
  60337. /**
  60338. * Gets the list of emitted constants
  60339. */
  60340. constants: string[];
  60341. /**
  60342. * Gets the list of emitted samplers
  60343. */
  60344. samplers: string[];
  60345. /**
  60346. * Gets the list of emitted functions
  60347. */
  60348. functions: {
  60349. [key: string]: string;
  60350. };
  60351. /**
  60352. * Gets the list of emitted extensions
  60353. */
  60354. extensions: {
  60355. [key: string]: string;
  60356. };
  60357. /**
  60358. * Gets the target of the compilation state
  60359. */
  60360. target: NodeMaterialBlockTargets;
  60361. /**
  60362. * Gets the list of emitted counters
  60363. */
  60364. counters: {
  60365. [key: string]: number;
  60366. };
  60367. /**
  60368. * Shared data between multiple NodeMaterialBuildState instances
  60369. */
  60370. sharedData: NodeMaterialBuildStateSharedData;
  60371. /** @hidden */
  60372. _vertexState: NodeMaterialBuildState;
  60373. /** @hidden */
  60374. _attributeDeclaration: string;
  60375. /** @hidden */
  60376. _uniformDeclaration: string;
  60377. /** @hidden */
  60378. _constantDeclaration: string;
  60379. /** @hidden */
  60380. _samplerDeclaration: string;
  60381. /** @hidden */
  60382. _varyingTransfer: string;
  60383. private _repeatableContentAnchorIndex;
  60384. /** @hidden */
  60385. _builtCompilationString: string;
  60386. /**
  60387. * Gets the emitted compilation strings
  60388. */
  60389. compilationString: string;
  60390. /**
  60391. * Finalize the compilation strings
  60392. * @param state defines the current compilation state
  60393. */
  60394. finalize(state: NodeMaterialBuildState): void;
  60395. /** @hidden */
  60396. get _repeatableContentAnchor(): string;
  60397. /** @hidden */
  60398. _getFreeVariableName(prefix: string): string;
  60399. /** @hidden */
  60400. _getFreeDefineName(prefix: string): string;
  60401. /** @hidden */
  60402. _excludeVariableName(name: string): void;
  60403. /** @hidden */
  60404. _emit2DSampler(name: string): void;
  60405. /** @hidden */
  60406. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60407. /** @hidden */
  60408. _emitExtension(name: string, extension: string): void;
  60409. /** @hidden */
  60410. _emitFunction(name: string, code: string, comments: string): void;
  60411. /** @hidden */
  60412. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60413. replaceStrings?: {
  60414. search: RegExp;
  60415. replace: string;
  60416. }[];
  60417. repeatKey?: string;
  60418. }): string;
  60419. /** @hidden */
  60420. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60421. repeatKey?: string;
  60422. removeAttributes?: boolean;
  60423. removeUniforms?: boolean;
  60424. removeVaryings?: boolean;
  60425. removeIfDef?: boolean;
  60426. replaceStrings?: {
  60427. search: RegExp;
  60428. replace: string;
  60429. }[];
  60430. }, storeKey?: string): void;
  60431. /** @hidden */
  60432. _registerTempVariable(name: string): boolean;
  60433. /** @hidden */
  60434. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60435. /** @hidden */
  60436. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60437. /** @hidden */
  60438. _emitFloat(value: number): string;
  60439. }
  60440. }
  60441. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60442. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60444. import { Nullable } from "babylonjs/types";
  60445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60446. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60447. import { Effect } from "babylonjs/Materials/effect";
  60448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60449. import { Mesh } from "babylonjs/Meshes/mesh";
  60450. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60451. import { Scene } from "babylonjs/scene";
  60452. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60453. /**
  60454. * Defines a block that can be used inside a node based material
  60455. */
  60456. export class NodeMaterialBlock {
  60457. private _buildId;
  60458. private _buildTarget;
  60459. private _target;
  60460. private _isFinalMerger;
  60461. private _isInput;
  60462. protected _isUnique: boolean;
  60463. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60464. inputsAreExclusive: boolean;
  60465. /** @hidden */
  60466. _codeVariableName: string;
  60467. /** @hidden */
  60468. _inputs: NodeMaterialConnectionPoint[];
  60469. /** @hidden */
  60470. _outputs: NodeMaterialConnectionPoint[];
  60471. /** @hidden */
  60472. _preparationId: number;
  60473. /**
  60474. * Gets or sets the name of the block
  60475. */
  60476. name: string;
  60477. /**
  60478. * Gets or sets the unique id of the node
  60479. */
  60480. uniqueId: number;
  60481. /**
  60482. * Gets or sets the comments associated with this block
  60483. */
  60484. comments: string;
  60485. /**
  60486. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60487. */
  60488. get isUnique(): boolean;
  60489. /**
  60490. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60491. */
  60492. get isFinalMerger(): boolean;
  60493. /**
  60494. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60495. */
  60496. get isInput(): boolean;
  60497. /**
  60498. * Gets or sets the build Id
  60499. */
  60500. get buildId(): number;
  60501. set buildId(value: number);
  60502. /**
  60503. * Gets or sets the target of the block
  60504. */
  60505. get target(): NodeMaterialBlockTargets;
  60506. set target(value: NodeMaterialBlockTargets);
  60507. /**
  60508. * Gets the list of input points
  60509. */
  60510. get inputs(): NodeMaterialConnectionPoint[];
  60511. /** Gets the list of output points */
  60512. get outputs(): NodeMaterialConnectionPoint[];
  60513. /**
  60514. * Find an input by its name
  60515. * @param name defines the name of the input to look for
  60516. * @returns the input or null if not found
  60517. */
  60518. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60519. /**
  60520. * Find an output by its name
  60521. * @param name defines the name of the outputto look for
  60522. * @returns the output or null if not found
  60523. */
  60524. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60525. /**
  60526. * Creates a new NodeMaterialBlock
  60527. * @param name defines the block name
  60528. * @param target defines the target of that block (Vertex by default)
  60529. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60530. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60531. */
  60532. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60533. /**
  60534. * Initialize the block and prepare the context for build
  60535. * @param state defines the state that will be used for the build
  60536. */
  60537. initialize(state: NodeMaterialBuildState): void;
  60538. /**
  60539. * Bind data to effect. Will only be called for blocks with isBindable === true
  60540. * @param effect defines the effect to bind data to
  60541. * @param nodeMaterial defines the hosting NodeMaterial
  60542. * @param mesh defines the mesh that will be rendered
  60543. */
  60544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60545. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60546. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60547. protected _writeFloat(value: number): string;
  60548. /**
  60549. * Gets the current class name e.g. "NodeMaterialBlock"
  60550. * @returns the class name
  60551. */
  60552. getClassName(): string;
  60553. /**
  60554. * Register a new input. Must be called inside a block constructor
  60555. * @param name defines the connection point name
  60556. * @param type defines the connection point type
  60557. * @param isOptional defines a boolean indicating that this input can be omitted
  60558. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60559. * @returns the current block
  60560. */
  60561. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60562. /**
  60563. * Register a new output. Must be called inside a block constructor
  60564. * @param name defines the connection point name
  60565. * @param type defines the connection point type
  60566. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60567. * @returns the current block
  60568. */
  60569. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60570. /**
  60571. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60572. * @param forOutput defines an optional connection point to check compatibility with
  60573. * @returns the first available input or null
  60574. */
  60575. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60576. /**
  60577. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60578. * @param forBlock defines an optional block to check compatibility with
  60579. * @returns the first available input or null
  60580. */
  60581. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60582. /**
  60583. * Gets the sibling of the given output
  60584. * @param current defines the current output
  60585. * @returns the next output in the list or null
  60586. */
  60587. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60588. /**
  60589. * Connect current block with another block
  60590. * @param other defines the block to connect with
  60591. * @param options define the various options to help pick the right connections
  60592. * @returns the current block
  60593. */
  60594. connectTo(other: NodeMaterialBlock, options?: {
  60595. input?: string;
  60596. output?: string;
  60597. outputSwizzle?: string;
  60598. }): this | undefined;
  60599. protected _buildBlock(state: NodeMaterialBuildState): void;
  60600. /**
  60601. * Add uniforms, samplers and uniform buffers at compilation time
  60602. * @param state defines the state to update
  60603. * @param nodeMaterial defines the node material requesting the update
  60604. * @param defines defines the material defines to update
  60605. * @param uniformBuffers defines the list of uniform buffer names
  60606. */
  60607. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60608. /**
  60609. * Add potential fallbacks if shader compilation fails
  60610. * @param mesh defines the mesh to be rendered
  60611. * @param fallbacks defines the current prioritized list of fallbacks
  60612. */
  60613. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60614. /**
  60615. * Initialize defines for shader compilation
  60616. * @param mesh defines the mesh to be rendered
  60617. * @param nodeMaterial defines the node material requesting the update
  60618. * @param defines defines the material defines to update
  60619. * @param useInstances specifies that instances should be used
  60620. */
  60621. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60622. /**
  60623. * Update defines for shader compilation
  60624. * @param mesh defines the mesh to be rendered
  60625. * @param nodeMaterial defines the node material requesting the update
  60626. * @param defines defines the material defines to update
  60627. * @param useInstances specifies that instances should be used
  60628. */
  60629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60630. /**
  60631. * Lets the block try to connect some inputs automatically
  60632. * @param material defines the hosting NodeMaterial
  60633. */
  60634. autoConfigure(material: NodeMaterial): void;
  60635. /**
  60636. * Function called when a block is declared as repeatable content generator
  60637. * @param vertexShaderState defines the current compilation state for the vertex shader
  60638. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60639. * @param mesh defines the mesh to be rendered
  60640. * @param defines defines the material defines to update
  60641. */
  60642. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60643. /**
  60644. * Checks if the block is ready
  60645. * @param mesh defines the mesh to be rendered
  60646. * @param nodeMaterial defines the node material requesting the update
  60647. * @param defines defines the material defines to update
  60648. * @param useInstances specifies that instances should be used
  60649. * @returns true if the block is ready
  60650. */
  60651. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60652. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60653. private _processBuild;
  60654. /**
  60655. * Compile the current node and generate the shader code
  60656. * @param state defines the current compilation state (uniforms, samplers, current string)
  60657. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60658. * @returns true if already built
  60659. */
  60660. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60661. protected _inputRename(name: string): string;
  60662. protected _outputRename(name: string): string;
  60663. protected _dumpPropertiesCode(): string;
  60664. /** @hidden */
  60665. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60666. /** @hidden */
  60667. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60668. /**
  60669. * Clone the current block to a new identical block
  60670. * @param scene defines the hosting scene
  60671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60672. * @returns a copy of the current block
  60673. */
  60674. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60675. /**
  60676. * Serializes this block in a JSON representation
  60677. * @returns the serialized block object
  60678. */
  60679. serialize(): any;
  60680. /** @hidden */
  60681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60682. /**
  60683. * Release resources
  60684. */
  60685. dispose(): void;
  60686. }
  60687. }
  60688. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60689. /**
  60690. * Enum defining the type of animations supported by InputBlock
  60691. */
  60692. export enum AnimatedInputBlockTypes {
  60693. /** No animation */
  60694. None = 0,
  60695. /** Time based animation. Will only work for floats */
  60696. Time = 1
  60697. }
  60698. }
  60699. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60701. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60702. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60703. import { Nullable } from "babylonjs/types";
  60704. import { Effect } from "babylonjs/Materials/effect";
  60705. import { Matrix } from "babylonjs/Maths/math.vector";
  60706. import { Scene } from "babylonjs/scene";
  60707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60709. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60710. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60711. /**
  60712. * Block used to expose an input value
  60713. */
  60714. export class InputBlock extends NodeMaterialBlock {
  60715. private _mode;
  60716. private _associatedVariableName;
  60717. private _storedValue;
  60718. private _valueCallback;
  60719. private _type;
  60720. private _animationType;
  60721. /** Gets or set a value used to limit the range of float values */
  60722. min: number;
  60723. /** Gets or set a value used to limit the range of float values */
  60724. max: number;
  60725. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60726. isBoolean: boolean;
  60727. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60728. matrixMode: number;
  60729. /** @hidden */
  60730. _systemValue: Nullable<NodeMaterialSystemValues>;
  60731. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60732. visibleInInspector: boolean;
  60733. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60734. isConstant: boolean;
  60735. /** Gets or sets the group to use to display this block in the Inspector */
  60736. groupInInspector: string;
  60737. /**
  60738. * Gets or sets the connection point type (default is float)
  60739. */
  60740. get type(): NodeMaterialBlockConnectionPointTypes;
  60741. /**
  60742. * Creates a new InputBlock
  60743. * @param name defines the block name
  60744. * @param target defines the target of that block (Vertex by default)
  60745. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60746. */
  60747. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60748. /**
  60749. * Gets the output component
  60750. */
  60751. get output(): NodeMaterialConnectionPoint;
  60752. /**
  60753. * Set the source of this connection point to a vertex attribute
  60754. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60755. * @returns the current connection point
  60756. */
  60757. setAsAttribute(attributeName?: string): InputBlock;
  60758. /**
  60759. * Set the source of this connection point to a system value
  60760. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60761. * @returns the current connection point
  60762. */
  60763. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60764. /**
  60765. * Gets or sets the value of that point.
  60766. * Please note that this value will be ignored if valueCallback is defined
  60767. */
  60768. get value(): any;
  60769. set value(value: any);
  60770. /**
  60771. * Gets or sets a callback used to get the value of that point.
  60772. * Please note that setting this value will force the connection point to ignore the value property
  60773. */
  60774. get valueCallback(): () => any;
  60775. set valueCallback(value: () => any);
  60776. /**
  60777. * Gets or sets the associated variable name in the shader
  60778. */
  60779. get associatedVariableName(): string;
  60780. set associatedVariableName(value: string);
  60781. /** Gets or sets the type of animation applied to the input */
  60782. get animationType(): AnimatedInputBlockTypes;
  60783. set animationType(value: AnimatedInputBlockTypes);
  60784. /**
  60785. * Gets a boolean indicating that this connection point not defined yet
  60786. */
  60787. get isUndefined(): boolean;
  60788. /**
  60789. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60790. * In this case the connection point name must be the name of the uniform to use.
  60791. * Can only be set on inputs
  60792. */
  60793. get isUniform(): boolean;
  60794. set isUniform(value: boolean);
  60795. /**
  60796. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60797. * In this case the connection point name must be the name of the attribute to use
  60798. * Can only be set on inputs
  60799. */
  60800. get isAttribute(): boolean;
  60801. set isAttribute(value: boolean);
  60802. /**
  60803. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60804. * Can only be set on exit points
  60805. */
  60806. get isVarying(): boolean;
  60807. set isVarying(value: boolean);
  60808. /**
  60809. * Gets a boolean indicating that the current connection point is a system value
  60810. */
  60811. get isSystemValue(): boolean;
  60812. /**
  60813. * Gets or sets the current well known value or null if not defined as a system value
  60814. */
  60815. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60816. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60817. /**
  60818. * Gets the current class name
  60819. * @returns the class name
  60820. */
  60821. getClassName(): string;
  60822. /**
  60823. * Animate the input if animationType !== None
  60824. * @param scene defines the rendering scene
  60825. */
  60826. animate(scene: Scene): void;
  60827. private _emitDefine;
  60828. initialize(state: NodeMaterialBuildState): void;
  60829. /**
  60830. * Set the input block to its default value (based on its type)
  60831. */
  60832. setDefaultValue(): void;
  60833. private _emitConstant;
  60834. private _emit;
  60835. /** @hidden */
  60836. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60837. /** @hidden */
  60838. _transmit(effect: Effect, scene: Scene): void;
  60839. protected _buildBlock(state: NodeMaterialBuildState): void;
  60840. protected _dumpPropertiesCode(): string;
  60841. serialize(): any;
  60842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60843. }
  60844. }
  60845. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60846. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60847. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60848. import { Nullable } from "babylonjs/types";
  60849. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60850. import { Observable } from "babylonjs/Misc/observable";
  60851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60852. /**
  60853. * Enum used to define the compatibility state between two connection points
  60854. */
  60855. export enum NodeMaterialConnectionPointCompatibilityStates {
  60856. /** Points are compatibles */
  60857. Compatible = 0,
  60858. /** Points are incompatible because of their types */
  60859. TypeIncompatible = 1,
  60860. /** Points are incompatible because of their targets (vertex vs fragment) */
  60861. TargetIncompatible = 2
  60862. }
  60863. /**
  60864. * Defines the direction of a connection point
  60865. */
  60866. export enum NodeMaterialConnectionPointDirection {
  60867. /** Input */
  60868. Input = 0,
  60869. /** Output */
  60870. Output = 1
  60871. }
  60872. /**
  60873. * Defines a connection point for a block
  60874. */
  60875. export class NodeMaterialConnectionPoint {
  60876. /** @hidden */
  60877. _ownerBlock: NodeMaterialBlock;
  60878. /** @hidden */
  60879. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60880. private _endpoints;
  60881. private _associatedVariableName;
  60882. private _direction;
  60883. /** @hidden */
  60884. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60885. /** @hidden */
  60886. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60887. private _type;
  60888. /** @hidden */
  60889. _enforceAssociatedVariableName: boolean;
  60890. /** Gets the direction of the point */
  60891. get direction(): NodeMaterialConnectionPointDirection;
  60892. /**
  60893. * Gets or sets the additional types supported by this connection point
  60894. */
  60895. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60896. /**
  60897. * Gets or sets the additional types excluded by this connection point
  60898. */
  60899. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60900. /**
  60901. * Observable triggered when this point is connected
  60902. */
  60903. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60904. /**
  60905. * Gets or sets the associated variable name in the shader
  60906. */
  60907. get associatedVariableName(): string;
  60908. set associatedVariableName(value: string);
  60909. /**
  60910. * Gets or sets the connection point type (default is float)
  60911. */
  60912. get type(): NodeMaterialBlockConnectionPointTypes;
  60913. set type(value: NodeMaterialBlockConnectionPointTypes);
  60914. /**
  60915. * Gets or sets the connection point name
  60916. */
  60917. name: string;
  60918. /**
  60919. * Gets or sets a boolean indicating that this connection point can be omitted
  60920. */
  60921. isOptional: boolean;
  60922. /**
  60923. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60924. */
  60925. define: string;
  60926. /** @hidden */
  60927. _prioritizeVertex: boolean;
  60928. private _target;
  60929. /** Gets or sets the target of that connection point */
  60930. get target(): NodeMaterialBlockTargets;
  60931. set target(value: NodeMaterialBlockTargets);
  60932. /**
  60933. * Gets a boolean indicating that the current point is connected
  60934. */
  60935. get isConnected(): boolean;
  60936. /**
  60937. * Gets a boolean indicating that the current point is connected to an input block
  60938. */
  60939. get isConnectedToInputBlock(): boolean;
  60940. /**
  60941. * Gets a the connected input block (if any)
  60942. */
  60943. get connectInputBlock(): Nullable<InputBlock>;
  60944. /** Get the other side of the connection (if any) */
  60945. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60946. /** Get the block that owns this connection point */
  60947. get ownerBlock(): NodeMaterialBlock;
  60948. /** Get the block connected on the other side of this connection (if any) */
  60949. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60950. /** Get the block connected on the endpoints of this connection (if any) */
  60951. get connectedBlocks(): Array<NodeMaterialBlock>;
  60952. /** Gets the list of connected endpoints */
  60953. get endpoints(): NodeMaterialConnectionPoint[];
  60954. /** Gets a boolean indicating if that output point is connected to at least one input */
  60955. get hasEndpoints(): boolean;
  60956. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60957. get isConnectedInVertexShader(): boolean;
  60958. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60959. get isConnectedInFragmentShader(): boolean;
  60960. /**
  60961. * Creates a new connection point
  60962. * @param name defines the connection point name
  60963. * @param ownerBlock defines the block hosting this connection point
  60964. * @param direction defines the direction of the connection point
  60965. */
  60966. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60967. /**
  60968. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60969. * @returns the class name
  60970. */
  60971. getClassName(): string;
  60972. /**
  60973. * Gets a boolean indicating if the current point can be connected to another point
  60974. * @param connectionPoint defines the other connection point
  60975. * @returns a boolean
  60976. */
  60977. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60978. /**
  60979. * Gets a number indicating if the current point can be connected to another point
  60980. * @param connectionPoint defines the other connection point
  60981. * @returns a number defining the compatibility state
  60982. */
  60983. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60984. /**
  60985. * Connect this point to another connection point
  60986. * @param connectionPoint defines the other connection point
  60987. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60988. * @returns the current connection point
  60989. */
  60990. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60991. /**
  60992. * Disconnect this point from one of his endpoint
  60993. * @param endpoint defines the other connection point
  60994. * @returns the current connection point
  60995. */
  60996. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Serializes this point in a JSON representation
  60999. * @returns the serialized point object
  61000. */
  61001. serialize(): any;
  61002. /**
  61003. * Release resources
  61004. */
  61005. dispose(): void;
  61006. }
  61007. }
  61008. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61012. import { Mesh } from "babylonjs/Meshes/mesh";
  61013. import { Effect } from "babylonjs/Materials/effect";
  61014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61015. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61016. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61017. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61018. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61019. /**
  61020. * Block used to add support for vertex skinning (bones)
  61021. */
  61022. export class BonesBlock extends NodeMaterialBlock {
  61023. /**
  61024. * Creates a new BonesBlock
  61025. * @param name defines the block name
  61026. */
  61027. constructor(name: string);
  61028. /**
  61029. * Initialize the block and prepare the context for build
  61030. * @param state defines the state that will be used for the build
  61031. */
  61032. initialize(state: NodeMaterialBuildState): void;
  61033. /**
  61034. * Gets the current class name
  61035. * @returns the class name
  61036. */
  61037. getClassName(): string;
  61038. /**
  61039. * Gets the matrix indices input component
  61040. */
  61041. get matricesIndices(): NodeMaterialConnectionPoint;
  61042. /**
  61043. * Gets the matrix weights input component
  61044. */
  61045. get matricesWeights(): NodeMaterialConnectionPoint;
  61046. /**
  61047. * Gets the extra matrix indices input component
  61048. */
  61049. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61050. /**
  61051. * Gets the extra matrix weights input component
  61052. */
  61053. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61054. /**
  61055. * Gets the world input component
  61056. */
  61057. get world(): NodeMaterialConnectionPoint;
  61058. /**
  61059. * Gets the output component
  61060. */
  61061. get output(): NodeMaterialConnectionPoint;
  61062. autoConfigure(material: NodeMaterial): void;
  61063. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61064. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61066. protected _buildBlock(state: NodeMaterialBuildState): this;
  61067. }
  61068. }
  61069. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61074. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61075. /**
  61076. * Block used to add support for instances
  61077. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61078. */
  61079. export class InstancesBlock extends NodeMaterialBlock {
  61080. /**
  61081. * Creates a new InstancesBlock
  61082. * @param name defines the block name
  61083. */
  61084. constructor(name: string);
  61085. /**
  61086. * Gets the current class name
  61087. * @returns the class name
  61088. */
  61089. getClassName(): string;
  61090. /**
  61091. * Gets the first world row input component
  61092. */
  61093. get world0(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Gets the second world row input component
  61096. */
  61097. get world1(): NodeMaterialConnectionPoint;
  61098. /**
  61099. * Gets the third world row input component
  61100. */
  61101. get world2(): NodeMaterialConnectionPoint;
  61102. /**
  61103. * Gets the forth world row input component
  61104. */
  61105. get world3(): NodeMaterialConnectionPoint;
  61106. /**
  61107. * Gets the world input component
  61108. */
  61109. get world(): NodeMaterialConnectionPoint;
  61110. /**
  61111. * Gets the output component
  61112. */
  61113. get output(): NodeMaterialConnectionPoint;
  61114. autoConfigure(material: NodeMaterial): void;
  61115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61116. protected _buildBlock(state: NodeMaterialBuildState): this;
  61117. }
  61118. }
  61119. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61124. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61125. import { Effect } from "babylonjs/Materials/effect";
  61126. import { Mesh } from "babylonjs/Meshes/mesh";
  61127. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61128. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61129. /**
  61130. * Block used to add morph targets support to vertex shader
  61131. */
  61132. export class MorphTargetsBlock extends NodeMaterialBlock {
  61133. private _repeatableContentAnchor;
  61134. /**
  61135. * Create a new MorphTargetsBlock
  61136. * @param name defines the block name
  61137. */
  61138. constructor(name: string);
  61139. /**
  61140. * Gets the current class name
  61141. * @returns the class name
  61142. */
  61143. getClassName(): string;
  61144. /**
  61145. * Gets the position input component
  61146. */
  61147. get position(): NodeMaterialConnectionPoint;
  61148. /**
  61149. * Gets the normal input component
  61150. */
  61151. get normal(): NodeMaterialConnectionPoint;
  61152. /**
  61153. * Gets the tangent input component
  61154. */
  61155. get tangent(): NodeMaterialConnectionPoint;
  61156. /**
  61157. * Gets the tangent input component
  61158. */
  61159. get uv(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the position output component
  61162. */
  61163. get positionOutput(): NodeMaterialConnectionPoint;
  61164. /**
  61165. * Gets the normal output component
  61166. */
  61167. get normalOutput(): NodeMaterialConnectionPoint;
  61168. /**
  61169. * Gets the tangent output component
  61170. */
  61171. get tangentOutput(): NodeMaterialConnectionPoint;
  61172. /**
  61173. * Gets the tangent output component
  61174. */
  61175. get uvOutput(): NodeMaterialConnectionPoint;
  61176. initialize(state: NodeMaterialBuildState): void;
  61177. autoConfigure(material: NodeMaterial): void;
  61178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61180. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61181. protected _buildBlock(state: NodeMaterialBuildState): this;
  61182. }
  61183. }
  61184. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61188. import { Nullable } from "babylonjs/types";
  61189. import { Scene } from "babylonjs/scene";
  61190. import { Effect } from "babylonjs/Materials/effect";
  61191. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61192. import { Mesh } from "babylonjs/Meshes/mesh";
  61193. import { Light } from "babylonjs/Lights/light";
  61194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61195. /**
  61196. * Block used to get data information from a light
  61197. */
  61198. export class LightInformationBlock extends NodeMaterialBlock {
  61199. private _lightDataUniformName;
  61200. private _lightColorUniformName;
  61201. private _lightTypeDefineName;
  61202. /**
  61203. * Gets or sets the light associated with this block
  61204. */
  61205. light: Nullable<Light>;
  61206. /**
  61207. * Creates a new LightInformationBlock
  61208. * @param name defines the block name
  61209. */
  61210. constructor(name: string);
  61211. /**
  61212. * Gets the current class name
  61213. * @returns the class name
  61214. */
  61215. getClassName(): string;
  61216. /**
  61217. * Gets the world position input component
  61218. */
  61219. get worldPosition(): NodeMaterialConnectionPoint;
  61220. /**
  61221. * Gets the direction output component
  61222. */
  61223. get direction(): NodeMaterialConnectionPoint;
  61224. /**
  61225. * Gets the direction output component
  61226. */
  61227. get color(): NodeMaterialConnectionPoint;
  61228. /**
  61229. * Gets the direction output component
  61230. */
  61231. get intensity(): NodeMaterialConnectionPoint;
  61232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61233. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61234. protected _buildBlock(state: NodeMaterialBuildState): this;
  61235. serialize(): any;
  61236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61237. }
  61238. }
  61239. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61240. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61241. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61242. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61243. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61244. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61245. }
  61246. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61251. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61252. import { Effect } from "babylonjs/Materials/effect";
  61253. import { Mesh } from "babylonjs/Meshes/mesh";
  61254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61255. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61256. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61257. /**
  61258. * Block used to add image processing support to fragment shader
  61259. */
  61260. export class ImageProcessingBlock extends NodeMaterialBlock {
  61261. /**
  61262. * Create a new ImageProcessingBlock
  61263. * @param name defines the block name
  61264. */
  61265. constructor(name: string);
  61266. /**
  61267. * Gets the current class name
  61268. * @returns the class name
  61269. */
  61270. getClassName(): string;
  61271. /**
  61272. * Gets the color input component
  61273. */
  61274. get color(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Gets the output component
  61277. */
  61278. get output(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Initialize the block and prepare the context for build
  61281. * @param state defines the state that will be used for the build
  61282. */
  61283. initialize(state: NodeMaterialBuildState): void;
  61284. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61286. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61287. protected _buildBlock(state: NodeMaterialBuildState): this;
  61288. }
  61289. }
  61290. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61294. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61296. import { Effect } from "babylonjs/Materials/effect";
  61297. import { Mesh } from "babylonjs/Meshes/mesh";
  61298. import { Scene } from "babylonjs/scene";
  61299. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61300. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61301. /**
  61302. * Block used to pertub normals based on a normal map
  61303. */
  61304. export class PerturbNormalBlock extends NodeMaterialBlock {
  61305. private _tangentSpaceParameterName;
  61306. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61307. invertX: boolean;
  61308. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61309. invertY: boolean;
  61310. /**
  61311. * Create a new PerturbNormalBlock
  61312. * @param name defines the block name
  61313. */
  61314. constructor(name: string);
  61315. /**
  61316. * Gets the current class name
  61317. * @returns the class name
  61318. */
  61319. getClassName(): string;
  61320. /**
  61321. * Gets the world position input component
  61322. */
  61323. get worldPosition(): NodeMaterialConnectionPoint;
  61324. /**
  61325. * Gets the world normal input component
  61326. */
  61327. get worldNormal(): NodeMaterialConnectionPoint;
  61328. /**
  61329. * Gets the uv input component
  61330. */
  61331. get uv(): NodeMaterialConnectionPoint;
  61332. /**
  61333. * Gets the normal map color input component
  61334. */
  61335. get normalMapColor(): NodeMaterialConnectionPoint;
  61336. /**
  61337. * Gets the strength input component
  61338. */
  61339. get strength(): NodeMaterialConnectionPoint;
  61340. /**
  61341. * Gets the output component
  61342. */
  61343. get output(): NodeMaterialConnectionPoint;
  61344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61346. autoConfigure(material: NodeMaterial): void;
  61347. protected _buildBlock(state: NodeMaterialBuildState): this;
  61348. protected _dumpPropertiesCode(): string;
  61349. serialize(): any;
  61350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61351. }
  61352. }
  61353. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61357. /**
  61358. * Block used to discard a pixel if a value is smaller than a cutoff
  61359. */
  61360. export class DiscardBlock extends NodeMaterialBlock {
  61361. /**
  61362. * Create a new DiscardBlock
  61363. * @param name defines the block name
  61364. */
  61365. constructor(name: string);
  61366. /**
  61367. * Gets the current class name
  61368. * @returns the class name
  61369. */
  61370. getClassName(): string;
  61371. /**
  61372. * Gets the color input component
  61373. */
  61374. get value(): NodeMaterialConnectionPoint;
  61375. /**
  61376. * Gets the cutoff input component
  61377. */
  61378. get cutoff(): NodeMaterialConnectionPoint;
  61379. protected _buildBlock(state: NodeMaterialBuildState): this;
  61380. }
  61381. }
  61382. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61386. /**
  61387. * Block used to test if the fragment shader is front facing
  61388. */
  61389. export class FrontFacingBlock extends NodeMaterialBlock {
  61390. /**
  61391. * Creates a new FrontFacingBlock
  61392. * @param name defines the block name
  61393. */
  61394. constructor(name: string);
  61395. /**
  61396. * Gets the current class name
  61397. * @returns the class name
  61398. */
  61399. getClassName(): string;
  61400. /**
  61401. * Gets the output component
  61402. */
  61403. get output(): NodeMaterialConnectionPoint;
  61404. protected _buildBlock(state: NodeMaterialBuildState): this;
  61405. }
  61406. }
  61407. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61411. /**
  61412. * Block used to get the derivative value on x and y of a given input
  61413. */
  61414. export class DerivativeBlock extends NodeMaterialBlock {
  61415. /**
  61416. * Create a new DerivativeBlock
  61417. * @param name defines the block name
  61418. */
  61419. constructor(name: string);
  61420. /**
  61421. * Gets the current class name
  61422. * @returns the class name
  61423. */
  61424. getClassName(): string;
  61425. /**
  61426. * Gets the input component
  61427. */
  61428. get input(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the derivative output on x
  61431. */
  61432. get dx(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the derivative output on y
  61435. */
  61436. get dy(): NodeMaterialConnectionPoint;
  61437. protected _buildBlock(state: NodeMaterialBuildState): this;
  61438. }
  61439. }
  61440. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61441. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61442. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61443. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61444. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61445. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61446. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61447. }
  61448. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61451. import { Mesh } from "babylonjs/Meshes/mesh";
  61452. import { Effect } from "babylonjs/Materials/effect";
  61453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61455. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61456. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61457. /**
  61458. * Block used to add support for scene fog
  61459. */
  61460. export class FogBlock extends NodeMaterialBlock {
  61461. private _fogDistanceName;
  61462. private _fogParameters;
  61463. /**
  61464. * Create a new FogBlock
  61465. * @param name defines the block name
  61466. */
  61467. constructor(name: string);
  61468. /**
  61469. * Gets the current class name
  61470. * @returns the class name
  61471. */
  61472. getClassName(): string;
  61473. /**
  61474. * Gets the world position input component
  61475. */
  61476. get worldPosition(): NodeMaterialConnectionPoint;
  61477. /**
  61478. * Gets the view input component
  61479. */
  61480. get view(): NodeMaterialConnectionPoint;
  61481. /**
  61482. * Gets the color input component
  61483. */
  61484. get input(): NodeMaterialConnectionPoint;
  61485. /**
  61486. * Gets the fog color input component
  61487. */
  61488. get fogColor(): NodeMaterialConnectionPoint;
  61489. /**
  61490. * Gets the output component
  61491. */
  61492. get output(): NodeMaterialConnectionPoint;
  61493. autoConfigure(material: NodeMaterial): void;
  61494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61495. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61496. protected _buildBlock(state: NodeMaterialBuildState): this;
  61497. }
  61498. }
  61499. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61504. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61505. import { Effect } from "babylonjs/Materials/effect";
  61506. import { Mesh } from "babylonjs/Meshes/mesh";
  61507. import { Light } from "babylonjs/Lights/light";
  61508. import { Nullable } from "babylonjs/types";
  61509. import { Scene } from "babylonjs/scene";
  61510. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61511. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61512. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61513. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61514. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61515. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61516. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61517. /**
  61518. * Block used to add light in the fragment shader
  61519. */
  61520. export class LightBlock extends NodeMaterialBlock {
  61521. private _lightId;
  61522. /**
  61523. * Gets or sets the light associated with this block
  61524. */
  61525. light: Nullable<Light>;
  61526. /**
  61527. * Create a new LightBlock
  61528. * @param name defines the block name
  61529. */
  61530. constructor(name: string);
  61531. /**
  61532. * Gets the current class name
  61533. * @returns the class name
  61534. */
  61535. getClassName(): string;
  61536. /**
  61537. * Gets the world position input component
  61538. */
  61539. get worldPosition(): NodeMaterialConnectionPoint;
  61540. /**
  61541. * Gets the world normal input component
  61542. */
  61543. get worldNormal(): NodeMaterialConnectionPoint;
  61544. /**
  61545. * Gets the camera (or eye) position component
  61546. */
  61547. get cameraPosition(): NodeMaterialConnectionPoint;
  61548. /**
  61549. * Gets the glossiness component
  61550. */
  61551. get glossiness(): NodeMaterialConnectionPoint;
  61552. /**
  61553. * Gets the glossinness power component
  61554. */
  61555. get glossPower(): NodeMaterialConnectionPoint;
  61556. /**
  61557. * Gets the diffuse color component
  61558. */
  61559. get diffuseColor(): NodeMaterialConnectionPoint;
  61560. /**
  61561. * Gets the specular color component
  61562. */
  61563. get specularColor(): NodeMaterialConnectionPoint;
  61564. /**
  61565. * Gets the diffuse output component
  61566. */
  61567. get diffuseOutput(): NodeMaterialConnectionPoint;
  61568. /**
  61569. * Gets the specular output component
  61570. */
  61571. get specularOutput(): NodeMaterialConnectionPoint;
  61572. /**
  61573. * Gets the shadow output component
  61574. */
  61575. get shadow(): NodeMaterialConnectionPoint;
  61576. autoConfigure(material: NodeMaterial): void;
  61577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61578. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61580. private _injectVertexCode;
  61581. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61582. serialize(): any;
  61583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61584. }
  61585. }
  61586. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61587. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61588. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61589. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61590. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61591. }
  61592. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61593. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61594. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61595. }
  61596. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61600. /**
  61601. * Block used to multiply 2 values
  61602. */
  61603. export class MultiplyBlock extends NodeMaterialBlock {
  61604. /**
  61605. * Creates a new MultiplyBlock
  61606. * @param name defines the block name
  61607. */
  61608. constructor(name: string);
  61609. /**
  61610. * Gets the current class name
  61611. * @returns the class name
  61612. */
  61613. getClassName(): string;
  61614. /**
  61615. * Gets the left operand input component
  61616. */
  61617. get left(): NodeMaterialConnectionPoint;
  61618. /**
  61619. * Gets the right operand input component
  61620. */
  61621. get right(): NodeMaterialConnectionPoint;
  61622. /**
  61623. * Gets the output component
  61624. */
  61625. get output(): NodeMaterialConnectionPoint;
  61626. protected _buildBlock(state: NodeMaterialBuildState): this;
  61627. }
  61628. }
  61629. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61633. /**
  61634. * Block used to add 2 vectors
  61635. */
  61636. export class AddBlock extends NodeMaterialBlock {
  61637. /**
  61638. * Creates a new AddBlock
  61639. * @param name defines the block name
  61640. */
  61641. constructor(name: string);
  61642. /**
  61643. * Gets the current class name
  61644. * @returns the class name
  61645. */
  61646. getClassName(): string;
  61647. /**
  61648. * Gets the left operand input component
  61649. */
  61650. get left(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the right operand input component
  61653. */
  61654. get right(): NodeMaterialConnectionPoint;
  61655. /**
  61656. * Gets the output component
  61657. */
  61658. get output(): NodeMaterialConnectionPoint;
  61659. protected _buildBlock(state: NodeMaterialBuildState): this;
  61660. }
  61661. }
  61662. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61666. /**
  61667. * Block used to scale a vector by a float
  61668. */
  61669. export class ScaleBlock extends NodeMaterialBlock {
  61670. /**
  61671. * Creates a new ScaleBlock
  61672. * @param name defines the block name
  61673. */
  61674. constructor(name: string);
  61675. /**
  61676. * Gets the current class name
  61677. * @returns the class name
  61678. */
  61679. getClassName(): string;
  61680. /**
  61681. * Gets the input component
  61682. */
  61683. get input(): NodeMaterialConnectionPoint;
  61684. /**
  61685. * Gets the factor input component
  61686. */
  61687. get factor(): NodeMaterialConnectionPoint;
  61688. /**
  61689. * Gets the output component
  61690. */
  61691. get output(): NodeMaterialConnectionPoint;
  61692. protected _buildBlock(state: NodeMaterialBuildState): this;
  61693. }
  61694. }
  61695. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61699. import { Scene } from "babylonjs/scene";
  61700. /**
  61701. * Block used to clamp a float
  61702. */
  61703. export class ClampBlock extends NodeMaterialBlock {
  61704. /** Gets or sets the minimum range */
  61705. minimum: number;
  61706. /** Gets or sets the maximum range */
  61707. maximum: number;
  61708. /**
  61709. * Creates a new ClampBlock
  61710. * @param name defines the block name
  61711. */
  61712. constructor(name: string);
  61713. /**
  61714. * Gets the current class name
  61715. * @returns the class name
  61716. */
  61717. getClassName(): string;
  61718. /**
  61719. * Gets the value input component
  61720. */
  61721. get value(): NodeMaterialConnectionPoint;
  61722. /**
  61723. * Gets the output component
  61724. */
  61725. get output(): NodeMaterialConnectionPoint;
  61726. protected _buildBlock(state: NodeMaterialBuildState): this;
  61727. protected _dumpPropertiesCode(): string;
  61728. serialize(): any;
  61729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61730. }
  61731. }
  61732. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61733. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61736. /**
  61737. * Block used to apply a cross product between 2 vectors
  61738. */
  61739. export class CrossBlock extends NodeMaterialBlock {
  61740. /**
  61741. * Creates a new CrossBlock
  61742. * @param name defines the block name
  61743. */
  61744. constructor(name: string);
  61745. /**
  61746. * Gets the current class name
  61747. * @returns the class name
  61748. */
  61749. getClassName(): string;
  61750. /**
  61751. * Gets the left operand input component
  61752. */
  61753. get left(): NodeMaterialConnectionPoint;
  61754. /**
  61755. * Gets the right operand input component
  61756. */
  61757. get right(): NodeMaterialConnectionPoint;
  61758. /**
  61759. * Gets the output component
  61760. */
  61761. get output(): NodeMaterialConnectionPoint;
  61762. protected _buildBlock(state: NodeMaterialBuildState): this;
  61763. }
  61764. }
  61765. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61769. /**
  61770. * Block used to apply a dot product between 2 vectors
  61771. */
  61772. export class DotBlock extends NodeMaterialBlock {
  61773. /**
  61774. * Creates a new DotBlock
  61775. * @param name defines the block name
  61776. */
  61777. constructor(name: string);
  61778. /**
  61779. * Gets the current class name
  61780. * @returns the class name
  61781. */
  61782. getClassName(): string;
  61783. /**
  61784. * Gets the left operand input component
  61785. */
  61786. get left(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the right operand input component
  61789. */
  61790. get right(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the output component
  61793. */
  61794. get output(): NodeMaterialConnectionPoint;
  61795. protected _buildBlock(state: NodeMaterialBuildState): this;
  61796. }
  61797. }
  61798. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61802. import { Vector2 } from "babylonjs/Maths/math.vector";
  61803. import { Scene } from "babylonjs/scene";
  61804. /**
  61805. * Block used to remap a float from a range to a new one
  61806. */
  61807. export class RemapBlock extends NodeMaterialBlock {
  61808. /**
  61809. * Gets or sets the source range
  61810. */
  61811. sourceRange: Vector2;
  61812. /**
  61813. * Gets or sets the target range
  61814. */
  61815. targetRange: Vector2;
  61816. /**
  61817. * Creates a new RemapBlock
  61818. * @param name defines the block name
  61819. */
  61820. constructor(name: string);
  61821. /**
  61822. * Gets the current class name
  61823. * @returns the class name
  61824. */
  61825. getClassName(): string;
  61826. /**
  61827. * Gets the input component
  61828. */
  61829. get input(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the source min input component
  61832. */
  61833. get sourceMin(): NodeMaterialConnectionPoint;
  61834. /**
  61835. * Gets the source max input component
  61836. */
  61837. get sourceMax(): NodeMaterialConnectionPoint;
  61838. /**
  61839. * Gets the target min input component
  61840. */
  61841. get targetMin(): NodeMaterialConnectionPoint;
  61842. /**
  61843. * Gets the target max input component
  61844. */
  61845. get targetMax(): NodeMaterialConnectionPoint;
  61846. /**
  61847. * Gets the output component
  61848. */
  61849. get output(): NodeMaterialConnectionPoint;
  61850. protected _buildBlock(state: NodeMaterialBuildState): this;
  61851. protected _dumpPropertiesCode(): string;
  61852. serialize(): any;
  61853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61854. }
  61855. }
  61856. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61860. /**
  61861. * Block used to normalize a vector
  61862. */
  61863. export class NormalizeBlock extends NodeMaterialBlock {
  61864. /**
  61865. * Creates a new NormalizeBlock
  61866. * @param name defines the block name
  61867. */
  61868. constructor(name: string);
  61869. /**
  61870. * Gets the current class name
  61871. * @returns the class name
  61872. */
  61873. getClassName(): string;
  61874. /**
  61875. * Gets the input component
  61876. */
  61877. get input(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the output component
  61880. */
  61881. get output(): NodeMaterialConnectionPoint;
  61882. protected _buildBlock(state: NodeMaterialBuildState): this;
  61883. }
  61884. }
  61885. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61889. import { Scene } from "babylonjs/scene";
  61890. /**
  61891. * Operations supported by the Trigonometry block
  61892. */
  61893. export enum TrigonometryBlockOperations {
  61894. /** Cos */
  61895. Cos = 0,
  61896. /** Sin */
  61897. Sin = 1,
  61898. /** Abs */
  61899. Abs = 2,
  61900. /** Exp */
  61901. Exp = 3,
  61902. /** Exp2 */
  61903. Exp2 = 4,
  61904. /** Round */
  61905. Round = 5,
  61906. /** Floor */
  61907. Floor = 6,
  61908. /** Ceiling */
  61909. Ceiling = 7,
  61910. /** Square root */
  61911. Sqrt = 8,
  61912. /** Log */
  61913. Log = 9,
  61914. /** Tangent */
  61915. Tan = 10,
  61916. /** Arc tangent */
  61917. ArcTan = 11,
  61918. /** Arc cosinus */
  61919. ArcCos = 12,
  61920. /** Arc sinus */
  61921. ArcSin = 13,
  61922. /** Fraction */
  61923. Fract = 14,
  61924. /** Sign */
  61925. Sign = 15,
  61926. /** To radians (from degrees) */
  61927. Radians = 16,
  61928. /** To degrees (from radians) */
  61929. Degrees = 17
  61930. }
  61931. /**
  61932. * Block used to apply trigonometry operation to floats
  61933. */
  61934. export class TrigonometryBlock extends NodeMaterialBlock {
  61935. /**
  61936. * Gets or sets the operation applied by the block
  61937. */
  61938. operation: TrigonometryBlockOperations;
  61939. /**
  61940. * Creates a new TrigonometryBlock
  61941. * @param name defines the block name
  61942. */
  61943. constructor(name: string);
  61944. /**
  61945. * Gets the current class name
  61946. * @returns the class name
  61947. */
  61948. getClassName(): string;
  61949. /**
  61950. * Gets the input component
  61951. */
  61952. get input(): NodeMaterialConnectionPoint;
  61953. /**
  61954. * Gets the output component
  61955. */
  61956. get output(): NodeMaterialConnectionPoint;
  61957. protected _buildBlock(state: NodeMaterialBuildState): this;
  61958. serialize(): any;
  61959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61960. protected _dumpPropertiesCode(): string;
  61961. }
  61962. }
  61963. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61967. /**
  61968. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61969. */
  61970. export class ColorMergerBlock extends NodeMaterialBlock {
  61971. /**
  61972. * Create a new ColorMergerBlock
  61973. * @param name defines the block name
  61974. */
  61975. constructor(name: string);
  61976. /**
  61977. * Gets the current class name
  61978. * @returns the class name
  61979. */
  61980. getClassName(): string;
  61981. /**
  61982. * Gets the rgb component (input)
  61983. */
  61984. get rgbIn(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the r component (input)
  61987. */
  61988. get r(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the g component (input)
  61991. */
  61992. get g(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the b component (input)
  61995. */
  61996. get b(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the a component (input)
  61999. */
  62000. get a(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the rgba component (output)
  62003. */
  62004. get rgba(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the rgb component (output)
  62007. */
  62008. get rgbOut(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the rgb component (output)
  62011. * @deprecated Please use rgbOut instead.
  62012. */
  62013. get rgb(): NodeMaterialConnectionPoint;
  62014. protected _buildBlock(state: NodeMaterialBuildState): this;
  62015. }
  62016. }
  62017. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62021. /**
  62022. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62023. */
  62024. export class VectorMergerBlock extends NodeMaterialBlock {
  62025. /**
  62026. * Create a new VectorMergerBlock
  62027. * @param name defines the block name
  62028. */
  62029. constructor(name: string);
  62030. /**
  62031. * Gets the current class name
  62032. * @returns the class name
  62033. */
  62034. getClassName(): string;
  62035. /**
  62036. * Gets the xyz component (input)
  62037. */
  62038. get xyzIn(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the xy component (input)
  62041. */
  62042. get xyIn(): NodeMaterialConnectionPoint;
  62043. /**
  62044. * Gets the x component (input)
  62045. */
  62046. get x(): NodeMaterialConnectionPoint;
  62047. /**
  62048. * Gets the y component (input)
  62049. */
  62050. get y(): NodeMaterialConnectionPoint;
  62051. /**
  62052. * Gets the z component (input)
  62053. */
  62054. get z(): NodeMaterialConnectionPoint;
  62055. /**
  62056. * Gets the w component (input)
  62057. */
  62058. get w(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the xyzw component (output)
  62061. */
  62062. get xyzw(): NodeMaterialConnectionPoint;
  62063. /**
  62064. * Gets the xyz component (output)
  62065. */
  62066. get xyzOut(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the xy component (output)
  62069. */
  62070. get xyOut(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the xy component (output)
  62073. * @deprecated Please use xyOut instead.
  62074. */
  62075. get xy(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the xyz component (output)
  62078. * @deprecated Please use xyzOut instead.
  62079. */
  62080. get xyz(): NodeMaterialConnectionPoint;
  62081. protected _buildBlock(state: NodeMaterialBuildState): this;
  62082. }
  62083. }
  62084. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62088. /**
  62089. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62090. */
  62091. export class ColorSplitterBlock extends NodeMaterialBlock {
  62092. /**
  62093. * Create a new ColorSplitterBlock
  62094. * @param name defines the block name
  62095. */
  62096. constructor(name: string);
  62097. /**
  62098. * Gets the current class name
  62099. * @returns the class name
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * Gets the rgba component (input)
  62104. */
  62105. get rgba(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the rgb component (input)
  62108. */
  62109. get rgbIn(): NodeMaterialConnectionPoint;
  62110. /**
  62111. * Gets the rgb component (output)
  62112. */
  62113. get rgbOut(): NodeMaterialConnectionPoint;
  62114. /**
  62115. * Gets the r component (output)
  62116. */
  62117. get r(): NodeMaterialConnectionPoint;
  62118. /**
  62119. * Gets the g component (output)
  62120. */
  62121. get g(): NodeMaterialConnectionPoint;
  62122. /**
  62123. * Gets the b component (output)
  62124. */
  62125. get b(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the a component (output)
  62128. */
  62129. get a(): NodeMaterialConnectionPoint;
  62130. protected _inputRename(name: string): string;
  62131. protected _outputRename(name: string): string;
  62132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62133. }
  62134. }
  62135. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62139. /**
  62140. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62141. */
  62142. export class VectorSplitterBlock extends NodeMaterialBlock {
  62143. /**
  62144. * Create a new VectorSplitterBlock
  62145. * @param name defines the block name
  62146. */
  62147. constructor(name: string);
  62148. /**
  62149. * Gets the current class name
  62150. * @returns the class name
  62151. */
  62152. getClassName(): string;
  62153. /**
  62154. * Gets the xyzw component (input)
  62155. */
  62156. get xyzw(): NodeMaterialConnectionPoint;
  62157. /**
  62158. * Gets the xyz component (input)
  62159. */
  62160. get xyzIn(): NodeMaterialConnectionPoint;
  62161. /**
  62162. * Gets the xy component (input)
  62163. */
  62164. get xyIn(): NodeMaterialConnectionPoint;
  62165. /**
  62166. * Gets the xyz component (output)
  62167. */
  62168. get xyzOut(): NodeMaterialConnectionPoint;
  62169. /**
  62170. * Gets the xy component (output)
  62171. */
  62172. get xyOut(): NodeMaterialConnectionPoint;
  62173. /**
  62174. * Gets the x component (output)
  62175. */
  62176. get x(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the y component (output)
  62179. */
  62180. get y(): NodeMaterialConnectionPoint;
  62181. /**
  62182. * Gets the z component (output)
  62183. */
  62184. get z(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the w component (output)
  62187. */
  62188. get w(): NodeMaterialConnectionPoint;
  62189. protected _inputRename(name: string): string;
  62190. protected _outputRename(name: string): string;
  62191. protected _buildBlock(state: NodeMaterialBuildState): this;
  62192. }
  62193. }
  62194. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62198. /**
  62199. * Block used to lerp between 2 values
  62200. */
  62201. export class LerpBlock extends NodeMaterialBlock {
  62202. /**
  62203. * Creates a new LerpBlock
  62204. * @param name defines the block name
  62205. */
  62206. constructor(name: string);
  62207. /**
  62208. * Gets the current class name
  62209. * @returns the class name
  62210. */
  62211. getClassName(): string;
  62212. /**
  62213. * Gets the left operand input component
  62214. */
  62215. get left(): NodeMaterialConnectionPoint;
  62216. /**
  62217. * Gets the right operand input component
  62218. */
  62219. get right(): NodeMaterialConnectionPoint;
  62220. /**
  62221. * Gets the gradient operand input component
  62222. */
  62223. get gradient(): NodeMaterialConnectionPoint;
  62224. /**
  62225. * Gets the output component
  62226. */
  62227. get output(): NodeMaterialConnectionPoint;
  62228. protected _buildBlock(state: NodeMaterialBuildState): this;
  62229. }
  62230. }
  62231. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62235. /**
  62236. * Block used to divide 2 vectors
  62237. */
  62238. export class DivideBlock extends NodeMaterialBlock {
  62239. /**
  62240. * Creates a new DivideBlock
  62241. * @param name defines the block name
  62242. */
  62243. constructor(name: string);
  62244. /**
  62245. * Gets the current class name
  62246. * @returns the class name
  62247. */
  62248. getClassName(): string;
  62249. /**
  62250. * Gets the left operand input component
  62251. */
  62252. get left(): NodeMaterialConnectionPoint;
  62253. /**
  62254. * Gets the right operand input component
  62255. */
  62256. get right(): NodeMaterialConnectionPoint;
  62257. /**
  62258. * Gets the output component
  62259. */
  62260. get output(): NodeMaterialConnectionPoint;
  62261. protected _buildBlock(state: NodeMaterialBuildState): this;
  62262. }
  62263. }
  62264. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62268. /**
  62269. * Block used to subtract 2 vectors
  62270. */
  62271. export class SubtractBlock extends NodeMaterialBlock {
  62272. /**
  62273. * Creates a new SubtractBlock
  62274. * @param name defines the block name
  62275. */
  62276. constructor(name: string);
  62277. /**
  62278. * Gets the current class name
  62279. * @returns the class name
  62280. */
  62281. getClassName(): string;
  62282. /**
  62283. * Gets the left operand input component
  62284. */
  62285. get left(): NodeMaterialConnectionPoint;
  62286. /**
  62287. * Gets the right operand input component
  62288. */
  62289. get right(): NodeMaterialConnectionPoint;
  62290. /**
  62291. * Gets the output component
  62292. */
  62293. get output(): NodeMaterialConnectionPoint;
  62294. protected _buildBlock(state: NodeMaterialBuildState): this;
  62295. }
  62296. }
  62297. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62301. /**
  62302. * Block used to step a value
  62303. */
  62304. export class StepBlock extends NodeMaterialBlock {
  62305. /**
  62306. * Creates a new StepBlock
  62307. * @param name defines the block name
  62308. */
  62309. constructor(name: string);
  62310. /**
  62311. * Gets the current class name
  62312. * @returns the class name
  62313. */
  62314. getClassName(): string;
  62315. /**
  62316. * Gets the value operand input component
  62317. */
  62318. get value(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the edge operand input component
  62321. */
  62322. get edge(): NodeMaterialConnectionPoint;
  62323. /**
  62324. * Gets the output component
  62325. */
  62326. get output(): NodeMaterialConnectionPoint;
  62327. protected _buildBlock(state: NodeMaterialBuildState): this;
  62328. }
  62329. }
  62330. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62334. /**
  62335. * Block used to get the opposite (1 - x) of a value
  62336. */
  62337. export class OneMinusBlock extends NodeMaterialBlock {
  62338. /**
  62339. * Creates a new OneMinusBlock
  62340. * @param name defines the block name
  62341. */
  62342. constructor(name: string);
  62343. /**
  62344. * Gets the current class name
  62345. * @returns the class name
  62346. */
  62347. getClassName(): string;
  62348. /**
  62349. * Gets the input component
  62350. */
  62351. get input(): NodeMaterialConnectionPoint;
  62352. /**
  62353. * Gets the output component
  62354. */
  62355. get output(): NodeMaterialConnectionPoint;
  62356. protected _buildBlock(state: NodeMaterialBuildState): this;
  62357. }
  62358. }
  62359. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62363. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62364. /**
  62365. * Block used to get the view direction
  62366. */
  62367. export class ViewDirectionBlock extends NodeMaterialBlock {
  62368. /**
  62369. * Creates a new ViewDirectionBlock
  62370. * @param name defines the block name
  62371. */
  62372. constructor(name: string);
  62373. /**
  62374. * Gets the current class name
  62375. * @returns the class name
  62376. */
  62377. getClassName(): string;
  62378. /**
  62379. * Gets the world position component
  62380. */
  62381. get worldPosition(): NodeMaterialConnectionPoint;
  62382. /**
  62383. * Gets the camera position component
  62384. */
  62385. get cameraPosition(): NodeMaterialConnectionPoint;
  62386. /**
  62387. * Gets the output component
  62388. */
  62389. get output(): NodeMaterialConnectionPoint;
  62390. autoConfigure(material: NodeMaterial): void;
  62391. protected _buildBlock(state: NodeMaterialBuildState): this;
  62392. }
  62393. }
  62394. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62398. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62399. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62400. /**
  62401. * Block used to compute fresnel value
  62402. */
  62403. export class FresnelBlock extends NodeMaterialBlock {
  62404. /**
  62405. * Create a new FresnelBlock
  62406. * @param name defines the block name
  62407. */
  62408. constructor(name: string);
  62409. /**
  62410. * Gets the current class name
  62411. * @returns the class name
  62412. */
  62413. getClassName(): string;
  62414. /**
  62415. * Gets the world normal input component
  62416. */
  62417. get worldNormal(): NodeMaterialConnectionPoint;
  62418. /**
  62419. * Gets the view direction input component
  62420. */
  62421. get viewDirection(): NodeMaterialConnectionPoint;
  62422. /**
  62423. * Gets the bias input component
  62424. */
  62425. get bias(): NodeMaterialConnectionPoint;
  62426. /**
  62427. * Gets the camera (or eye) position component
  62428. */
  62429. get power(): NodeMaterialConnectionPoint;
  62430. /**
  62431. * Gets the fresnel output component
  62432. */
  62433. get fresnel(): NodeMaterialConnectionPoint;
  62434. autoConfigure(material: NodeMaterial): void;
  62435. protected _buildBlock(state: NodeMaterialBuildState): this;
  62436. }
  62437. }
  62438. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62442. /**
  62443. * Block used to get the max of 2 values
  62444. */
  62445. export class MaxBlock extends NodeMaterialBlock {
  62446. /**
  62447. * Creates a new MaxBlock
  62448. * @param name defines the block name
  62449. */
  62450. constructor(name: string);
  62451. /**
  62452. * Gets the current class name
  62453. * @returns the class name
  62454. */
  62455. getClassName(): string;
  62456. /**
  62457. * Gets the left operand input component
  62458. */
  62459. get left(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the right operand input component
  62462. */
  62463. get right(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the output component
  62466. */
  62467. get output(): NodeMaterialConnectionPoint;
  62468. protected _buildBlock(state: NodeMaterialBuildState): this;
  62469. }
  62470. }
  62471. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62475. /**
  62476. * Block used to get the min of 2 values
  62477. */
  62478. export class MinBlock extends NodeMaterialBlock {
  62479. /**
  62480. * Creates a new MinBlock
  62481. * @param name defines the block name
  62482. */
  62483. constructor(name: string);
  62484. /**
  62485. * Gets the current class name
  62486. * @returns the class name
  62487. */
  62488. getClassName(): string;
  62489. /**
  62490. * Gets the left operand input component
  62491. */
  62492. get left(): NodeMaterialConnectionPoint;
  62493. /**
  62494. * Gets the right operand input component
  62495. */
  62496. get right(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the output component
  62499. */
  62500. get output(): NodeMaterialConnectionPoint;
  62501. protected _buildBlock(state: NodeMaterialBuildState): this;
  62502. }
  62503. }
  62504. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62508. /**
  62509. * Block used to get the distance between 2 values
  62510. */
  62511. export class DistanceBlock extends NodeMaterialBlock {
  62512. /**
  62513. * Creates a new DistanceBlock
  62514. * @param name defines the block name
  62515. */
  62516. constructor(name: string);
  62517. /**
  62518. * Gets the current class name
  62519. * @returns the class name
  62520. */
  62521. getClassName(): string;
  62522. /**
  62523. * Gets the left operand input component
  62524. */
  62525. get left(): NodeMaterialConnectionPoint;
  62526. /**
  62527. * Gets the right operand input component
  62528. */
  62529. get right(): NodeMaterialConnectionPoint;
  62530. /**
  62531. * Gets the output component
  62532. */
  62533. get output(): NodeMaterialConnectionPoint;
  62534. protected _buildBlock(state: NodeMaterialBuildState): this;
  62535. }
  62536. }
  62537. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62541. /**
  62542. * Block used to get the length of a vector
  62543. */
  62544. export class LengthBlock extends NodeMaterialBlock {
  62545. /**
  62546. * Creates a new LengthBlock
  62547. * @param name defines the block name
  62548. */
  62549. constructor(name: string);
  62550. /**
  62551. * Gets the current class name
  62552. * @returns the class name
  62553. */
  62554. getClassName(): string;
  62555. /**
  62556. * Gets the value input component
  62557. */
  62558. get value(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the output component
  62561. */
  62562. get output(): NodeMaterialConnectionPoint;
  62563. protected _buildBlock(state: NodeMaterialBuildState): this;
  62564. }
  62565. }
  62566. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62570. /**
  62571. * Block used to get negative version of a value (i.e. x * -1)
  62572. */
  62573. export class NegateBlock extends NodeMaterialBlock {
  62574. /**
  62575. * Creates a new NegateBlock
  62576. * @param name defines the block name
  62577. */
  62578. constructor(name: string);
  62579. /**
  62580. * Gets the current class name
  62581. * @returns the class name
  62582. */
  62583. getClassName(): string;
  62584. /**
  62585. * Gets the value input component
  62586. */
  62587. get value(): NodeMaterialConnectionPoint;
  62588. /**
  62589. * Gets the output component
  62590. */
  62591. get output(): NodeMaterialConnectionPoint;
  62592. protected _buildBlock(state: NodeMaterialBuildState): this;
  62593. }
  62594. }
  62595. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62596. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62598. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62599. /**
  62600. * Block used to get the value of the first parameter raised to the power of the second
  62601. */
  62602. export class PowBlock extends NodeMaterialBlock {
  62603. /**
  62604. * Creates a new PowBlock
  62605. * @param name defines the block name
  62606. */
  62607. constructor(name: string);
  62608. /**
  62609. * Gets the current class name
  62610. * @returns the class name
  62611. */
  62612. getClassName(): string;
  62613. /**
  62614. * Gets the value operand input component
  62615. */
  62616. get value(): NodeMaterialConnectionPoint;
  62617. /**
  62618. * Gets the power operand input component
  62619. */
  62620. get power(): NodeMaterialConnectionPoint;
  62621. /**
  62622. * Gets the output component
  62623. */
  62624. get output(): NodeMaterialConnectionPoint;
  62625. protected _buildBlock(state: NodeMaterialBuildState): this;
  62626. }
  62627. }
  62628. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62632. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62633. /**
  62634. * Block used to get a random number
  62635. */
  62636. export class RandomNumberBlock extends NodeMaterialBlock {
  62637. /**
  62638. * Creates a new RandomNumberBlock
  62639. * @param name defines the block name
  62640. */
  62641. constructor(name: string);
  62642. /**
  62643. * Gets the current class name
  62644. * @returns the class name
  62645. */
  62646. getClassName(): string;
  62647. /**
  62648. * Gets the seed input component
  62649. */
  62650. get seed(): NodeMaterialConnectionPoint;
  62651. /**
  62652. * Gets the output component
  62653. */
  62654. get output(): NodeMaterialConnectionPoint;
  62655. protected _buildBlock(state: NodeMaterialBuildState): this;
  62656. }
  62657. }
  62658. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62662. /**
  62663. * Block used to compute arc tangent of 2 values
  62664. */
  62665. export class ArcTan2Block extends NodeMaterialBlock {
  62666. /**
  62667. * Creates a new ArcTan2Block
  62668. * @param name defines the block name
  62669. */
  62670. constructor(name: string);
  62671. /**
  62672. * Gets the current class name
  62673. * @returns the class name
  62674. */
  62675. getClassName(): string;
  62676. /**
  62677. * Gets the x operand input component
  62678. */
  62679. get x(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the y operand input component
  62682. */
  62683. get y(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the output component
  62686. */
  62687. get output(): NodeMaterialConnectionPoint;
  62688. protected _buildBlock(state: NodeMaterialBuildState): this;
  62689. }
  62690. }
  62691. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62695. /**
  62696. * Block used to smooth step a value
  62697. */
  62698. export class SmoothStepBlock extends NodeMaterialBlock {
  62699. /**
  62700. * Creates a new SmoothStepBlock
  62701. * @param name defines the block name
  62702. */
  62703. constructor(name: string);
  62704. /**
  62705. * Gets the current class name
  62706. * @returns the class name
  62707. */
  62708. getClassName(): string;
  62709. /**
  62710. * Gets the value operand input component
  62711. */
  62712. get value(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the first edge operand input component
  62715. */
  62716. get edge0(): NodeMaterialConnectionPoint;
  62717. /**
  62718. * Gets the second edge operand input component
  62719. */
  62720. get edge1(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the output component
  62723. */
  62724. get output(): NodeMaterialConnectionPoint;
  62725. protected _buildBlock(state: NodeMaterialBuildState): this;
  62726. }
  62727. }
  62728. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62732. /**
  62733. * Block used to get the reciprocal (1 / x) of a value
  62734. */
  62735. export class ReciprocalBlock extends NodeMaterialBlock {
  62736. /**
  62737. * Creates a new ReciprocalBlock
  62738. * @param name defines the block name
  62739. */
  62740. constructor(name: string);
  62741. /**
  62742. * Gets the current class name
  62743. * @returns the class name
  62744. */
  62745. getClassName(): string;
  62746. /**
  62747. * Gets the input component
  62748. */
  62749. get input(): NodeMaterialConnectionPoint;
  62750. /**
  62751. * Gets the output component
  62752. */
  62753. get output(): NodeMaterialConnectionPoint;
  62754. protected _buildBlock(state: NodeMaterialBuildState): this;
  62755. }
  62756. }
  62757. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62761. /**
  62762. * Block used to replace a color by another one
  62763. */
  62764. export class ReplaceColorBlock extends NodeMaterialBlock {
  62765. /**
  62766. * Creates a new ReplaceColorBlock
  62767. * @param name defines the block name
  62768. */
  62769. constructor(name: string);
  62770. /**
  62771. * Gets the current class name
  62772. * @returns the class name
  62773. */
  62774. getClassName(): string;
  62775. /**
  62776. * Gets the value input component
  62777. */
  62778. get value(): NodeMaterialConnectionPoint;
  62779. /**
  62780. * Gets the reference input component
  62781. */
  62782. get reference(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the distance input component
  62785. */
  62786. get distance(): NodeMaterialConnectionPoint;
  62787. /**
  62788. * Gets the replacement input component
  62789. */
  62790. get replacement(): NodeMaterialConnectionPoint;
  62791. /**
  62792. * Gets the output component
  62793. */
  62794. get output(): NodeMaterialConnectionPoint;
  62795. protected _buildBlock(state: NodeMaterialBuildState): this;
  62796. }
  62797. }
  62798. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62802. /**
  62803. * Block used to posterize a value
  62804. * @see https://en.wikipedia.org/wiki/Posterization
  62805. */
  62806. export class PosterizeBlock extends NodeMaterialBlock {
  62807. /**
  62808. * Creates a new PosterizeBlock
  62809. * @param name defines the block name
  62810. */
  62811. constructor(name: string);
  62812. /**
  62813. * Gets the current class name
  62814. * @returns the class name
  62815. */
  62816. getClassName(): string;
  62817. /**
  62818. * Gets the value input component
  62819. */
  62820. get value(): NodeMaterialConnectionPoint;
  62821. /**
  62822. * Gets the steps input component
  62823. */
  62824. get steps(): NodeMaterialConnectionPoint;
  62825. /**
  62826. * Gets the output component
  62827. */
  62828. get output(): NodeMaterialConnectionPoint;
  62829. protected _buildBlock(state: NodeMaterialBuildState): this;
  62830. }
  62831. }
  62832. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62836. import { Scene } from "babylonjs/scene";
  62837. /**
  62838. * Operations supported by the Wave block
  62839. */
  62840. export enum WaveBlockKind {
  62841. /** SawTooth */
  62842. SawTooth = 0,
  62843. /** Square */
  62844. Square = 1,
  62845. /** Triangle */
  62846. Triangle = 2
  62847. }
  62848. /**
  62849. * Block used to apply wave operation to floats
  62850. */
  62851. export class WaveBlock extends NodeMaterialBlock {
  62852. /**
  62853. * Gets or sets the kibnd of wave to be applied by the block
  62854. */
  62855. kind: WaveBlockKind;
  62856. /**
  62857. * Creates a new WaveBlock
  62858. * @param name defines the block name
  62859. */
  62860. constructor(name: string);
  62861. /**
  62862. * Gets the current class name
  62863. * @returns the class name
  62864. */
  62865. getClassName(): string;
  62866. /**
  62867. * Gets the input component
  62868. */
  62869. get input(): NodeMaterialConnectionPoint;
  62870. /**
  62871. * Gets the output component
  62872. */
  62873. get output(): NodeMaterialConnectionPoint;
  62874. protected _buildBlock(state: NodeMaterialBuildState): this;
  62875. serialize(): any;
  62876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62877. }
  62878. }
  62879. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62883. import { Color3 } from "babylonjs/Maths/math.color";
  62884. import { Scene } from "babylonjs/scene";
  62885. /**
  62886. * Class used to store a color step for the GradientBlock
  62887. */
  62888. export class GradientBlockColorStep {
  62889. /**
  62890. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62891. */
  62892. step: number;
  62893. /**
  62894. * Gets or sets the color associated with this step
  62895. */
  62896. color: Color3;
  62897. /**
  62898. * Creates a new GradientBlockColorStep
  62899. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62900. * @param color defines the color associated with this step
  62901. */
  62902. constructor(
  62903. /**
  62904. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62905. */
  62906. step: number,
  62907. /**
  62908. * Gets or sets the color associated with this step
  62909. */
  62910. color: Color3);
  62911. }
  62912. /**
  62913. * Block used to return a color from a gradient based on an input value between 0 and 1
  62914. */
  62915. export class GradientBlock extends NodeMaterialBlock {
  62916. /**
  62917. * Gets or sets the list of color steps
  62918. */
  62919. colorSteps: GradientBlockColorStep[];
  62920. /**
  62921. * Creates a new GradientBlock
  62922. * @param name defines the block name
  62923. */
  62924. constructor(name: string);
  62925. /**
  62926. * Gets the current class name
  62927. * @returns the class name
  62928. */
  62929. getClassName(): string;
  62930. /**
  62931. * Gets the gradient input component
  62932. */
  62933. get gradient(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the output component
  62936. */
  62937. get output(): NodeMaterialConnectionPoint;
  62938. private _writeColorConstant;
  62939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62940. serialize(): any;
  62941. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62942. protected _dumpPropertiesCode(): string;
  62943. }
  62944. }
  62945. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62949. /**
  62950. * Block used to normalize lerp between 2 values
  62951. */
  62952. export class NLerpBlock extends NodeMaterialBlock {
  62953. /**
  62954. * Creates a new NLerpBlock
  62955. * @param name defines the block name
  62956. */
  62957. constructor(name: string);
  62958. /**
  62959. * Gets the current class name
  62960. * @returns the class name
  62961. */
  62962. getClassName(): string;
  62963. /**
  62964. * Gets the left operand input component
  62965. */
  62966. get left(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the right operand input component
  62969. */
  62970. get right(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the gradient operand input component
  62973. */
  62974. get gradient(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the output component
  62977. */
  62978. get output(): NodeMaterialConnectionPoint;
  62979. protected _buildBlock(state: NodeMaterialBuildState): this;
  62980. }
  62981. }
  62982. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62986. import { Scene } from "babylonjs/scene";
  62987. /**
  62988. * block used to Generate a Worley Noise 3D Noise Pattern
  62989. */
  62990. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62991. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62992. manhattanDistance: boolean;
  62993. /**
  62994. * Creates a new WorleyNoise3DBlock
  62995. * @param name defines the block name
  62996. */
  62997. constructor(name: string);
  62998. /**
  62999. * Gets the current class name
  63000. * @returns the class name
  63001. */
  63002. getClassName(): string;
  63003. /**
  63004. * Gets the seed input component
  63005. */
  63006. get seed(): NodeMaterialConnectionPoint;
  63007. /**
  63008. * Gets the jitter input component
  63009. */
  63010. get jitter(): NodeMaterialConnectionPoint;
  63011. /**
  63012. * Gets the output component
  63013. */
  63014. get output(): NodeMaterialConnectionPoint;
  63015. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63016. /**
  63017. * Exposes the properties to the UI?
  63018. */
  63019. protected _dumpPropertiesCode(): string;
  63020. /**
  63021. * Exposes the properties to the Seralize?
  63022. */
  63023. serialize(): any;
  63024. /**
  63025. * Exposes the properties to the deseralize?
  63026. */
  63027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63028. }
  63029. }
  63030. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63034. /**
  63035. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63036. */
  63037. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63038. /**
  63039. * Creates a new SimplexPerlin3DBlock
  63040. * @param name defines the block name
  63041. */
  63042. constructor(name: string);
  63043. /**
  63044. * Gets the current class name
  63045. * @returns the class name
  63046. */
  63047. getClassName(): string;
  63048. /**
  63049. * Gets the seed operand input component
  63050. */
  63051. get seed(): NodeMaterialConnectionPoint;
  63052. /**
  63053. * Gets the output component
  63054. */
  63055. get output(): NodeMaterialConnectionPoint;
  63056. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63057. }
  63058. }
  63059. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63063. /**
  63064. * Block used to blend normals
  63065. */
  63066. export class NormalBlendBlock extends NodeMaterialBlock {
  63067. /**
  63068. * Creates a new NormalBlendBlock
  63069. * @param name defines the block name
  63070. */
  63071. constructor(name: string);
  63072. /**
  63073. * Gets the current class name
  63074. * @returns the class name
  63075. */
  63076. getClassName(): string;
  63077. /**
  63078. * Gets the first input component
  63079. */
  63080. get normalMap0(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the second input component
  63083. */
  63084. get normalMap1(): NodeMaterialConnectionPoint;
  63085. /**
  63086. * Gets the output component
  63087. */
  63088. get output(): NodeMaterialConnectionPoint;
  63089. protected _buildBlock(state: NodeMaterialBuildState): this;
  63090. }
  63091. }
  63092. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63096. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63097. /**
  63098. * Block used to rotate a 2d vector by a given angle
  63099. */
  63100. export class Rotate2dBlock extends NodeMaterialBlock {
  63101. /**
  63102. * Creates a new Rotate2dBlock
  63103. * @param name defines the block name
  63104. */
  63105. constructor(name: string);
  63106. /**
  63107. * Gets the current class name
  63108. * @returns the class name
  63109. */
  63110. getClassName(): string;
  63111. /**
  63112. * Gets the input vector
  63113. */
  63114. get input(): NodeMaterialConnectionPoint;
  63115. /**
  63116. * Gets the input angle
  63117. */
  63118. get angle(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the output component
  63121. */
  63122. get output(): NodeMaterialConnectionPoint;
  63123. autoConfigure(material: NodeMaterial): void;
  63124. protected _buildBlock(state: NodeMaterialBuildState): this;
  63125. }
  63126. }
  63127. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63131. /**
  63132. * Block used to get the reflected vector from a direction and a normal
  63133. */
  63134. export class ReflectBlock extends NodeMaterialBlock {
  63135. /**
  63136. * Creates a new ReflectBlock
  63137. * @param name defines the block name
  63138. */
  63139. constructor(name: string);
  63140. /**
  63141. * Gets the current class name
  63142. * @returns the class name
  63143. */
  63144. getClassName(): string;
  63145. /**
  63146. * Gets the incident component
  63147. */
  63148. get incident(): NodeMaterialConnectionPoint;
  63149. /**
  63150. * Gets the normal component
  63151. */
  63152. get normal(): NodeMaterialConnectionPoint;
  63153. /**
  63154. * Gets the output component
  63155. */
  63156. get output(): NodeMaterialConnectionPoint;
  63157. protected _buildBlock(state: NodeMaterialBuildState): this;
  63158. }
  63159. }
  63160. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63164. /**
  63165. * Block used to get the refracted vector from a direction and a normal
  63166. */
  63167. export class RefractBlock extends NodeMaterialBlock {
  63168. /**
  63169. * Creates a new RefractBlock
  63170. * @param name defines the block name
  63171. */
  63172. constructor(name: string);
  63173. /**
  63174. * Gets the current class name
  63175. * @returns the class name
  63176. */
  63177. getClassName(): string;
  63178. /**
  63179. * Gets the incident component
  63180. */
  63181. get incident(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the normal component
  63184. */
  63185. get normal(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the index of refraction component
  63188. */
  63189. get ior(): NodeMaterialConnectionPoint;
  63190. /**
  63191. * Gets the output component
  63192. */
  63193. get output(): NodeMaterialConnectionPoint;
  63194. protected _buildBlock(state: NodeMaterialBuildState): this;
  63195. }
  63196. }
  63197. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63201. /**
  63202. * Block used to desaturate a color
  63203. */
  63204. export class DesaturateBlock extends NodeMaterialBlock {
  63205. /**
  63206. * Creates a new DesaturateBlock
  63207. * @param name defines the block name
  63208. */
  63209. constructor(name: string);
  63210. /**
  63211. * Gets the current class name
  63212. * @returns the class name
  63213. */
  63214. getClassName(): string;
  63215. /**
  63216. * Gets the color operand input component
  63217. */
  63218. get color(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the level operand input component
  63221. */
  63222. get level(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the output component
  63225. */
  63226. get output(): NodeMaterialConnectionPoint;
  63227. protected _buildBlock(state: NodeMaterialBuildState): this;
  63228. }
  63229. }
  63230. declare module "babylonjs/Materials/Node/Blocks/index" {
  63231. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63232. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63233. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63234. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63235. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63236. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63237. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63238. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63239. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63240. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63241. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63242. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63243. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63244. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63245. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63246. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63247. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63248. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63249. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63250. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63251. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63252. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63253. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63254. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63255. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63256. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63257. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63258. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63259. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63260. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63261. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63262. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63263. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63264. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63265. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63266. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63267. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63268. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63269. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63270. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63271. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63272. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63273. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63274. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63275. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63276. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63277. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63278. }
  63279. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63280. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63281. }
  63282. declare module "babylonjs/Materials/Node/index" {
  63283. export * from "babylonjs/Materials/Node/Enums/index";
  63284. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63285. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63286. export * from "babylonjs/Materials/Node/nodeMaterial";
  63287. export * from "babylonjs/Materials/Node/Blocks/index";
  63288. export * from "babylonjs/Materials/Node/Optimizers/index";
  63289. }
  63290. declare module "babylonjs/Materials/effectRenderer" {
  63291. import { Nullable } from "babylonjs/types";
  63292. import { Texture } from "babylonjs/Materials/Textures/texture";
  63293. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63294. import { Viewport } from "babylonjs/Maths/math.viewport";
  63295. import { Observable } from "babylonjs/Misc/observable";
  63296. import { Effect } from "babylonjs/Materials/effect";
  63297. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63298. import "babylonjs/Shaders/postprocess.vertex";
  63299. /**
  63300. * Effect Render Options
  63301. */
  63302. export interface IEffectRendererOptions {
  63303. /**
  63304. * Defines the vertices positions.
  63305. */
  63306. positions?: number[];
  63307. /**
  63308. * Defines the indices.
  63309. */
  63310. indices?: number[];
  63311. }
  63312. /**
  63313. * Helper class to render one or more effects
  63314. */
  63315. export class EffectRenderer {
  63316. private engine;
  63317. private static _DefaultOptions;
  63318. private _vertexBuffers;
  63319. private _indexBuffer;
  63320. private _ringBufferIndex;
  63321. private _ringScreenBuffer;
  63322. private _fullscreenViewport;
  63323. private _getNextFrameBuffer;
  63324. /**
  63325. * Creates an effect renderer
  63326. * @param engine the engine to use for rendering
  63327. * @param options defines the options of the effect renderer
  63328. */
  63329. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63330. /**
  63331. * Sets the current viewport in normalized coordinates 0-1
  63332. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63333. */
  63334. setViewport(viewport?: Viewport): void;
  63335. /**
  63336. * Binds the embedded attributes buffer to the effect.
  63337. * @param effect Defines the effect to bind the attributes for
  63338. */
  63339. bindBuffers(effect: Effect): void;
  63340. /**
  63341. * Sets the current effect wrapper to use during draw.
  63342. * The effect needs to be ready before calling this api.
  63343. * This also sets the default full screen position attribute.
  63344. * @param effectWrapper Defines the effect to draw with
  63345. */
  63346. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63347. /**
  63348. * Draws a full screen quad.
  63349. */
  63350. draw(): void;
  63351. /**
  63352. * renders one or more effects to a specified texture
  63353. * @param effectWrappers list of effects to renderer
  63354. * @param outputTexture texture to draw to, if null it will render to the screen
  63355. */
  63356. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63357. /**
  63358. * Disposes of the effect renderer
  63359. */
  63360. dispose(): void;
  63361. }
  63362. /**
  63363. * Options to create an EffectWrapper
  63364. */
  63365. interface EffectWrapperCreationOptions {
  63366. /**
  63367. * Engine to use to create the effect
  63368. */
  63369. engine: ThinEngine;
  63370. /**
  63371. * Fragment shader for the effect
  63372. */
  63373. fragmentShader: string;
  63374. /**
  63375. * Vertex shader for the effect
  63376. */
  63377. vertexShader?: string;
  63378. /**
  63379. * Attributes to use in the shader
  63380. */
  63381. attributeNames?: Array<string>;
  63382. /**
  63383. * Uniforms to use in the shader
  63384. */
  63385. uniformNames?: Array<string>;
  63386. /**
  63387. * Texture sampler names to use in the shader
  63388. */
  63389. samplerNames?: Array<string>;
  63390. /**
  63391. * The friendly name of the effect displayed in Spector.
  63392. */
  63393. name?: string;
  63394. }
  63395. /**
  63396. * Wraps an effect to be used for rendering
  63397. */
  63398. export class EffectWrapper {
  63399. /**
  63400. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63401. */
  63402. onApplyObservable: Observable<{}>;
  63403. /**
  63404. * The underlying effect
  63405. */
  63406. effect: Effect;
  63407. /**
  63408. * Creates an effect to be renderer
  63409. * @param creationOptions options to create the effect
  63410. */
  63411. constructor(creationOptions: EffectWrapperCreationOptions);
  63412. /**
  63413. * Disposes of the effect wrapper
  63414. */
  63415. dispose(): void;
  63416. }
  63417. }
  63418. declare module "babylonjs/Materials/index" {
  63419. export * from "babylonjs/Materials/Background/index";
  63420. export * from "babylonjs/Materials/colorCurves";
  63421. export * from "babylonjs/Materials/iEffectFallbacks";
  63422. export * from "babylonjs/Materials/effectFallbacks";
  63423. export * from "babylonjs/Materials/effect";
  63424. export * from "babylonjs/Materials/fresnelParameters";
  63425. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63426. export * from "babylonjs/Materials/material";
  63427. export * from "babylonjs/Materials/materialDefines";
  63428. export * from "babylonjs/Materials/materialHelper";
  63429. export * from "babylonjs/Materials/multiMaterial";
  63430. export * from "babylonjs/Materials/PBR/index";
  63431. export * from "babylonjs/Materials/pushMaterial";
  63432. export * from "babylonjs/Materials/shaderMaterial";
  63433. export * from "babylonjs/Materials/standardMaterial";
  63434. export * from "babylonjs/Materials/Textures/index";
  63435. export * from "babylonjs/Materials/uniformBuffer";
  63436. export * from "babylonjs/Materials/materialFlags";
  63437. export * from "babylonjs/Materials/Node/index";
  63438. export * from "babylonjs/Materials/effectRenderer";
  63439. }
  63440. declare module "babylonjs/Maths/index" {
  63441. export * from "babylonjs/Maths/math.scalar";
  63442. export * from "babylonjs/Maths/math";
  63443. export * from "babylonjs/Maths/sphericalPolynomial";
  63444. }
  63445. declare module "babylonjs/Misc/workerPool" {
  63446. import { IDisposable } from "babylonjs/scene";
  63447. /**
  63448. * Helper class to push actions to a pool of workers.
  63449. */
  63450. export class WorkerPool implements IDisposable {
  63451. private _workerInfos;
  63452. private _pendingActions;
  63453. /**
  63454. * Constructor
  63455. * @param workers Array of workers to use for actions
  63456. */
  63457. constructor(workers: Array<Worker>);
  63458. /**
  63459. * Terminates all workers and clears any pending actions.
  63460. */
  63461. dispose(): void;
  63462. /**
  63463. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63464. * pended until a worker has completed its action.
  63465. * @param action The action to perform. Call onComplete when the action is complete.
  63466. */
  63467. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63468. private _execute;
  63469. }
  63470. }
  63471. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63472. import { IDisposable } from "babylonjs/scene";
  63473. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63474. /**
  63475. * Configuration for Draco compression
  63476. */
  63477. export interface IDracoCompressionConfiguration {
  63478. /**
  63479. * Configuration for the decoder.
  63480. */
  63481. decoder: {
  63482. /**
  63483. * The url to the WebAssembly module.
  63484. */
  63485. wasmUrl?: string;
  63486. /**
  63487. * The url to the WebAssembly binary.
  63488. */
  63489. wasmBinaryUrl?: string;
  63490. /**
  63491. * The url to the fallback JavaScript module.
  63492. */
  63493. fallbackUrl?: string;
  63494. };
  63495. }
  63496. /**
  63497. * Draco compression (https://google.github.io/draco/)
  63498. *
  63499. * This class wraps the Draco module.
  63500. *
  63501. * **Encoder**
  63502. *
  63503. * The encoder is not currently implemented.
  63504. *
  63505. * **Decoder**
  63506. *
  63507. * 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.
  63508. *
  63509. * To update the configuration, use the following code:
  63510. * ```javascript
  63511. * DracoCompression.Configuration = {
  63512. * decoder: {
  63513. * wasmUrl: "<url to the WebAssembly library>",
  63514. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63515. * fallbackUrl: "<url to the fallback JavaScript library>",
  63516. * }
  63517. * };
  63518. * ```
  63519. *
  63520. * 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.
  63521. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63522. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63523. *
  63524. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63525. * ```javascript
  63526. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63527. * ```
  63528. *
  63529. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63530. */
  63531. export class DracoCompression implements IDisposable {
  63532. private _workerPoolPromise?;
  63533. private _decoderModulePromise?;
  63534. /**
  63535. * The configuration. Defaults to the following urls:
  63536. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63537. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63538. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63539. */
  63540. static Configuration: IDracoCompressionConfiguration;
  63541. /**
  63542. * Returns true if the decoder configuration is available.
  63543. */
  63544. static get DecoderAvailable(): boolean;
  63545. /**
  63546. * Default number of workers to create when creating the draco compression object.
  63547. */
  63548. static DefaultNumWorkers: number;
  63549. private static GetDefaultNumWorkers;
  63550. private static _Default;
  63551. /**
  63552. * Default instance for the draco compression object.
  63553. */
  63554. static get Default(): DracoCompression;
  63555. /**
  63556. * Constructor
  63557. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63558. */
  63559. constructor(numWorkers?: number);
  63560. /**
  63561. * Stop all async operations and release resources.
  63562. */
  63563. dispose(): void;
  63564. /**
  63565. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63566. * @returns a promise that resolves when ready
  63567. */
  63568. whenReadyAsync(): Promise<void>;
  63569. /**
  63570. * Decode Draco compressed mesh data to vertex data.
  63571. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63572. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63573. * @returns A promise that resolves with the decoded vertex data
  63574. */
  63575. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63576. [kind: string]: number;
  63577. }): Promise<VertexData>;
  63578. }
  63579. }
  63580. declare module "babylonjs/Meshes/Compression/index" {
  63581. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63582. }
  63583. declare module "babylonjs/Meshes/csg" {
  63584. import { Nullable } from "babylonjs/types";
  63585. import { Scene } from "babylonjs/scene";
  63586. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63587. import { Mesh } from "babylonjs/Meshes/mesh";
  63588. import { Material } from "babylonjs/Materials/material";
  63589. /**
  63590. * Class for building Constructive Solid Geometry
  63591. */
  63592. export class CSG {
  63593. private polygons;
  63594. /**
  63595. * The world matrix
  63596. */
  63597. matrix: Matrix;
  63598. /**
  63599. * Stores the position
  63600. */
  63601. position: Vector3;
  63602. /**
  63603. * Stores the rotation
  63604. */
  63605. rotation: Vector3;
  63606. /**
  63607. * Stores the rotation quaternion
  63608. */
  63609. rotationQuaternion: Nullable<Quaternion>;
  63610. /**
  63611. * Stores the scaling vector
  63612. */
  63613. scaling: Vector3;
  63614. /**
  63615. * Convert the Mesh to CSG
  63616. * @param mesh The Mesh to convert to CSG
  63617. * @returns A new CSG from the Mesh
  63618. */
  63619. static FromMesh(mesh: Mesh): CSG;
  63620. /**
  63621. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63622. * @param polygons Polygons used to construct a CSG solid
  63623. */
  63624. private static FromPolygons;
  63625. /**
  63626. * Clones, or makes a deep copy, of the CSG
  63627. * @returns A new CSG
  63628. */
  63629. clone(): CSG;
  63630. /**
  63631. * Unions this CSG with another CSG
  63632. * @param csg The CSG to union against this CSG
  63633. * @returns The unioned CSG
  63634. */
  63635. union(csg: CSG): CSG;
  63636. /**
  63637. * Unions this CSG with another CSG in place
  63638. * @param csg The CSG to union against this CSG
  63639. */
  63640. unionInPlace(csg: CSG): void;
  63641. /**
  63642. * Subtracts this CSG with another CSG
  63643. * @param csg The CSG to subtract against this CSG
  63644. * @returns A new CSG
  63645. */
  63646. subtract(csg: CSG): CSG;
  63647. /**
  63648. * Subtracts this CSG with another CSG in place
  63649. * @param csg The CSG to subtact against this CSG
  63650. */
  63651. subtractInPlace(csg: CSG): void;
  63652. /**
  63653. * Intersect this CSG with another CSG
  63654. * @param csg The CSG to intersect against this CSG
  63655. * @returns A new CSG
  63656. */
  63657. intersect(csg: CSG): CSG;
  63658. /**
  63659. * Intersects this CSG with another CSG in place
  63660. * @param csg The CSG to intersect against this CSG
  63661. */
  63662. intersectInPlace(csg: CSG): void;
  63663. /**
  63664. * Return a new CSG solid with solid and empty space switched. This solid is
  63665. * not modified.
  63666. * @returns A new CSG solid with solid and empty space switched
  63667. */
  63668. inverse(): CSG;
  63669. /**
  63670. * Inverses the CSG in place
  63671. */
  63672. inverseInPlace(): void;
  63673. /**
  63674. * This is used to keep meshes transformations so they can be restored
  63675. * when we build back a Babylon Mesh
  63676. * NB : All CSG operations are performed in world coordinates
  63677. * @param csg The CSG to copy the transform attributes from
  63678. * @returns This CSG
  63679. */
  63680. copyTransformAttributes(csg: CSG): CSG;
  63681. /**
  63682. * Build Raw mesh from CSG
  63683. * Coordinates here are in world space
  63684. * @param name The name of the mesh geometry
  63685. * @param scene The Scene
  63686. * @param keepSubMeshes Specifies if the submeshes should be kept
  63687. * @returns A new Mesh
  63688. */
  63689. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63690. /**
  63691. * Build Mesh from CSG taking material and transforms into account
  63692. * @param name The name of the Mesh
  63693. * @param material The material of the Mesh
  63694. * @param scene The Scene
  63695. * @param keepSubMeshes Specifies if submeshes should be kept
  63696. * @returns The new Mesh
  63697. */
  63698. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63699. }
  63700. }
  63701. declare module "babylonjs/Meshes/trailMesh" {
  63702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63703. import { Mesh } from "babylonjs/Meshes/mesh";
  63704. import { Scene } from "babylonjs/scene";
  63705. /**
  63706. * Class used to create a trail following a mesh
  63707. */
  63708. export class TrailMesh extends Mesh {
  63709. private _generator;
  63710. private _autoStart;
  63711. private _running;
  63712. private _diameter;
  63713. private _length;
  63714. private _sectionPolygonPointsCount;
  63715. private _sectionVectors;
  63716. private _sectionNormalVectors;
  63717. private _beforeRenderObserver;
  63718. /**
  63719. * @constructor
  63720. * @param name The value used by scene.getMeshByName() to do a lookup.
  63721. * @param generator The mesh to generate a trail.
  63722. * @param scene The scene to add this mesh to.
  63723. * @param diameter Diameter of trailing mesh. Default is 1.
  63724. * @param length Length of trailing mesh. Default is 60.
  63725. * @param autoStart Automatically start trailing mesh. Default true.
  63726. */
  63727. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63728. /**
  63729. * "TrailMesh"
  63730. * @returns "TrailMesh"
  63731. */
  63732. getClassName(): string;
  63733. private _createMesh;
  63734. /**
  63735. * Start trailing mesh.
  63736. */
  63737. start(): void;
  63738. /**
  63739. * Stop trailing mesh.
  63740. */
  63741. stop(): void;
  63742. /**
  63743. * Update trailing mesh geometry.
  63744. */
  63745. update(): void;
  63746. /**
  63747. * Returns a new TrailMesh object.
  63748. * @param name is a string, the name given to the new mesh
  63749. * @param newGenerator use new generator object for cloned trail mesh
  63750. * @returns a new mesh
  63751. */
  63752. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  63753. /**
  63754. * Serializes this trail mesh
  63755. * @param serializationObject object to write serialization to
  63756. */
  63757. serialize(serializationObject: any): void;
  63758. /**
  63759. * Parses a serialized trail mesh
  63760. * @param parsedMesh the serialized mesh
  63761. * @param scene the scene to create the trail mesh in
  63762. * @returns the created trail mesh
  63763. */
  63764. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63765. }
  63766. }
  63767. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63768. import { Nullable } from "babylonjs/types";
  63769. import { Scene } from "babylonjs/scene";
  63770. import { Vector4 } from "babylonjs/Maths/math.vector";
  63771. import { Color4 } from "babylonjs/Maths/math.color";
  63772. import { Mesh } from "babylonjs/Meshes/mesh";
  63773. /**
  63774. * Class containing static functions to help procedurally build meshes
  63775. */
  63776. export class TiledBoxBuilder {
  63777. /**
  63778. * Creates a box mesh
  63779. * 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)
  63780. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63784. * @param name defines the name of the mesh
  63785. * @param options defines the options used to create the mesh
  63786. * @param scene defines the hosting scene
  63787. * @returns the box mesh
  63788. */
  63789. static CreateTiledBox(name: string, options: {
  63790. pattern?: number;
  63791. width?: number;
  63792. height?: number;
  63793. depth?: number;
  63794. tileSize?: number;
  63795. tileWidth?: number;
  63796. tileHeight?: number;
  63797. alignHorizontal?: number;
  63798. alignVertical?: number;
  63799. faceUV?: Vector4[];
  63800. faceColors?: Color4[];
  63801. sideOrientation?: number;
  63802. updatable?: boolean;
  63803. }, scene?: Nullable<Scene>): Mesh;
  63804. }
  63805. }
  63806. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63807. import { Vector4 } from "babylonjs/Maths/math.vector";
  63808. import { Mesh } from "babylonjs/Meshes/mesh";
  63809. /**
  63810. * Class containing static functions to help procedurally build meshes
  63811. */
  63812. export class TorusKnotBuilder {
  63813. /**
  63814. * Creates a torus knot mesh
  63815. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63816. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63817. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63818. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63822. * @param name defines the name of the mesh
  63823. * @param options defines the options used to create the mesh
  63824. * @param scene defines the hosting scene
  63825. * @returns the torus knot mesh
  63826. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63827. */
  63828. static CreateTorusKnot(name: string, options: {
  63829. radius?: number;
  63830. tube?: number;
  63831. radialSegments?: number;
  63832. tubularSegments?: number;
  63833. p?: number;
  63834. q?: number;
  63835. updatable?: boolean;
  63836. sideOrientation?: number;
  63837. frontUVs?: Vector4;
  63838. backUVs?: Vector4;
  63839. }, scene: any): Mesh;
  63840. }
  63841. }
  63842. declare module "babylonjs/Meshes/polygonMesh" {
  63843. import { Scene } from "babylonjs/scene";
  63844. import { Vector2 } from "babylonjs/Maths/math.vector";
  63845. import { Mesh } from "babylonjs/Meshes/mesh";
  63846. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63847. import { Path2 } from "babylonjs/Maths/math.path";
  63848. /**
  63849. * Polygon
  63850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63851. */
  63852. export class Polygon {
  63853. /**
  63854. * Creates a rectangle
  63855. * @param xmin bottom X coord
  63856. * @param ymin bottom Y coord
  63857. * @param xmax top X coord
  63858. * @param ymax top Y coord
  63859. * @returns points that make the resulting rectation
  63860. */
  63861. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63862. /**
  63863. * Creates a circle
  63864. * @param radius radius of circle
  63865. * @param cx scale in x
  63866. * @param cy scale in y
  63867. * @param numberOfSides number of sides that make up the circle
  63868. * @returns points that make the resulting circle
  63869. */
  63870. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63871. /**
  63872. * Creates a polygon from input string
  63873. * @param input Input polygon data
  63874. * @returns the parsed points
  63875. */
  63876. static Parse(input: string): Vector2[];
  63877. /**
  63878. * Starts building a polygon from x and y coordinates
  63879. * @param x x coordinate
  63880. * @param y y coordinate
  63881. * @returns the started path2
  63882. */
  63883. static StartingAt(x: number, y: number): Path2;
  63884. }
  63885. /**
  63886. * Builds a polygon
  63887. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63888. */
  63889. export class PolygonMeshBuilder {
  63890. private _points;
  63891. private _outlinepoints;
  63892. private _holes;
  63893. private _name;
  63894. private _scene;
  63895. private _epoints;
  63896. private _eholes;
  63897. private _addToepoint;
  63898. /**
  63899. * Babylon reference to the earcut plugin.
  63900. */
  63901. bjsEarcut: any;
  63902. /**
  63903. * Creates a PolygonMeshBuilder
  63904. * @param name name of the builder
  63905. * @param contours Path of the polygon
  63906. * @param scene scene to add to when creating the mesh
  63907. * @param earcutInjection can be used to inject your own earcut reference
  63908. */
  63909. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63910. /**
  63911. * Adds a whole within the polygon
  63912. * @param hole Array of points defining the hole
  63913. * @returns this
  63914. */
  63915. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63916. /**
  63917. * Creates the polygon
  63918. * @param updatable If the mesh should be updatable
  63919. * @param depth The depth of the mesh created
  63920. * @returns the created mesh
  63921. */
  63922. build(updatable?: boolean, depth?: number): Mesh;
  63923. /**
  63924. * Creates the polygon
  63925. * @param depth The depth of the mesh created
  63926. * @returns the created VertexData
  63927. */
  63928. buildVertexData(depth?: number): VertexData;
  63929. /**
  63930. * Adds a side to the polygon
  63931. * @param positions points that make the polygon
  63932. * @param normals normals of the polygon
  63933. * @param uvs uvs of the polygon
  63934. * @param indices indices of the polygon
  63935. * @param bounds bounds of the polygon
  63936. * @param points points of the polygon
  63937. * @param depth depth of the polygon
  63938. * @param flip flip of the polygon
  63939. */
  63940. private addSide;
  63941. }
  63942. }
  63943. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63944. import { Scene } from "babylonjs/scene";
  63945. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63946. import { Color4 } from "babylonjs/Maths/math.color";
  63947. import { Mesh } from "babylonjs/Meshes/mesh";
  63948. import { Nullable } from "babylonjs/types";
  63949. /**
  63950. * Class containing static functions to help procedurally build meshes
  63951. */
  63952. export class PolygonBuilder {
  63953. /**
  63954. * Creates a polygon mesh
  63955. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63956. * * 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
  63957. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63960. * * Remember you can only change the shape positions, not their number when updating a polygon
  63961. * @param name defines the name of the mesh
  63962. * @param options defines the options used to create the mesh
  63963. * @param scene defines the hosting scene
  63964. * @param earcutInjection can be used to inject your own earcut reference
  63965. * @returns the polygon mesh
  63966. */
  63967. static CreatePolygon(name: string, options: {
  63968. shape: Vector3[];
  63969. holes?: Vector3[][];
  63970. depth?: number;
  63971. faceUV?: Vector4[];
  63972. faceColors?: Color4[];
  63973. updatable?: boolean;
  63974. sideOrientation?: number;
  63975. frontUVs?: Vector4;
  63976. backUVs?: Vector4;
  63977. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63978. /**
  63979. * Creates an extruded polygon mesh, with depth in the Y direction.
  63980. * * 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)
  63981. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63982. * @param name defines the name of the mesh
  63983. * @param options defines the options used to create the mesh
  63984. * @param scene defines the hosting scene
  63985. * @param earcutInjection can be used to inject your own earcut reference
  63986. * @returns the polygon mesh
  63987. */
  63988. static ExtrudePolygon(name: string, options: {
  63989. shape: Vector3[];
  63990. holes?: Vector3[][];
  63991. depth?: number;
  63992. faceUV?: Vector4[];
  63993. faceColors?: Color4[];
  63994. updatable?: boolean;
  63995. sideOrientation?: number;
  63996. frontUVs?: Vector4;
  63997. backUVs?: Vector4;
  63998. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63999. }
  64000. }
  64001. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64002. import { Scene } from "babylonjs/scene";
  64003. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64004. import { Mesh } from "babylonjs/Meshes/mesh";
  64005. import { Nullable } from "babylonjs/types";
  64006. /**
  64007. * Class containing static functions to help procedurally build meshes
  64008. */
  64009. export class LatheBuilder {
  64010. /**
  64011. * Creates lathe mesh.
  64012. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64013. * * 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
  64014. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64015. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64016. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64017. * * 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
  64018. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64019. * * 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
  64020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64024. * @param name defines the name of the mesh
  64025. * @param options defines the options used to create the mesh
  64026. * @param scene defines the hosting scene
  64027. * @returns the lathe mesh
  64028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64029. */
  64030. static CreateLathe(name: string, options: {
  64031. shape: Vector3[];
  64032. radius?: number;
  64033. tessellation?: number;
  64034. clip?: number;
  64035. arc?: number;
  64036. closed?: boolean;
  64037. updatable?: boolean;
  64038. sideOrientation?: number;
  64039. frontUVs?: Vector4;
  64040. backUVs?: Vector4;
  64041. cap?: number;
  64042. invertUV?: boolean;
  64043. }, scene?: Nullable<Scene>): Mesh;
  64044. }
  64045. }
  64046. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64047. import { Nullable } from "babylonjs/types";
  64048. import { Scene } from "babylonjs/scene";
  64049. import { Vector4 } from "babylonjs/Maths/math.vector";
  64050. import { Mesh } from "babylonjs/Meshes/mesh";
  64051. /**
  64052. * Class containing static functions to help procedurally build meshes
  64053. */
  64054. export class TiledPlaneBuilder {
  64055. /**
  64056. * Creates a tiled plane mesh
  64057. * * The parameter `pattern` will, depending on value, do nothing or
  64058. * * * flip (reflect about central vertical) alternate tiles across and up
  64059. * * * flip every tile on alternate rows
  64060. * * * rotate (180 degs) alternate tiles across and up
  64061. * * * rotate every tile on alternate rows
  64062. * * * flip and rotate alternate tiles across and up
  64063. * * * flip and rotate every tile on alternate rows
  64064. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64065. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64068. * * 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)
  64069. * * 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)
  64070. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64071. * @param name defines the name of the mesh
  64072. * @param options defines the options used to create the mesh
  64073. * @param scene defines the hosting scene
  64074. * @returns the box mesh
  64075. */
  64076. static CreateTiledPlane(name: string, options: {
  64077. pattern?: number;
  64078. tileSize?: number;
  64079. tileWidth?: number;
  64080. tileHeight?: number;
  64081. size?: number;
  64082. width?: number;
  64083. height?: number;
  64084. alignHorizontal?: number;
  64085. alignVertical?: number;
  64086. sideOrientation?: number;
  64087. frontUVs?: Vector4;
  64088. backUVs?: Vector4;
  64089. updatable?: boolean;
  64090. }, scene?: Nullable<Scene>): Mesh;
  64091. }
  64092. }
  64093. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64094. import { Nullable } from "babylonjs/types";
  64095. import { Scene } from "babylonjs/scene";
  64096. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64097. import { Mesh } from "babylonjs/Meshes/mesh";
  64098. /**
  64099. * Class containing static functions to help procedurally build meshes
  64100. */
  64101. export class TubeBuilder {
  64102. /**
  64103. * Creates a tube mesh.
  64104. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64105. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64106. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64107. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64108. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64109. * * 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)
  64110. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64111. * * 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
  64112. * * 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
  64113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64115. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64117. * @param name defines the name of the mesh
  64118. * @param options defines the options used to create the mesh
  64119. * @param scene defines the hosting scene
  64120. * @returns the tube mesh
  64121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64122. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64123. */
  64124. static CreateTube(name: string, options: {
  64125. path: Vector3[];
  64126. radius?: number;
  64127. tessellation?: number;
  64128. radiusFunction?: {
  64129. (i: number, distance: number): number;
  64130. };
  64131. cap?: number;
  64132. arc?: number;
  64133. updatable?: boolean;
  64134. sideOrientation?: number;
  64135. frontUVs?: Vector4;
  64136. backUVs?: Vector4;
  64137. instance?: Mesh;
  64138. invertUV?: boolean;
  64139. }, scene?: Nullable<Scene>): Mesh;
  64140. }
  64141. }
  64142. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64143. import { Scene } from "babylonjs/scene";
  64144. import { Vector4 } from "babylonjs/Maths/math.vector";
  64145. import { Mesh } from "babylonjs/Meshes/mesh";
  64146. import { Nullable } from "babylonjs/types";
  64147. /**
  64148. * Class containing static functions to help procedurally build meshes
  64149. */
  64150. export class IcoSphereBuilder {
  64151. /**
  64152. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64153. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64154. * * 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`)
  64155. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64156. * * 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
  64157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64160. * @param name defines the name of the mesh
  64161. * @param options defines the options used to create the mesh
  64162. * @param scene defines the hosting scene
  64163. * @returns the icosahedron mesh
  64164. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64165. */
  64166. static CreateIcoSphere(name: string, options: {
  64167. radius?: number;
  64168. radiusX?: number;
  64169. radiusY?: number;
  64170. radiusZ?: number;
  64171. flat?: boolean;
  64172. subdivisions?: number;
  64173. sideOrientation?: number;
  64174. frontUVs?: Vector4;
  64175. backUVs?: Vector4;
  64176. updatable?: boolean;
  64177. }, scene?: Nullable<Scene>): Mesh;
  64178. }
  64179. }
  64180. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64181. import { Vector3 } from "babylonjs/Maths/math.vector";
  64182. import { Mesh } from "babylonjs/Meshes/mesh";
  64183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64184. /**
  64185. * Class containing static functions to help procedurally build meshes
  64186. */
  64187. export class DecalBuilder {
  64188. /**
  64189. * Creates a decal mesh.
  64190. * 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
  64191. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64192. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64193. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64194. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64195. * @param name defines the name of the mesh
  64196. * @param sourceMesh defines the mesh where the decal must be applied
  64197. * @param options defines the options used to create the mesh
  64198. * @param scene defines the hosting scene
  64199. * @returns the decal mesh
  64200. * @see https://doc.babylonjs.com/how_to/decals
  64201. */
  64202. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64203. position?: Vector3;
  64204. normal?: Vector3;
  64205. size?: Vector3;
  64206. angle?: number;
  64207. }): Mesh;
  64208. }
  64209. }
  64210. declare module "babylonjs/Meshes/meshBuilder" {
  64211. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64212. import { Nullable } from "babylonjs/types";
  64213. import { Scene } from "babylonjs/scene";
  64214. import { Mesh } from "babylonjs/Meshes/mesh";
  64215. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64216. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64218. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64219. import { Plane } from "babylonjs/Maths/math.plane";
  64220. /**
  64221. * Class containing static functions to help procedurally build meshes
  64222. */
  64223. export class MeshBuilder {
  64224. /**
  64225. * Creates a box mesh
  64226. * * The parameter `size` sets the size (float) of each box side (default 1)
  64227. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64228. * * 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)
  64229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64233. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64234. * @param name defines the name of the mesh
  64235. * @param options defines the options used to create the mesh
  64236. * @param scene defines the hosting scene
  64237. * @returns the box mesh
  64238. */
  64239. static CreateBox(name: string, options: {
  64240. size?: number;
  64241. width?: number;
  64242. height?: number;
  64243. depth?: number;
  64244. faceUV?: Vector4[];
  64245. faceColors?: Color4[];
  64246. sideOrientation?: number;
  64247. frontUVs?: Vector4;
  64248. backUVs?: Vector4;
  64249. updatable?: boolean;
  64250. }, scene?: Nullable<Scene>): Mesh;
  64251. /**
  64252. * Creates a tiled box mesh
  64253. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64255. * @param name defines the name of the mesh
  64256. * @param options defines the options used to create the mesh
  64257. * @param scene defines the hosting scene
  64258. * @returns the tiled box mesh
  64259. */
  64260. static CreateTiledBox(name: string, options: {
  64261. pattern?: number;
  64262. size?: number;
  64263. width?: number;
  64264. height?: number;
  64265. depth: number;
  64266. tileSize?: number;
  64267. tileWidth?: number;
  64268. tileHeight?: number;
  64269. faceUV?: Vector4[];
  64270. faceColors?: Color4[];
  64271. alignHorizontal?: number;
  64272. alignVertical?: number;
  64273. sideOrientation?: number;
  64274. updatable?: boolean;
  64275. }, scene?: Nullable<Scene>): Mesh;
  64276. /**
  64277. * Creates a sphere mesh
  64278. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64279. * * 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`)
  64280. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64281. * * 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
  64282. * * 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)
  64283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64286. * @param name defines the name of the mesh
  64287. * @param options defines the options used to create the mesh
  64288. * @param scene defines the hosting scene
  64289. * @returns the sphere mesh
  64290. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64291. */
  64292. static CreateSphere(name: string, options: {
  64293. segments?: number;
  64294. diameter?: number;
  64295. diameterX?: number;
  64296. diameterY?: number;
  64297. diameterZ?: number;
  64298. arc?: number;
  64299. slice?: number;
  64300. sideOrientation?: number;
  64301. frontUVs?: Vector4;
  64302. backUVs?: Vector4;
  64303. updatable?: boolean;
  64304. }, scene?: Nullable<Scene>): Mesh;
  64305. /**
  64306. * Creates a plane polygonal mesh. By default, this is a disc
  64307. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64308. * * 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
  64309. * * 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
  64310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64313. * @param name defines the name of the mesh
  64314. * @param options defines the options used to create the mesh
  64315. * @param scene defines the hosting scene
  64316. * @returns the plane polygonal mesh
  64317. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64318. */
  64319. static CreateDisc(name: string, options: {
  64320. radius?: number;
  64321. tessellation?: number;
  64322. arc?: number;
  64323. updatable?: boolean;
  64324. sideOrientation?: number;
  64325. frontUVs?: Vector4;
  64326. backUVs?: Vector4;
  64327. }, scene?: Nullable<Scene>): Mesh;
  64328. /**
  64329. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64330. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64331. * * 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`)
  64332. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64333. * * 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
  64334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64337. * @param name defines the name of the mesh
  64338. * @param options defines the options used to create the mesh
  64339. * @param scene defines the hosting scene
  64340. * @returns the icosahedron mesh
  64341. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64342. */
  64343. static CreateIcoSphere(name: string, options: {
  64344. radius?: number;
  64345. radiusX?: number;
  64346. radiusY?: number;
  64347. radiusZ?: number;
  64348. flat?: boolean;
  64349. subdivisions?: number;
  64350. sideOrientation?: number;
  64351. frontUVs?: Vector4;
  64352. backUVs?: Vector4;
  64353. updatable?: boolean;
  64354. }, scene?: Nullable<Scene>): Mesh;
  64355. /**
  64356. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64357. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64358. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64359. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64360. * * 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
  64361. * * 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
  64362. * * 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
  64363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64365. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64366. * * 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
  64367. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64368. * * 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
  64369. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64371. * @param name defines the name of the mesh
  64372. * @param options defines the options used to create the mesh
  64373. * @param scene defines the hosting scene
  64374. * @returns the ribbon mesh
  64375. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64376. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64377. */
  64378. static CreateRibbon(name: string, options: {
  64379. pathArray: Vector3[][];
  64380. closeArray?: boolean;
  64381. closePath?: boolean;
  64382. offset?: number;
  64383. updatable?: boolean;
  64384. sideOrientation?: number;
  64385. frontUVs?: Vector4;
  64386. backUVs?: Vector4;
  64387. instance?: Mesh;
  64388. invertUV?: boolean;
  64389. uvs?: Vector2[];
  64390. colors?: Color4[];
  64391. }, scene?: Nullable<Scene>): Mesh;
  64392. /**
  64393. * Creates a cylinder or a cone mesh
  64394. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64395. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64396. * * 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.
  64397. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64398. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64399. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64400. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64401. * * 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).
  64402. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64403. * * 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).
  64404. * * 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
  64405. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64406. * * 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
  64407. * * 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.
  64408. * * If `enclose` is false, a ring surface is one element.
  64409. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64410. * * 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
  64411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64414. * @param name defines the name of the mesh
  64415. * @param options defines the options used to create the mesh
  64416. * @param scene defines the hosting scene
  64417. * @returns the cylinder mesh
  64418. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64419. */
  64420. static CreateCylinder(name: string, options: {
  64421. height?: number;
  64422. diameterTop?: number;
  64423. diameterBottom?: number;
  64424. diameter?: number;
  64425. tessellation?: number;
  64426. subdivisions?: number;
  64427. arc?: number;
  64428. faceColors?: Color4[];
  64429. faceUV?: Vector4[];
  64430. updatable?: boolean;
  64431. hasRings?: boolean;
  64432. enclose?: boolean;
  64433. cap?: number;
  64434. sideOrientation?: number;
  64435. frontUVs?: Vector4;
  64436. backUVs?: Vector4;
  64437. }, scene?: Nullable<Scene>): Mesh;
  64438. /**
  64439. * Creates a torus mesh
  64440. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64441. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64442. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64446. * @param name defines the name of the mesh
  64447. * @param options defines the options used to create the mesh
  64448. * @param scene defines the hosting scene
  64449. * @returns the torus mesh
  64450. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64451. */
  64452. static CreateTorus(name: string, options: {
  64453. diameter?: number;
  64454. thickness?: number;
  64455. tessellation?: number;
  64456. updatable?: boolean;
  64457. sideOrientation?: number;
  64458. frontUVs?: Vector4;
  64459. backUVs?: Vector4;
  64460. }, scene?: Nullable<Scene>): Mesh;
  64461. /**
  64462. * Creates a torus knot mesh
  64463. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64464. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64465. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64466. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64470. * @param name defines the name of the mesh
  64471. * @param options defines the options used to create the mesh
  64472. * @param scene defines the hosting scene
  64473. * @returns the torus knot mesh
  64474. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64475. */
  64476. static CreateTorusKnot(name: string, options: {
  64477. radius?: number;
  64478. tube?: number;
  64479. radialSegments?: number;
  64480. tubularSegments?: number;
  64481. p?: number;
  64482. q?: number;
  64483. updatable?: boolean;
  64484. sideOrientation?: number;
  64485. frontUVs?: Vector4;
  64486. backUVs?: Vector4;
  64487. }, scene?: Nullable<Scene>): Mesh;
  64488. /**
  64489. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64490. * * 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
  64491. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64492. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64493. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64494. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64495. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64496. * * 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
  64497. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64500. * @param name defines the name of the new line system
  64501. * @param options defines the options used to create the line system
  64502. * @param scene defines the hosting scene
  64503. * @returns a new line system mesh
  64504. */
  64505. static CreateLineSystem(name: string, options: {
  64506. lines: Vector3[][];
  64507. updatable?: boolean;
  64508. instance?: Nullable<LinesMesh>;
  64509. colors?: Nullable<Color4[][]>;
  64510. useVertexAlpha?: boolean;
  64511. }, scene: Nullable<Scene>): LinesMesh;
  64512. /**
  64513. * Creates a line mesh
  64514. * 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
  64515. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64516. * * The parameter `points` is an array successive Vector3
  64517. * * 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
  64518. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64519. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64520. * * When updating an instance, remember that only point positions can change, not the number of points
  64521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64523. * @param name defines the name of the new line system
  64524. * @param options defines the options used to create the line system
  64525. * @param scene defines the hosting scene
  64526. * @returns a new line mesh
  64527. */
  64528. static CreateLines(name: string, options: {
  64529. points: Vector3[];
  64530. updatable?: boolean;
  64531. instance?: Nullable<LinesMesh>;
  64532. colors?: Color4[];
  64533. useVertexAlpha?: boolean;
  64534. }, scene?: Nullable<Scene>): LinesMesh;
  64535. /**
  64536. * Creates a dashed line mesh
  64537. * * 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
  64538. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64539. * * The parameter `points` is an array successive Vector3
  64540. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64541. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64542. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64543. * * 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
  64544. * * When updating an instance, remember that only point positions can change, not the number of points
  64545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64546. * @param name defines the name of the mesh
  64547. * @param options defines the options used to create the mesh
  64548. * @param scene defines the hosting scene
  64549. * @returns the dashed line mesh
  64550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64551. */
  64552. static CreateDashedLines(name: string, options: {
  64553. points: Vector3[];
  64554. dashSize?: number;
  64555. gapSize?: number;
  64556. dashNb?: number;
  64557. updatable?: boolean;
  64558. instance?: LinesMesh;
  64559. }, scene?: Nullable<Scene>): LinesMesh;
  64560. /**
  64561. * 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.
  64562. * * 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.
  64563. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64564. * * 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.
  64565. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64566. * * 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
  64567. * * 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
  64568. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64571. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64573. * @param name defines the name of the mesh
  64574. * @param options defines the options used to create the mesh
  64575. * @param scene defines the hosting scene
  64576. * @returns the extruded shape mesh
  64577. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64578. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64579. */
  64580. static ExtrudeShape(name: string, options: {
  64581. shape: Vector3[];
  64582. path: Vector3[];
  64583. scale?: number;
  64584. rotation?: number;
  64585. cap?: number;
  64586. updatable?: boolean;
  64587. sideOrientation?: number;
  64588. frontUVs?: Vector4;
  64589. backUVs?: Vector4;
  64590. instance?: Mesh;
  64591. invertUV?: boolean;
  64592. }, scene?: Nullable<Scene>): Mesh;
  64593. /**
  64594. * Creates an custom extruded shape mesh.
  64595. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64596. * * 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.
  64597. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64598. * * 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
  64599. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64600. * * 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
  64601. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64602. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64603. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64604. * * 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
  64605. * * 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
  64606. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64611. * @param name defines the name of the mesh
  64612. * @param options defines the options used to create the mesh
  64613. * @param scene defines the hosting scene
  64614. * @returns the custom extruded shape mesh
  64615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64616. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64618. */
  64619. static ExtrudeShapeCustom(name: string, options: {
  64620. shape: Vector3[];
  64621. path: Vector3[];
  64622. scaleFunction?: any;
  64623. rotationFunction?: any;
  64624. ribbonCloseArray?: boolean;
  64625. ribbonClosePath?: boolean;
  64626. cap?: number;
  64627. updatable?: boolean;
  64628. sideOrientation?: number;
  64629. frontUVs?: Vector4;
  64630. backUVs?: Vector4;
  64631. instance?: Mesh;
  64632. invertUV?: boolean;
  64633. }, scene?: Nullable<Scene>): Mesh;
  64634. /**
  64635. * Creates lathe mesh.
  64636. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64637. * * 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
  64638. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64639. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64640. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64641. * * 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
  64642. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64643. * * 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
  64644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64648. * @param name defines the name of the mesh
  64649. * @param options defines the options used to create the mesh
  64650. * @param scene defines the hosting scene
  64651. * @returns the lathe mesh
  64652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64653. */
  64654. static CreateLathe(name: string, options: {
  64655. shape: Vector3[];
  64656. radius?: number;
  64657. tessellation?: number;
  64658. clip?: number;
  64659. arc?: number;
  64660. closed?: boolean;
  64661. updatable?: boolean;
  64662. sideOrientation?: number;
  64663. frontUVs?: Vector4;
  64664. backUVs?: Vector4;
  64665. cap?: number;
  64666. invertUV?: boolean;
  64667. }, scene?: Nullable<Scene>): Mesh;
  64668. /**
  64669. * Creates a tiled plane mesh
  64670. * * You can set a limited pattern arrangement with the tiles
  64671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64674. * @param name defines the name of the mesh
  64675. * @param options defines the options used to create the mesh
  64676. * @param scene defines the hosting scene
  64677. * @returns the plane mesh
  64678. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64679. */
  64680. static CreateTiledPlane(name: string, options: {
  64681. pattern?: number;
  64682. tileSize?: number;
  64683. tileWidth?: number;
  64684. tileHeight?: number;
  64685. size?: number;
  64686. width?: number;
  64687. height?: number;
  64688. alignHorizontal?: number;
  64689. alignVertical?: number;
  64690. sideOrientation?: number;
  64691. frontUVs?: Vector4;
  64692. backUVs?: Vector4;
  64693. updatable?: boolean;
  64694. }, scene?: Nullable<Scene>): Mesh;
  64695. /**
  64696. * Creates a plane mesh
  64697. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64698. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64699. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64703. * @param name defines the name of the mesh
  64704. * @param options defines the options used to create the mesh
  64705. * @param scene defines the hosting scene
  64706. * @returns the plane mesh
  64707. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64708. */
  64709. static CreatePlane(name: string, options: {
  64710. size?: number;
  64711. width?: number;
  64712. height?: number;
  64713. sideOrientation?: number;
  64714. frontUVs?: Vector4;
  64715. backUVs?: Vector4;
  64716. updatable?: boolean;
  64717. sourcePlane?: Plane;
  64718. }, scene?: Nullable<Scene>): Mesh;
  64719. /**
  64720. * Creates a ground mesh
  64721. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64722. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64724. * @param name defines the name of the mesh
  64725. * @param options defines the options used to create the mesh
  64726. * @param scene defines the hosting scene
  64727. * @returns the ground mesh
  64728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64729. */
  64730. static CreateGround(name: string, options: {
  64731. width?: number;
  64732. height?: number;
  64733. subdivisions?: number;
  64734. subdivisionsX?: number;
  64735. subdivisionsY?: number;
  64736. updatable?: boolean;
  64737. }, scene?: Nullable<Scene>): Mesh;
  64738. /**
  64739. * Creates a tiled ground mesh
  64740. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64741. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64742. * * 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
  64743. * * 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
  64744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64745. * @param name defines the name of the mesh
  64746. * @param options defines the options used to create the mesh
  64747. * @param scene defines the hosting scene
  64748. * @returns the tiled ground mesh
  64749. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64750. */
  64751. static CreateTiledGround(name: string, options: {
  64752. xmin: number;
  64753. zmin: number;
  64754. xmax: number;
  64755. zmax: number;
  64756. subdivisions?: {
  64757. w: number;
  64758. h: number;
  64759. };
  64760. precision?: {
  64761. w: number;
  64762. h: number;
  64763. };
  64764. updatable?: boolean;
  64765. }, scene?: Nullable<Scene>): Mesh;
  64766. /**
  64767. * Creates a ground mesh from a height map
  64768. * * The parameter `url` sets the URL of the height map image resource.
  64769. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64770. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64771. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64772. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64773. * * 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.
  64774. * * 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).
  64775. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64777. * @param name defines the name of the mesh
  64778. * @param url defines the url to the height map
  64779. * @param options defines the options used to create the mesh
  64780. * @param scene defines the hosting scene
  64781. * @returns the ground mesh
  64782. * @see https://doc.babylonjs.com/babylon101/height_map
  64783. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64784. */
  64785. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64786. width?: number;
  64787. height?: number;
  64788. subdivisions?: number;
  64789. minHeight?: number;
  64790. maxHeight?: number;
  64791. colorFilter?: Color3;
  64792. alphaFilter?: number;
  64793. updatable?: boolean;
  64794. onReady?: (mesh: GroundMesh) => void;
  64795. }, scene?: Nullable<Scene>): GroundMesh;
  64796. /**
  64797. * Creates a polygon mesh
  64798. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64799. * * 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
  64800. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64803. * * Remember you can only change the shape positions, not their number when updating a polygon
  64804. * @param name defines the name of the mesh
  64805. * @param options defines the options used to create the mesh
  64806. * @param scene defines the hosting scene
  64807. * @param earcutInjection can be used to inject your own earcut reference
  64808. * @returns the polygon mesh
  64809. */
  64810. static CreatePolygon(name: string, options: {
  64811. shape: Vector3[];
  64812. holes?: Vector3[][];
  64813. depth?: number;
  64814. faceUV?: Vector4[];
  64815. faceColors?: Color4[];
  64816. updatable?: boolean;
  64817. sideOrientation?: number;
  64818. frontUVs?: Vector4;
  64819. backUVs?: Vector4;
  64820. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64821. /**
  64822. * Creates an extruded polygon mesh, with depth in the Y direction.
  64823. * * 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)
  64824. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64825. * @param name defines the name of the mesh
  64826. * @param options defines the options used to create the mesh
  64827. * @param scene defines the hosting scene
  64828. * @param earcutInjection can be used to inject your own earcut reference
  64829. * @returns the polygon mesh
  64830. */
  64831. static ExtrudePolygon(name: string, options: {
  64832. shape: Vector3[];
  64833. holes?: Vector3[][];
  64834. depth?: number;
  64835. faceUV?: Vector4[];
  64836. faceColors?: Color4[];
  64837. updatable?: boolean;
  64838. sideOrientation?: number;
  64839. frontUVs?: Vector4;
  64840. backUVs?: Vector4;
  64841. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64842. /**
  64843. * Creates a tube mesh.
  64844. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64845. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64846. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64847. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64848. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64849. * * 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)
  64850. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64851. * * 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
  64852. * * 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
  64853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64855. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64857. * @param name defines the name of the mesh
  64858. * @param options defines the options used to create the mesh
  64859. * @param scene defines the hosting scene
  64860. * @returns the tube mesh
  64861. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64862. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64863. */
  64864. static CreateTube(name: string, options: {
  64865. path: Vector3[];
  64866. radius?: number;
  64867. tessellation?: number;
  64868. radiusFunction?: {
  64869. (i: number, distance: number): number;
  64870. };
  64871. cap?: number;
  64872. arc?: number;
  64873. updatable?: boolean;
  64874. sideOrientation?: number;
  64875. frontUVs?: Vector4;
  64876. backUVs?: Vector4;
  64877. instance?: Mesh;
  64878. invertUV?: boolean;
  64879. }, scene?: Nullable<Scene>): Mesh;
  64880. /**
  64881. * Creates a polyhedron mesh
  64882. * * 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
  64883. * * The parameter `size` (positive float, default 1) sets the polygon size
  64884. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64885. * * 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`
  64886. * * 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
  64887. * * 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)`)
  64888. * * 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
  64889. * * 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
  64890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64893. * @param name defines the name of the mesh
  64894. * @param options defines the options used to create the mesh
  64895. * @param scene defines the hosting scene
  64896. * @returns the polyhedron mesh
  64897. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64898. */
  64899. static CreatePolyhedron(name: string, options: {
  64900. type?: number;
  64901. size?: number;
  64902. sizeX?: number;
  64903. sizeY?: number;
  64904. sizeZ?: number;
  64905. custom?: any;
  64906. faceUV?: Vector4[];
  64907. faceColors?: Color4[];
  64908. flat?: boolean;
  64909. updatable?: boolean;
  64910. sideOrientation?: number;
  64911. frontUVs?: Vector4;
  64912. backUVs?: Vector4;
  64913. }, scene?: Nullable<Scene>): Mesh;
  64914. /**
  64915. * Creates a decal mesh.
  64916. * 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
  64917. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64918. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64919. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64920. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64921. * @param name defines the name of the mesh
  64922. * @param sourceMesh defines the mesh where the decal must be applied
  64923. * @param options defines the options used to create the mesh
  64924. * @param scene defines the hosting scene
  64925. * @returns the decal mesh
  64926. * @see https://doc.babylonjs.com/how_to/decals
  64927. */
  64928. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64929. position?: Vector3;
  64930. normal?: Vector3;
  64931. size?: Vector3;
  64932. angle?: number;
  64933. }): Mesh;
  64934. }
  64935. }
  64936. declare module "babylonjs/Meshes/meshSimplification" {
  64937. import { Mesh } from "babylonjs/Meshes/mesh";
  64938. /**
  64939. * A simplifier interface for future simplification implementations
  64940. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64941. */
  64942. export interface ISimplifier {
  64943. /**
  64944. * Simplification of a given mesh according to the given settings.
  64945. * Since this requires computation, it is assumed that the function runs async.
  64946. * @param settings The settings of the simplification, including quality and distance
  64947. * @param successCallback A callback that will be called after the mesh was simplified.
  64948. * @param errorCallback in case of an error, this callback will be called. optional.
  64949. */
  64950. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64951. }
  64952. /**
  64953. * Expected simplification settings.
  64954. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64955. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64956. */
  64957. export interface ISimplificationSettings {
  64958. /**
  64959. * Gets or sets the expected quality
  64960. */
  64961. quality: number;
  64962. /**
  64963. * Gets or sets the distance when this optimized version should be used
  64964. */
  64965. distance: number;
  64966. /**
  64967. * Gets an already optimized mesh
  64968. */
  64969. optimizeMesh?: boolean;
  64970. }
  64971. /**
  64972. * Class used to specify simplification options
  64973. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64974. */
  64975. export class SimplificationSettings implements ISimplificationSettings {
  64976. /** expected quality */
  64977. quality: number;
  64978. /** distance when this optimized version should be used */
  64979. distance: number;
  64980. /** already optimized mesh */
  64981. optimizeMesh?: boolean | undefined;
  64982. /**
  64983. * Creates a SimplificationSettings
  64984. * @param quality expected quality
  64985. * @param distance distance when this optimized version should be used
  64986. * @param optimizeMesh already optimized mesh
  64987. */
  64988. constructor(
  64989. /** expected quality */
  64990. quality: number,
  64991. /** distance when this optimized version should be used */
  64992. distance: number,
  64993. /** already optimized mesh */
  64994. optimizeMesh?: boolean | undefined);
  64995. }
  64996. /**
  64997. * Interface used to define a simplification task
  64998. */
  64999. export interface ISimplificationTask {
  65000. /**
  65001. * Array of settings
  65002. */
  65003. settings: Array<ISimplificationSettings>;
  65004. /**
  65005. * Simplification type
  65006. */
  65007. simplificationType: SimplificationType;
  65008. /**
  65009. * Mesh to simplify
  65010. */
  65011. mesh: Mesh;
  65012. /**
  65013. * Callback called on success
  65014. */
  65015. successCallback?: () => void;
  65016. /**
  65017. * Defines if parallel processing can be used
  65018. */
  65019. parallelProcessing: boolean;
  65020. }
  65021. /**
  65022. * Queue used to order the simplification tasks
  65023. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65024. */
  65025. export class SimplificationQueue {
  65026. private _simplificationArray;
  65027. /**
  65028. * Gets a boolean indicating that the process is still running
  65029. */
  65030. running: boolean;
  65031. /**
  65032. * Creates a new queue
  65033. */
  65034. constructor();
  65035. /**
  65036. * Adds a new simplification task
  65037. * @param task defines a task to add
  65038. */
  65039. addTask(task: ISimplificationTask): void;
  65040. /**
  65041. * Execute next task
  65042. */
  65043. executeNext(): void;
  65044. /**
  65045. * Execute a simplification task
  65046. * @param task defines the task to run
  65047. */
  65048. runSimplification(task: ISimplificationTask): void;
  65049. private getSimplifier;
  65050. }
  65051. /**
  65052. * The implemented types of simplification
  65053. * At the moment only Quadratic Error Decimation is implemented
  65054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65055. */
  65056. export enum SimplificationType {
  65057. /** Quadratic error decimation */
  65058. QUADRATIC = 0
  65059. }
  65060. }
  65061. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65062. import { Scene } from "babylonjs/scene";
  65063. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65064. import { ISceneComponent } from "babylonjs/sceneComponent";
  65065. module "babylonjs/scene" {
  65066. interface Scene {
  65067. /** @hidden (Backing field) */
  65068. _simplificationQueue: SimplificationQueue;
  65069. /**
  65070. * Gets or sets the simplification queue attached to the scene
  65071. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65072. */
  65073. simplificationQueue: SimplificationQueue;
  65074. }
  65075. }
  65076. module "babylonjs/Meshes/mesh" {
  65077. interface Mesh {
  65078. /**
  65079. * Simplify the mesh according to the given array of settings.
  65080. * Function will return immediately and will simplify async
  65081. * @param settings a collection of simplification settings
  65082. * @param parallelProcessing should all levels calculate parallel or one after the other
  65083. * @param simplificationType the type of simplification to run
  65084. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65085. * @returns the current mesh
  65086. */
  65087. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65088. }
  65089. }
  65090. /**
  65091. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65092. * created in a scene
  65093. */
  65094. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65095. /**
  65096. * The component name helpfull to identify the component in the list of scene components.
  65097. */
  65098. readonly name: string;
  65099. /**
  65100. * The scene the component belongs to.
  65101. */
  65102. scene: Scene;
  65103. /**
  65104. * Creates a new instance of the component for the given scene
  65105. * @param scene Defines the scene to register the component in
  65106. */
  65107. constructor(scene: Scene);
  65108. /**
  65109. * Registers the component in a given scene
  65110. */
  65111. register(): void;
  65112. /**
  65113. * Rebuilds the elements related to this component in case of
  65114. * context lost for instance.
  65115. */
  65116. rebuild(): void;
  65117. /**
  65118. * Disposes the component and the associated ressources
  65119. */
  65120. dispose(): void;
  65121. private _beforeCameraUpdate;
  65122. }
  65123. }
  65124. declare module "babylonjs/Meshes/Builders/index" {
  65125. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65126. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65127. export * from "babylonjs/Meshes/Builders/discBuilder";
  65128. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65129. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65130. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65131. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65132. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65133. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65134. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65135. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65136. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65137. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65138. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65139. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65140. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65141. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65142. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65143. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65144. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65145. }
  65146. declare module "babylonjs/Meshes/index" {
  65147. export * from "babylonjs/Meshes/abstractMesh";
  65148. export * from "babylonjs/Meshes/buffer";
  65149. export * from "babylonjs/Meshes/Compression/index";
  65150. export * from "babylonjs/Meshes/csg";
  65151. export * from "babylonjs/Meshes/geometry";
  65152. export * from "babylonjs/Meshes/groundMesh";
  65153. export * from "babylonjs/Meshes/trailMesh";
  65154. export * from "babylonjs/Meshes/instancedMesh";
  65155. export * from "babylonjs/Meshes/linesMesh";
  65156. export * from "babylonjs/Meshes/mesh";
  65157. export * from "babylonjs/Meshes/mesh.vertexData";
  65158. export * from "babylonjs/Meshes/meshBuilder";
  65159. export * from "babylonjs/Meshes/meshSimplification";
  65160. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65161. export * from "babylonjs/Meshes/polygonMesh";
  65162. export * from "babylonjs/Meshes/subMesh";
  65163. export * from "babylonjs/Meshes/meshLODLevel";
  65164. export * from "babylonjs/Meshes/transformNode";
  65165. export * from "babylonjs/Meshes/Builders/index";
  65166. export * from "babylonjs/Meshes/dataBuffer";
  65167. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65168. }
  65169. declare module "babylonjs/Morph/index" {
  65170. export * from "babylonjs/Morph/morphTarget";
  65171. export * from "babylonjs/Morph/morphTargetManager";
  65172. }
  65173. declare module "babylonjs/Navigation/INavigationEngine" {
  65174. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65175. import { Vector3 } from "babylonjs/Maths/math";
  65176. import { Mesh } from "babylonjs/Meshes/mesh";
  65177. import { Scene } from "babylonjs/scene";
  65178. /**
  65179. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65180. */
  65181. export interface INavigationEnginePlugin {
  65182. /**
  65183. * plugin name
  65184. */
  65185. name: string;
  65186. /**
  65187. * Creates a navigation mesh
  65188. * @param meshes array of all the geometry used to compute the navigatio mesh
  65189. * @param parameters bunch of parameters used to filter geometry
  65190. */
  65191. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65192. /**
  65193. * Create a navigation mesh debug mesh
  65194. * @param scene is where the mesh will be added
  65195. * @returns debug display mesh
  65196. */
  65197. createDebugNavMesh(scene: Scene): Mesh;
  65198. /**
  65199. * Get a navigation mesh constrained position, closest to the parameter position
  65200. * @param position world position
  65201. * @returns the closest point to position constrained by the navigation mesh
  65202. */
  65203. getClosestPoint(position: Vector3): Vector3;
  65204. /**
  65205. * Get a navigation mesh constrained position, within a particular radius
  65206. * @param position world position
  65207. * @param maxRadius the maximum distance to the constrained world position
  65208. * @returns the closest point to position constrained by the navigation mesh
  65209. */
  65210. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65211. /**
  65212. * Compute the final position from a segment made of destination-position
  65213. * @param position world position
  65214. * @param destination world position
  65215. * @returns the resulting point along the navmesh
  65216. */
  65217. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65218. /**
  65219. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65220. * @param start world position
  65221. * @param end world position
  65222. * @returns array containing world position composing the path
  65223. */
  65224. computePath(start: Vector3, end: Vector3): Vector3[];
  65225. /**
  65226. * If this plugin is supported
  65227. * @returns true if plugin is supported
  65228. */
  65229. isSupported(): boolean;
  65230. /**
  65231. * Create a new Crowd so you can add agents
  65232. * @param maxAgents the maximum agent count in the crowd
  65233. * @param maxAgentRadius the maximum radius an agent can have
  65234. * @param scene to attach the crowd to
  65235. * @returns the crowd you can add agents to
  65236. */
  65237. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65238. /**
  65239. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65240. * The queries will try to find a solution within those bounds
  65241. * default is (1,1,1)
  65242. * @param extent x,y,z value that define the extent around the queries point of reference
  65243. */
  65244. setDefaultQueryExtent(extent: Vector3): void;
  65245. /**
  65246. * Get the Bounding box extent specified by setDefaultQueryExtent
  65247. * @returns the box extent values
  65248. */
  65249. getDefaultQueryExtent(): Vector3;
  65250. /**
  65251. * Release all resources
  65252. */
  65253. dispose(): void;
  65254. }
  65255. /**
  65256. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65257. */
  65258. export interface ICrowd {
  65259. /**
  65260. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65261. * You can attach anything to that node. The node position is updated in the scene update tick.
  65262. * @param pos world position that will be constrained by the navigation mesh
  65263. * @param parameters agent parameters
  65264. * @param transform hooked to the agent that will be update by the scene
  65265. * @returns agent index
  65266. */
  65267. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65268. /**
  65269. * Returns the agent position in world space
  65270. * @param index agent index returned by addAgent
  65271. * @returns world space position
  65272. */
  65273. getAgentPosition(index: number): Vector3;
  65274. /**
  65275. * Gets the agent velocity in world space
  65276. * @param index agent index returned by addAgent
  65277. * @returns world space velocity
  65278. */
  65279. getAgentVelocity(index: number): Vector3;
  65280. /**
  65281. * remove a particular agent previously created
  65282. * @param index agent index returned by addAgent
  65283. */
  65284. removeAgent(index: number): void;
  65285. /**
  65286. * get the list of all agents attached to this crowd
  65287. * @returns list of agent indices
  65288. */
  65289. getAgents(): number[];
  65290. /**
  65291. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65292. * @param deltaTime in seconds
  65293. */
  65294. update(deltaTime: number): void;
  65295. /**
  65296. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65297. * @param index agent index returned by addAgent
  65298. * @param destination targeted world position
  65299. */
  65300. agentGoto(index: number, destination: Vector3): void;
  65301. /**
  65302. * Teleport the agent to a new position
  65303. * @param index agent index returned by addAgent
  65304. * @param destination targeted world position
  65305. */
  65306. agentTeleport(index: number, destination: Vector3): void;
  65307. /**
  65308. * Update agent parameters
  65309. * @param index agent index returned by addAgent
  65310. * @param parameters agent parameters
  65311. */
  65312. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65313. /**
  65314. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65315. * The queries will try to find a solution within those bounds
  65316. * default is (1,1,1)
  65317. * @param extent x,y,z value that define the extent around the queries point of reference
  65318. */
  65319. setDefaultQueryExtent(extent: Vector3): void;
  65320. /**
  65321. * Get the Bounding box extent specified by setDefaultQueryExtent
  65322. * @returns the box extent values
  65323. */
  65324. getDefaultQueryExtent(): Vector3;
  65325. /**
  65326. * Release all resources
  65327. */
  65328. dispose(): void;
  65329. }
  65330. /**
  65331. * Configures an agent
  65332. */
  65333. export interface IAgentParameters {
  65334. /**
  65335. * Agent radius. [Limit: >= 0]
  65336. */
  65337. radius: number;
  65338. /**
  65339. * Agent height. [Limit: > 0]
  65340. */
  65341. height: number;
  65342. /**
  65343. * Maximum allowed acceleration. [Limit: >= 0]
  65344. */
  65345. maxAcceleration: number;
  65346. /**
  65347. * Maximum allowed speed. [Limit: >= 0]
  65348. */
  65349. maxSpeed: number;
  65350. /**
  65351. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65352. */
  65353. collisionQueryRange: number;
  65354. /**
  65355. * The path visibility optimization range. [Limit: > 0]
  65356. */
  65357. pathOptimizationRange: number;
  65358. /**
  65359. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65360. */
  65361. separationWeight: number;
  65362. }
  65363. /**
  65364. * Configures the navigation mesh creation
  65365. */
  65366. export interface INavMeshParameters {
  65367. /**
  65368. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65369. */
  65370. cs: number;
  65371. /**
  65372. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65373. */
  65374. ch: number;
  65375. /**
  65376. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65377. */
  65378. walkableSlopeAngle: number;
  65379. /**
  65380. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65381. * be considered walkable. [Limit: >= 3] [Units: vx]
  65382. */
  65383. walkableHeight: number;
  65384. /**
  65385. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65386. */
  65387. walkableClimb: number;
  65388. /**
  65389. * The distance to erode/shrink the walkable area of the heightfield away from
  65390. * obstructions. [Limit: >=0] [Units: vx]
  65391. */
  65392. walkableRadius: number;
  65393. /**
  65394. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65395. */
  65396. maxEdgeLen: number;
  65397. /**
  65398. * The maximum distance a simplfied contour's border edges should deviate
  65399. * the original raw contour. [Limit: >=0] [Units: vx]
  65400. */
  65401. maxSimplificationError: number;
  65402. /**
  65403. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65404. */
  65405. minRegionArea: number;
  65406. /**
  65407. * Any regions with a span count smaller than this value will, if possible,
  65408. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65409. */
  65410. mergeRegionArea: number;
  65411. /**
  65412. * The maximum number of vertices allowed for polygons generated during the
  65413. * contour to polygon conversion process. [Limit: >= 3]
  65414. */
  65415. maxVertsPerPoly: number;
  65416. /**
  65417. * Sets the sampling distance to use when generating the detail mesh.
  65418. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65419. */
  65420. detailSampleDist: number;
  65421. /**
  65422. * The maximum distance the detail mesh surface should deviate from heightfield
  65423. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65424. */
  65425. detailSampleMaxError: number;
  65426. }
  65427. }
  65428. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65429. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65430. import { Mesh } from "babylonjs/Meshes/mesh";
  65431. import { Scene } from "babylonjs/scene";
  65432. import { Vector3 } from "babylonjs/Maths/math";
  65433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65434. /**
  65435. * RecastJS navigation plugin
  65436. */
  65437. export class RecastJSPlugin implements INavigationEnginePlugin {
  65438. /**
  65439. * Reference to the Recast library
  65440. */
  65441. bjsRECAST: any;
  65442. /**
  65443. * plugin name
  65444. */
  65445. name: string;
  65446. /**
  65447. * the first navmesh created. We might extend this to support multiple navmeshes
  65448. */
  65449. navMesh: any;
  65450. /**
  65451. * Initializes the recastJS plugin
  65452. * @param recastInjection can be used to inject your own recast reference
  65453. */
  65454. constructor(recastInjection?: any);
  65455. /**
  65456. * Creates a navigation mesh
  65457. * @param meshes array of all the geometry used to compute the navigatio mesh
  65458. * @param parameters bunch of parameters used to filter geometry
  65459. */
  65460. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65461. /**
  65462. * Create a navigation mesh debug mesh
  65463. * @param scene is where the mesh will be added
  65464. * @returns debug display mesh
  65465. */
  65466. createDebugNavMesh(scene: Scene): Mesh;
  65467. /**
  65468. * Get a navigation mesh constrained position, closest to the parameter position
  65469. * @param position world position
  65470. * @returns the closest point to position constrained by the navigation mesh
  65471. */
  65472. getClosestPoint(position: Vector3): Vector3;
  65473. /**
  65474. * Get a navigation mesh constrained position, within a particular radius
  65475. * @param position world position
  65476. * @param maxRadius the maximum distance to the constrained world position
  65477. * @returns the closest point to position constrained by the navigation mesh
  65478. */
  65479. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65480. /**
  65481. * Compute the final position from a segment made of destination-position
  65482. * @param position world position
  65483. * @param destination world position
  65484. * @returns the resulting point along the navmesh
  65485. */
  65486. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65487. /**
  65488. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65489. * @param start world position
  65490. * @param end world position
  65491. * @returns array containing world position composing the path
  65492. */
  65493. computePath(start: Vector3, end: Vector3): Vector3[];
  65494. /**
  65495. * Create a new Crowd so you can add agents
  65496. * @param maxAgents the maximum agent count in the crowd
  65497. * @param maxAgentRadius the maximum radius an agent can have
  65498. * @param scene to attach the crowd to
  65499. * @returns the crowd you can add agents to
  65500. */
  65501. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65502. /**
  65503. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65504. * The queries will try to find a solution within those bounds
  65505. * default is (1,1,1)
  65506. * @param extent x,y,z value that define the extent around the queries point of reference
  65507. */
  65508. setDefaultQueryExtent(extent: Vector3): void;
  65509. /**
  65510. * Get the Bounding box extent specified by setDefaultQueryExtent
  65511. * @returns the box extent values
  65512. */
  65513. getDefaultQueryExtent(): Vector3;
  65514. /**
  65515. * Disposes
  65516. */
  65517. dispose(): void;
  65518. /**
  65519. * If this plugin is supported
  65520. * @returns true if plugin is supported
  65521. */
  65522. isSupported(): boolean;
  65523. }
  65524. /**
  65525. * Recast detour crowd implementation
  65526. */
  65527. export class RecastJSCrowd implements ICrowd {
  65528. /**
  65529. * Recast/detour plugin
  65530. */
  65531. bjsRECASTPlugin: RecastJSPlugin;
  65532. /**
  65533. * Link to the detour crowd
  65534. */
  65535. recastCrowd: any;
  65536. /**
  65537. * One transform per agent
  65538. */
  65539. transforms: TransformNode[];
  65540. /**
  65541. * All agents created
  65542. */
  65543. agents: number[];
  65544. /**
  65545. * Link to the scene is kept to unregister the crowd from the scene
  65546. */
  65547. private _scene;
  65548. /**
  65549. * Observer for crowd updates
  65550. */
  65551. private _onBeforeAnimationsObserver;
  65552. /**
  65553. * Constructor
  65554. * @param plugin recastJS plugin
  65555. * @param maxAgents the maximum agent count in the crowd
  65556. * @param maxAgentRadius the maximum radius an agent can have
  65557. * @param scene to attach the crowd to
  65558. * @returns the crowd you can add agents to
  65559. */
  65560. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65561. /**
  65562. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65563. * You can attach anything to that node. The node position is updated in the scene update tick.
  65564. * @param pos world position that will be constrained by the navigation mesh
  65565. * @param parameters agent parameters
  65566. * @param transform hooked to the agent that will be update by the scene
  65567. * @returns agent index
  65568. */
  65569. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65570. /**
  65571. * Returns the agent position in world space
  65572. * @param index agent index returned by addAgent
  65573. * @returns world space position
  65574. */
  65575. getAgentPosition(index: number): Vector3;
  65576. /**
  65577. * Returns the agent velocity in world space
  65578. * @param index agent index returned by addAgent
  65579. * @returns world space velocity
  65580. */
  65581. getAgentVelocity(index: number): Vector3;
  65582. /**
  65583. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65584. * @param index agent index returned by addAgent
  65585. * @param destination targeted world position
  65586. */
  65587. agentGoto(index: number, destination: Vector3): void;
  65588. /**
  65589. * Teleport the agent to a new position
  65590. * @param index agent index returned by addAgent
  65591. * @param destination targeted world position
  65592. */
  65593. agentTeleport(index: number, destination: Vector3): void;
  65594. /**
  65595. * Update agent parameters
  65596. * @param index agent index returned by addAgent
  65597. * @param parameters agent parameters
  65598. */
  65599. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65600. /**
  65601. * remove a particular agent previously created
  65602. * @param index agent index returned by addAgent
  65603. */
  65604. removeAgent(index: number): void;
  65605. /**
  65606. * get the list of all agents attached to this crowd
  65607. * @returns list of agent indices
  65608. */
  65609. getAgents(): number[];
  65610. /**
  65611. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65612. * @param deltaTime in seconds
  65613. */
  65614. update(deltaTime: number): void;
  65615. /**
  65616. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65617. * The queries will try to find a solution within those bounds
  65618. * default is (1,1,1)
  65619. * @param extent x,y,z value that define the extent around the queries point of reference
  65620. */
  65621. setDefaultQueryExtent(extent: Vector3): void;
  65622. /**
  65623. * Get the Bounding box extent specified by setDefaultQueryExtent
  65624. * @returns the box extent values
  65625. */
  65626. getDefaultQueryExtent(): Vector3;
  65627. /**
  65628. * Release all resources
  65629. */
  65630. dispose(): void;
  65631. }
  65632. }
  65633. declare module "babylonjs/Navigation/Plugins/index" {
  65634. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65635. }
  65636. declare module "babylonjs/Navigation/index" {
  65637. export * from "babylonjs/Navigation/INavigationEngine";
  65638. export * from "babylonjs/Navigation/Plugins/index";
  65639. }
  65640. declare module "babylonjs/Offline/database" {
  65641. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65642. /**
  65643. * Class used to enable access to IndexedDB
  65644. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65645. */
  65646. export class Database implements IOfflineProvider {
  65647. private _callbackManifestChecked;
  65648. private _currentSceneUrl;
  65649. private _db;
  65650. private _enableSceneOffline;
  65651. private _enableTexturesOffline;
  65652. private _manifestVersionFound;
  65653. private _mustUpdateRessources;
  65654. private _hasReachedQuota;
  65655. private _isSupported;
  65656. private _idbFactory;
  65657. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65658. private static IsUASupportingBlobStorage;
  65659. /**
  65660. * Gets a boolean indicating if Database storate is enabled (off by default)
  65661. */
  65662. static IDBStorageEnabled: boolean;
  65663. /**
  65664. * Gets a boolean indicating if scene must be saved in the database
  65665. */
  65666. get enableSceneOffline(): boolean;
  65667. /**
  65668. * Gets a boolean indicating if textures must be saved in the database
  65669. */
  65670. get enableTexturesOffline(): boolean;
  65671. /**
  65672. * Creates a new Database
  65673. * @param urlToScene defines the url to load the scene
  65674. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65675. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65676. */
  65677. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65678. private static _ParseURL;
  65679. private static _ReturnFullUrlLocation;
  65680. private _checkManifestFile;
  65681. /**
  65682. * Open the database and make it available
  65683. * @param successCallback defines the callback to call on success
  65684. * @param errorCallback defines the callback to call on error
  65685. */
  65686. open(successCallback: () => void, errorCallback: () => void): void;
  65687. /**
  65688. * Loads an image from the database
  65689. * @param url defines the url to load from
  65690. * @param image defines the target DOM image
  65691. */
  65692. loadImage(url: string, image: HTMLImageElement): void;
  65693. private _loadImageFromDBAsync;
  65694. private _saveImageIntoDBAsync;
  65695. private _checkVersionFromDB;
  65696. private _loadVersionFromDBAsync;
  65697. private _saveVersionIntoDBAsync;
  65698. /**
  65699. * Loads a file from database
  65700. * @param url defines the URL to load from
  65701. * @param sceneLoaded defines a callback to call on success
  65702. * @param progressCallBack defines a callback to call when progress changed
  65703. * @param errorCallback defines a callback to call on error
  65704. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65705. */
  65706. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65707. private _loadFileAsync;
  65708. private _saveFileAsync;
  65709. /**
  65710. * Validates if xhr data is correct
  65711. * @param xhr defines the request to validate
  65712. * @param dataType defines the expected data type
  65713. * @returns true if data is correct
  65714. */
  65715. private static _ValidateXHRData;
  65716. }
  65717. }
  65718. declare module "babylonjs/Offline/index" {
  65719. export * from "babylonjs/Offline/database";
  65720. export * from "babylonjs/Offline/IOfflineProvider";
  65721. }
  65722. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65723. /** @hidden */
  65724. export var gpuUpdateParticlesPixelShader: {
  65725. name: string;
  65726. shader: string;
  65727. };
  65728. }
  65729. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65730. /** @hidden */
  65731. export var gpuUpdateParticlesVertexShader: {
  65732. name: string;
  65733. shader: string;
  65734. };
  65735. }
  65736. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65737. /** @hidden */
  65738. export var clipPlaneFragmentDeclaration2: {
  65739. name: string;
  65740. shader: string;
  65741. };
  65742. }
  65743. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65744. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65745. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65746. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65747. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65748. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65749. /** @hidden */
  65750. export var gpuRenderParticlesPixelShader: {
  65751. name: string;
  65752. shader: string;
  65753. };
  65754. }
  65755. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65756. /** @hidden */
  65757. export var clipPlaneVertexDeclaration2: {
  65758. name: string;
  65759. shader: string;
  65760. };
  65761. }
  65762. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65763. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65764. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65765. /** @hidden */
  65766. export var gpuRenderParticlesVertexShader: {
  65767. name: string;
  65768. shader: string;
  65769. };
  65770. }
  65771. declare module "babylonjs/Particles/gpuParticleSystem" {
  65772. import { Nullable } from "babylonjs/types";
  65773. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65774. import { Observable } from "babylonjs/Misc/observable";
  65775. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65776. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65777. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65778. import { Scene, IDisposable } from "babylonjs/scene";
  65779. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65780. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65781. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65782. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65783. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65784. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65785. /**
  65786. * This represents a GPU particle system in Babylon
  65787. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65788. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65789. */
  65790. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65791. /**
  65792. * The layer mask we are rendering the particles through.
  65793. */
  65794. layerMask: number;
  65795. private _capacity;
  65796. private _activeCount;
  65797. private _currentActiveCount;
  65798. private _accumulatedCount;
  65799. private _renderEffect;
  65800. private _updateEffect;
  65801. private _buffer0;
  65802. private _buffer1;
  65803. private _spriteBuffer;
  65804. private _updateVAO;
  65805. private _renderVAO;
  65806. private _targetIndex;
  65807. private _sourceBuffer;
  65808. private _targetBuffer;
  65809. private _engine;
  65810. private _currentRenderId;
  65811. private _started;
  65812. private _stopped;
  65813. private _timeDelta;
  65814. private _randomTexture;
  65815. private _randomTexture2;
  65816. private _attributesStrideSize;
  65817. private _updateEffectOptions;
  65818. private _randomTextureSize;
  65819. private _actualFrame;
  65820. private readonly _rawTextureWidth;
  65821. /**
  65822. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65823. */
  65824. static get IsSupported(): boolean;
  65825. /**
  65826. * An event triggered when the system is disposed.
  65827. */
  65828. onDisposeObservable: Observable<GPUParticleSystem>;
  65829. /**
  65830. * Gets the maximum number of particles active at the same time.
  65831. * @returns The max number of active particles.
  65832. */
  65833. getCapacity(): number;
  65834. /**
  65835. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65836. * to override the particles.
  65837. */
  65838. forceDepthWrite: boolean;
  65839. /**
  65840. * Gets or set the number of active particles
  65841. */
  65842. get activeParticleCount(): number;
  65843. set activeParticleCount(value: number);
  65844. private _preWarmDone;
  65845. /**
  65846. * Is this system ready to be used/rendered
  65847. * @return true if the system is ready
  65848. */
  65849. isReady(): boolean;
  65850. /**
  65851. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65852. * @returns True if it has been started, otherwise false.
  65853. */
  65854. isStarted(): boolean;
  65855. /**
  65856. * Starts the particle system and begins to emit
  65857. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65858. */
  65859. start(delay?: number): void;
  65860. /**
  65861. * Stops the particle system.
  65862. */
  65863. stop(): void;
  65864. /**
  65865. * Remove all active particles
  65866. */
  65867. reset(): void;
  65868. /**
  65869. * Returns the string "GPUParticleSystem"
  65870. * @returns a string containing the class name
  65871. */
  65872. getClassName(): string;
  65873. private _colorGradientsTexture;
  65874. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65875. /**
  65876. * Adds a new color gradient
  65877. * @param gradient defines the gradient to use (between 0 and 1)
  65878. * @param color1 defines the color to affect to the specified gradient
  65879. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65880. * @returns the current particle system
  65881. */
  65882. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65883. /**
  65884. * Remove a specific color gradient
  65885. * @param gradient defines the gradient to remove
  65886. * @returns the current particle system
  65887. */
  65888. removeColorGradient(gradient: number): GPUParticleSystem;
  65889. private _angularSpeedGradientsTexture;
  65890. private _sizeGradientsTexture;
  65891. private _velocityGradientsTexture;
  65892. private _limitVelocityGradientsTexture;
  65893. private _dragGradientsTexture;
  65894. private _addFactorGradient;
  65895. /**
  65896. * Adds a new size gradient
  65897. * @param gradient defines the gradient to use (between 0 and 1)
  65898. * @param factor defines the size factor to affect to the specified gradient
  65899. * @returns the current particle system
  65900. */
  65901. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65902. /**
  65903. * Remove a specific size gradient
  65904. * @param gradient defines the gradient to remove
  65905. * @returns the current particle system
  65906. */
  65907. removeSizeGradient(gradient: number): GPUParticleSystem;
  65908. /**
  65909. * Adds a new angular speed gradient
  65910. * @param gradient defines the gradient to use (between 0 and 1)
  65911. * @param factor defines the angular speed to affect to the specified gradient
  65912. * @returns the current particle system
  65913. */
  65914. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65915. /**
  65916. * Remove a specific angular speed gradient
  65917. * @param gradient defines the gradient to remove
  65918. * @returns the current particle system
  65919. */
  65920. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65921. /**
  65922. * Adds a new velocity gradient
  65923. * @param gradient defines the gradient to use (between 0 and 1)
  65924. * @param factor defines the velocity to affect to the specified gradient
  65925. * @returns the current particle system
  65926. */
  65927. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65928. /**
  65929. * Remove a specific velocity gradient
  65930. * @param gradient defines the gradient to remove
  65931. * @returns the current particle system
  65932. */
  65933. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65934. /**
  65935. * Adds a new limit velocity gradient
  65936. * @param gradient defines the gradient to use (between 0 and 1)
  65937. * @param factor defines the limit velocity value to affect to the specified gradient
  65938. * @returns the current particle system
  65939. */
  65940. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65941. /**
  65942. * Remove a specific limit velocity gradient
  65943. * @param gradient defines the gradient to remove
  65944. * @returns the current particle system
  65945. */
  65946. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65947. /**
  65948. * Adds a new drag gradient
  65949. * @param gradient defines the gradient to use (between 0 and 1)
  65950. * @param factor defines the drag value to affect to the specified gradient
  65951. * @returns the current particle system
  65952. */
  65953. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65954. /**
  65955. * Remove a specific drag gradient
  65956. * @param gradient defines the gradient to remove
  65957. * @returns the current particle system
  65958. */
  65959. removeDragGradient(gradient: number): GPUParticleSystem;
  65960. /**
  65961. * Not supported by GPUParticleSystem
  65962. * @param gradient defines the gradient to use (between 0 and 1)
  65963. * @param factor defines the emit rate value to affect to the specified gradient
  65964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65965. * @returns the current particle system
  65966. */
  65967. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65968. /**
  65969. * Not supported by GPUParticleSystem
  65970. * @param gradient defines the gradient to remove
  65971. * @returns the current particle system
  65972. */
  65973. removeEmitRateGradient(gradient: number): IParticleSystem;
  65974. /**
  65975. * Not supported by GPUParticleSystem
  65976. * @param gradient defines the gradient to use (between 0 and 1)
  65977. * @param factor defines the start size value to affect to the specified gradient
  65978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65979. * @returns the current particle system
  65980. */
  65981. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65982. /**
  65983. * Not supported by GPUParticleSystem
  65984. * @param gradient defines the gradient to remove
  65985. * @returns the current particle system
  65986. */
  65987. removeStartSizeGradient(gradient: number): IParticleSystem;
  65988. /**
  65989. * Not supported by GPUParticleSystem
  65990. * @param gradient defines the gradient to use (between 0 and 1)
  65991. * @param min defines the color remap minimal range
  65992. * @param max defines the color remap maximal range
  65993. * @returns the current particle system
  65994. */
  65995. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65996. /**
  65997. * Not supported by GPUParticleSystem
  65998. * @param gradient defines the gradient to remove
  65999. * @returns the current particle system
  66000. */
  66001. removeColorRemapGradient(): IParticleSystem;
  66002. /**
  66003. * Not supported by GPUParticleSystem
  66004. * @param gradient defines the gradient to use (between 0 and 1)
  66005. * @param min defines the alpha remap minimal range
  66006. * @param max defines the alpha remap maximal range
  66007. * @returns the current particle system
  66008. */
  66009. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66010. /**
  66011. * Not supported by GPUParticleSystem
  66012. * @param gradient defines the gradient to remove
  66013. * @returns the current particle system
  66014. */
  66015. removeAlphaRemapGradient(): IParticleSystem;
  66016. /**
  66017. * Not supported by GPUParticleSystem
  66018. * @param gradient defines the gradient to use (between 0 and 1)
  66019. * @param color defines the color to affect to the specified gradient
  66020. * @returns the current particle system
  66021. */
  66022. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66023. /**
  66024. * Not supported by GPUParticleSystem
  66025. * @param gradient defines the gradient to remove
  66026. * @returns the current particle system
  66027. */
  66028. removeRampGradient(): IParticleSystem;
  66029. /**
  66030. * Not supported by GPUParticleSystem
  66031. * @returns the list of ramp gradients
  66032. */
  66033. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66034. /**
  66035. * Not supported by GPUParticleSystem
  66036. * Gets or sets a boolean indicating that ramp gradients must be used
  66037. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66038. */
  66039. get useRampGradients(): boolean;
  66040. set useRampGradients(value: boolean);
  66041. /**
  66042. * Not supported by GPUParticleSystem
  66043. * @param gradient defines the gradient to use (between 0 and 1)
  66044. * @param factor defines the life time factor to affect to the specified gradient
  66045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66046. * @returns the current particle system
  66047. */
  66048. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66049. /**
  66050. * Not supported by GPUParticleSystem
  66051. * @param gradient defines the gradient to remove
  66052. * @returns the current particle system
  66053. */
  66054. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66055. /**
  66056. * Instantiates a GPU particle system.
  66057. * 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.
  66058. * @param name The name of the particle system
  66059. * @param options The options used to create the system
  66060. * @param scene The scene the particle system belongs to
  66061. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66062. */
  66063. constructor(name: string, options: Partial<{
  66064. capacity: number;
  66065. randomTextureSize: number;
  66066. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66067. protected _reset(): void;
  66068. private _createUpdateVAO;
  66069. private _createRenderVAO;
  66070. private _initialize;
  66071. /** @hidden */
  66072. _recreateUpdateEffect(): void;
  66073. /** @hidden */
  66074. _recreateRenderEffect(): void;
  66075. /**
  66076. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66077. * @param preWarm defines if we are in the pre-warmimg phase
  66078. */
  66079. animate(preWarm?: boolean): void;
  66080. private _createFactorGradientTexture;
  66081. private _createSizeGradientTexture;
  66082. private _createAngularSpeedGradientTexture;
  66083. private _createVelocityGradientTexture;
  66084. private _createLimitVelocityGradientTexture;
  66085. private _createDragGradientTexture;
  66086. private _createColorGradientTexture;
  66087. /**
  66088. * Renders the particle system in its current state
  66089. * @param preWarm defines if the system should only update the particles but not render them
  66090. * @returns the current number of particles
  66091. */
  66092. render(preWarm?: boolean): number;
  66093. /**
  66094. * Rebuilds the particle system
  66095. */
  66096. rebuild(): void;
  66097. private _releaseBuffers;
  66098. private _releaseVAOs;
  66099. /**
  66100. * Disposes the particle system and free the associated resources
  66101. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66102. */
  66103. dispose(disposeTexture?: boolean): void;
  66104. /**
  66105. * Clones the particle system.
  66106. * @param name The name of the cloned object
  66107. * @param newEmitter The new emitter to use
  66108. * @returns the cloned particle system
  66109. */
  66110. clone(name: string, newEmitter: any): GPUParticleSystem;
  66111. /**
  66112. * Serializes the particle system to a JSON object.
  66113. * @returns the JSON object
  66114. */
  66115. serialize(): any;
  66116. /**
  66117. * Parses a JSON object to create a GPU particle system.
  66118. * @param parsedParticleSystem The JSON object to parse
  66119. * @param scene The scene to create the particle system in
  66120. * @param rootUrl The root url to use to load external dependencies like texture
  66121. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66122. * @returns the parsed GPU particle system
  66123. */
  66124. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66125. }
  66126. }
  66127. declare module "babylonjs/Particles/particleSystemSet" {
  66128. import { Nullable } from "babylonjs/types";
  66129. import { Color3 } from "babylonjs/Maths/math.color";
  66130. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66132. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66133. import { Scene, IDisposable } from "babylonjs/scene";
  66134. /**
  66135. * Represents a set of particle systems working together to create a specific effect
  66136. */
  66137. export class ParticleSystemSet implements IDisposable {
  66138. /**
  66139. * Gets or sets base Assets URL
  66140. */
  66141. static BaseAssetsUrl: string;
  66142. private _emitterCreationOptions;
  66143. private _emitterNode;
  66144. /**
  66145. * Gets the particle system list
  66146. */
  66147. systems: IParticleSystem[];
  66148. /**
  66149. * Gets the emitter node used with this set
  66150. */
  66151. get emitterNode(): Nullable<TransformNode>;
  66152. /**
  66153. * Creates a new emitter mesh as a sphere
  66154. * @param options defines the options used to create the sphere
  66155. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66156. * @param scene defines the hosting scene
  66157. */
  66158. setEmitterAsSphere(options: {
  66159. diameter: number;
  66160. segments: number;
  66161. color: Color3;
  66162. }, renderingGroupId: number, scene: Scene): void;
  66163. /**
  66164. * Starts all particle systems of the set
  66165. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66166. */
  66167. start(emitter?: AbstractMesh): void;
  66168. /**
  66169. * Release all associated resources
  66170. */
  66171. dispose(): void;
  66172. /**
  66173. * Serialize the set into a JSON compatible object
  66174. * @returns a JSON compatible representation of the set
  66175. */
  66176. serialize(): any;
  66177. /**
  66178. * Parse a new ParticleSystemSet from a serialized source
  66179. * @param data defines a JSON compatible representation of the set
  66180. * @param scene defines the hosting scene
  66181. * @param gpu defines if we want GPU particles or CPU particles
  66182. * @returns a new ParticleSystemSet
  66183. */
  66184. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66185. }
  66186. }
  66187. declare module "babylonjs/Particles/particleHelper" {
  66188. import { Nullable } from "babylonjs/types";
  66189. import { Scene } from "babylonjs/scene";
  66190. import { Vector3 } from "babylonjs/Maths/math.vector";
  66191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66192. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66193. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66194. /**
  66195. * This class is made for on one-liner static method to help creating particle system set.
  66196. */
  66197. export class ParticleHelper {
  66198. /**
  66199. * Gets or sets base Assets URL
  66200. */
  66201. static BaseAssetsUrl: string;
  66202. /**
  66203. * Create a default particle system that you can tweak
  66204. * @param emitter defines the emitter to use
  66205. * @param capacity defines the system capacity (default is 500 particles)
  66206. * @param scene defines the hosting scene
  66207. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66208. * @returns the new Particle system
  66209. */
  66210. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66211. /**
  66212. * This is the main static method (one-liner) of this helper to create different particle systems
  66213. * @param type This string represents the type to the particle system to create
  66214. * @param scene The scene where the particle system should live
  66215. * @param gpu If the system will use gpu
  66216. * @returns the ParticleSystemSet created
  66217. */
  66218. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66219. /**
  66220. * Static function used to export a particle system to a ParticleSystemSet variable.
  66221. * Please note that the emitter shape is not exported
  66222. * @param systems defines the particle systems to export
  66223. * @returns the created particle system set
  66224. */
  66225. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66226. }
  66227. }
  66228. declare module "babylonjs/Particles/particleSystemComponent" {
  66229. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66230. import { Effect } from "babylonjs/Materials/effect";
  66231. import "babylonjs/Shaders/particles.vertex";
  66232. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66233. module "babylonjs/Engines/engine" {
  66234. interface Engine {
  66235. /**
  66236. * Create an effect to use with particle systems.
  66237. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66238. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66239. * @param uniformsNames defines a list of attribute names
  66240. * @param samplers defines an array of string used to represent textures
  66241. * @param defines defines the string containing the defines to use to compile the shaders
  66242. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66243. * @param onCompiled defines a function to call when the effect creation is successful
  66244. * @param onError defines a function to call when the effect creation has failed
  66245. * @returns the new Effect
  66246. */
  66247. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66248. }
  66249. }
  66250. module "babylonjs/Meshes/mesh" {
  66251. interface Mesh {
  66252. /**
  66253. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66254. * @returns an array of IParticleSystem
  66255. */
  66256. getEmittedParticleSystems(): IParticleSystem[];
  66257. /**
  66258. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66259. * @returns an array of IParticleSystem
  66260. */
  66261. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66262. }
  66263. }
  66264. /**
  66265. * @hidden
  66266. */
  66267. export var _IDoNeedToBeInTheBuild: number;
  66268. }
  66269. declare module "babylonjs/Particles/pointsCloudSystem" {
  66270. import { Color4 } from "babylonjs/Maths/math";
  66271. import { Mesh } from "babylonjs/Meshes/mesh";
  66272. import { Scene, IDisposable } from "babylonjs/scene";
  66273. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66274. /** Defines the 4 color options */
  66275. export enum PointColor {
  66276. /** color value */
  66277. Color = 2,
  66278. /** uv value */
  66279. UV = 1,
  66280. /** random value */
  66281. Random = 0,
  66282. /** stated value */
  66283. Stated = 3
  66284. }
  66285. /**
  66286. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66287. * 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.
  66288. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66289. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66290. *
  66291. * Full documentation here : TO BE ENTERED
  66292. */
  66293. export class PointsCloudSystem implements IDisposable {
  66294. /**
  66295. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66296. * Example : var p = SPS.particles[i];
  66297. */
  66298. particles: CloudPoint[];
  66299. /**
  66300. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66301. */
  66302. nbParticles: number;
  66303. /**
  66304. * This a counter for your own usage. It's not set by any SPS functions.
  66305. */
  66306. counter: number;
  66307. /**
  66308. * The PCS name. This name is also given to the underlying mesh.
  66309. */
  66310. name: string;
  66311. /**
  66312. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66313. */
  66314. mesh: Mesh;
  66315. /**
  66316. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66317. * Please read :
  66318. */
  66319. vars: any;
  66320. /**
  66321. * @hidden
  66322. */
  66323. _size: number;
  66324. private _scene;
  66325. private _promises;
  66326. private _positions;
  66327. private _indices;
  66328. private _normals;
  66329. private _colors;
  66330. private _uvs;
  66331. private _indices32;
  66332. private _positions32;
  66333. private _colors32;
  66334. private _uvs32;
  66335. private _updatable;
  66336. private _isVisibilityBoxLocked;
  66337. private _alwaysVisible;
  66338. private _groups;
  66339. private _groupCounter;
  66340. private _computeParticleColor;
  66341. private _computeParticleTexture;
  66342. private _computeParticleRotation;
  66343. private _computeBoundingBox;
  66344. private _isReady;
  66345. /**
  66346. * Creates a PCS (Points Cloud System) object
  66347. * @param name (String) is the PCS name, this will be the underlying mesh name
  66348. * @param pointSize (number) is the size for each point
  66349. * @param scene (Scene) is the scene in which the PCS is added
  66350. * @param options defines the options of the PCS e.g.
  66351. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66352. */
  66353. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66354. updatable?: boolean;
  66355. });
  66356. /**
  66357. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66358. * If no points were added to the PCS, the returned mesh is just a single point.
  66359. * @returns a promise for the created mesh
  66360. */
  66361. buildMeshAsync(): Promise<Mesh>;
  66362. /**
  66363. * @hidden
  66364. */
  66365. private _buildMesh;
  66366. private _addParticle;
  66367. private _randomUnitVector;
  66368. private _getColorIndicesForCoord;
  66369. private _setPointsColorOrUV;
  66370. private _colorFromTexture;
  66371. private _calculateDensity;
  66372. /**
  66373. * Adds points to the PCS in random positions within a unit sphere
  66374. * @param nb (positive integer) the number of particles to be created from this model
  66375. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66376. * @returns the number of groups in the system
  66377. */
  66378. addPoints(nb: number, pointFunction?: any): number;
  66379. /**
  66380. * Adds points to the PCS from the surface of the model shape
  66381. * @param mesh is any Mesh object that will be used as a surface model for the points
  66382. * @param nb (positive integer) the number of particles to be created from this model
  66383. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66384. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66385. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66386. * @returns the number of groups in the system
  66387. */
  66388. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66389. /**
  66390. * Adds points to the PCS inside the model shape
  66391. * @param mesh is any Mesh object that will be used as a surface model for the points
  66392. * @param nb (positive integer) the number of particles to be created from this model
  66393. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66394. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66395. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66396. * @returns the number of groups in the system
  66397. */
  66398. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66399. /**
  66400. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66401. * This method calls `updateParticle()` for each particle of the SPS.
  66402. * For an animated SPS, it is usually called within the render loop.
  66403. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66404. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66405. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66406. * @returns the PCS.
  66407. */
  66408. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66409. /**
  66410. * Disposes the PCS.
  66411. */
  66412. dispose(): void;
  66413. /**
  66414. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66415. * doc :
  66416. * @returns the PCS.
  66417. */
  66418. refreshVisibleSize(): PointsCloudSystem;
  66419. /**
  66420. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66421. * @param size the size (float) of the visibility box
  66422. * note : this doesn't lock the PCS mesh bounding box.
  66423. * doc :
  66424. */
  66425. setVisibilityBox(size: number): void;
  66426. /**
  66427. * Gets whether the PCS is always visible or not
  66428. * doc :
  66429. */
  66430. get isAlwaysVisible(): boolean;
  66431. /**
  66432. * Sets the PCS as always visible or not
  66433. * doc :
  66434. */
  66435. set isAlwaysVisible(val: boolean);
  66436. /**
  66437. * Tells to `setParticles()` to compute the particle rotations or not
  66438. * Default value : false. The PCS is faster when it's set to false
  66439. * Note : particle rotations are only applied to parent particles
  66440. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66441. */
  66442. set computeParticleRotation(val: boolean);
  66443. /**
  66444. * Tells to `setParticles()` to compute the particle colors or not.
  66445. * Default value : true. The PCS is faster when it's set to false.
  66446. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66447. */
  66448. set computeParticleColor(val: boolean);
  66449. set computeParticleTexture(val: boolean);
  66450. /**
  66451. * Gets if `setParticles()` computes the particle colors or not.
  66452. * Default value : false. The PCS is faster when it's set to false.
  66453. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66454. */
  66455. get computeParticleColor(): boolean;
  66456. /**
  66457. * Gets if `setParticles()` computes the particle textures or not.
  66458. * Default value : false. The PCS is faster when it's set to false.
  66459. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66460. */
  66461. get computeParticleTexture(): boolean;
  66462. /**
  66463. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66464. */
  66465. set computeBoundingBox(val: boolean);
  66466. /**
  66467. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66468. */
  66469. get computeBoundingBox(): boolean;
  66470. /**
  66471. * This function does nothing. It may be overwritten to set all the particle first values.
  66472. * The PCS doesn't call this function, you may have to call it by your own.
  66473. * doc :
  66474. */
  66475. initParticles(): void;
  66476. /**
  66477. * This function does nothing. It may be overwritten to recycle a particle
  66478. * The PCS doesn't call this function, you can to call it
  66479. * doc :
  66480. * @param particle The particle to recycle
  66481. * @returns the recycled particle
  66482. */
  66483. recycleParticle(particle: CloudPoint): CloudPoint;
  66484. /**
  66485. * Updates a particle : this function should be overwritten by the user.
  66486. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66487. * doc :
  66488. * @example : just set a particle position or velocity and recycle conditions
  66489. * @param particle The particle to update
  66490. * @returns the updated particle
  66491. */
  66492. updateParticle(particle: CloudPoint): CloudPoint;
  66493. /**
  66494. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66495. * This does nothing and may be overwritten by the user.
  66496. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66497. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66498. * @param update the boolean update value actually passed to setParticles()
  66499. */
  66500. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66501. /**
  66502. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66503. * This will be passed three parameters.
  66504. * This does nothing and may be overwritten by the user.
  66505. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66506. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66507. * @param update the boolean update value actually passed to setParticles()
  66508. */
  66509. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66510. }
  66511. }
  66512. declare module "babylonjs/Particles/cloudPoint" {
  66513. import { Nullable } from "babylonjs/types";
  66514. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66515. import { Mesh } from "babylonjs/Meshes/mesh";
  66516. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66517. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66518. /**
  66519. * Represents one particle of a points cloud system.
  66520. */
  66521. export class CloudPoint {
  66522. /**
  66523. * particle global index
  66524. */
  66525. idx: number;
  66526. /**
  66527. * The color of the particle
  66528. */
  66529. color: Nullable<Color4>;
  66530. /**
  66531. * The world space position of the particle.
  66532. */
  66533. position: Vector3;
  66534. /**
  66535. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66536. */
  66537. rotation: Vector3;
  66538. /**
  66539. * The world space rotation quaternion of the particle.
  66540. */
  66541. rotationQuaternion: Nullable<Quaternion>;
  66542. /**
  66543. * The uv of the particle.
  66544. */
  66545. uv: Nullable<Vector2>;
  66546. /**
  66547. * The current speed of the particle.
  66548. */
  66549. velocity: Vector3;
  66550. /**
  66551. * The pivot point in the particle local space.
  66552. */
  66553. pivot: Vector3;
  66554. /**
  66555. * Must the particle be translated from its pivot point in its local space ?
  66556. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66557. * Default : false
  66558. */
  66559. translateFromPivot: boolean;
  66560. /**
  66561. * Index of this particle in the global "positions" array (Internal use)
  66562. * @hidden
  66563. */
  66564. _pos: number;
  66565. /**
  66566. * @hidden Index of this particle in the global "indices" array (Internal use)
  66567. */
  66568. _ind: number;
  66569. /**
  66570. * Group this particle belongs to
  66571. */
  66572. _group: PointsGroup;
  66573. /**
  66574. * Group id of this particle
  66575. */
  66576. groupId: number;
  66577. /**
  66578. * Index of the particle in its group id (Internal use)
  66579. */
  66580. idxInGroup: number;
  66581. /**
  66582. * @hidden Particle BoundingInfo object (Internal use)
  66583. */
  66584. _boundingInfo: BoundingInfo;
  66585. /**
  66586. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66587. */
  66588. _pcs: PointsCloudSystem;
  66589. /**
  66590. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66591. */
  66592. _stillInvisible: boolean;
  66593. /**
  66594. * @hidden Last computed particle rotation matrix
  66595. */
  66596. _rotationMatrix: number[];
  66597. /**
  66598. * Parent particle Id, if any.
  66599. * Default null.
  66600. */
  66601. parentId: Nullable<number>;
  66602. /**
  66603. * @hidden Internal global position in the PCS.
  66604. */
  66605. _globalPosition: Vector3;
  66606. /**
  66607. * Creates a Point Cloud object.
  66608. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66609. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66610. * @param group (PointsGroup) is the group the particle belongs to
  66611. * @param groupId (integer) is the group identifier in the PCS.
  66612. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66613. * @param pcs defines the PCS it is associated to
  66614. */
  66615. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66616. /**
  66617. * get point size
  66618. */
  66619. get size(): Vector3;
  66620. /**
  66621. * Set point size
  66622. */
  66623. set size(scale: Vector3);
  66624. /**
  66625. * Legacy support, changed quaternion to rotationQuaternion
  66626. */
  66627. get quaternion(): Nullable<Quaternion>;
  66628. /**
  66629. * Legacy support, changed quaternion to rotationQuaternion
  66630. */
  66631. set quaternion(q: Nullable<Quaternion>);
  66632. /**
  66633. * Returns a boolean. True if the particle intersects a mesh, else false
  66634. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66635. * @param target is the object (point or mesh) what the intersection is computed against
  66636. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66637. * @returns true if it intersects
  66638. */
  66639. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66640. /**
  66641. * get the rotation matrix of the particle
  66642. * @hidden
  66643. */
  66644. getRotationMatrix(m: Matrix): void;
  66645. }
  66646. /**
  66647. * Represents a group of points in a points cloud system
  66648. * * PCS internal tool, don't use it manually.
  66649. */
  66650. export class PointsGroup {
  66651. /**
  66652. * The group id
  66653. * @hidden
  66654. */
  66655. groupID: number;
  66656. /**
  66657. * image data for group (internal use)
  66658. * @hidden
  66659. */
  66660. _groupImageData: Nullable<ArrayBufferView>;
  66661. /**
  66662. * Image Width (internal use)
  66663. * @hidden
  66664. */
  66665. _groupImgWidth: number;
  66666. /**
  66667. * Image Height (internal use)
  66668. * @hidden
  66669. */
  66670. _groupImgHeight: number;
  66671. /**
  66672. * Custom position function (internal use)
  66673. * @hidden
  66674. */
  66675. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66676. /**
  66677. * density per facet for surface points
  66678. * @hidden
  66679. */
  66680. _groupDensity: number[];
  66681. /**
  66682. * Only when points are colored by texture carries pointer to texture list array
  66683. * @hidden
  66684. */
  66685. _textureNb: number;
  66686. /**
  66687. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66688. * PCS internal tool, don't use it manually.
  66689. * @hidden
  66690. */
  66691. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66692. }
  66693. }
  66694. declare module "babylonjs/Particles/index" {
  66695. export * from "babylonjs/Particles/baseParticleSystem";
  66696. export * from "babylonjs/Particles/EmitterTypes/index";
  66697. export * from "babylonjs/Particles/gpuParticleSystem";
  66698. export * from "babylonjs/Particles/IParticleSystem";
  66699. export * from "babylonjs/Particles/particle";
  66700. export * from "babylonjs/Particles/particleHelper";
  66701. export * from "babylonjs/Particles/particleSystem";
  66702. export * from "babylonjs/Particles/particleSystemComponent";
  66703. export * from "babylonjs/Particles/particleSystemSet";
  66704. export * from "babylonjs/Particles/solidParticle";
  66705. export * from "babylonjs/Particles/solidParticleSystem";
  66706. export * from "babylonjs/Particles/cloudPoint";
  66707. export * from "babylonjs/Particles/pointsCloudSystem";
  66708. export * from "babylonjs/Particles/subEmitter";
  66709. }
  66710. declare module "babylonjs/Physics/physicsEngineComponent" {
  66711. import { Nullable } from "babylonjs/types";
  66712. import { Observable, Observer } from "babylonjs/Misc/observable";
  66713. import { Vector3 } from "babylonjs/Maths/math.vector";
  66714. import { Mesh } from "babylonjs/Meshes/mesh";
  66715. import { ISceneComponent } from "babylonjs/sceneComponent";
  66716. import { Scene } from "babylonjs/scene";
  66717. import { Node } from "babylonjs/node";
  66718. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66719. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66720. module "babylonjs/scene" {
  66721. interface Scene {
  66722. /** @hidden (Backing field) */
  66723. _physicsEngine: Nullable<IPhysicsEngine>;
  66724. /** @hidden */
  66725. _physicsTimeAccumulator: number;
  66726. /**
  66727. * Gets the current physics engine
  66728. * @returns a IPhysicsEngine or null if none attached
  66729. */
  66730. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66731. /**
  66732. * Enables physics to the current scene
  66733. * @param gravity defines the scene's gravity for the physics engine
  66734. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66735. * @return a boolean indicating if the physics engine was initialized
  66736. */
  66737. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66738. /**
  66739. * Disables and disposes the physics engine associated with the scene
  66740. */
  66741. disablePhysicsEngine(): void;
  66742. /**
  66743. * Gets a boolean indicating if there is an active physics engine
  66744. * @returns a boolean indicating if there is an active physics engine
  66745. */
  66746. isPhysicsEnabled(): boolean;
  66747. /**
  66748. * Deletes a physics compound impostor
  66749. * @param compound defines the compound to delete
  66750. */
  66751. deleteCompoundImpostor(compound: any): void;
  66752. /**
  66753. * An event triggered when physic simulation is about to be run
  66754. */
  66755. onBeforePhysicsObservable: Observable<Scene>;
  66756. /**
  66757. * An event triggered when physic simulation has been done
  66758. */
  66759. onAfterPhysicsObservable: Observable<Scene>;
  66760. }
  66761. }
  66762. module "babylonjs/Meshes/abstractMesh" {
  66763. interface AbstractMesh {
  66764. /** @hidden */
  66765. _physicsImpostor: Nullable<PhysicsImpostor>;
  66766. /**
  66767. * Gets or sets impostor used for physic simulation
  66768. * @see http://doc.babylonjs.com/features/physics_engine
  66769. */
  66770. physicsImpostor: Nullable<PhysicsImpostor>;
  66771. /**
  66772. * Gets the current physics impostor
  66773. * @see http://doc.babylonjs.com/features/physics_engine
  66774. * @returns a physics impostor or null
  66775. */
  66776. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66777. /** Apply a physic impulse to the mesh
  66778. * @param force defines the force to apply
  66779. * @param contactPoint defines where to apply the force
  66780. * @returns the current mesh
  66781. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66782. */
  66783. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66784. /**
  66785. * Creates a physic joint between two meshes
  66786. * @param otherMesh defines the other mesh to use
  66787. * @param pivot1 defines the pivot to use on this mesh
  66788. * @param pivot2 defines the pivot to use on the other mesh
  66789. * @param options defines additional options (can be plugin dependent)
  66790. * @returns the current mesh
  66791. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66792. */
  66793. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66794. /** @hidden */
  66795. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66796. }
  66797. }
  66798. /**
  66799. * Defines the physics engine scene component responsible to manage a physics engine
  66800. */
  66801. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66802. /**
  66803. * The component name helpful to identify the component in the list of scene components.
  66804. */
  66805. readonly name: string;
  66806. /**
  66807. * The scene the component belongs to.
  66808. */
  66809. scene: Scene;
  66810. /**
  66811. * Creates a new instance of the component for the given scene
  66812. * @param scene Defines the scene to register the component in
  66813. */
  66814. constructor(scene: Scene);
  66815. /**
  66816. * Registers the component in a given scene
  66817. */
  66818. register(): void;
  66819. /**
  66820. * Rebuilds the elements related to this component in case of
  66821. * context lost for instance.
  66822. */
  66823. rebuild(): void;
  66824. /**
  66825. * Disposes the component and the associated ressources
  66826. */
  66827. dispose(): void;
  66828. }
  66829. }
  66830. declare module "babylonjs/Physics/physicsHelper" {
  66831. import { Nullable } from "babylonjs/types";
  66832. import { Vector3 } from "babylonjs/Maths/math.vector";
  66833. import { Mesh } from "babylonjs/Meshes/mesh";
  66834. import { Scene } from "babylonjs/scene";
  66835. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66836. /**
  66837. * A helper for physics simulations
  66838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66839. */
  66840. export class PhysicsHelper {
  66841. private _scene;
  66842. private _physicsEngine;
  66843. /**
  66844. * Initializes the Physics helper
  66845. * @param scene Babylon.js scene
  66846. */
  66847. constructor(scene: Scene);
  66848. /**
  66849. * Applies a radial explosion impulse
  66850. * @param origin the origin of the explosion
  66851. * @param radiusOrEventOptions the radius or the options of radial explosion
  66852. * @param strength the explosion strength
  66853. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66854. * @returns A physics radial explosion event, or null
  66855. */
  66856. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66857. /**
  66858. * Applies a radial explosion force
  66859. * @param origin the origin of the explosion
  66860. * @param radiusOrEventOptions the radius or the options of radial explosion
  66861. * @param strength the explosion strength
  66862. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66863. * @returns A physics radial explosion event, or null
  66864. */
  66865. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66866. /**
  66867. * Creates a gravitational field
  66868. * @param origin the origin of the explosion
  66869. * @param radiusOrEventOptions the radius or the options of radial explosion
  66870. * @param strength the explosion strength
  66871. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66872. * @returns A physics gravitational field event, or null
  66873. */
  66874. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66875. /**
  66876. * Creates a physics updraft event
  66877. * @param origin the origin of the updraft
  66878. * @param radiusOrEventOptions the radius or the options of the updraft
  66879. * @param strength the strength of the updraft
  66880. * @param height the height of the updraft
  66881. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66882. * @returns A physics updraft event, or null
  66883. */
  66884. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66885. /**
  66886. * Creates a physics vortex event
  66887. * @param origin the of the vortex
  66888. * @param radiusOrEventOptions the radius or the options of the vortex
  66889. * @param strength the strength of the vortex
  66890. * @param height the height of the vortex
  66891. * @returns a Physics vortex event, or null
  66892. * A physics vortex event or null
  66893. */
  66894. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66895. }
  66896. /**
  66897. * Represents a physics radial explosion event
  66898. */
  66899. class PhysicsRadialExplosionEvent {
  66900. private _scene;
  66901. private _options;
  66902. private _sphere;
  66903. private _dataFetched;
  66904. /**
  66905. * Initializes a radial explosioin event
  66906. * @param _scene BabylonJS scene
  66907. * @param _options The options for the vortex event
  66908. */
  66909. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66910. /**
  66911. * Returns the data related to the radial explosion event (sphere).
  66912. * @returns The radial explosion event data
  66913. */
  66914. getData(): PhysicsRadialExplosionEventData;
  66915. /**
  66916. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66917. * @param impostor A physics imposter
  66918. * @param origin the origin of the explosion
  66919. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66920. */
  66921. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66922. /**
  66923. * Triggers affecterd impostors callbacks
  66924. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66925. */
  66926. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66927. /**
  66928. * Disposes the sphere.
  66929. * @param force Specifies if the sphere should be disposed by force
  66930. */
  66931. dispose(force?: boolean): void;
  66932. /*** Helpers ***/
  66933. private _prepareSphere;
  66934. private _intersectsWithSphere;
  66935. }
  66936. /**
  66937. * Represents a gravitational field event
  66938. */
  66939. class PhysicsGravitationalFieldEvent {
  66940. private _physicsHelper;
  66941. private _scene;
  66942. private _origin;
  66943. private _options;
  66944. private _tickCallback;
  66945. private _sphere;
  66946. private _dataFetched;
  66947. /**
  66948. * Initializes the physics gravitational field event
  66949. * @param _physicsHelper A physics helper
  66950. * @param _scene BabylonJS scene
  66951. * @param _origin The origin position of the gravitational field event
  66952. * @param _options The options for the vortex event
  66953. */
  66954. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66955. /**
  66956. * Returns the data related to the gravitational field event (sphere).
  66957. * @returns A gravitational field event
  66958. */
  66959. getData(): PhysicsGravitationalFieldEventData;
  66960. /**
  66961. * Enables the gravitational field.
  66962. */
  66963. enable(): void;
  66964. /**
  66965. * Disables the gravitational field.
  66966. */
  66967. disable(): void;
  66968. /**
  66969. * Disposes the sphere.
  66970. * @param force The force to dispose from the gravitational field event
  66971. */
  66972. dispose(force?: boolean): void;
  66973. private _tick;
  66974. }
  66975. /**
  66976. * Represents a physics updraft event
  66977. */
  66978. class PhysicsUpdraftEvent {
  66979. private _scene;
  66980. private _origin;
  66981. private _options;
  66982. private _physicsEngine;
  66983. private _originTop;
  66984. private _originDirection;
  66985. private _tickCallback;
  66986. private _cylinder;
  66987. private _cylinderPosition;
  66988. private _dataFetched;
  66989. /**
  66990. * Initializes the physics updraft event
  66991. * @param _scene BabylonJS scene
  66992. * @param _origin The origin position of the updraft
  66993. * @param _options The options for the updraft event
  66994. */
  66995. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66996. /**
  66997. * Returns the data related to the updraft event (cylinder).
  66998. * @returns A physics updraft event
  66999. */
  67000. getData(): PhysicsUpdraftEventData;
  67001. /**
  67002. * Enables the updraft.
  67003. */
  67004. enable(): void;
  67005. /**
  67006. * Disables the updraft.
  67007. */
  67008. disable(): void;
  67009. /**
  67010. * Disposes the cylinder.
  67011. * @param force Specifies if the updraft should be disposed by force
  67012. */
  67013. dispose(force?: boolean): void;
  67014. private getImpostorHitData;
  67015. private _tick;
  67016. /*** Helpers ***/
  67017. private _prepareCylinder;
  67018. private _intersectsWithCylinder;
  67019. }
  67020. /**
  67021. * Represents a physics vortex event
  67022. */
  67023. class PhysicsVortexEvent {
  67024. private _scene;
  67025. private _origin;
  67026. private _options;
  67027. private _physicsEngine;
  67028. private _originTop;
  67029. private _tickCallback;
  67030. private _cylinder;
  67031. private _cylinderPosition;
  67032. private _dataFetched;
  67033. /**
  67034. * Initializes the physics vortex event
  67035. * @param _scene The BabylonJS scene
  67036. * @param _origin The origin position of the vortex
  67037. * @param _options The options for the vortex event
  67038. */
  67039. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67040. /**
  67041. * Returns the data related to the vortex event (cylinder).
  67042. * @returns The physics vortex event data
  67043. */
  67044. getData(): PhysicsVortexEventData;
  67045. /**
  67046. * Enables the vortex.
  67047. */
  67048. enable(): void;
  67049. /**
  67050. * Disables the cortex.
  67051. */
  67052. disable(): void;
  67053. /**
  67054. * Disposes the sphere.
  67055. * @param force
  67056. */
  67057. dispose(force?: boolean): void;
  67058. private getImpostorHitData;
  67059. private _tick;
  67060. /*** Helpers ***/
  67061. private _prepareCylinder;
  67062. private _intersectsWithCylinder;
  67063. }
  67064. /**
  67065. * Options fot the radial explosion event
  67066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67067. */
  67068. export class PhysicsRadialExplosionEventOptions {
  67069. /**
  67070. * The radius of the sphere for the radial explosion.
  67071. */
  67072. radius: number;
  67073. /**
  67074. * The strenth of the explosion.
  67075. */
  67076. strength: number;
  67077. /**
  67078. * The strenght of the force in correspondence to the distance of the affected object
  67079. */
  67080. falloff: PhysicsRadialImpulseFalloff;
  67081. /**
  67082. * Sphere options for the radial explosion.
  67083. */
  67084. sphere: {
  67085. segments: number;
  67086. diameter: number;
  67087. };
  67088. /**
  67089. * Sphere options for the radial explosion.
  67090. */
  67091. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67092. }
  67093. /**
  67094. * Options fot the updraft event
  67095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67096. */
  67097. export class PhysicsUpdraftEventOptions {
  67098. /**
  67099. * The radius of the cylinder for the vortex
  67100. */
  67101. radius: number;
  67102. /**
  67103. * The strenth of the updraft.
  67104. */
  67105. strength: number;
  67106. /**
  67107. * The height of the cylinder for the updraft.
  67108. */
  67109. height: number;
  67110. /**
  67111. * The mode for the the updraft.
  67112. */
  67113. updraftMode: PhysicsUpdraftMode;
  67114. }
  67115. /**
  67116. * Options fot the vortex event
  67117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67118. */
  67119. export class PhysicsVortexEventOptions {
  67120. /**
  67121. * The radius of the cylinder for the vortex
  67122. */
  67123. radius: number;
  67124. /**
  67125. * The strenth of the vortex.
  67126. */
  67127. strength: number;
  67128. /**
  67129. * The height of the cylinder for the vortex.
  67130. */
  67131. height: number;
  67132. /**
  67133. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67134. */
  67135. centripetalForceThreshold: number;
  67136. /**
  67137. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67138. */
  67139. centripetalForceMultiplier: number;
  67140. /**
  67141. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67142. */
  67143. centrifugalForceMultiplier: number;
  67144. /**
  67145. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67146. */
  67147. updraftForceMultiplier: number;
  67148. }
  67149. /**
  67150. * The strenght of the force in correspondence to the distance of the affected object
  67151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67152. */
  67153. export enum PhysicsRadialImpulseFalloff {
  67154. /** Defines that impulse is constant in strength across it's whole radius */
  67155. Constant = 0,
  67156. /** Defines that impulse gets weaker if it's further from the origin */
  67157. Linear = 1
  67158. }
  67159. /**
  67160. * The strength of the force in correspondence to the distance of the affected object
  67161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67162. */
  67163. export enum PhysicsUpdraftMode {
  67164. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67165. Center = 0,
  67166. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67167. Perpendicular = 1
  67168. }
  67169. /**
  67170. * Interface for a physics hit data
  67171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67172. */
  67173. export interface PhysicsHitData {
  67174. /**
  67175. * The force applied at the contact point
  67176. */
  67177. force: Vector3;
  67178. /**
  67179. * The contact point
  67180. */
  67181. contactPoint: Vector3;
  67182. /**
  67183. * The distance from the origin to the contact point
  67184. */
  67185. distanceFromOrigin: number;
  67186. }
  67187. /**
  67188. * Interface for radial explosion event data
  67189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67190. */
  67191. export interface PhysicsRadialExplosionEventData {
  67192. /**
  67193. * A sphere used for the radial explosion event
  67194. */
  67195. sphere: Mesh;
  67196. }
  67197. /**
  67198. * Interface for gravitational field event data
  67199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67200. */
  67201. export interface PhysicsGravitationalFieldEventData {
  67202. /**
  67203. * A sphere mesh used for the gravitational field event
  67204. */
  67205. sphere: Mesh;
  67206. }
  67207. /**
  67208. * Interface for updraft event data
  67209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67210. */
  67211. export interface PhysicsUpdraftEventData {
  67212. /**
  67213. * A cylinder used for the updraft event
  67214. */
  67215. cylinder: Mesh;
  67216. }
  67217. /**
  67218. * Interface for vortex event data
  67219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67220. */
  67221. export interface PhysicsVortexEventData {
  67222. /**
  67223. * A cylinder used for the vortex event
  67224. */
  67225. cylinder: Mesh;
  67226. }
  67227. /**
  67228. * Interface for an affected physics impostor
  67229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67230. */
  67231. export interface PhysicsAffectedImpostorWithData {
  67232. /**
  67233. * The impostor affected by the effect
  67234. */
  67235. impostor: PhysicsImpostor;
  67236. /**
  67237. * The data about the hit/horce from the explosion
  67238. */
  67239. hitData: PhysicsHitData;
  67240. }
  67241. }
  67242. declare module "babylonjs/Physics/Plugins/index" {
  67243. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67244. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67245. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67246. }
  67247. declare module "babylonjs/Physics/index" {
  67248. export * from "babylonjs/Physics/IPhysicsEngine";
  67249. export * from "babylonjs/Physics/physicsEngine";
  67250. export * from "babylonjs/Physics/physicsEngineComponent";
  67251. export * from "babylonjs/Physics/physicsHelper";
  67252. export * from "babylonjs/Physics/physicsImpostor";
  67253. export * from "babylonjs/Physics/physicsJoint";
  67254. export * from "babylonjs/Physics/Plugins/index";
  67255. }
  67256. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67257. /** @hidden */
  67258. export var blackAndWhitePixelShader: {
  67259. name: string;
  67260. shader: string;
  67261. };
  67262. }
  67263. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67264. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67265. import { Camera } from "babylonjs/Cameras/camera";
  67266. import { Engine } from "babylonjs/Engines/engine";
  67267. import "babylonjs/Shaders/blackAndWhite.fragment";
  67268. /**
  67269. * Post process used to render in black and white
  67270. */
  67271. export class BlackAndWhitePostProcess extends PostProcess {
  67272. /**
  67273. * Linear about to convert he result to black and white (default: 1)
  67274. */
  67275. degree: number;
  67276. /**
  67277. * Creates a black and white post process
  67278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67279. * @param name The name of the effect.
  67280. * @param options The required width/height ratio to downsize to before computing the render pass.
  67281. * @param camera The camera to apply the render pass to.
  67282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67283. * @param engine The engine which the post process will be applied. (default: current engine)
  67284. * @param reusable If the post process can be reused on the same frame. (default: false)
  67285. */
  67286. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67287. }
  67288. }
  67289. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67290. import { Nullable } from "babylonjs/types";
  67291. import { Camera } from "babylonjs/Cameras/camera";
  67292. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67293. import { Engine } from "babylonjs/Engines/engine";
  67294. /**
  67295. * This represents a set of one or more post processes in Babylon.
  67296. * A post process can be used to apply a shader to a texture after it is rendered.
  67297. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67298. */
  67299. export class PostProcessRenderEffect {
  67300. private _postProcesses;
  67301. private _getPostProcesses;
  67302. private _singleInstance;
  67303. private _cameras;
  67304. private _indicesForCamera;
  67305. /**
  67306. * Name of the effect
  67307. * @hidden
  67308. */
  67309. _name: string;
  67310. /**
  67311. * Instantiates a post process render effect.
  67312. * A post process can be used to apply a shader to a texture after it is rendered.
  67313. * @param engine The engine the effect is tied to
  67314. * @param name The name of the effect
  67315. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67316. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67317. */
  67318. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67319. /**
  67320. * Checks if all the post processes in the effect are supported.
  67321. */
  67322. get isSupported(): boolean;
  67323. /**
  67324. * Updates the current state of the effect
  67325. * @hidden
  67326. */
  67327. _update(): void;
  67328. /**
  67329. * Attaches the effect on cameras
  67330. * @param cameras The camera to attach to.
  67331. * @hidden
  67332. */
  67333. _attachCameras(cameras: Camera): void;
  67334. /**
  67335. * Attaches the effect on cameras
  67336. * @param cameras The camera to attach to.
  67337. * @hidden
  67338. */
  67339. _attachCameras(cameras: Camera[]): void;
  67340. /**
  67341. * Detaches the effect on cameras
  67342. * @param cameras The camera to detatch from.
  67343. * @hidden
  67344. */
  67345. _detachCameras(cameras: Camera): void;
  67346. /**
  67347. * Detatches the effect on cameras
  67348. * @param cameras The camera to detatch from.
  67349. * @hidden
  67350. */
  67351. _detachCameras(cameras: Camera[]): void;
  67352. /**
  67353. * Enables the effect on given cameras
  67354. * @param cameras The camera to enable.
  67355. * @hidden
  67356. */
  67357. _enable(cameras: Camera): void;
  67358. /**
  67359. * Enables the effect on given cameras
  67360. * @param cameras The camera to enable.
  67361. * @hidden
  67362. */
  67363. _enable(cameras: Nullable<Camera[]>): void;
  67364. /**
  67365. * Disables the effect on the given cameras
  67366. * @param cameras The camera to disable.
  67367. * @hidden
  67368. */
  67369. _disable(cameras: Camera): void;
  67370. /**
  67371. * Disables the effect on the given cameras
  67372. * @param cameras The camera to disable.
  67373. * @hidden
  67374. */
  67375. _disable(cameras: Nullable<Camera[]>): void;
  67376. /**
  67377. * Gets a list of the post processes contained in the effect.
  67378. * @param camera The camera to get the post processes on.
  67379. * @returns The list of the post processes in the effect.
  67380. */
  67381. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67382. }
  67383. }
  67384. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67385. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67386. /** @hidden */
  67387. export var extractHighlightsPixelShader: {
  67388. name: string;
  67389. shader: string;
  67390. };
  67391. }
  67392. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67393. import { Nullable } from "babylonjs/types";
  67394. import { Camera } from "babylonjs/Cameras/camera";
  67395. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67396. import { Engine } from "babylonjs/Engines/engine";
  67397. import "babylonjs/Shaders/extractHighlights.fragment";
  67398. /**
  67399. * 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.
  67400. */
  67401. export class ExtractHighlightsPostProcess extends PostProcess {
  67402. /**
  67403. * The luminance threshold, pixels below this value will be set to black.
  67404. */
  67405. threshold: number;
  67406. /** @hidden */
  67407. _exposure: number;
  67408. /**
  67409. * Post process which has the input texture to be used when performing highlight extraction
  67410. * @hidden
  67411. */
  67412. _inputPostProcess: Nullable<PostProcess>;
  67413. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67414. }
  67415. }
  67416. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67417. /** @hidden */
  67418. export var bloomMergePixelShader: {
  67419. name: string;
  67420. shader: string;
  67421. };
  67422. }
  67423. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67424. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67425. import { Nullable } from "babylonjs/types";
  67426. import { Engine } from "babylonjs/Engines/engine";
  67427. import { Camera } from "babylonjs/Cameras/camera";
  67428. import "babylonjs/Shaders/bloomMerge.fragment";
  67429. /**
  67430. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67431. */
  67432. export class BloomMergePostProcess extends PostProcess {
  67433. /** Weight of the bloom to be added to the original input. */
  67434. weight: number;
  67435. /**
  67436. * Creates a new instance of @see BloomMergePostProcess
  67437. * @param name The name of the effect.
  67438. * @param originalFromInput Post process which's input will be used for the merge.
  67439. * @param blurred Blurred highlights post process which's output will be used.
  67440. * @param weight Weight of the bloom to be added to the original input.
  67441. * @param options The required width/height ratio to downsize to before computing the render pass.
  67442. * @param camera The camera to apply the render pass to.
  67443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67444. * @param engine The engine which the post process will be applied. (default: current engine)
  67445. * @param reusable If the post process can be reused on the same frame. (default: false)
  67446. * @param textureType Type of textures used when performing the post process. (default: 0)
  67447. * @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)
  67448. */
  67449. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67450. /** Weight of the bloom to be added to the original input. */
  67451. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67452. }
  67453. }
  67454. declare module "babylonjs/PostProcesses/bloomEffect" {
  67455. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67457. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67458. import { Camera } from "babylonjs/Cameras/camera";
  67459. import { Scene } from "babylonjs/scene";
  67460. /**
  67461. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67462. */
  67463. export class BloomEffect extends PostProcessRenderEffect {
  67464. private bloomScale;
  67465. /**
  67466. * @hidden Internal
  67467. */
  67468. _effects: Array<PostProcess>;
  67469. /**
  67470. * @hidden Internal
  67471. */
  67472. _downscale: ExtractHighlightsPostProcess;
  67473. private _blurX;
  67474. private _blurY;
  67475. private _merge;
  67476. /**
  67477. * The luminance threshold to find bright areas of the image to bloom.
  67478. */
  67479. get threshold(): number;
  67480. set threshold(value: number);
  67481. /**
  67482. * The strength of the bloom.
  67483. */
  67484. get weight(): number;
  67485. set weight(value: number);
  67486. /**
  67487. * Specifies the size of the bloom blur kernel, relative to the final output size
  67488. */
  67489. get kernel(): number;
  67490. set kernel(value: number);
  67491. /**
  67492. * Creates a new instance of @see BloomEffect
  67493. * @param scene The scene the effect belongs to.
  67494. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67495. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67496. * @param bloomWeight The the strength of bloom.
  67497. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67498. * @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)
  67499. */
  67500. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67501. /**
  67502. * Disposes each of the internal effects for a given camera.
  67503. * @param camera The camera to dispose the effect on.
  67504. */
  67505. disposeEffects(camera: Camera): void;
  67506. /**
  67507. * @hidden Internal
  67508. */
  67509. _updateEffects(): void;
  67510. /**
  67511. * Internal
  67512. * @returns if all the contained post processes are ready.
  67513. * @hidden
  67514. */
  67515. _isReady(): boolean;
  67516. }
  67517. }
  67518. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67519. /** @hidden */
  67520. export var chromaticAberrationPixelShader: {
  67521. name: string;
  67522. shader: string;
  67523. };
  67524. }
  67525. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67526. import { Vector2 } from "babylonjs/Maths/math.vector";
  67527. import { Nullable } from "babylonjs/types";
  67528. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67529. import { Camera } from "babylonjs/Cameras/camera";
  67530. import { Engine } from "babylonjs/Engines/engine";
  67531. import "babylonjs/Shaders/chromaticAberration.fragment";
  67532. /**
  67533. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67534. */
  67535. export class ChromaticAberrationPostProcess extends PostProcess {
  67536. /**
  67537. * The amount of seperation of rgb channels (default: 30)
  67538. */
  67539. aberrationAmount: number;
  67540. /**
  67541. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67542. */
  67543. radialIntensity: number;
  67544. /**
  67545. * 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))
  67546. */
  67547. direction: Vector2;
  67548. /**
  67549. * 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))
  67550. */
  67551. centerPosition: Vector2;
  67552. /**
  67553. * Creates a new instance ChromaticAberrationPostProcess
  67554. * @param name The name of the effect.
  67555. * @param screenWidth The width of the screen to apply the effect on.
  67556. * @param screenHeight The height of the screen to apply the effect on.
  67557. * @param options The required width/height ratio to downsize to before computing the render pass.
  67558. * @param camera The camera to apply the render pass to.
  67559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67560. * @param engine The engine which the post process will be applied. (default: current engine)
  67561. * @param reusable If the post process can be reused on the same frame. (default: false)
  67562. * @param textureType Type of textures used when performing the post process. (default: 0)
  67563. * @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)
  67564. */
  67565. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67566. }
  67567. }
  67568. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67569. /** @hidden */
  67570. export var circleOfConfusionPixelShader: {
  67571. name: string;
  67572. shader: string;
  67573. };
  67574. }
  67575. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67576. import { Nullable } from "babylonjs/types";
  67577. import { Engine } from "babylonjs/Engines/engine";
  67578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67580. import { Camera } from "babylonjs/Cameras/camera";
  67581. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67582. /**
  67583. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67584. */
  67585. export class CircleOfConfusionPostProcess extends PostProcess {
  67586. /**
  67587. * 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.
  67588. */
  67589. lensSize: number;
  67590. /**
  67591. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67592. */
  67593. fStop: number;
  67594. /**
  67595. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67596. */
  67597. focusDistance: number;
  67598. /**
  67599. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67600. */
  67601. focalLength: number;
  67602. private _depthTexture;
  67603. /**
  67604. * Creates a new instance CircleOfConfusionPostProcess
  67605. * @param name The name of the effect.
  67606. * @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.
  67607. * @param options The required width/height ratio to downsize to before computing the render pass.
  67608. * @param camera The camera to apply the render pass to.
  67609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67610. * @param engine The engine which the post process will be applied. (default: current engine)
  67611. * @param reusable If the post process can be reused on the same frame. (default: false)
  67612. * @param textureType Type of textures used when performing the post process. (default: 0)
  67613. * @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)
  67614. */
  67615. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67616. /**
  67617. * 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.
  67618. */
  67619. set depthTexture(value: RenderTargetTexture);
  67620. }
  67621. }
  67622. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67623. /** @hidden */
  67624. export var colorCorrectionPixelShader: {
  67625. name: string;
  67626. shader: string;
  67627. };
  67628. }
  67629. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67631. import { Engine } from "babylonjs/Engines/engine";
  67632. import { Camera } from "babylonjs/Cameras/camera";
  67633. import "babylonjs/Shaders/colorCorrection.fragment";
  67634. /**
  67635. *
  67636. * This post-process allows the modification of rendered colors by using
  67637. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67638. *
  67639. * The object needs to be provided an url to a texture containing the color
  67640. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67641. * Use an image editing software to tweak the LUT to match your needs.
  67642. *
  67643. * For an example of a color LUT, see here:
  67644. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67645. * For explanations on color grading, see here:
  67646. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67647. *
  67648. */
  67649. export class ColorCorrectionPostProcess extends PostProcess {
  67650. private _colorTableTexture;
  67651. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67652. }
  67653. }
  67654. declare module "babylonjs/Shaders/convolution.fragment" {
  67655. /** @hidden */
  67656. export var convolutionPixelShader: {
  67657. name: string;
  67658. shader: string;
  67659. };
  67660. }
  67661. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67662. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67663. import { Nullable } from "babylonjs/types";
  67664. import { Camera } from "babylonjs/Cameras/camera";
  67665. import { Engine } from "babylonjs/Engines/engine";
  67666. import "babylonjs/Shaders/convolution.fragment";
  67667. /**
  67668. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67669. * input texture to perform effects such as edge detection or sharpening
  67670. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67671. */
  67672. export class ConvolutionPostProcess extends PostProcess {
  67673. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67674. kernel: number[];
  67675. /**
  67676. * Creates a new instance ConvolutionPostProcess
  67677. * @param name The name of the effect.
  67678. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67679. * @param options The required width/height ratio to downsize to before computing the render pass.
  67680. * @param camera The camera to apply the render pass to.
  67681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67682. * @param engine The engine which the post process will be applied. (default: current engine)
  67683. * @param reusable If the post process can be reused on the same frame. (default: false)
  67684. * @param textureType Type of textures used when performing the post process. (default: 0)
  67685. */
  67686. constructor(name: string,
  67687. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67688. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67689. /**
  67690. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67691. */
  67692. static EdgeDetect0Kernel: number[];
  67693. /**
  67694. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67695. */
  67696. static EdgeDetect1Kernel: number[];
  67697. /**
  67698. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67699. */
  67700. static EdgeDetect2Kernel: number[];
  67701. /**
  67702. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67703. */
  67704. static SharpenKernel: number[];
  67705. /**
  67706. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67707. */
  67708. static EmbossKernel: number[];
  67709. /**
  67710. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67711. */
  67712. static GaussianKernel: number[];
  67713. }
  67714. }
  67715. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67716. import { Nullable } from "babylonjs/types";
  67717. import { Vector2 } from "babylonjs/Maths/math.vector";
  67718. import { Camera } from "babylonjs/Cameras/camera";
  67719. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67720. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67721. import { Engine } from "babylonjs/Engines/engine";
  67722. import { Scene } from "babylonjs/scene";
  67723. /**
  67724. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67725. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67726. * based on samples that have a large difference in distance than the center pixel.
  67727. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67728. */
  67729. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67730. direction: Vector2;
  67731. /**
  67732. * Creates a new instance CircleOfConfusionPostProcess
  67733. * @param name The name of the effect.
  67734. * @param scene The scene the effect belongs to.
  67735. * @param direction The direction the blur should be applied.
  67736. * @param kernel The size of the kernel used to blur.
  67737. * @param options The required width/height ratio to downsize to before computing the render pass.
  67738. * @param camera The camera to apply the render pass to.
  67739. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67740. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67742. * @param engine The engine which the post process will be applied. (default: current engine)
  67743. * @param reusable If the post process can be reused on the same frame. (default: false)
  67744. * @param textureType Type of textures used when performing the post process. (default: 0)
  67745. * @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)
  67746. */
  67747. 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);
  67748. }
  67749. }
  67750. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67751. /** @hidden */
  67752. export var depthOfFieldMergePixelShader: {
  67753. name: string;
  67754. shader: string;
  67755. };
  67756. }
  67757. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67758. import { Nullable } from "babylonjs/types";
  67759. import { Camera } from "babylonjs/Cameras/camera";
  67760. import { Effect } from "babylonjs/Materials/effect";
  67761. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67762. import { Engine } from "babylonjs/Engines/engine";
  67763. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67764. /**
  67765. * Options to be set when merging outputs from the default pipeline.
  67766. */
  67767. export class DepthOfFieldMergePostProcessOptions {
  67768. /**
  67769. * The original image to merge on top of
  67770. */
  67771. originalFromInput: PostProcess;
  67772. /**
  67773. * Parameters to perform the merge of the depth of field effect
  67774. */
  67775. depthOfField?: {
  67776. circleOfConfusion: PostProcess;
  67777. blurSteps: Array<PostProcess>;
  67778. };
  67779. /**
  67780. * Parameters to perform the merge of bloom effect
  67781. */
  67782. bloom?: {
  67783. blurred: PostProcess;
  67784. weight: number;
  67785. };
  67786. }
  67787. /**
  67788. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67789. */
  67790. export class DepthOfFieldMergePostProcess extends PostProcess {
  67791. private blurSteps;
  67792. /**
  67793. * Creates a new instance of DepthOfFieldMergePostProcess
  67794. * @param name The name of the effect.
  67795. * @param originalFromInput Post process which's input will be used for the merge.
  67796. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67797. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67798. * @param options The required width/height ratio to downsize to before computing the render pass.
  67799. * @param camera The camera to apply the render pass to.
  67800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67801. * @param engine The engine which the post process will be applied. (default: current engine)
  67802. * @param reusable If the post process can be reused on the same frame. (default: false)
  67803. * @param textureType Type of textures used when performing the post process. (default: 0)
  67804. * @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)
  67805. */
  67806. 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);
  67807. /**
  67808. * Updates the effect with the current post process compile time values and recompiles the shader.
  67809. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67810. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67811. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67812. * @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
  67813. * @param onCompiled Called when the shader has been compiled.
  67814. * @param onError Called if there is an error when compiling a shader.
  67815. */
  67816. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67817. }
  67818. }
  67819. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67820. import { Nullable } from "babylonjs/types";
  67821. import { Camera } from "babylonjs/Cameras/camera";
  67822. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67823. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67824. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67825. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67826. import { Scene } from "babylonjs/scene";
  67827. /**
  67828. * Specifies the level of max blur that should be applied when using the depth of field effect
  67829. */
  67830. export enum DepthOfFieldEffectBlurLevel {
  67831. /**
  67832. * Subtle blur
  67833. */
  67834. Low = 0,
  67835. /**
  67836. * Medium blur
  67837. */
  67838. Medium = 1,
  67839. /**
  67840. * Large blur
  67841. */
  67842. High = 2
  67843. }
  67844. /**
  67845. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67846. */
  67847. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67848. private _circleOfConfusion;
  67849. /**
  67850. * @hidden Internal, blurs from high to low
  67851. */
  67852. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67853. private _depthOfFieldBlurY;
  67854. private _dofMerge;
  67855. /**
  67856. * @hidden Internal post processes in depth of field effect
  67857. */
  67858. _effects: Array<PostProcess>;
  67859. /**
  67860. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67861. */
  67862. set focalLength(value: number);
  67863. get focalLength(): number;
  67864. /**
  67865. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67866. */
  67867. set fStop(value: number);
  67868. get fStop(): number;
  67869. /**
  67870. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67871. */
  67872. set focusDistance(value: number);
  67873. get focusDistance(): number;
  67874. /**
  67875. * 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.
  67876. */
  67877. set lensSize(value: number);
  67878. get lensSize(): number;
  67879. /**
  67880. * Creates a new instance DepthOfFieldEffect
  67881. * @param scene The scene the effect belongs to.
  67882. * @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.
  67883. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67884. * @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)
  67885. */
  67886. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67887. /**
  67888. * Get the current class name of the current effet
  67889. * @returns "DepthOfFieldEffect"
  67890. */
  67891. getClassName(): string;
  67892. /**
  67893. * 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.
  67894. */
  67895. set depthTexture(value: RenderTargetTexture);
  67896. /**
  67897. * Disposes each of the internal effects for a given camera.
  67898. * @param camera The camera to dispose the effect on.
  67899. */
  67900. disposeEffects(camera: Camera): void;
  67901. /**
  67902. * @hidden Internal
  67903. */
  67904. _updateEffects(): void;
  67905. /**
  67906. * Internal
  67907. * @returns if all the contained post processes are ready.
  67908. * @hidden
  67909. */
  67910. _isReady(): boolean;
  67911. }
  67912. }
  67913. declare module "babylonjs/Shaders/displayPass.fragment" {
  67914. /** @hidden */
  67915. export var displayPassPixelShader: {
  67916. name: string;
  67917. shader: string;
  67918. };
  67919. }
  67920. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67921. import { Nullable } from "babylonjs/types";
  67922. import { Camera } from "babylonjs/Cameras/camera";
  67923. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67924. import { Engine } from "babylonjs/Engines/engine";
  67925. import "babylonjs/Shaders/displayPass.fragment";
  67926. /**
  67927. * DisplayPassPostProcess which produces an output the same as it's input
  67928. */
  67929. export class DisplayPassPostProcess extends PostProcess {
  67930. /**
  67931. * Creates the DisplayPassPostProcess
  67932. * @param name The name of the effect.
  67933. * @param options The required width/height ratio to downsize to before computing the render pass.
  67934. * @param camera The camera to apply the render pass to.
  67935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67936. * @param engine The engine which the post process will be applied. (default: current engine)
  67937. * @param reusable If the post process can be reused on the same frame. (default: false)
  67938. */
  67939. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67940. }
  67941. }
  67942. declare module "babylonjs/Shaders/filter.fragment" {
  67943. /** @hidden */
  67944. export var filterPixelShader: {
  67945. name: string;
  67946. shader: string;
  67947. };
  67948. }
  67949. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67950. import { Nullable } from "babylonjs/types";
  67951. import { Matrix } from "babylonjs/Maths/math.vector";
  67952. import { Camera } from "babylonjs/Cameras/camera";
  67953. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67954. import { Engine } from "babylonjs/Engines/engine";
  67955. import "babylonjs/Shaders/filter.fragment";
  67956. /**
  67957. * Applies a kernel filter to the image
  67958. */
  67959. export class FilterPostProcess extends PostProcess {
  67960. /** The matrix to be applied to the image */
  67961. kernelMatrix: Matrix;
  67962. /**
  67963. *
  67964. * @param name The name of the effect.
  67965. * @param kernelMatrix The matrix to be applied to the image
  67966. * @param options The required width/height ratio to downsize to before computing the render pass.
  67967. * @param camera The camera to apply the render pass to.
  67968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67969. * @param engine The engine which the post process will be applied. (default: current engine)
  67970. * @param reusable If the post process can be reused on the same frame. (default: false)
  67971. */
  67972. constructor(name: string,
  67973. /** The matrix to be applied to the image */
  67974. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67975. }
  67976. }
  67977. declare module "babylonjs/Shaders/fxaa.fragment" {
  67978. /** @hidden */
  67979. export var fxaaPixelShader: {
  67980. name: string;
  67981. shader: string;
  67982. };
  67983. }
  67984. declare module "babylonjs/Shaders/fxaa.vertex" {
  67985. /** @hidden */
  67986. export var fxaaVertexShader: {
  67987. name: string;
  67988. shader: string;
  67989. };
  67990. }
  67991. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67992. import { Nullable } from "babylonjs/types";
  67993. import { Camera } from "babylonjs/Cameras/camera";
  67994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67995. import { Engine } from "babylonjs/Engines/engine";
  67996. import "babylonjs/Shaders/fxaa.fragment";
  67997. import "babylonjs/Shaders/fxaa.vertex";
  67998. /**
  67999. * Fxaa post process
  68000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68001. */
  68002. export class FxaaPostProcess extends PostProcess {
  68003. /** @hidden */
  68004. texelWidth: number;
  68005. /** @hidden */
  68006. texelHeight: number;
  68007. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68008. private _getDefines;
  68009. }
  68010. }
  68011. declare module "babylonjs/Shaders/grain.fragment" {
  68012. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68013. /** @hidden */
  68014. export var grainPixelShader: {
  68015. name: string;
  68016. shader: string;
  68017. };
  68018. }
  68019. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68020. import { Nullable } from "babylonjs/types";
  68021. import { Camera } from "babylonjs/Cameras/camera";
  68022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68023. import { Engine } from "babylonjs/Engines/engine";
  68024. import "babylonjs/Shaders/grain.fragment";
  68025. /**
  68026. * The GrainPostProcess adds noise to the image at mid luminance levels
  68027. */
  68028. export class GrainPostProcess extends PostProcess {
  68029. /**
  68030. * The intensity of the grain added (default: 30)
  68031. */
  68032. intensity: number;
  68033. /**
  68034. * If the grain should be randomized on every frame
  68035. */
  68036. animated: boolean;
  68037. /**
  68038. * Creates a new instance of @see GrainPostProcess
  68039. * @param name The name of the effect.
  68040. * @param options The required width/height ratio to downsize to before computing the render pass.
  68041. * @param camera The camera to apply the render pass to.
  68042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68043. * @param engine The engine which the post process will be applied. (default: current engine)
  68044. * @param reusable If the post process can be reused on the same frame. (default: false)
  68045. * @param textureType Type of textures used when performing the post process. (default: 0)
  68046. * @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)
  68047. */
  68048. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68049. }
  68050. }
  68051. declare module "babylonjs/Shaders/highlights.fragment" {
  68052. /** @hidden */
  68053. export var highlightsPixelShader: {
  68054. name: string;
  68055. shader: string;
  68056. };
  68057. }
  68058. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68059. import { Nullable } from "babylonjs/types";
  68060. import { Camera } from "babylonjs/Cameras/camera";
  68061. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68062. import { Engine } from "babylonjs/Engines/engine";
  68063. import "babylonjs/Shaders/highlights.fragment";
  68064. /**
  68065. * Extracts highlights from the image
  68066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68067. */
  68068. export class HighlightsPostProcess extends PostProcess {
  68069. /**
  68070. * Extracts highlights from the image
  68071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68072. * @param name The name of the effect.
  68073. * @param options The required width/height ratio to downsize to before computing the render pass.
  68074. * @param camera The camera to apply the render pass to.
  68075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68076. * @param engine The engine which the post process will be applied. (default: current engine)
  68077. * @param reusable If the post process can be reused on the same frame. (default: false)
  68078. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68079. */
  68080. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68081. }
  68082. }
  68083. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68084. /** @hidden */
  68085. export var mrtFragmentDeclaration: {
  68086. name: string;
  68087. shader: string;
  68088. };
  68089. }
  68090. declare module "babylonjs/Shaders/geometry.fragment" {
  68091. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68092. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68093. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68094. /** @hidden */
  68095. export var geometryPixelShader: {
  68096. name: string;
  68097. shader: string;
  68098. };
  68099. }
  68100. declare module "babylonjs/Shaders/geometry.vertex" {
  68101. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68102. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68103. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68104. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68105. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68106. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68107. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68108. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68109. /** @hidden */
  68110. export var geometryVertexShader: {
  68111. name: string;
  68112. shader: string;
  68113. };
  68114. }
  68115. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68116. import { Matrix } from "babylonjs/Maths/math.vector";
  68117. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68118. import { Mesh } from "babylonjs/Meshes/mesh";
  68119. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68120. import { Effect } from "babylonjs/Materials/effect";
  68121. import { Scene } from "babylonjs/scene";
  68122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68123. import "babylonjs/Shaders/geometry.fragment";
  68124. import "babylonjs/Shaders/geometry.vertex";
  68125. /** @hidden */
  68126. interface ISavedTransformationMatrix {
  68127. world: Matrix;
  68128. viewProjection: Matrix;
  68129. }
  68130. /**
  68131. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68132. */
  68133. export class GeometryBufferRenderer {
  68134. /**
  68135. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68136. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68137. */
  68138. static readonly POSITION_TEXTURE_TYPE: number;
  68139. /**
  68140. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68141. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68142. */
  68143. static readonly VELOCITY_TEXTURE_TYPE: number;
  68144. /**
  68145. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68146. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68147. */
  68148. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68149. /**
  68150. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68151. * in order to compute objects velocities when enableVelocity is set to "true"
  68152. * @hidden
  68153. */
  68154. _previousTransformationMatrices: {
  68155. [index: number]: ISavedTransformationMatrix;
  68156. };
  68157. /**
  68158. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68159. * in order to compute objects velocities when enableVelocity is set to "true"
  68160. * @hidden
  68161. */
  68162. _previousBonesTransformationMatrices: {
  68163. [index: number]: Float32Array;
  68164. };
  68165. /**
  68166. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68167. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68168. */
  68169. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68170. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68171. renderTransparentMeshes: boolean;
  68172. private _scene;
  68173. private _multiRenderTarget;
  68174. private _ratio;
  68175. private _enablePosition;
  68176. private _enableVelocity;
  68177. private _enableReflectivity;
  68178. private _positionIndex;
  68179. private _velocityIndex;
  68180. private _reflectivityIndex;
  68181. protected _effect: Effect;
  68182. protected _cachedDefines: string;
  68183. /**
  68184. * Set the render list (meshes to be rendered) used in the G buffer.
  68185. */
  68186. set renderList(meshes: Mesh[]);
  68187. /**
  68188. * Gets wether or not G buffer are supported by the running hardware.
  68189. * This requires draw buffer supports
  68190. */
  68191. get isSupported(): boolean;
  68192. /**
  68193. * Returns the index of the given texture type in the G-Buffer textures array
  68194. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68195. * @returns the index of the given texture type in the G-Buffer textures array
  68196. */
  68197. getTextureIndex(textureType: number): number;
  68198. /**
  68199. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68200. */
  68201. get enablePosition(): boolean;
  68202. /**
  68203. * Sets whether or not objects positions are enabled for the G buffer.
  68204. */
  68205. set enablePosition(enable: boolean);
  68206. /**
  68207. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68208. */
  68209. get enableVelocity(): boolean;
  68210. /**
  68211. * Sets wether or not objects velocities are enabled for the G buffer.
  68212. */
  68213. set enableVelocity(enable: boolean);
  68214. /**
  68215. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68216. */
  68217. get enableReflectivity(): boolean;
  68218. /**
  68219. * Sets wether or not objects roughness are enabled for the G buffer.
  68220. */
  68221. set enableReflectivity(enable: boolean);
  68222. /**
  68223. * Gets the scene associated with the buffer.
  68224. */
  68225. get scene(): Scene;
  68226. /**
  68227. * Gets the ratio used by the buffer during its creation.
  68228. * How big is the buffer related to the main canvas.
  68229. */
  68230. get ratio(): number;
  68231. /** @hidden */
  68232. static _SceneComponentInitialization: (scene: Scene) => void;
  68233. /**
  68234. * Creates a new G Buffer for the scene
  68235. * @param scene The scene the buffer belongs to
  68236. * @param ratio How big is the buffer related to the main canvas.
  68237. */
  68238. constructor(scene: Scene, ratio?: number);
  68239. /**
  68240. * Checks wether everything is ready to render a submesh to the G buffer.
  68241. * @param subMesh the submesh to check readiness for
  68242. * @param useInstances is the mesh drawn using instance or not
  68243. * @returns true if ready otherwise false
  68244. */
  68245. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68246. /**
  68247. * Gets the current underlying G Buffer.
  68248. * @returns the buffer
  68249. */
  68250. getGBuffer(): MultiRenderTarget;
  68251. /**
  68252. * Gets the number of samples used to render the buffer (anti aliasing).
  68253. */
  68254. get samples(): number;
  68255. /**
  68256. * Sets the number of samples used to render the buffer (anti aliasing).
  68257. */
  68258. set samples(value: number);
  68259. /**
  68260. * Disposes the renderer and frees up associated resources.
  68261. */
  68262. dispose(): void;
  68263. protected _createRenderTargets(): void;
  68264. private _copyBonesTransformationMatrices;
  68265. }
  68266. }
  68267. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68268. import { Nullable } from "babylonjs/types";
  68269. import { Scene } from "babylonjs/scene";
  68270. import { ISceneComponent } from "babylonjs/sceneComponent";
  68271. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68272. module "babylonjs/scene" {
  68273. interface Scene {
  68274. /** @hidden (Backing field) */
  68275. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68276. /**
  68277. * Gets or Sets the current geometry buffer associated to the scene.
  68278. */
  68279. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68280. /**
  68281. * Enables a GeometryBufferRender and associates it with the scene
  68282. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68283. * @returns the GeometryBufferRenderer
  68284. */
  68285. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68286. /**
  68287. * Disables the GeometryBufferRender associated with the scene
  68288. */
  68289. disableGeometryBufferRenderer(): void;
  68290. }
  68291. }
  68292. /**
  68293. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68294. * in several rendering techniques.
  68295. */
  68296. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68297. /**
  68298. * The component name helpful to identify the component in the list of scene components.
  68299. */
  68300. readonly name: string;
  68301. /**
  68302. * The scene the component belongs to.
  68303. */
  68304. scene: Scene;
  68305. /**
  68306. * Creates a new instance of the component for the given scene
  68307. * @param scene Defines the scene to register the component in
  68308. */
  68309. constructor(scene: Scene);
  68310. /**
  68311. * Registers the component in a given scene
  68312. */
  68313. register(): void;
  68314. /**
  68315. * Rebuilds the elements related to this component in case of
  68316. * context lost for instance.
  68317. */
  68318. rebuild(): void;
  68319. /**
  68320. * Disposes the component and the associated ressources
  68321. */
  68322. dispose(): void;
  68323. private _gatherRenderTargets;
  68324. }
  68325. }
  68326. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68327. /** @hidden */
  68328. export var motionBlurPixelShader: {
  68329. name: string;
  68330. shader: string;
  68331. };
  68332. }
  68333. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68334. import { Nullable } from "babylonjs/types";
  68335. import { Camera } from "babylonjs/Cameras/camera";
  68336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68337. import { Scene } from "babylonjs/scene";
  68338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68339. import "babylonjs/Animations/animatable";
  68340. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68341. import "babylonjs/Shaders/motionBlur.fragment";
  68342. import { Engine } from "babylonjs/Engines/engine";
  68343. /**
  68344. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68345. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68346. * As an example, all you have to do is to create the post-process:
  68347. * var mb = new BABYLON.MotionBlurPostProcess(
  68348. * 'mb', // The name of the effect.
  68349. * scene, // The scene containing the objects to blur according to their velocity.
  68350. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68351. * camera // The camera to apply the render pass to.
  68352. * );
  68353. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68354. */
  68355. export class MotionBlurPostProcess extends PostProcess {
  68356. /**
  68357. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68358. */
  68359. motionStrength: number;
  68360. /**
  68361. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68362. */
  68363. get motionBlurSamples(): number;
  68364. /**
  68365. * Sets the number of iterations to be used for motion blur quality
  68366. */
  68367. set motionBlurSamples(samples: number);
  68368. private _motionBlurSamples;
  68369. private _geometryBufferRenderer;
  68370. /**
  68371. * Creates a new instance MotionBlurPostProcess
  68372. * @param name The name of the effect.
  68373. * @param scene The scene containing the objects to blur according to their velocity.
  68374. * @param options The required width/height ratio to downsize to before computing the render pass.
  68375. * @param camera The camera to apply the render pass to.
  68376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68377. * @param engine The engine which the post process will be applied. (default: current engine)
  68378. * @param reusable If the post process can be reused on the same frame. (default: false)
  68379. * @param textureType Type of textures used when performing the post process. (default: 0)
  68380. * @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)
  68381. */
  68382. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68383. /**
  68384. * Excludes the given skinned mesh from computing bones velocities.
  68385. * 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.
  68386. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68387. */
  68388. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68389. /**
  68390. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68391. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68392. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68393. */
  68394. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68395. /**
  68396. * Disposes the post process.
  68397. * @param camera The camera to dispose the post process on.
  68398. */
  68399. dispose(camera?: Camera): void;
  68400. }
  68401. }
  68402. declare module "babylonjs/Shaders/refraction.fragment" {
  68403. /** @hidden */
  68404. export var refractionPixelShader: {
  68405. name: string;
  68406. shader: string;
  68407. };
  68408. }
  68409. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68410. import { Color3 } from "babylonjs/Maths/math.color";
  68411. import { Camera } from "babylonjs/Cameras/camera";
  68412. import { Texture } from "babylonjs/Materials/Textures/texture";
  68413. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68414. import { Engine } from "babylonjs/Engines/engine";
  68415. import "babylonjs/Shaders/refraction.fragment";
  68416. /**
  68417. * Post process which applies a refractin texture
  68418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68419. */
  68420. export class RefractionPostProcess extends PostProcess {
  68421. /** the base color of the refraction (used to taint the rendering) */
  68422. color: Color3;
  68423. /** simulated refraction depth */
  68424. depth: number;
  68425. /** the coefficient of the base color (0 to remove base color tainting) */
  68426. colorLevel: number;
  68427. private _refTexture;
  68428. private _ownRefractionTexture;
  68429. /**
  68430. * Gets or sets the refraction texture
  68431. * Please note that you are responsible for disposing the texture if you set it manually
  68432. */
  68433. get refractionTexture(): Texture;
  68434. set refractionTexture(value: Texture);
  68435. /**
  68436. * Initializes the RefractionPostProcess
  68437. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68438. * @param name The name of the effect.
  68439. * @param refractionTextureUrl Url of the refraction texture to use
  68440. * @param color the base color of the refraction (used to taint the rendering)
  68441. * @param depth simulated refraction depth
  68442. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68443. * @param camera The camera to apply the render pass to.
  68444. * @param options The required width/height ratio to downsize to before computing the render pass.
  68445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68446. * @param engine The engine which the post process will be applied. (default: current engine)
  68447. * @param reusable If the post process can be reused on the same frame. (default: false)
  68448. */
  68449. constructor(name: string, refractionTextureUrl: string,
  68450. /** the base color of the refraction (used to taint the rendering) */
  68451. color: Color3,
  68452. /** simulated refraction depth */
  68453. depth: number,
  68454. /** the coefficient of the base color (0 to remove base color tainting) */
  68455. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68456. /**
  68457. * Disposes of the post process
  68458. * @param camera Camera to dispose post process on
  68459. */
  68460. dispose(camera: Camera): void;
  68461. }
  68462. }
  68463. declare module "babylonjs/Shaders/sharpen.fragment" {
  68464. /** @hidden */
  68465. export var sharpenPixelShader: {
  68466. name: string;
  68467. shader: string;
  68468. };
  68469. }
  68470. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68471. import { Nullable } from "babylonjs/types";
  68472. import { Camera } from "babylonjs/Cameras/camera";
  68473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68474. import "babylonjs/Shaders/sharpen.fragment";
  68475. import { Engine } from "babylonjs/Engines/engine";
  68476. /**
  68477. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68478. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68479. */
  68480. export class SharpenPostProcess extends PostProcess {
  68481. /**
  68482. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68483. */
  68484. colorAmount: number;
  68485. /**
  68486. * How much sharpness should be applied (default: 0.3)
  68487. */
  68488. edgeAmount: number;
  68489. /**
  68490. * Creates a new instance ConvolutionPostProcess
  68491. * @param name The name of the effect.
  68492. * @param options The required width/height ratio to downsize to before computing the render pass.
  68493. * @param camera The camera to apply the render pass to.
  68494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68495. * @param engine The engine which the post process will be applied. (default: current engine)
  68496. * @param reusable If the post process can be reused on the same frame. (default: false)
  68497. * @param textureType Type of textures used when performing the post process. (default: 0)
  68498. * @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)
  68499. */
  68500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68501. }
  68502. }
  68503. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68504. import { Nullable } from "babylonjs/types";
  68505. import { Camera } from "babylonjs/Cameras/camera";
  68506. import { Engine } from "babylonjs/Engines/engine";
  68507. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68508. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68509. /**
  68510. * PostProcessRenderPipeline
  68511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68512. */
  68513. export class PostProcessRenderPipeline {
  68514. private engine;
  68515. private _renderEffects;
  68516. private _renderEffectsForIsolatedPass;
  68517. /**
  68518. * List of inspectable custom properties (used by the Inspector)
  68519. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68520. */
  68521. inspectableCustomProperties: IInspectable[];
  68522. /**
  68523. * @hidden
  68524. */
  68525. protected _cameras: Camera[];
  68526. /** @hidden */
  68527. _name: string;
  68528. /**
  68529. * Gets pipeline name
  68530. */
  68531. get name(): string;
  68532. /** Gets the list of attached cameras */
  68533. get cameras(): Camera[];
  68534. /**
  68535. * Initializes a PostProcessRenderPipeline
  68536. * @param engine engine to add the pipeline to
  68537. * @param name name of the pipeline
  68538. */
  68539. constructor(engine: Engine, name: string);
  68540. /**
  68541. * Gets the class name
  68542. * @returns "PostProcessRenderPipeline"
  68543. */
  68544. getClassName(): string;
  68545. /**
  68546. * If all the render effects in the pipeline are supported
  68547. */
  68548. get isSupported(): boolean;
  68549. /**
  68550. * Adds an effect to the pipeline
  68551. * @param renderEffect the effect to add
  68552. */
  68553. addEffect(renderEffect: PostProcessRenderEffect): void;
  68554. /** @hidden */
  68555. _rebuild(): void;
  68556. /** @hidden */
  68557. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68558. /** @hidden */
  68559. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68560. /** @hidden */
  68561. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68562. /** @hidden */
  68563. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68564. /** @hidden */
  68565. _attachCameras(cameras: Camera, unique: boolean): void;
  68566. /** @hidden */
  68567. _attachCameras(cameras: Camera[], unique: boolean): void;
  68568. /** @hidden */
  68569. _detachCameras(cameras: Camera): void;
  68570. /** @hidden */
  68571. _detachCameras(cameras: Nullable<Camera[]>): void;
  68572. /** @hidden */
  68573. _update(): void;
  68574. /** @hidden */
  68575. _reset(): void;
  68576. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68577. /**
  68578. * Disposes of the pipeline
  68579. */
  68580. dispose(): void;
  68581. }
  68582. }
  68583. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68584. import { Camera } from "babylonjs/Cameras/camera";
  68585. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68586. /**
  68587. * PostProcessRenderPipelineManager class
  68588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68589. */
  68590. export class PostProcessRenderPipelineManager {
  68591. private _renderPipelines;
  68592. /**
  68593. * Initializes a PostProcessRenderPipelineManager
  68594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68595. */
  68596. constructor();
  68597. /**
  68598. * Gets the list of supported render pipelines
  68599. */
  68600. get supportedPipelines(): PostProcessRenderPipeline[];
  68601. /**
  68602. * Adds a pipeline to the manager
  68603. * @param renderPipeline The pipeline to add
  68604. */
  68605. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68606. /**
  68607. * Attaches a camera to the pipeline
  68608. * @param renderPipelineName The name of the pipeline to attach to
  68609. * @param cameras the camera to attach
  68610. * @param unique if the camera can be attached multiple times to the pipeline
  68611. */
  68612. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68613. /**
  68614. * Detaches a camera from the pipeline
  68615. * @param renderPipelineName The name of the pipeline to detach from
  68616. * @param cameras the camera to detach
  68617. */
  68618. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68619. /**
  68620. * Enables an effect by name on a pipeline
  68621. * @param renderPipelineName the name of the pipeline to enable the effect in
  68622. * @param renderEffectName the name of the effect to enable
  68623. * @param cameras the cameras that the effect should be enabled on
  68624. */
  68625. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68626. /**
  68627. * Disables an effect by name on a pipeline
  68628. * @param renderPipelineName the name of the pipeline to disable the effect in
  68629. * @param renderEffectName the name of the effect to disable
  68630. * @param cameras the cameras that the effect should be disabled on
  68631. */
  68632. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68633. /**
  68634. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68635. */
  68636. update(): void;
  68637. /** @hidden */
  68638. _rebuild(): void;
  68639. /**
  68640. * Disposes of the manager and pipelines
  68641. */
  68642. dispose(): void;
  68643. }
  68644. }
  68645. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68646. import { ISceneComponent } from "babylonjs/sceneComponent";
  68647. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68648. import { Scene } from "babylonjs/scene";
  68649. module "babylonjs/scene" {
  68650. interface Scene {
  68651. /** @hidden (Backing field) */
  68652. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68653. /**
  68654. * Gets the postprocess render pipeline manager
  68655. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68656. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68657. */
  68658. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68659. }
  68660. }
  68661. /**
  68662. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68663. */
  68664. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68665. /**
  68666. * The component name helpfull to identify the component in the list of scene components.
  68667. */
  68668. readonly name: string;
  68669. /**
  68670. * The scene the component belongs to.
  68671. */
  68672. scene: Scene;
  68673. /**
  68674. * Creates a new instance of the component for the given scene
  68675. * @param scene Defines the scene to register the component in
  68676. */
  68677. constructor(scene: Scene);
  68678. /**
  68679. * Registers the component in a given scene
  68680. */
  68681. register(): void;
  68682. /**
  68683. * Rebuilds the elements related to this component in case of
  68684. * context lost for instance.
  68685. */
  68686. rebuild(): void;
  68687. /**
  68688. * Disposes the component and the associated ressources
  68689. */
  68690. dispose(): void;
  68691. private _gatherRenderTargets;
  68692. }
  68693. }
  68694. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68695. import { Nullable } from "babylonjs/types";
  68696. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68697. import { Camera } from "babylonjs/Cameras/camera";
  68698. import { IDisposable } from "babylonjs/scene";
  68699. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68700. import { Scene } from "babylonjs/scene";
  68701. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68702. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68703. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68704. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68705. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68706. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68707. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68708. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68709. import { Animation } from "babylonjs/Animations/animation";
  68710. /**
  68711. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68712. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68713. */
  68714. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68715. private _scene;
  68716. private _camerasToBeAttached;
  68717. /**
  68718. * ID of the sharpen post process,
  68719. */
  68720. private readonly SharpenPostProcessId;
  68721. /**
  68722. * @ignore
  68723. * ID of the image processing post process;
  68724. */
  68725. readonly ImageProcessingPostProcessId: string;
  68726. /**
  68727. * @ignore
  68728. * ID of the Fast Approximate Anti-Aliasing post process;
  68729. */
  68730. readonly FxaaPostProcessId: string;
  68731. /**
  68732. * ID of the chromatic aberration post process,
  68733. */
  68734. private readonly ChromaticAberrationPostProcessId;
  68735. /**
  68736. * ID of the grain post process
  68737. */
  68738. private readonly GrainPostProcessId;
  68739. /**
  68740. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68741. */
  68742. sharpen: SharpenPostProcess;
  68743. private _sharpenEffect;
  68744. private bloom;
  68745. /**
  68746. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68747. */
  68748. depthOfField: DepthOfFieldEffect;
  68749. /**
  68750. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68751. */
  68752. fxaa: FxaaPostProcess;
  68753. /**
  68754. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68755. */
  68756. imageProcessing: ImageProcessingPostProcess;
  68757. /**
  68758. * Chromatic aberration post process which will shift rgb colors in the image
  68759. */
  68760. chromaticAberration: ChromaticAberrationPostProcess;
  68761. private _chromaticAberrationEffect;
  68762. /**
  68763. * Grain post process which add noise to the image
  68764. */
  68765. grain: GrainPostProcess;
  68766. private _grainEffect;
  68767. /**
  68768. * Glow post process which adds a glow to emissive areas of the image
  68769. */
  68770. private _glowLayer;
  68771. /**
  68772. * Animations which can be used to tweak settings over a period of time
  68773. */
  68774. animations: Animation[];
  68775. private _imageProcessingConfigurationObserver;
  68776. private _sharpenEnabled;
  68777. private _bloomEnabled;
  68778. private _depthOfFieldEnabled;
  68779. private _depthOfFieldBlurLevel;
  68780. private _fxaaEnabled;
  68781. private _imageProcessingEnabled;
  68782. private _defaultPipelineTextureType;
  68783. private _bloomScale;
  68784. private _chromaticAberrationEnabled;
  68785. private _grainEnabled;
  68786. private _buildAllowed;
  68787. /**
  68788. * Gets active scene
  68789. */
  68790. get scene(): Scene;
  68791. /**
  68792. * Enable or disable the sharpen process from the pipeline
  68793. */
  68794. set sharpenEnabled(enabled: boolean);
  68795. get sharpenEnabled(): boolean;
  68796. private _resizeObserver;
  68797. private _hardwareScaleLevel;
  68798. private _bloomKernel;
  68799. /**
  68800. * Specifies the size of the bloom blur kernel, relative to the final output size
  68801. */
  68802. get bloomKernel(): number;
  68803. set bloomKernel(value: number);
  68804. /**
  68805. * Specifies the weight of the bloom in the final rendering
  68806. */
  68807. private _bloomWeight;
  68808. /**
  68809. * Specifies the luma threshold for the area that will be blurred by the bloom
  68810. */
  68811. private _bloomThreshold;
  68812. private _hdr;
  68813. /**
  68814. * The strength of the bloom.
  68815. */
  68816. set bloomWeight(value: number);
  68817. get bloomWeight(): number;
  68818. /**
  68819. * The strength of the bloom.
  68820. */
  68821. set bloomThreshold(value: number);
  68822. get bloomThreshold(): number;
  68823. /**
  68824. * The scale of the bloom, lower value will provide better performance.
  68825. */
  68826. set bloomScale(value: number);
  68827. get bloomScale(): number;
  68828. /**
  68829. * Enable or disable the bloom from the pipeline
  68830. */
  68831. set bloomEnabled(enabled: boolean);
  68832. get bloomEnabled(): boolean;
  68833. private _rebuildBloom;
  68834. /**
  68835. * If the depth of field is enabled.
  68836. */
  68837. get depthOfFieldEnabled(): boolean;
  68838. set depthOfFieldEnabled(enabled: boolean);
  68839. /**
  68840. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68841. */
  68842. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68843. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68844. /**
  68845. * If the anti aliasing is enabled.
  68846. */
  68847. set fxaaEnabled(enabled: boolean);
  68848. get fxaaEnabled(): boolean;
  68849. private _samples;
  68850. /**
  68851. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68852. */
  68853. set samples(sampleCount: number);
  68854. get samples(): number;
  68855. /**
  68856. * If image processing is enabled.
  68857. */
  68858. set imageProcessingEnabled(enabled: boolean);
  68859. get imageProcessingEnabled(): boolean;
  68860. /**
  68861. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68862. */
  68863. set glowLayerEnabled(enabled: boolean);
  68864. get glowLayerEnabled(): boolean;
  68865. /**
  68866. * Gets the glow layer (or null if not defined)
  68867. */
  68868. get glowLayer(): Nullable<GlowLayer>;
  68869. /**
  68870. * Enable or disable the chromaticAberration process from the pipeline
  68871. */
  68872. set chromaticAberrationEnabled(enabled: boolean);
  68873. get chromaticAberrationEnabled(): boolean;
  68874. /**
  68875. * Enable or disable the grain process from the pipeline
  68876. */
  68877. set grainEnabled(enabled: boolean);
  68878. get grainEnabled(): boolean;
  68879. /**
  68880. * @constructor
  68881. * @param name - The rendering pipeline name (default: "")
  68882. * @param hdr - If high dynamic range textures should be used (default: true)
  68883. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68884. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68885. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68886. */
  68887. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68888. /**
  68889. * Get the class name
  68890. * @returns "DefaultRenderingPipeline"
  68891. */
  68892. getClassName(): string;
  68893. /**
  68894. * Force the compilation of the entire pipeline.
  68895. */
  68896. prepare(): void;
  68897. private _hasCleared;
  68898. private _prevPostProcess;
  68899. private _prevPrevPostProcess;
  68900. private _setAutoClearAndTextureSharing;
  68901. private _depthOfFieldSceneObserver;
  68902. private _buildPipeline;
  68903. private _disposePostProcesses;
  68904. /**
  68905. * Adds a camera to the pipeline
  68906. * @param camera the camera to be added
  68907. */
  68908. addCamera(camera: Camera): void;
  68909. /**
  68910. * Removes a camera from the pipeline
  68911. * @param camera the camera to remove
  68912. */
  68913. removeCamera(camera: Camera): void;
  68914. /**
  68915. * Dispose of the pipeline and stop all post processes
  68916. */
  68917. dispose(): void;
  68918. /**
  68919. * Serialize the rendering pipeline (Used when exporting)
  68920. * @returns the serialized object
  68921. */
  68922. serialize(): any;
  68923. /**
  68924. * Parse the serialized pipeline
  68925. * @param source Source pipeline.
  68926. * @param scene The scene to load the pipeline to.
  68927. * @param rootUrl The URL of the serialized pipeline.
  68928. * @returns An instantiated pipeline from the serialized object.
  68929. */
  68930. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68931. }
  68932. }
  68933. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68934. /** @hidden */
  68935. export var lensHighlightsPixelShader: {
  68936. name: string;
  68937. shader: string;
  68938. };
  68939. }
  68940. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68941. /** @hidden */
  68942. export var depthOfFieldPixelShader: {
  68943. name: string;
  68944. shader: string;
  68945. };
  68946. }
  68947. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68948. import { Camera } from "babylonjs/Cameras/camera";
  68949. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68950. import { Scene } from "babylonjs/scene";
  68951. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68952. import "babylonjs/Shaders/chromaticAberration.fragment";
  68953. import "babylonjs/Shaders/lensHighlights.fragment";
  68954. import "babylonjs/Shaders/depthOfField.fragment";
  68955. /**
  68956. * BABYLON.JS Chromatic Aberration GLSL Shader
  68957. * Author: Olivier Guyot
  68958. * Separates very slightly R, G and B colors on the edges of the screen
  68959. * Inspired by Francois Tarlier & Martins Upitis
  68960. */
  68961. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68962. /**
  68963. * @ignore
  68964. * The chromatic aberration PostProcess id in the pipeline
  68965. */
  68966. LensChromaticAberrationEffect: string;
  68967. /**
  68968. * @ignore
  68969. * The highlights enhancing PostProcess id in the pipeline
  68970. */
  68971. HighlightsEnhancingEffect: string;
  68972. /**
  68973. * @ignore
  68974. * The depth-of-field PostProcess id in the pipeline
  68975. */
  68976. LensDepthOfFieldEffect: string;
  68977. private _scene;
  68978. private _depthTexture;
  68979. private _grainTexture;
  68980. private _chromaticAberrationPostProcess;
  68981. private _highlightsPostProcess;
  68982. private _depthOfFieldPostProcess;
  68983. private _edgeBlur;
  68984. private _grainAmount;
  68985. private _chromaticAberration;
  68986. private _distortion;
  68987. private _highlightsGain;
  68988. private _highlightsThreshold;
  68989. private _dofDistance;
  68990. private _dofAperture;
  68991. private _dofDarken;
  68992. private _dofPentagon;
  68993. private _blurNoise;
  68994. /**
  68995. * @constructor
  68996. *
  68997. * Effect parameters are as follow:
  68998. * {
  68999. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69000. * edge_blur: number; // from 0 to x (1 for realism)
  69001. * distortion: number; // from 0 to x (1 for realism)
  69002. * grain_amount: number; // from 0 to 1
  69003. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69004. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69005. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69006. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69007. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69008. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69009. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69010. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69011. * }
  69012. * Note: if an effect parameter is unset, effect is disabled
  69013. *
  69014. * @param name The rendering pipeline name
  69015. * @param parameters - An object containing all parameters (see above)
  69016. * @param scene The scene linked to this pipeline
  69017. * @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)
  69018. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69019. */
  69020. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69021. /**
  69022. * Get the class name
  69023. * @returns "LensRenderingPipeline"
  69024. */
  69025. getClassName(): string;
  69026. /**
  69027. * Gets associated scene
  69028. */
  69029. get scene(): Scene;
  69030. /**
  69031. * Gets or sets the edge blur
  69032. */
  69033. get edgeBlur(): number;
  69034. set edgeBlur(value: number);
  69035. /**
  69036. * Gets or sets the grain amount
  69037. */
  69038. get grainAmount(): number;
  69039. set grainAmount(value: number);
  69040. /**
  69041. * Gets or sets the chromatic aberration amount
  69042. */
  69043. get chromaticAberration(): number;
  69044. set chromaticAberration(value: number);
  69045. /**
  69046. * Gets or sets the depth of field aperture
  69047. */
  69048. get dofAperture(): number;
  69049. set dofAperture(value: number);
  69050. /**
  69051. * Gets or sets the edge distortion
  69052. */
  69053. get edgeDistortion(): number;
  69054. set edgeDistortion(value: number);
  69055. /**
  69056. * Gets or sets the depth of field distortion
  69057. */
  69058. get dofDistortion(): number;
  69059. set dofDistortion(value: number);
  69060. /**
  69061. * Gets or sets the darken out of focus amount
  69062. */
  69063. get darkenOutOfFocus(): number;
  69064. set darkenOutOfFocus(value: number);
  69065. /**
  69066. * Gets or sets a boolean indicating if blur noise is enabled
  69067. */
  69068. get blurNoise(): boolean;
  69069. set blurNoise(value: boolean);
  69070. /**
  69071. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69072. */
  69073. get pentagonBokeh(): boolean;
  69074. set pentagonBokeh(value: boolean);
  69075. /**
  69076. * Gets or sets the highlight grain amount
  69077. */
  69078. get highlightsGain(): number;
  69079. set highlightsGain(value: number);
  69080. /**
  69081. * Gets or sets the highlight threshold
  69082. */
  69083. get highlightsThreshold(): number;
  69084. set highlightsThreshold(value: number);
  69085. /**
  69086. * Sets the amount of blur at the edges
  69087. * @param amount blur amount
  69088. */
  69089. setEdgeBlur(amount: number): void;
  69090. /**
  69091. * Sets edge blur to 0
  69092. */
  69093. disableEdgeBlur(): void;
  69094. /**
  69095. * Sets the amout of grain
  69096. * @param amount Amount of grain
  69097. */
  69098. setGrainAmount(amount: number): void;
  69099. /**
  69100. * Set grain amount to 0
  69101. */
  69102. disableGrain(): void;
  69103. /**
  69104. * Sets the chromatic aberration amount
  69105. * @param amount amount of chromatic aberration
  69106. */
  69107. setChromaticAberration(amount: number): void;
  69108. /**
  69109. * Sets chromatic aberration amount to 0
  69110. */
  69111. disableChromaticAberration(): void;
  69112. /**
  69113. * Sets the EdgeDistortion amount
  69114. * @param amount amount of EdgeDistortion
  69115. */
  69116. setEdgeDistortion(amount: number): void;
  69117. /**
  69118. * Sets edge distortion to 0
  69119. */
  69120. disableEdgeDistortion(): void;
  69121. /**
  69122. * Sets the FocusDistance amount
  69123. * @param amount amount of FocusDistance
  69124. */
  69125. setFocusDistance(amount: number): void;
  69126. /**
  69127. * Disables depth of field
  69128. */
  69129. disableDepthOfField(): void;
  69130. /**
  69131. * Sets the Aperture amount
  69132. * @param amount amount of Aperture
  69133. */
  69134. setAperture(amount: number): void;
  69135. /**
  69136. * Sets the DarkenOutOfFocus amount
  69137. * @param amount amount of DarkenOutOfFocus
  69138. */
  69139. setDarkenOutOfFocus(amount: number): void;
  69140. private _pentagonBokehIsEnabled;
  69141. /**
  69142. * Creates a pentagon bokeh effect
  69143. */
  69144. enablePentagonBokeh(): void;
  69145. /**
  69146. * Disables the pentagon bokeh effect
  69147. */
  69148. disablePentagonBokeh(): void;
  69149. /**
  69150. * Enables noise blur
  69151. */
  69152. enableNoiseBlur(): void;
  69153. /**
  69154. * Disables noise blur
  69155. */
  69156. disableNoiseBlur(): void;
  69157. /**
  69158. * Sets the HighlightsGain amount
  69159. * @param amount amount of HighlightsGain
  69160. */
  69161. setHighlightsGain(amount: number): void;
  69162. /**
  69163. * Sets the HighlightsThreshold amount
  69164. * @param amount amount of HighlightsThreshold
  69165. */
  69166. setHighlightsThreshold(amount: number): void;
  69167. /**
  69168. * Disables highlights
  69169. */
  69170. disableHighlights(): void;
  69171. /**
  69172. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69173. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69174. */
  69175. dispose(disableDepthRender?: boolean): void;
  69176. private _createChromaticAberrationPostProcess;
  69177. private _createHighlightsPostProcess;
  69178. private _createDepthOfFieldPostProcess;
  69179. private _createGrainTexture;
  69180. }
  69181. }
  69182. declare module "babylonjs/Shaders/ssao2.fragment" {
  69183. /** @hidden */
  69184. export var ssao2PixelShader: {
  69185. name: string;
  69186. shader: string;
  69187. };
  69188. }
  69189. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69190. /** @hidden */
  69191. export var ssaoCombinePixelShader: {
  69192. name: string;
  69193. shader: string;
  69194. };
  69195. }
  69196. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69197. import { Camera } from "babylonjs/Cameras/camera";
  69198. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69199. import { Scene } from "babylonjs/scene";
  69200. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69201. import "babylonjs/Shaders/ssao2.fragment";
  69202. import "babylonjs/Shaders/ssaoCombine.fragment";
  69203. /**
  69204. * Render pipeline to produce ssao effect
  69205. */
  69206. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69207. /**
  69208. * @ignore
  69209. * The PassPostProcess id in the pipeline that contains the original scene color
  69210. */
  69211. SSAOOriginalSceneColorEffect: string;
  69212. /**
  69213. * @ignore
  69214. * The SSAO PostProcess id in the pipeline
  69215. */
  69216. SSAORenderEffect: string;
  69217. /**
  69218. * @ignore
  69219. * The horizontal blur PostProcess id in the pipeline
  69220. */
  69221. SSAOBlurHRenderEffect: string;
  69222. /**
  69223. * @ignore
  69224. * The vertical blur PostProcess id in the pipeline
  69225. */
  69226. SSAOBlurVRenderEffect: string;
  69227. /**
  69228. * @ignore
  69229. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69230. */
  69231. SSAOCombineRenderEffect: string;
  69232. /**
  69233. * The output strength of the SSAO post-process. Default value is 1.0.
  69234. */
  69235. totalStrength: number;
  69236. /**
  69237. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69238. */
  69239. maxZ: number;
  69240. /**
  69241. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69242. */
  69243. minZAspect: number;
  69244. private _samples;
  69245. /**
  69246. * Number of samples used for the SSAO calculations. Default value is 8
  69247. */
  69248. set samples(n: number);
  69249. get samples(): number;
  69250. private _textureSamples;
  69251. /**
  69252. * Number of samples to use for antialiasing
  69253. */
  69254. set textureSamples(n: number);
  69255. get textureSamples(): number;
  69256. /**
  69257. * Ratio object used for SSAO ratio and blur ratio
  69258. */
  69259. private _ratio;
  69260. /**
  69261. * Dynamically generated sphere sampler.
  69262. */
  69263. private _sampleSphere;
  69264. /**
  69265. * Blur filter offsets
  69266. */
  69267. private _samplerOffsets;
  69268. private _expensiveBlur;
  69269. /**
  69270. * If bilateral blur should be used
  69271. */
  69272. set expensiveBlur(b: boolean);
  69273. get expensiveBlur(): boolean;
  69274. /**
  69275. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69276. */
  69277. radius: number;
  69278. /**
  69279. * The base color of the SSAO post-process
  69280. * The final result is "base + ssao" between [0, 1]
  69281. */
  69282. base: number;
  69283. /**
  69284. * Support test.
  69285. */
  69286. static get IsSupported(): boolean;
  69287. private _scene;
  69288. private _depthTexture;
  69289. private _normalTexture;
  69290. private _randomTexture;
  69291. private _originalColorPostProcess;
  69292. private _ssaoPostProcess;
  69293. private _blurHPostProcess;
  69294. private _blurVPostProcess;
  69295. private _ssaoCombinePostProcess;
  69296. /**
  69297. * Gets active scene
  69298. */
  69299. get scene(): Scene;
  69300. /**
  69301. * @constructor
  69302. * @param name The rendering pipeline name
  69303. * @param scene The scene linked to this pipeline
  69304. * @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 }
  69305. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69306. */
  69307. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69308. /**
  69309. * Get the class name
  69310. * @returns "SSAO2RenderingPipeline"
  69311. */
  69312. getClassName(): string;
  69313. /**
  69314. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69315. */
  69316. dispose(disableGeometryBufferRenderer?: boolean): void;
  69317. private _createBlurPostProcess;
  69318. /** @hidden */
  69319. _rebuild(): void;
  69320. private _bits;
  69321. private _radicalInverse_VdC;
  69322. private _hammersley;
  69323. private _hemisphereSample_uniform;
  69324. private _generateHemisphere;
  69325. private _createSSAOPostProcess;
  69326. private _createSSAOCombinePostProcess;
  69327. private _createRandomTexture;
  69328. /**
  69329. * Serialize the rendering pipeline (Used when exporting)
  69330. * @returns the serialized object
  69331. */
  69332. serialize(): any;
  69333. /**
  69334. * Parse the serialized pipeline
  69335. * @param source Source pipeline.
  69336. * @param scene The scene to load the pipeline to.
  69337. * @param rootUrl The URL of the serialized pipeline.
  69338. * @returns An instantiated pipeline from the serialized object.
  69339. */
  69340. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69341. }
  69342. }
  69343. declare module "babylonjs/Shaders/ssao.fragment" {
  69344. /** @hidden */
  69345. export var ssaoPixelShader: {
  69346. name: string;
  69347. shader: string;
  69348. };
  69349. }
  69350. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69351. import { Camera } from "babylonjs/Cameras/camera";
  69352. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69353. import { Scene } from "babylonjs/scene";
  69354. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69355. import "babylonjs/Shaders/ssao.fragment";
  69356. import "babylonjs/Shaders/ssaoCombine.fragment";
  69357. /**
  69358. * Render pipeline to produce ssao effect
  69359. */
  69360. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69361. /**
  69362. * @ignore
  69363. * The PassPostProcess id in the pipeline that contains the original scene color
  69364. */
  69365. SSAOOriginalSceneColorEffect: string;
  69366. /**
  69367. * @ignore
  69368. * The SSAO PostProcess id in the pipeline
  69369. */
  69370. SSAORenderEffect: string;
  69371. /**
  69372. * @ignore
  69373. * The horizontal blur PostProcess id in the pipeline
  69374. */
  69375. SSAOBlurHRenderEffect: string;
  69376. /**
  69377. * @ignore
  69378. * The vertical blur PostProcess id in the pipeline
  69379. */
  69380. SSAOBlurVRenderEffect: string;
  69381. /**
  69382. * @ignore
  69383. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69384. */
  69385. SSAOCombineRenderEffect: string;
  69386. /**
  69387. * The output strength of the SSAO post-process. Default value is 1.0.
  69388. */
  69389. totalStrength: number;
  69390. /**
  69391. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69392. */
  69393. radius: number;
  69394. /**
  69395. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69396. * Must not be equal to fallOff and superior to fallOff.
  69397. * Default value is 0.0075
  69398. */
  69399. area: number;
  69400. /**
  69401. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69402. * Must not be equal to area and inferior to area.
  69403. * Default value is 0.000001
  69404. */
  69405. fallOff: number;
  69406. /**
  69407. * The base color of the SSAO post-process
  69408. * The final result is "base + ssao" between [0, 1]
  69409. */
  69410. base: number;
  69411. private _scene;
  69412. private _depthTexture;
  69413. private _randomTexture;
  69414. private _originalColorPostProcess;
  69415. private _ssaoPostProcess;
  69416. private _blurHPostProcess;
  69417. private _blurVPostProcess;
  69418. private _ssaoCombinePostProcess;
  69419. private _firstUpdate;
  69420. /**
  69421. * Gets active scene
  69422. */
  69423. get scene(): Scene;
  69424. /**
  69425. * @constructor
  69426. * @param name - The rendering pipeline name
  69427. * @param scene - The scene linked to this pipeline
  69428. * @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 }
  69429. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69430. */
  69431. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69432. /**
  69433. * Get the class name
  69434. * @returns "SSAORenderingPipeline"
  69435. */
  69436. getClassName(): string;
  69437. /**
  69438. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69439. */
  69440. dispose(disableDepthRender?: boolean): void;
  69441. private _createBlurPostProcess;
  69442. /** @hidden */
  69443. _rebuild(): void;
  69444. private _createSSAOPostProcess;
  69445. private _createSSAOCombinePostProcess;
  69446. private _createRandomTexture;
  69447. }
  69448. }
  69449. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69450. /** @hidden */
  69451. export var screenSpaceReflectionPixelShader: {
  69452. name: string;
  69453. shader: string;
  69454. };
  69455. }
  69456. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69457. import { Nullable } from "babylonjs/types";
  69458. import { Camera } from "babylonjs/Cameras/camera";
  69459. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69460. import { Scene } from "babylonjs/scene";
  69461. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69462. import { Engine } from "babylonjs/Engines/engine";
  69463. /**
  69464. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69465. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69466. */
  69467. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69468. /**
  69469. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69470. */
  69471. threshold: number;
  69472. /**
  69473. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69474. */
  69475. strength: number;
  69476. /**
  69477. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69478. */
  69479. reflectionSpecularFalloffExponent: number;
  69480. /**
  69481. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  69482. */
  69483. step: number;
  69484. /**
  69485. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69486. */
  69487. roughnessFactor: number;
  69488. private _geometryBufferRenderer;
  69489. private _enableSmoothReflections;
  69490. private _reflectionSamples;
  69491. private _smoothSteps;
  69492. /**
  69493. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69494. * @param name The name of the effect.
  69495. * @param scene The scene containing the objects to calculate reflections.
  69496. * @param options The required width/height ratio to downsize to before computing the render pass.
  69497. * @param camera The camera to apply the render pass to.
  69498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69499. * @param engine The engine which the post process will be applied. (default: current engine)
  69500. * @param reusable If the post process can be reused on the same frame. (default: false)
  69501. * @param textureType Type of textures used when performing the post process. (default: 0)
  69502. * @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)
  69503. */
  69504. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69505. /**
  69506. * Gets wether or not smoothing reflections is enabled.
  69507. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69508. */
  69509. get enableSmoothReflections(): boolean;
  69510. /**
  69511. * Sets wether or not smoothing reflections is enabled.
  69512. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69513. */
  69514. set enableSmoothReflections(enabled: boolean);
  69515. /**
  69516. * Gets the number of samples taken while computing reflections. More samples count is high,
  69517. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69518. */
  69519. get reflectionSamples(): number;
  69520. /**
  69521. * Sets the number of samples taken while computing reflections. More samples count is high,
  69522. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69523. */
  69524. set reflectionSamples(samples: number);
  69525. /**
  69526. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69527. * more the post-process will require GPU power and can generate a drop in FPS.
  69528. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69529. */
  69530. get smoothSteps(): number;
  69531. set smoothSteps(steps: number);
  69532. private _updateEffectDefines;
  69533. }
  69534. }
  69535. declare module "babylonjs/Shaders/standard.fragment" {
  69536. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69537. /** @hidden */
  69538. export var standardPixelShader: {
  69539. name: string;
  69540. shader: string;
  69541. };
  69542. }
  69543. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69544. import { Nullable } from "babylonjs/types";
  69545. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69546. import { Camera } from "babylonjs/Cameras/camera";
  69547. import { Texture } from "babylonjs/Materials/Textures/texture";
  69548. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69549. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69550. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69551. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69552. import { IDisposable } from "babylonjs/scene";
  69553. import { SpotLight } from "babylonjs/Lights/spotLight";
  69554. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69555. import { Scene } from "babylonjs/scene";
  69556. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69557. import { Animation } from "babylonjs/Animations/animation";
  69558. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69559. import "babylonjs/Shaders/standard.fragment";
  69560. /**
  69561. * Standard rendering pipeline
  69562. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69563. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69564. */
  69565. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69566. /**
  69567. * Public members
  69568. */
  69569. /**
  69570. * Post-process which contains the original scene color before the pipeline applies all the effects
  69571. */
  69572. originalPostProcess: Nullable<PostProcess>;
  69573. /**
  69574. * Post-process used to down scale an image x4
  69575. */
  69576. downSampleX4PostProcess: Nullable<PostProcess>;
  69577. /**
  69578. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69579. */
  69580. brightPassPostProcess: Nullable<PostProcess>;
  69581. /**
  69582. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69583. */
  69584. blurHPostProcesses: PostProcess[];
  69585. /**
  69586. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69587. */
  69588. blurVPostProcesses: PostProcess[];
  69589. /**
  69590. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69591. */
  69592. textureAdderPostProcess: Nullable<PostProcess>;
  69593. /**
  69594. * Post-process used to create volumetric lighting effect
  69595. */
  69596. volumetricLightPostProcess: Nullable<PostProcess>;
  69597. /**
  69598. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69599. */
  69600. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69601. /**
  69602. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69603. */
  69604. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69605. /**
  69606. * Post-process used to merge the volumetric light effect and the real scene color
  69607. */
  69608. volumetricLightMergePostProces: Nullable<PostProcess>;
  69609. /**
  69610. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69611. */
  69612. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69613. /**
  69614. * Base post-process used to calculate the average luminance of the final image for HDR
  69615. */
  69616. luminancePostProcess: Nullable<PostProcess>;
  69617. /**
  69618. * Post-processes used to create down sample post-processes in order to get
  69619. * the average luminance of the final image for HDR
  69620. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69621. */
  69622. luminanceDownSamplePostProcesses: PostProcess[];
  69623. /**
  69624. * Post-process used to create a HDR effect (light adaptation)
  69625. */
  69626. hdrPostProcess: Nullable<PostProcess>;
  69627. /**
  69628. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69629. */
  69630. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69631. /**
  69632. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69633. */
  69634. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69635. /**
  69636. * Post-process used to merge the final HDR post-process and the real scene color
  69637. */
  69638. hdrFinalPostProcess: Nullable<PostProcess>;
  69639. /**
  69640. * Post-process used to create a lens flare effect
  69641. */
  69642. lensFlarePostProcess: Nullable<PostProcess>;
  69643. /**
  69644. * Post-process that merges the result of the lens flare post-process and the real scene color
  69645. */
  69646. lensFlareComposePostProcess: Nullable<PostProcess>;
  69647. /**
  69648. * Post-process used to create a motion blur effect
  69649. */
  69650. motionBlurPostProcess: Nullable<PostProcess>;
  69651. /**
  69652. * Post-process used to create a depth of field effect
  69653. */
  69654. depthOfFieldPostProcess: Nullable<PostProcess>;
  69655. /**
  69656. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69657. */
  69658. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69659. /**
  69660. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69661. */
  69662. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69663. /**
  69664. * Represents the brightness threshold in order to configure the illuminated surfaces
  69665. */
  69666. brightThreshold: number;
  69667. /**
  69668. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69669. */
  69670. blurWidth: number;
  69671. /**
  69672. * Sets if the blur for highlighted surfaces must be only horizontal
  69673. */
  69674. horizontalBlur: boolean;
  69675. /**
  69676. * Gets the overall exposure used by the pipeline
  69677. */
  69678. get exposure(): number;
  69679. /**
  69680. * Sets the overall exposure used by the pipeline
  69681. */
  69682. set exposure(value: number);
  69683. /**
  69684. * Texture used typically to simulate "dirty" on camera lens
  69685. */
  69686. lensTexture: Nullable<Texture>;
  69687. /**
  69688. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69689. */
  69690. volumetricLightCoefficient: number;
  69691. /**
  69692. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69693. */
  69694. volumetricLightPower: number;
  69695. /**
  69696. * Used the set the blur intensity to smooth the volumetric lights
  69697. */
  69698. volumetricLightBlurScale: number;
  69699. /**
  69700. * Light (spot or directional) used to generate the volumetric lights rays
  69701. * The source light must have a shadow generate so the pipeline can get its
  69702. * depth map
  69703. */
  69704. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69705. /**
  69706. * For eye adaptation, represents the minimum luminance the eye can see
  69707. */
  69708. hdrMinimumLuminance: number;
  69709. /**
  69710. * For eye adaptation, represents the decrease luminance speed
  69711. */
  69712. hdrDecreaseRate: number;
  69713. /**
  69714. * For eye adaptation, represents the increase luminance speed
  69715. */
  69716. hdrIncreaseRate: number;
  69717. /**
  69718. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69719. */
  69720. get hdrAutoExposure(): boolean;
  69721. /**
  69722. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69723. */
  69724. set hdrAutoExposure(value: boolean);
  69725. /**
  69726. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69727. */
  69728. lensColorTexture: Nullable<Texture>;
  69729. /**
  69730. * The overall strengh for the lens flare effect
  69731. */
  69732. lensFlareStrength: number;
  69733. /**
  69734. * Dispersion coefficient for lens flare ghosts
  69735. */
  69736. lensFlareGhostDispersal: number;
  69737. /**
  69738. * Main lens flare halo width
  69739. */
  69740. lensFlareHaloWidth: number;
  69741. /**
  69742. * Based on the lens distortion effect, defines how much the lens flare result
  69743. * is distorted
  69744. */
  69745. lensFlareDistortionStrength: number;
  69746. /**
  69747. * Configures the blur intensity used for for lens flare (halo)
  69748. */
  69749. lensFlareBlurWidth: number;
  69750. /**
  69751. * Lens star texture must be used to simulate rays on the flares and is available
  69752. * in the documentation
  69753. */
  69754. lensStarTexture: Nullable<Texture>;
  69755. /**
  69756. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69757. * flare effect by taking account of the dirt texture
  69758. */
  69759. lensFlareDirtTexture: Nullable<Texture>;
  69760. /**
  69761. * Represents the focal length for the depth of field effect
  69762. */
  69763. depthOfFieldDistance: number;
  69764. /**
  69765. * Represents the blur intensity for the blurred part of the depth of field effect
  69766. */
  69767. depthOfFieldBlurWidth: number;
  69768. /**
  69769. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69770. */
  69771. get motionStrength(): number;
  69772. /**
  69773. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69774. */
  69775. set motionStrength(strength: number);
  69776. /**
  69777. * Gets wether or not the motion blur post-process is object based or screen based.
  69778. */
  69779. get objectBasedMotionBlur(): boolean;
  69780. /**
  69781. * Sets wether or not the motion blur post-process should be object based or screen based
  69782. */
  69783. set objectBasedMotionBlur(value: boolean);
  69784. /**
  69785. * List of animations for the pipeline (IAnimatable implementation)
  69786. */
  69787. animations: Animation[];
  69788. /**
  69789. * Private members
  69790. */
  69791. private _scene;
  69792. private _currentDepthOfFieldSource;
  69793. private _basePostProcess;
  69794. private _fixedExposure;
  69795. private _currentExposure;
  69796. private _hdrAutoExposure;
  69797. private _hdrCurrentLuminance;
  69798. private _motionStrength;
  69799. private _isObjectBasedMotionBlur;
  69800. private _floatTextureType;
  69801. private _camerasToBeAttached;
  69802. private _ratio;
  69803. private _bloomEnabled;
  69804. private _depthOfFieldEnabled;
  69805. private _vlsEnabled;
  69806. private _lensFlareEnabled;
  69807. private _hdrEnabled;
  69808. private _motionBlurEnabled;
  69809. private _fxaaEnabled;
  69810. private _screenSpaceReflectionsEnabled;
  69811. private _motionBlurSamples;
  69812. private _volumetricLightStepsCount;
  69813. private _samples;
  69814. /**
  69815. * @ignore
  69816. * Specifies if the bloom pipeline is enabled
  69817. */
  69818. get BloomEnabled(): boolean;
  69819. set BloomEnabled(enabled: boolean);
  69820. /**
  69821. * @ignore
  69822. * Specifies if the depth of field pipeline is enabed
  69823. */
  69824. get DepthOfFieldEnabled(): boolean;
  69825. set DepthOfFieldEnabled(enabled: boolean);
  69826. /**
  69827. * @ignore
  69828. * Specifies if the lens flare pipeline is enabed
  69829. */
  69830. get LensFlareEnabled(): boolean;
  69831. set LensFlareEnabled(enabled: boolean);
  69832. /**
  69833. * @ignore
  69834. * Specifies if the HDR pipeline is enabled
  69835. */
  69836. get HDREnabled(): boolean;
  69837. set HDREnabled(enabled: boolean);
  69838. /**
  69839. * @ignore
  69840. * Specifies if the volumetric lights scattering effect is enabled
  69841. */
  69842. get VLSEnabled(): boolean;
  69843. set VLSEnabled(enabled: boolean);
  69844. /**
  69845. * @ignore
  69846. * Specifies if the motion blur effect is enabled
  69847. */
  69848. get MotionBlurEnabled(): boolean;
  69849. set MotionBlurEnabled(enabled: boolean);
  69850. /**
  69851. * Specifies if anti-aliasing is enabled
  69852. */
  69853. get fxaaEnabled(): boolean;
  69854. set fxaaEnabled(enabled: boolean);
  69855. /**
  69856. * Specifies if screen space reflections are enabled.
  69857. */
  69858. get screenSpaceReflectionsEnabled(): boolean;
  69859. set screenSpaceReflectionsEnabled(enabled: boolean);
  69860. /**
  69861. * Specifies the number of steps used to calculate the volumetric lights
  69862. * Typically in interval [50, 200]
  69863. */
  69864. get volumetricLightStepsCount(): number;
  69865. set volumetricLightStepsCount(count: number);
  69866. /**
  69867. * Specifies the number of samples used for the motion blur effect
  69868. * Typically in interval [16, 64]
  69869. */
  69870. get motionBlurSamples(): number;
  69871. set motionBlurSamples(samples: number);
  69872. /**
  69873. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69874. */
  69875. get samples(): number;
  69876. set samples(sampleCount: number);
  69877. /**
  69878. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69879. * @constructor
  69880. * @param name The rendering pipeline name
  69881. * @param scene The scene linked to this pipeline
  69882. * @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)
  69883. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69884. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69885. */
  69886. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69887. private _buildPipeline;
  69888. private _createDownSampleX4PostProcess;
  69889. private _createBrightPassPostProcess;
  69890. private _createBlurPostProcesses;
  69891. private _createTextureAdderPostProcess;
  69892. private _createVolumetricLightPostProcess;
  69893. private _createLuminancePostProcesses;
  69894. private _createHdrPostProcess;
  69895. private _createLensFlarePostProcess;
  69896. private _createDepthOfFieldPostProcess;
  69897. private _createMotionBlurPostProcess;
  69898. private _getDepthTexture;
  69899. private _disposePostProcesses;
  69900. /**
  69901. * Dispose of the pipeline and stop all post processes
  69902. */
  69903. dispose(): void;
  69904. /**
  69905. * Serialize the rendering pipeline (Used when exporting)
  69906. * @returns the serialized object
  69907. */
  69908. serialize(): any;
  69909. /**
  69910. * Parse the serialized pipeline
  69911. * @param source Source pipeline.
  69912. * @param scene The scene to load the pipeline to.
  69913. * @param rootUrl The URL of the serialized pipeline.
  69914. * @returns An instantiated pipeline from the serialized object.
  69915. */
  69916. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69917. /**
  69918. * Luminance steps
  69919. */
  69920. static LuminanceSteps: number;
  69921. }
  69922. }
  69923. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69924. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69925. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69926. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69927. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69928. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69929. }
  69930. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69931. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69932. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69933. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69934. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69935. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69936. }
  69937. declare module "babylonjs/Shaders/tonemap.fragment" {
  69938. /** @hidden */
  69939. export var tonemapPixelShader: {
  69940. name: string;
  69941. shader: string;
  69942. };
  69943. }
  69944. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69945. import { Camera } from "babylonjs/Cameras/camera";
  69946. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69947. import "babylonjs/Shaders/tonemap.fragment";
  69948. import { Engine } from "babylonjs/Engines/engine";
  69949. /** Defines operator used for tonemapping */
  69950. export enum TonemappingOperator {
  69951. /** Hable */
  69952. Hable = 0,
  69953. /** Reinhard */
  69954. Reinhard = 1,
  69955. /** HejiDawson */
  69956. HejiDawson = 2,
  69957. /** Photographic */
  69958. Photographic = 3
  69959. }
  69960. /**
  69961. * Defines a post process to apply tone mapping
  69962. */
  69963. export class TonemapPostProcess extends PostProcess {
  69964. private _operator;
  69965. /** Defines the required exposure adjustement */
  69966. exposureAdjustment: number;
  69967. /**
  69968. * Creates a new TonemapPostProcess
  69969. * @param name defines the name of the postprocess
  69970. * @param _operator defines the operator to use
  69971. * @param exposureAdjustment defines the required exposure adjustement
  69972. * @param camera defines the camera to use (can be null)
  69973. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69974. * @param engine defines the hosting engine (can be ignore if camera is set)
  69975. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69976. */
  69977. constructor(name: string, _operator: TonemappingOperator,
  69978. /** Defines the required exposure adjustement */
  69979. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69980. }
  69981. }
  69982. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69983. /** @hidden */
  69984. export var volumetricLightScatteringPixelShader: {
  69985. name: string;
  69986. shader: string;
  69987. };
  69988. }
  69989. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69990. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69993. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69994. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69995. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69996. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69997. /** @hidden */
  69998. export var volumetricLightScatteringPassVertexShader: {
  69999. name: string;
  70000. shader: string;
  70001. };
  70002. }
  70003. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70004. /** @hidden */
  70005. export var volumetricLightScatteringPassPixelShader: {
  70006. name: string;
  70007. shader: string;
  70008. };
  70009. }
  70010. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70011. import { Vector3 } from "babylonjs/Maths/math.vector";
  70012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70013. import { Mesh } from "babylonjs/Meshes/mesh";
  70014. import { Camera } from "babylonjs/Cameras/camera";
  70015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70017. import { Scene } from "babylonjs/scene";
  70018. import "babylonjs/Meshes/Builders/planeBuilder";
  70019. import "babylonjs/Shaders/depth.vertex";
  70020. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70021. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70022. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70023. import { Engine } from "babylonjs/Engines/engine";
  70024. /**
  70025. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70026. */
  70027. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70028. private _volumetricLightScatteringPass;
  70029. private _volumetricLightScatteringRTT;
  70030. private _viewPort;
  70031. private _screenCoordinates;
  70032. private _cachedDefines;
  70033. /**
  70034. * If not undefined, the mesh position is computed from the attached node position
  70035. */
  70036. attachedNode: {
  70037. position: Vector3;
  70038. };
  70039. /**
  70040. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70041. */
  70042. customMeshPosition: Vector3;
  70043. /**
  70044. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70045. */
  70046. useCustomMeshPosition: boolean;
  70047. /**
  70048. * If the post-process should inverse the light scattering direction
  70049. */
  70050. invert: boolean;
  70051. /**
  70052. * The internal mesh used by the post-process
  70053. */
  70054. mesh: Mesh;
  70055. /**
  70056. * @hidden
  70057. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70058. */
  70059. get useDiffuseColor(): boolean;
  70060. set useDiffuseColor(useDiffuseColor: boolean);
  70061. /**
  70062. * Array containing the excluded meshes not rendered in the internal pass
  70063. */
  70064. excludedMeshes: AbstractMesh[];
  70065. /**
  70066. * Controls the overall intensity of the post-process
  70067. */
  70068. exposure: number;
  70069. /**
  70070. * Dissipates each sample's contribution in range [0, 1]
  70071. */
  70072. decay: number;
  70073. /**
  70074. * Controls the overall intensity of each sample
  70075. */
  70076. weight: number;
  70077. /**
  70078. * Controls the density of each sample
  70079. */
  70080. density: number;
  70081. /**
  70082. * @constructor
  70083. * @param name The post-process name
  70084. * @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)
  70085. * @param camera The camera that the post-process will be attached to
  70086. * @param mesh The mesh used to create the light scattering
  70087. * @param samples The post-process quality, default 100
  70088. * @param samplingModeThe post-process filtering mode
  70089. * @param engine The babylon engine
  70090. * @param reusable If the post-process is reusable
  70091. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70092. */
  70093. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70094. /**
  70095. * Returns the string "VolumetricLightScatteringPostProcess"
  70096. * @returns "VolumetricLightScatteringPostProcess"
  70097. */
  70098. getClassName(): string;
  70099. private _isReady;
  70100. /**
  70101. * Sets the new light position for light scattering effect
  70102. * @param position The new custom light position
  70103. */
  70104. setCustomMeshPosition(position: Vector3): void;
  70105. /**
  70106. * Returns the light position for light scattering effect
  70107. * @return Vector3 The custom light position
  70108. */
  70109. getCustomMeshPosition(): Vector3;
  70110. /**
  70111. * Disposes the internal assets and detaches the post-process from the camera
  70112. */
  70113. dispose(camera: Camera): void;
  70114. /**
  70115. * Returns the render target texture used by the post-process
  70116. * @return the render target texture used by the post-process
  70117. */
  70118. getPass(): RenderTargetTexture;
  70119. private _meshExcluded;
  70120. private _createPass;
  70121. private _updateMeshScreenCoordinates;
  70122. /**
  70123. * Creates a default mesh for the Volumeric Light Scattering post-process
  70124. * @param name The mesh name
  70125. * @param scene The scene where to create the mesh
  70126. * @return the default mesh
  70127. */
  70128. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70129. }
  70130. }
  70131. declare module "babylonjs/PostProcesses/index" {
  70132. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70133. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70134. export * from "babylonjs/PostProcesses/bloomEffect";
  70135. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70136. export * from "babylonjs/PostProcesses/blurPostProcess";
  70137. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70138. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70139. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70140. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70141. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70142. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70143. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70144. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70145. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70146. export * from "babylonjs/PostProcesses/filterPostProcess";
  70147. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70148. export * from "babylonjs/PostProcesses/grainPostProcess";
  70149. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70150. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70151. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70152. export * from "babylonjs/PostProcesses/passPostProcess";
  70153. export * from "babylonjs/PostProcesses/postProcess";
  70154. export * from "babylonjs/PostProcesses/postProcessManager";
  70155. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70156. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70157. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70158. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70159. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70160. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70161. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70162. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70163. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70164. }
  70165. declare module "babylonjs/Probes/index" {
  70166. export * from "babylonjs/Probes/reflectionProbe";
  70167. }
  70168. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70169. import { Scene } from "babylonjs/scene";
  70170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70171. import { SmartArray } from "babylonjs/Misc/smartArray";
  70172. import { ISceneComponent } from "babylonjs/sceneComponent";
  70173. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70174. import "babylonjs/Meshes/Builders/boxBuilder";
  70175. import "babylonjs/Shaders/color.fragment";
  70176. import "babylonjs/Shaders/color.vertex";
  70177. import { Color3 } from "babylonjs/Maths/math.color";
  70178. module "babylonjs/scene" {
  70179. interface Scene {
  70180. /** @hidden (Backing field) */
  70181. _boundingBoxRenderer: BoundingBoxRenderer;
  70182. /** @hidden (Backing field) */
  70183. _forceShowBoundingBoxes: boolean;
  70184. /**
  70185. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70186. */
  70187. forceShowBoundingBoxes: boolean;
  70188. /**
  70189. * Gets the bounding box renderer associated with the scene
  70190. * @returns a BoundingBoxRenderer
  70191. */
  70192. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70193. }
  70194. }
  70195. module "babylonjs/Meshes/abstractMesh" {
  70196. interface AbstractMesh {
  70197. /** @hidden (Backing field) */
  70198. _showBoundingBox: boolean;
  70199. /**
  70200. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70201. */
  70202. showBoundingBox: boolean;
  70203. }
  70204. }
  70205. /**
  70206. * Component responsible of rendering the bounding box of the meshes in a scene.
  70207. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70208. */
  70209. export class BoundingBoxRenderer implements ISceneComponent {
  70210. /**
  70211. * The component name helpfull to identify the component in the list of scene components.
  70212. */
  70213. readonly name: string;
  70214. /**
  70215. * The scene the component belongs to.
  70216. */
  70217. scene: Scene;
  70218. /**
  70219. * Color of the bounding box lines placed in front of an object
  70220. */
  70221. frontColor: Color3;
  70222. /**
  70223. * Color of the bounding box lines placed behind an object
  70224. */
  70225. backColor: Color3;
  70226. /**
  70227. * Defines if the renderer should show the back lines or not
  70228. */
  70229. showBackLines: boolean;
  70230. /**
  70231. * @hidden
  70232. */
  70233. renderList: SmartArray<BoundingBox>;
  70234. private _colorShader;
  70235. private _vertexBuffers;
  70236. private _indexBuffer;
  70237. private _fillIndexBuffer;
  70238. private _fillIndexData;
  70239. /**
  70240. * Instantiates a new bounding box renderer in a scene.
  70241. * @param scene the scene the renderer renders in
  70242. */
  70243. constructor(scene: Scene);
  70244. /**
  70245. * Registers the component in a given scene
  70246. */
  70247. register(): void;
  70248. private _evaluateSubMesh;
  70249. private _activeMesh;
  70250. private _prepareRessources;
  70251. private _createIndexBuffer;
  70252. /**
  70253. * Rebuilds the elements related to this component in case of
  70254. * context lost for instance.
  70255. */
  70256. rebuild(): void;
  70257. /**
  70258. * @hidden
  70259. */
  70260. reset(): void;
  70261. /**
  70262. * Render the bounding boxes of a specific rendering group
  70263. * @param renderingGroupId defines the rendering group to render
  70264. */
  70265. render(renderingGroupId: number): void;
  70266. /**
  70267. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70268. * @param mesh Define the mesh to render the occlusion bounding box for
  70269. */
  70270. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70271. /**
  70272. * Dispose and release the resources attached to this renderer.
  70273. */
  70274. dispose(): void;
  70275. }
  70276. }
  70277. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70278. import { Nullable } from "babylonjs/types";
  70279. import { Scene } from "babylonjs/scene";
  70280. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70281. import { Camera } from "babylonjs/Cameras/camera";
  70282. import { ISceneComponent } from "babylonjs/sceneComponent";
  70283. module "babylonjs/scene" {
  70284. interface Scene {
  70285. /** @hidden (Backing field) */
  70286. _depthRenderer: {
  70287. [id: string]: DepthRenderer;
  70288. };
  70289. /**
  70290. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70291. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70292. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70293. * @returns the created depth renderer
  70294. */
  70295. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70296. /**
  70297. * Disables a depth renderer for a given camera
  70298. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70299. */
  70300. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70301. }
  70302. }
  70303. /**
  70304. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70305. * in several rendering techniques.
  70306. */
  70307. export class DepthRendererSceneComponent implements ISceneComponent {
  70308. /**
  70309. * The component name helpfull to identify the component in the list of scene components.
  70310. */
  70311. readonly name: string;
  70312. /**
  70313. * The scene the component belongs to.
  70314. */
  70315. scene: Scene;
  70316. /**
  70317. * Creates a new instance of the component for the given scene
  70318. * @param scene Defines the scene to register the component in
  70319. */
  70320. constructor(scene: Scene);
  70321. /**
  70322. * Registers the component in a given scene
  70323. */
  70324. register(): void;
  70325. /**
  70326. * Rebuilds the elements related to this component in case of
  70327. * context lost for instance.
  70328. */
  70329. rebuild(): void;
  70330. /**
  70331. * Disposes the component and the associated ressources
  70332. */
  70333. dispose(): void;
  70334. private _gatherRenderTargets;
  70335. private _gatherActiveCameraRenderTargets;
  70336. }
  70337. }
  70338. declare module "babylonjs/Shaders/outline.fragment" {
  70339. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70340. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70341. /** @hidden */
  70342. export var outlinePixelShader: {
  70343. name: string;
  70344. shader: string;
  70345. };
  70346. }
  70347. declare module "babylonjs/Shaders/outline.vertex" {
  70348. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70349. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70350. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70351. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70352. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70353. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70354. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70355. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70356. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70357. /** @hidden */
  70358. export var outlineVertexShader: {
  70359. name: string;
  70360. shader: string;
  70361. };
  70362. }
  70363. declare module "babylonjs/Rendering/outlineRenderer" {
  70364. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70365. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70366. import { Scene } from "babylonjs/scene";
  70367. import { ISceneComponent } from "babylonjs/sceneComponent";
  70368. import "babylonjs/Shaders/outline.fragment";
  70369. import "babylonjs/Shaders/outline.vertex";
  70370. module "babylonjs/scene" {
  70371. interface Scene {
  70372. /** @hidden */
  70373. _outlineRenderer: OutlineRenderer;
  70374. /**
  70375. * Gets the outline renderer associated with the scene
  70376. * @returns a OutlineRenderer
  70377. */
  70378. getOutlineRenderer(): OutlineRenderer;
  70379. }
  70380. }
  70381. module "babylonjs/Meshes/abstractMesh" {
  70382. interface AbstractMesh {
  70383. /** @hidden (Backing field) */
  70384. _renderOutline: boolean;
  70385. /**
  70386. * Gets or sets a boolean indicating if the outline must be rendered as well
  70387. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70388. */
  70389. renderOutline: boolean;
  70390. /** @hidden (Backing field) */
  70391. _renderOverlay: boolean;
  70392. /**
  70393. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70394. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70395. */
  70396. renderOverlay: boolean;
  70397. }
  70398. }
  70399. /**
  70400. * This class is responsible to draw bothe outline/overlay of meshes.
  70401. * It should not be used directly but through the available method on mesh.
  70402. */
  70403. export class OutlineRenderer implements ISceneComponent {
  70404. /**
  70405. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70406. */
  70407. private static _StencilReference;
  70408. /**
  70409. * The name of the component. Each component must have a unique name.
  70410. */
  70411. name: string;
  70412. /**
  70413. * The scene the component belongs to.
  70414. */
  70415. scene: Scene;
  70416. /**
  70417. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70418. */
  70419. zOffset: number;
  70420. private _engine;
  70421. private _effect;
  70422. private _cachedDefines;
  70423. private _savedDepthWrite;
  70424. /**
  70425. * Instantiates a new outline renderer. (There could be only one per scene).
  70426. * @param scene Defines the scene it belongs to
  70427. */
  70428. constructor(scene: Scene);
  70429. /**
  70430. * Register the component to one instance of a scene.
  70431. */
  70432. register(): void;
  70433. /**
  70434. * Rebuilds the elements related to this component in case of
  70435. * context lost for instance.
  70436. */
  70437. rebuild(): void;
  70438. /**
  70439. * Disposes the component and the associated ressources.
  70440. */
  70441. dispose(): void;
  70442. /**
  70443. * Renders the outline in the canvas.
  70444. * @param subMesh Defines the sumesh to render
  70445. * @param batch Defines the batch of meshes in case of instances
  70446. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70447. */
  70448. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70449. /**
  70450. * Returns whether or not the outline renderer is ready for a given submesh.
  70451. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70452. * @param subMesh Defines the submesh to check readyness for
  70453. * @param useInstances Defines wheter wee are trying to render instances or not
  70454. * @returns true if ready otherwise false
  70455. */
  70456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70457. private _beforeRenderingMesh;
  70458. private _afterRenderingMesh;
  70459. }
  70460. }
  70461. declare module "babylonjs/Rendering/index" {
  70462. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70463. export * from "babylonjs/Rendering/depthRenderer";
  70464. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70465. export * from "babylonjs/Rendering/edgesRenderer";
  70466. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70467. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70468. export * from "babylonjs/Rendering/outlineRenderer";
  70469. export * from "babylonjs/Rendering/renderingGroup";
  70470. export * from "babylonjs/Rendering/renderingManager";
  70471. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70472. }
  70473. declare module "babylonjs/Sprites/ISprites" {
  70474. /**
  70475. * Defines the basic options interface of a Sprite Frame Source Size.
  70476. */
  70477. export interface ISpriteJSONSpriteSourceSize {
  70478. /**
  70479. * number of the original width of the Frame
  70480. */
  70481. w: number;
  70482. /**
  70483. * number of the original height of the Frame
  70484. */
  70485. h: number;
  70486. }
  70487. /**
  70488. * Defines the basic options interface of a Sprite Frame Data.
  70489. */
  70490. export interface ISpriteJSONSpriteFrameData {
  70491. /**
  70492. * number of the x offset of the Frame
  70493. */
  70494. x: number;
  70495. /**
  70496. * number of the y offset of the Frame
  70497. */
  70498. y: number;
  70499. /**
  70500. * number of the width of the Frame
  70501. */
  70502. w: number;
  70503. /**
  70504. * number of the height of the Frame
  70505. */
  70506. h: number;
  70507. }
  70508. /**
  70509. * Defines the basic options interface of a JSON Sprite.
  70510. */
  70511. export interface ISpriteJSONSprite {
  70512. /**
  70513. * string name of the Frame
  70514. */
  70515. filename: string;
  70516. /**
  70517. * ISpriteJSONSpriteFrame basic object of the frame data
  70518. */
  70519. frame: ISpriteJSONSpriteFrameData;
  70520. /**
  70521. * boolean to flag is the frame was rotated.
  70522. */
  70523. rotated: boolean;
  70524. /**
  70525. * boolean to flag is the frame was trimmed.
  70526. */
  70527. trimmed: boolean;
  70528. /**
  70529. * ISpriteJSONSpriteFrame basic object of the source data
  70530. */
  70531. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70532. /**
  70533. * ISpriteJSONSpriteFrame basic object of the source data
  70534. */
  70535. sourceSize: ISpriteJSONSpriteSourceSize;
  70536. }
  70537. /**
  70538. * Defines the basic options interface of a JSON atlas.
  70539. */
  70540. export interface ISpriteJSONAtlas {
  70541. /**
  70542. * Array of objects that contain the frame data.
  70543. */
  70544. frames: Array<ISpriteJSONSprite>;
  70545. /**
  70546. * object basic object containing the sprite meta data.
  70547. */
  70548. meta?: object;
  70549. }
  70550. }
  70551. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70552. /** @hidden */
  70553. export var spriteMapPixelShader: {
  70554. name: string;
  70555. shader: string;
  70556. };
  70557. }
  70558. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70559. /** @hidden */
  70560. export var spriteMapVertexShader: {
  70561. name: string;
  70562. shader: string;
  70563. };
  70564. }
  70565. declare module "babylonjs/Sprites/spriteMap" {
  70566. import { IDisposable, Scene } from "babylonjs/scene";
  70567. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70568. import { Texture } from "babylonjs/Materials/Textures/texture";
  70569. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70570. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70571. import "babylonjs/Meshes/Builders/planeBuilder";
  70572. import "babylonjs/Shaders/spriteMap.fragment";
  70573. import "babylonjs/Shaders/spriteMap.vertex";
  70574. /**
  70575. * Defines the basic options interface of a SpriteMap
  70576. */
  70577. export interface ISpriteMapOptions {
  70578. /**
  70579. * Vector2 of the number of cells in the grid.
  70580. */
  70581. stageSize?: Vector2;
  70582. /**
  70583. * Vector2 of the size of the output plane in World Units.
  70584. */
  70585. outputSize?: Vector2;
  70586. /**
  70587. * Vector3 of the position of the output plane in World Units.
  70588. */
  70589. outputPosition?: Vector3;
  70590. /**
  70591. * Vector3 of the rotation of the output plane.
  70592. */
  70593. outputRotation?: Vector3;
  70594. /**
  70595. * number of layers that the system will reserve in resources.
  70596. */
  70597. layerCount?: number;
  70598. /**
  70599. * number of max animation frames a single cell will reserve in resources.
  70600. */
  70601. maxAnimationFrames?: number;
  70602. /**
  70603. * number cell index of the base tile when the system compiles.
  70604. */
  70605. baseTile?: number;
  70606. /**
  70607. * boolean flip the sprite after its been repositioned by the framing data.
  70608. */
  70609. flipU?: boolean;
  70610. /**
  70611. * Vector3 scalar of the global RGB values of the SpriteMap.
  70612. */
  70613. colorMultiply?: Vector3;
  70614. }
  70615. /**
  70616. * Defines the IDisposable interface in order to be cleanable from resources.
  70617. */
  70618. export interface ISpriteMap extends IDisposable {
  70619. /**
  70620. * String name of the SpriteMap.
  70621. */
  70622. name: string;
  70623. /**
  70624. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70625. */
  70626. atlasJSON: ISpriteJSONAtlas;
  70627. /**
  70628. * Texture of the SpriteMap.
  70629. */
  70630. spriteSheet: Texture;
  70631. /**
  70632. * The parameters to initialize the SpriteMap with.
  70633. */
  70634. options: ISpriteMapOptions;
  70635. }
  70636. /**
  70637. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70638. */
  70639. export class SpriteMap implements ISpriteMap {
  70640. /** The Name of the spriteMap */
  70641. name: string;
  70642. /** The JSON file with the frame and meta data */
  70643. atlasJSON: ISpriteJSONAtlas;
  70644. /** The systems Sprite Sheet Texture */
  70645. spriteSheet: Texture;
  70646. /** Arguments passed with the Constructor */
  70647. options: ISpriteMapOptions;
  70648. /** Public Sprite Storage array, parsed from atlasJSON */
  70649. sprites: Array<ISpriteJSONSprite>;
  70650. /** Returns the Number of Sprites in the System */
  70651. get spriteCount(): number;
  70652. /** Returns the Position of Output Plane*/
  70653. get position(): Vector3;
  70654. /** Returns the Position of Output Plane*/
  70655. set position(v: Vector3);
  70656. /** Returns the Rotation of Output Plane*/
  70657. get rotation(): Vector3;
  70658. /** Returns the Rotation of Output Plane*/
  70659. set rotation(v: Vector3);
  70660. /** Sets the AnimationMap*/
  70661. get animationMap(): RawTexture;
  70662. /** Sets the AnimationMap*/
  70663. set animationMap(v: RawTexture);
  70664. /** Scene that the SpriteMap was created in */
  70665. private _scene;
  70666. /** Texture Buffer of Float32 that holds tile frame data*/
  70667. private _frameMap;
  70668. /** Texture Buffers of Float32 that holds tileMap data*/
  70669. private _tileMaps;
  70670. /** Texture Buffer of Float32 that holds Animation Data*/
  70671. private _animationMap;
  70672. /** Custom ShaderMaterial Central to the System*/
  70673. private _material;
  70674. /** Custom ShaderMaterial Central to the System*/
  70675. private _output;
  70676. /** Systems Time Ticker*/
  70677. private _time;
  70678. /**
  70679. * Creates a new SpriteMap
  70680. * @param name defines the SpriteMaps Name
  70681. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70682. * @param spriteSheet is the Texture that the Sprites are on.
  70683. * @param options a basic deployment configuration
  70684. * @param scene The Scene that the map is deployed on
  70685. */
  70686. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70687. /**
  70688. * Returns tileID location
  70689. * @returns Vector2 the cell position ID
  70690. */
  70691. getTileID(): Vector2;
  70692. /**
  70693. * Gets the UV location of the mouse over the SpriteMap.
  70694. * @returns Vector2 the UV position of the mouse interaction
  70695. */
  70696. getMousePosition(): Vector2;
  70697. /**
  70698. * Creates the "frame" texture Buffer
  70699. * -------------------------------------
  70700. * Structure of frames
  70701. * "filename": "Falling-Water-2.png",
  70702. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70703. * "rotated": true,
  70704. * "trimmed": true,
  70705. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70706. * "sourceSize": {"w":32,"h":32}
  70707. * @returns RawTexture of the frameMap
  70708. */
  70709. private _createFrameBuffer;
  70710. /**
  70711. * Creates the tileMap texture Buffer
  70712. * @param buffer normally and array of numbers, or a false to generate from scratch
  70713. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70714. * @returns RawTexture of the tileMap
  70715. */
  70716. private _createTileBuffer;
  70717. /**
  70718. * Modifies the data of the tileMaps
  70719. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70720. * @param pos is the iVector2 Coordinates of the Tile
  70721. * @param tile The SpriteIndex of the new Tile
  70722. */
  70723. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70724. /**
  70725. * Creates the animationMap texture Buffer
  70726. * @param buffer normally and array of numbers, or a false to generate from scratch
  70727. * @returns RawTexture of the animationMap
  70728. */
  70729. private _createTileAnimationBuffer;
  70730. /**
  70731. * Modifies the data of the animationMap
  70732. * @param cellID is the Index of the Sprite
  70733. * @param _frame is the target Animation frame
  70734. * @param toCell is the Target Index of the next frame of the animation
  70735. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70736. * @param speed is a global scalar of the time variable on the map.
  70737. */
  70738. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70739. /**
  70740. * Exports the .tilemaps file
  70741. */
  70742. saveTileMaps(): void;
  70743. /**
  70744. * Imports the .tilemaps file
  70745. * @param url of the .tilemaps file
  70746. */
  70747. loadTileMaps(url: string): void;
  70748. /**
  70749. * Release associated resources
  70750. */
  70751. dispose(): void;
  70752. }
  70753. }
  70754. declare module "babylonjs/Sprites/spritePackedManager" {
  70755. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70756. import { Scene } from "babylonjs/scene";
  70757. /**
  70758. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70759. * @see http://doc.babylonjs.com/babylon101/sprites
  70760. */
  70761. export class SpritePackedManager extends SpriteManager {
  70762. /** defines the packed manager's name */
  70763. name: string;
  70764. /**
  70765. * Creates a new sprite manager from a packed sprite sheet
  70766. * @param name defines the manager's name
  70767. * @param imgUrl defines the sprite sheet url
  70768. * @param capacity defines the maximum allowed number of sprites
  70769. * @param scene defines the hosting scene
  70770. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70771. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70772. * @param samplingMode defines the smapling mode to use with spritesheet
  70773. * @param fromPacked set to true; do not alter
  70774. */
  70775. constructor(
  70776. /** defines the packed manager's name */
  70777. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70778. }
  70779. }
  70780. declare module "babylonjs/Sprites/index" {
  70781. export * from "babylonjs/Sprites/sprite";
  70782. export * from "babylonjs/Sprites/ISprites";
  70783. export * from "babylonjs/Sprites/spriteManager";
  70784. export * from "babylonjs/Sprites/spriteMap";
  70785. export * from "babylonjs/Sprites/spritePackedManager";
  70786. export * from "babylonjs/Sprites/spriteSceneComponent";
  70787. }
  70788. declare module "babylonjs/States/index" {
  70789. export * from "babylonjs/States/alphaCullingState";
  70790. export * from "babylonjs/States/depthCullingState";
  70791. export * from "babylonjs/States/stencilState";
  70792. }
  70793. declare module "babylonjs/Misc/assetsManager" {
  70794. import { Scene } from "babylonjs/scene";
  70795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70796. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70797. import { Skeleton } from "babylonjs/Bones/skeleton";
  70798. import { Observable } from "babylonjs/Misc/observable";
  70799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70800. import { Texture } from "babylonjs/Materials/Textures/texture";
  70801. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70802. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70803. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70804. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70805. /**
  70806. * Defines the list of states available for a task inside a AssetsManager
  70807. */
  70808. export enum AssetTaskState {
  70809. /**
  70810. * Initialization
  70811. */
  70812. INIT = 0,
  70813. /**
  70814. * Running
  70815. */
  70816. RUNNING = 1,
  70817. /**
  70818. * Done
  70819. */
  70820. DONE = 2,
  70821. /**
  70822. * Error
  70823. */
  70824. ERROR = 3
  70825. }
  70826. /**
  70827. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70828. */
  70829. export abstract class AbstractAssetTask {
  70830. /**
  70831. * Task name
  70832. */ name: string;
  70833. /**
  70834. * Callback called when the task is successful
  70835. */
  70836. onSuccess: (task: any) => void;
  70837. /**
  70838. * Callback called when the task is not successful
  70839. */
  70840. onError: (task: any, message?: string, exception?: any) => void;
  70841. /**
  70842. * Creates a new AssetsManager
  70843. * @param name defines the name of the task
  70844. */
  70845. constructor(
  70846. /**
  70847. * Task name
  70848. */ name: string);
  70849. private _isCompleted;
  70850. private _taskState;
  70851. private _errorObject;
  70852. /**
  70853. * Get if the task is completed
  70854. */
  70855. get isCompleted(): boolean;
  70856. /**
  70857. * Gets the current state of the task
  70858. */
  70859. get taskState(): AssetTaskState;
  70860. /**
  70861. * Gets the current error object (if task is in error)
  70862. */
  70863. get errorObject(): {
  70864. message?: string;
  70865. exception?: any;
  70866. };
  70867. /**
  70868. * Internal only
  70869. * @hidden
  70870. */
  70871. _setErrorObject(message?: string, exception?: any): void;
  70872. /**
  70873. * Execute the current task
  70874. * @param scene defines the scene where you want your assets to be loaded
  70875. * @param onSuccess is a callback called when the task is successfully executed
  70876. * @param onError is a callback called if an error occurs
  70877. */
  70878. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70879. /**
  70880. * Execute the current task
  70881. * @param scene defines the scene where you want your assets to be loaded
  70882. * @param onSuccess is a callback called when the task is successfully executed
  70883. * @param onError is a callback called if an error occurs
  70884. */
  70885. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70886. /**
  70887. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70888. * This can be used with failed tasks that have the reason for failure fixed.
  70889. */
  70890. reset(): void;
  70891. private onErrorCallback;
  70892. private onDoneCallback;
  70893. }
  70894. /**
  70895. * Define the interface used by progress events raised during assets loading
  70896. */
  70897. export interface IAssetsProgressEvent {
  70898. /**
  70899. * Defines the number of remaining tasks to process
  70900. */
  70901. remainingCount: number;
  70902. /**
  70903. * Defines the total number of tasks
  70904. */
  70905. totalCount: number;
  70906. /**
  70907. * Defines the task that was just processed
  70908. */
  70909. task: AbstractAssetTask;
  70910. }
  70911. /**
  70912. * Class used to share progress information about assets loading
  70913. */
  70914. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70915. /**
  70916. * Defines the number of remaining tasks to process
  70917. */
  70918. remainingCount: number;
  70919. /**
  70920. * Defines the total number of tasks
  70921. */
  70922. totalCount: number;
  70923. /**
  70924. * Defines the task that was just processed
  70925. */
  70926. task: AbstractAssetTask;
  70927. /**
  70928. * Creates a AssetsProgressEvent
  70929. * @param remainingCount defines the number of remaining tasks to process
  70930. * @param totalCount defines the total number of tasks
  70931. * @param task defines the task that was just processed
  70932. */
  70933. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70934. }
  70935. /**
  70936. * Define a task used by AssetsManager to load meshes
  70937. */
  70938. export class MeshAssetTask extends AbstractAssetTask {
  70939. /**
  70940. * Defines the name of the task
  70941. */
  70942. name: string;
  70943. /**
  70944. * Defines the list of mesh's names you want to load
  70945. */
  70946. meshesNames: any;
  70947. /**
  70948. * Defines the root url to use as a base to load your meshes and associated resources
  70949. */
  70950. rootUrl: string;
  70951. /**
  70952. * Defines the filename of the scene to load from
  70953. */
  70954. sceneFilename: string;
  70955. /**
  70956. * Gets the list of loaded meshes
  70957. */
  70958. loadedMeshes: Array<AbstractMesh>;
  70959. /**
  70960. * Gets the list of loaded particle systems
  70961. */
  70962. loadedParticleSystems: Array<IParticleSystem>;
  70963. /**
  70964. * Gets the list of loaded skeletons
  70965. */
  70966. loadedSkeletons: Array<Skeleton>;
  70967. /**
  70968. * Gets the list of loaded animation groups
  70969. */
  70970. loadedAnimationGroups: Array<AnimationGroup>;
  70971. /**
  70972. * Callback called when the task is successful
  70973. */
  70974. onSuccess: (task: MeshAssetTask) => void;
  70975. /**
  70976. * Callback called when the task is successful
  70977. */
  70978. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70979. /**
  70980. * Creates a new MeshAssetTask
  70981. * @param name defines the name of the task
  70982. * @param meshesNames defines the list of mesh's names you want to load
  70983. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70984. * @param sceneFilename defines the filename of the scene to load from
  70985. */
  70986. constructor(
  70987. /**
  70988. * Defines the name of the task
  70989. */
  70990. name: string,
  70991. /**
  70992. * Defines the list of mesh's names you want to load
  70993. */
  70994. meshesNames: any,
  70995. /**
  70996. * Defines the root url to use as a base to load your meshes and associated resources
  70997. */
  70998. rootUrl: string,
  70999. /**
  71000. * Defines the filename of the scene to load from
  71001. */
  71002. sceneFilename: string);
  71003. /**
  71004. * Execute the current task
  71005. * @param scene defines the scene where you want your assets to be loaded
  71006. * @param onSuccess is a callback called when the task is successfully executed
  71007. * @param onError is a callback called if an error occurs
  71008. */
  71009. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71010. }
  71011. /**
  71012. * Define a task used by AssetsManager to load text content
  71013. */
  71014. export class TextFileAssetTask extends AbstractAssetTask {
  71015. /**
  71016. * Defines the name of the task
  71017. */
  71018. name: string;
  71019. /**
  71020. * Defines the location of the file to load
  71021. */
  71022. url: string;
  71023. /**
  71024. * Gets the loaded text string
  71025. */
  71026. text: string;
  71027. /**
  71028. * Callback called when the task is successful
  71029. */
  71030. onSuccess: (task: TextFileAssetTask) => void;
  71031. /**
  71032. * Callback called when the task is successful
  71033. */
  71034. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71035. /**
  71036. * Creates a new TextFileAssetTask object
  71037. * @param name defines the name of the task
  71038. * @param url defines the location of the file to load
  71039. */
  71040. constructor(
  71041. /**
  71042. * Defines the name of the task
  71043. */
  71044. name: string,
  71045. /**
  71046. * Defines the location of the file to load
  71047. */
  71048. url: string);
  71049. /**
  71050. * Execute the current task
  71051. * @param scene defines the scene where you want your assets to be loaded
  71052. * @param onSuccess is a callback called when the task is successfully executed
  71053. * @param onError is a callback called if an error occurs
  71054. */
  71055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71056. }
  71057. /**
  71058. * Define a task used by AssetsManager to load binary data
  71059. */
  71060. export class BinaryFileAssetTask extends AbstractAssetTask {
  71061. /**
  71062. * Defines the name of the task
  71063. */
  71064. name: string;
  71065. /**
  71066. * Defines the location of the file to load
  71067. */
  71068. url: string;
  71069. /**
  71070. * Gets the lodaded data (as an array buffer)
  71071. */
  71072. data: ArrayBuffer;
  71073. /**
  71074. * Callback called when the task is successful
  71075. */
  71076. onSuccess: (task: BinaryFileAssetTask) => void;
  71077. /**
  71078. * Callback called when the task is successful
  71079. */
  71080. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71081. /**
  71082. * Creates a new BinaryFileAssetTask object
  71083. * @param name defines the name of the new task
  71084. * @param url defines the location of the file to load
  71085. */
  71086. constructor(
  71087. /**
  71088. * Defines the name of the task
  71089. */
  71090. name: string,
  71091. /**
  71092. * Defines the location of the file to load
  71093. */
  71094. url: string);
  71095. /**
  71096. * Execute the current task
  71097. * @param scene defines the scene where you want your assets to be loaded
  71098. * @param onSuccess is a callback called when the task is successfully executed
  71099. * @param onError is a callback called if an error occurs
  71100. */
  71101. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71102. }
  71103. /**
  71104. * Define a task used by AssetsManager to load images
  71105. */
  71106. export class ImageAssetTask extends AbstractAssetTask {
  71107. /**
  71108. * Defines the name of the task
  71109. */
  71110. name: string;
  71111. /**
  71112. * Defines the location of the image to load
  71113. */
  71114. url: string;
  71115. /**
  71116. * Gets the loaded images
  71117. */
  71118. image: HTMLImageElement;
  71119. /**
  71120. * Callback called when the task is successful
  71121. */
  71122. onSuccess: (task: ImageAssetTask) => void;
  71123. /**
  71124. * Callback called when the task is successful
  71125. */
  71126. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71127. /**
  71128. * Creates a new ImageAssetTask
  71129. * @param name defines the name of the task
  71130. * @param url defines the location of the image to load
  71131. */
  71132. constructor(
  71133. /**
  71134. * Defines the name of the task
  71135. */
  71136. name: string,
  71137. /**
  71138. * Defines the location of the image to load
  71139. */
  71140. url: string);
  71141. /**
  71142. * Execute the current task
  71143. * @param scene defines the scene where you want your assets to be loaded
  71144. * @param onSuccess is a callback called when the task is successfully executed
  71145. * @param onError is a callback called if an error occurs
  71146. */
  71147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71148. }
  71149. /**
  71150. * Defines the interface used by texture loading tasks
  71151. */
  71152. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71153. /**
  71154. * Gets the loaded texture
  71155. */
  71156. texture: TEX;
  71157. }
  71158. /**
  71159. * Define a task used by AssetsManager to load 2D textures
  71160. */
  71161. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71162. /**
  71163. * Defines the name of the task
  71164. */
  71165. name: string;
  71166. /**
  71167. * Defines the location of the file to load
  71168. */
  71169. url: string;
  71170. /**
  71171. * Defines if mipmap should not be generated (default is false)
  71172. */
  71173. noMipmap?: boolean | undefined;
  71174. /**
  71175. * Defines if texture must be inverted on Y axis (default is false)
  71176. */
  71177. invertY?: boolean | undefined;
  71178. /**
  71179. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71180. */
  71181. samplingMode: number;
  71182. /**
  71183. * Gets the loaded texture
  71184. */
  71185. texture: Texture;
  71186. /**
  71187. * Callback called when the task is successful
  71188. */
  71189. onSuccess: (task: TextureAssetTask) => void;
  71190. /**
  71191. * Callback called when the task is successful
  71192. */
  71193. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71194. /**
  71195. * Creates a new TextureAssetTask object
  71196. * @param name defines the name of the task
  71197. * @param url defines the location of the file to load
  71198. * @param noMipmap defines if mipmap should not be generated (default is false)
  71199. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71200. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71201. */
  71202. constructor(
  71203. /**
  71204. * Defines the name of the task
  71205. */
  71206. name: string,
  71207. /**
  71208. * Defines the location of the file to load
  71209. */
  71210. url: string,
  71211. /**
  71212. * Defines if mipmap should not be generated (default is false)
  71213. */
  71214. noMipmap?: boolean | undefined,
  71215. /**
  71216. * Defines if texture must be inverted on Y axis (default is false)
  71217. */
  71218. invertY?: boolean | undefined,
  71219. /**
  71220. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71221. */
  71222. samplingMode?: number);
  71223. /**
  71224. * Execute the current task
  71225. * @param scene defines the scene where you want your assets to be loaded
  71226. * @param onSuccess is a callback called when the task is successfully executed
  71227. * @param onError is a callback called if an error occurs
  71228. */
  71229. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71230. }
  71231. /**
  71232. * Define a task used by AssetsManager to load cube textures
  71233. */
  71234. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71235. /**
  71236. * Defines the name of the task
  71237. */
  71238. name: string;
  71239. /**
  71240. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71241. */
  71242. url: string;
  71243. /**
  71244. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71245. */
  71246. extensions?: string[] | undefined;
  71247. /**
  71248. * Defines if mipmaps should not be generated (default is false)
  71249. */
  71250. noMipmap?: boolean | undefined;
  71251. /**
  71252. * Defines the explicit list of files (undefined by default)
  71253. */
  71254. files?: string[] | undefined;
  71255. /**
  71256. * Gets the loaded texture
  71257. */
  71258. texture: CubeTexture;
  71259. /**
  71260. * Callback called when the task is successful
  71261. */
  71262. onSuccess: (task: CubeTextureAssetTask) => void;
  71263. /**
  71264. * Callback called when the task is successful
  71265. */
  71266. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71267. /**
  71268. * Creates a new CubeTextureAssetTask
  71269. * @param name defines the name of the task
  71270. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71271. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71272. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71273. * @param files defines the explicit list of files (undefined by default)
  71274. */
  71275. constructor(
  71276. /**
  71277. * Defines the name of the task
  71278. */
  71279. name: string,
  71280. /**
  71281. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71282. */
  71283. url: string,
  71284. /**
  71285. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71286. */
  71287. extensions?: string[] | undefined,
  71288. /**
  71289. * Defines if mipmaps should not be generated (default is false)
  71290. */
  71291. noMipmap?: boolean | undefined,
  71292. /**
  71293. * Defines the explicit list of files (undefined by default)
  71294. */
  71295. files?: string[] | undefined);
  71296. /**
  71297. * Execute the current task
  71298. * @param scene defines the scene where you want your assets to be loaded
  71299. * @param onSuccess is a callback called when the task is successfully executed
  71300. * @param onError is a callback called if an error occurs
  71301. */
  71302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71303. }
  71304. /**
  71305. * Define a task used by AssetsManager to load HDR cube textures
  71306. */
  71307. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71308. /**
  71309. * Defines the name of the task
  71310. */
  71311. name: string;
  71312. /**
  71313. * Defines the location of the file to load
  71314. */
  71315. url: string;
  71316. /**
  71317. * Defines the desired size (the more it increases the longer the generation will be)
  71318. */
  71319. size: number;
  71320. /**
  71321. * Defines if mipmaps should not be generated (default is false)
  71322. */
  71323. noMipmap: boolean;
  71324. /**
  71325. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71326. */
  71327. generateHarmonics: boolean;
  71328. /**
  71329. * 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)
  71330. */
  71331. gammaSpace: boolean;
  71332. /**
  71333. * Internal Use Only
  71334. */
  71335. reserved: boolean;
  71336. /**
  71337. * Gets the loaded texture
  71338. */
  71339. texture: HDRCubeTexture;
  71340. /**
  71341. * Callback called when the task is successful
  71342. */
  71343. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71344. /**
  71345. * Callback called when the task is successful
  71346. */
  71347. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71348. /**
  71349. * Creates a new HDRCubeTextureAssetTask object
  71350. * @param name defines the name of the task
  71351. * @param url defines the location of the file to load
  71352. * @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.
  71353. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71354. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71355. * @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)
  71356. * @param reserved Internal use only
  71357. */
  71358. constructor(
  71359. /**
  71360. * Defines the name of the task
  71361. */
  71362. name: string,
  71363. /**
  71364. * Defines the location of the file to load
  71365. */
  71366. url: string,
  71367. /**
  71368. * Defines the desired size (the more it increases the longer the generation will be)
  71369. */
  71370. size: number,
  71371. /**
  71372. * Defines if mipmaps should not be generated (default is false)
  71373. */
  71374. noMipmap?: boolean,
  71375. /**
  71376. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71377. */
  71378. generateHarmonics?: boolean,
  71379. /**
  71380. * 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)
  71381. */
  71382. gammaSpace?: boolean,
  71383. /**
  71384. * Internal Use Only
  71385. */
  71386. reserved?: boolean);
  71387. /**
  71388. * Execute the current task
  71389. * @param scene defines the scene where you want your assets to be loaded
  71390. * @param onSuccess is a callback called when the task is successfully executed
  71391. * @param onError is a callback called if an error occurs
  71392. */
  71393. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71394. }
  71395. /**
  71396. * Define a task used by AssetsManager to load Equirectangular cube textures
  71397. */
  71398. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71399. /**
  71400. * Defines the name of the task
  71401. */
  71402. name: string;
  71403. /**
  71404. * Defines the location of the file to load
  71405. */
  71406. url: string;
  71407. /**
  71408. * Defines the desired size (the more it increases the longer the generation will be)
  71409. */
  71410. size: number;
  71411. /**
  71412. * Defines if mipmaps should not be generated (default is false)
  71413. */
  71414. noMipmap: boolean;
  71415. /**
  71416. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71417. * but the standard material would require them in Gamma space) (default is true)
  71418. */
  71419. gammaSpace: boolean;
  71420. /**
  71421. * Gets the loaded texture
  71422. */
  71423. texture: EquiRectangularCubeTexture;
  71424. /**
  71425. * Callback called when the task is successful
  71426. */
  71427. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71428. /**
  71429. * Callback called when the task is successful
  71430. */
  71431. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71432. /**
  71433. * Creates a new EquiRectangularCubeTextureAssetTask object
  71434. * @param name defines the name of the task
  71435. * @param url defines the location of the file to load
  71436. * @param size defines the desired size (the more it increases the longer the generation will be)
  71437. * If the size is omitted this implies you are using a preprocessed cubemap.
  71438. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71439. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71440. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71441. * (default is true)
  71442. */
  71443. constructor(
  71444. /**
  71445. * Defines the name of the task
  71446. */
  71447. name: string,
  71448. /**
  71449. * Defines the location of the file to load
  71450. */
  71451. url: string,
  71452. /**
  71453. * Defines the desired size (the more it increases the longer the generation will be)
  71454. */
  71455. size: number,
  71456. /**
  71457. * Defines if mipmaps should not be generated (default is false)
  71458. */
  71459. noMipmap?: boolean,
  71460. /**
  71461. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71462. * but the standard material would require them in Gamma space) (default is true)
  71463. */
  71464. gammaSpace?: boolean);
  71465. /**
  71466. * Execute the current task
  71467. * @param scene defines the scene where you want your assets to be loaded
  71468. * @param onSuccess is a callback called when the task is successfully executed
  71469. * @param onError is a callback called if an error occurs
  71470. */
  71471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71472. }
  71473. /**
  71474. * This class can be used to easily import assets into a scene
  71475. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71476. */
  71477. export class AssetsManager {
  71478. private _scene;
  71479. private _isLoading;
  71480. protected _tasks: AbstractAssetTask[];
  71481. protected _waitingTasksCount: number;
  71482. protected _totalTasksCount: number;
  71483. /**
  71484. * Callback called when all tasks are processed
  71485. */
  71486. onFinish: (tasks: AbstractAssetTask[]) => void;
  71487. /**
  71488. * Callback called when a task is successful
  71489. */
  71490. onTaskSuccess: (task: AbstractAssetTask) => void;
  71491. /**
  71492. * Callback called when a task had an error
  71493. */
  71494. onTaskError: (task: AbstractAssetTask) => void;
  71495. /**
  71496. * Callback called when a task is done (whatever the result is)
  71497. */
  71498. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71499. /**
  71500. * Observable called when all tasks are processed
  71501. */
  71502. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71503. /**
  71504. * Observable called when a task had an error
  71505. */
  71506. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71507. /**
  71508. * Observable called when all tasks were executed
  71509. */
  71510. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71511. /**
  71512. * Observable called when a task is done (whatever the result is)
  71513. */
  71514. onProgressObservable: Observable<IAssetsProgressEvent>;
  71515. /**
  71516. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71517. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71518. */
  71519. useDefaultLoadingScreen: boolean;
  71520. /**
  71521. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71522. * when all assets have been downloaded.
  71523. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71524. */
  71525. autoHideLoadingUI: boolean;
  71526. /**
  71527. * Creates a new AssetsManager
  71528. * @param scene defines the scene to work on
  71529. */
  71530. constructor(scene: Scene);
  71531. /**
  71532. * Add a MeshAssetTask to the list of active tasks
  71533. * @param taskName defines the name of the new task
  71534. * @param meshesNames defines the name of meshes to load
  71535. * @param rootUrl defines the root url to use to locate files
  71536. * @param sceneFilename defines the filename of the scene file
  71537. * @returns a new MeshAssetTask object
  71538. */
  71539. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71540. /**
  71541. * Add a TextFileAssetTask to the list of active tasks
  71542. * @param taskName defines the name of the new task
  71543. * @param url defines the url of the file to load
  71544. * @returns a new TextFileAssetTask object
  71545. */
  71546. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71547. /**
  71548. * Add a BinaryFileAssetTask to the list of active tasks
  71549. * @param taskName defines the name of the new task
  71550. * @param url defines the url of the file to load
  71551. * @returns a new BinaryFileAssetTask object
  71552. */
  71553. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71554. /**
  71555. * Add a ImageAssetTask to the list of active tasks
  71556. * @param taskName defines the name of the new task
  71557. * @param url defines the url of the file to load
  71558. * @returns a new ImageAssetTask object
  71559. */
  71560. addImageTask(taskName: string, url: string): ImageAssetTask;
  71561. /**
  71562. * Add a TextureAssetTask to the list of active tasks
  71563. * @param taskName defines the name of the new task
  71564. * @param url defines the url of the file to load
  71565. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71566. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71567. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71568. * @returns a new TextureAssetTask object
  71569. */
  71570. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71571. /**
  71572. * Add a CubeTextureAssetTask to the list of active tasks
  71573. * @param taskName defines the name of the new task
  71574. * @param url defines the url of the file to load
  71575. * @param extensions defines the extension to use to load the cube map (can be null)
  71576. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71577. * @param files defines the list of files to load (can be null)
  71578. * @returns a new CubeTextureAssetTask object
  71579. */
  71580. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71581. /**
  71582. *
  71583. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71584. * @param taskName defines the name of the new task
  71585. * @param url defines the url of the file to load
  71586. * @param size defines the size you want for the cubemap (can be null)
  71587. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71588. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71589. * @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)
  71590. * @param reserved Internal use only
  71591. * @returns a new HDRCubeTextureAssetTask object
  71592. */
  71593. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71594. /**
  71595. *
  71596. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71597. * @param taskName defines the name of the new task
  71598. * @param url defines the url of the file to load
  71599. * @param size defines the size you want for the cubemap (can be null)
  71600. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71601. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71602. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71603. * @returns a new EquiRectangularCubeTextureAssetTask object
  71604. */
  71605. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71606. /**
  71607. * Remove a task from the assets manager.
  71608. * @param task the task to remove
  71609. */
  71610. removeTask(task: AbstractAssetTask): void;
  71611. private _decreaseWaitingTasksCount;
  71612. private _runTask;
  71613. /**
  71614. * Reset the AssetsManager and remove all tasks
  71615. * @return the current instance of the AssetsManager
  71616. */
  71617. reset(): AssetsManager;
  71618. /**
  71619. * Start the loading process
  71620. * @return the current instance of the AssetsManager
  71621. */
  71622. load(): AssetsManager;
  71623. /**
  71624. * Start the loading process as an async operation
  71625. * @return a promise returning the list of failed tasks
  71626. */
  71627. loadAsync(): Promise<void>;
  71628. }
  71629. }
  71630. declare module "babylonjs/Misc/deferred" {
  71631. /**
  71632. * Wrapper class for promise with external resolve and reject.
  71633. */
  71634. export class Deferred<T> {
  71635. /**
  71636. * The promise associated with this deferred object.
  71637. */
  71638. readonly promise: Promise<T>;
  71639. private _resolve;
  71640. private _reject;
  71641. /**
  71642. * The resolve method of the promise associated with this deferred object.
  71643. */
  71644. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71645. /**
  71646. * The reject method of the promise associated with this deferred object.
  71647. */
  71648. get reject(): (reason?: any) => void;
  71649. /**
  71650. * Constructor for this deferred object.
  71651. */
  71652. constructor();
  71653. }
  71654. }
  71655. declare module "babylonjs/Misc/meshExploder" {
  71656. import { Mesh } from "babylonjs/Meshes/mesh";
  71657. /**
  71658. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71659. */
  71660. export class MeshExploder {
  71661. private _centerMesh;
  71662. private _meshes;
  71663. private _meshesOrigins;
  71664. private _toCenterVectors;
  71665. private _scaledDirection;
  71666. private _newPosition;
  71667. private _centerPosition;
  71668. /**
  71669. * Explodes meshes from a center mesh.
  71670. * @param meshes The meshes to explode.
  71671. * @param centerMesh The mesh to be center of explosion.
  71672. */
  71673. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71674. private _setCenterMesh;
  71675. /**
  71676. * Get class name
  71677. * @returns "MeshExploder"
  71678. */
  71679. getClassName(): string;
  71680. /**
  71681. * "Exploded meshes"
  71682. * @returns Array of meshes with the centerMesh at index 0.
  71683. */
  71684. getMeshes(): Array<Mesh>;
  71685. /**
  71686. * Explodes meshes giving a specific direction
  71687. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71688. */
  71689. explode(direction?: number): void;
  71690. }
  71691. }
  71692. declare module "babylonjs/Misc/filesInput" {
  71693. import { Engine } from "babylonjs/Engines/engine";
  71694. import { Scene } from "babylonjs/scene";
  71695. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71696. /**
  71697. * Class used to help managing file picking and drag'n'drop
  71698. */
  71699. export class FilesInput {
  71700. /**
  71701. * List of files ready to be loaded
  71702. */
  71703. static get FilesToLoad(): {
  71704. [key: string]: File;
  71705. };
  71706. /**
  71707. * Callback called when a file is processed
  71708. */
  71709. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71710. private _engine;
  71711. private _currentScene;
  71712. private _sceneLoadedCallback;
  71713. private _progressCallback;
  71714. private _additionalRenderLoopLogicCallback;
  71715. private _textureLoadingCallback;
  71716. private _startingProcessingFilesCallback;
  71717. private _onReloadCallback;
  71718. private _errorCallback;
  71719. private _elementToMonitor;
  71720. private _sceneFileToLoad;
  71721. private _filesToLoad;
  71722. /**
  71723. * Creates a new FilesInput
  71724. * @param engine defines the rendering engine
  71725. * @param scene defines the hosting scene
  71726. * @param sceneLoadedCallback callback called when scene is loaded
  71727. * @param progressCallback callback called to track progress
  71728. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71729. * @param textureLoadingCallback callback called when a texture is loading
  71730. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71731. * @param onReloadCallback callback called when a reload is requested
  71732. * @param errorCallback callback call if an error occurs
  71733. */
  71734. 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);
  71735. private _dragEnterHandler;
  71736. private _dragOverHandler;
  71737. private _dropHandler;
  71738. /**
  71739. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71740. * @param elementToMonitor defines the DOM element to track
  71741. */
  71742. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71743. /**
  71744. * Release all associated resources
  71745. */
  71746. dispose(): void;
  71747. private renderFunction;
  71748. private drag;
  71749. private drop;
  71750. private _traverseFolder;
  71751. private _processFiles;
  71752. /**
  71753. * Load files from a drop event
  71754. * @param event defines the drop event to use as source
  71755. */
  71756. loadFiles(event: any): void;
  71757. private _processReload;
  71758. /**
  71759. * Reload the current scene from the loaded files
  71760. */
  71761. reload(): void;
  71762. }
  71763. }
  71764. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71765. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71766. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71767. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71768. }
  71769. declare module "babylonjs/Misc/sceneOptimizer" {
  71770. import { Scene, IDisposable } from "babylonjs/scene";
  71771. import { Observable } from "babylonjs/Misc/observable";
  71772. /**
  71773. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71775. */
  71776. export class SceneOptimization {
  71777. /**
  71778. * Defines the priority of this optimization (0 by default which means first in the list)
  71779. */
  71780. priority: number;
  71781. /**
  71782. * Gets a string describing the action executed by the current optimization
  71783. * @returns description string
  71784. */
  71785. getDescription(): string;
  71786. /**
  71787. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71788. * @param scene defines the current scene where to apply this optimization
  71789. * @param optimizer defines the current optimizer
  71790. * @returns true if everything that can be done was applied
  71791. */
  71792. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71793. /**
  71794. * Creates the SceneOptimization object
  71795. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71796. * @param desc defines the description associated with the optimization
  71797. */
  71798. constructor(
  71799. /**
  71800. * Defines the priority of this optimization (0 by default which means first in the list)
  71801. */
  71802. priority?: number);
  71803. }
  71804. /**
  71805. * Defines an optimization used to reduce the size of render target textures
  71806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71807. */
  71808. export class TextureOptimization extends SceneOptimization {
  71809. /**
  71810. * Defines the priority of this optimization (0 by default which means first in the list)
  71811. */
  71812. priority: number;
  71813. /**
  71814. * 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
  71815. */
  71816. maximumSize: number;
  71817. /**
  71818. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71819. */
  71820. step: number;
  71821. /**
  71822. * Gets a string describing the action executed by the current optimization
  71823. * @returns description string
  71824. */
  71825. getDescription(): string;
  71826. /**
  71827. * Creates the TextureOptimization object
  71828. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71829. * @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
  71830. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71831. */
  71832. constructor(
  71833. /**
  71834. * Defines the priority of this optimization (0 by default which means first in the list)
  71835. */
  71836. priority?: number,
  71837. /**
  71838. * 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
  71839. */
  71840. maximumSize?: number,
  71841. /**
  71842. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71843. */
  71844. step?: number);
  71845. /**
  71846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71847. * @param scene defines the current scene where to apply this optimization
  71848. * @param optimizer defines the current optimizer
  71849. * @returns true if everything that can be done was applied
  71850. */
  71851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71852. }
  71853. /**
  71854. * Defines an optimization used to increase or decrease the rendering resolution
  71855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71856. */
  71857. export class HardwareScalingOptimization extends SceneOptimization {
  71858. /**
  71859. * Defines the priority of this optimization (0 by default which means first in the list)
  71860. */
  71861. priority: number;
  71862. /**
  71863. * Defines the maximum scale to use (2 by default)
  71864. */
  71865. maximumScale: number;
  71866. /**
  71867. * Defines the step to use between two passes (0.5 by default)
  71868. */
  71869. step: number;
  71870. private _currentScale;
  71871. private _directionOffset;
  71872. /**
  71873. * Gets a string describing the action executed by the current optimization
  71874. * @return description string
  71875. */
  71876. getDescription(): string;
  71877. /**
  71878. * Creates the HardwareScalingOptimization object
  71879. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71880. * @param maximumScale defines the maximum scale to use (2 by default)
  71881. * @param step defines the step to use between two passes (0.5 by default)
  71882. */
  71883. constructor(
  71884. /**
  71885. * Defines the priority of this optimization (0 by default which means first in the list)
  71886. */
  71887. priority?: number,
  71888. /**
  71889. * Defines the maximum scale to use (2 by default)
  71890. */
  71891. maximumScale?: number,
  71892. /**
  71893. * Defines the step to use between two passes (0.5 by default)
  71894. */
  71895. step?: number);
  71896. /**
  71897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71898. * @param scene defines the current scene where to apply this optimization
  71899. * @param optimizer defines the current optimizer
  71900. * @returns true if everything that can be done was applied
  71901. */
  71902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71903. }
  71904. /**
  71905. * Defines an optimization used to remove shadows
  71906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71907. */
  71908. export class ShadowsOptimization extends SceneOptimization {
  71909. /**
  71910. * Gets a string describing the action executed by the current optimization
  71911. * @return description string
  71912. */
  71913. getDescription(): string;
  71914. /**
  71915. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71916. * @param scene defines the current scene where to apply this optimization
  71917. * @param optimizer defines the current optimizer
  71918. * @returns true if everything that can be done was applied
  71919. */
  71920. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71921. }
  71922. /**
  71923. * Defines an optimization used to turn post-processes off
  71924. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71925. */
  71926. export class PostProcessesOptimization extends SceneOptimization {
  71927. /**
  71928. * Gets a string describing the action executed by the current optimization
  71929. * @return description string
  71930. */
  71931. getDescription(): string;
  71932. /**
  71933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71934. * @param scene defines the current scene where to apply this optimization
  71935. * @param optimizer defines the current optimizer
  71936. * @returns true if everything that can be done was applied
  71937. */
  71938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71939. }
  71940. /**
  71941. * Defines an optimization used to turn lens flares off
  71942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71943. */
  71944. export class LensFlaresOptimization extends SceneOptimization {
  71945. /**
  71946. * Gets a string describing the action executed by the current optimization
  71947. * @return description string
  71948. */
  71949. getDescription(): string;
  71950. /**
  71951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71952. * @param scene defines the current scene where to apply this optimization
  71953. * @param optimizer defines the current optimizer
  71954. * @returns true if everything that can be done was applied
  71955. */
  71956. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71957. }
  71958. /**
  71959. * Defines an optimization based on user defined callback.
  71960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71961. */
  71962. export class CustomOptimization extends SceneOptimization {
  71963. /**
  71964. * Callback called to apply the custom optimization.
  71965. */
  71966. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71967. /**
  71968. * Callback called to get custom description
  71969. */
  71970. onGetDescription: () => string;
  71971. /**
  71972. * Gets a string describing the action executed by the current optimization
  71973. * @returns description string
  71974. */
  71975. getDescription(): string;
  71976. /**
  71977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71978. * @param scene defines the current scene where to apply this optimization
  71979. * @param optimizer defines the current optimizer
  71980. * @returns true if everything that can be done was applied
  71981. */
  71982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71983. }
  71984. /**
  71985. * Defines an optimization used to turn particles off
  71986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71987. */
  71988. export class ParticlesOptimization extends SceneOptimization {
  71989. /**
  71990. * Gets a string describing the action executed by the current optimization
  71991. * @return description string
  71992. */
  71993. getDescription(): string;
  71994. /**
  71995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71996. * @param scene defines the current scene where to apply this optimization
  71997. * @param optimizer defines the current optimizer
  71998. * @returns true if everything that can be done was applied
  71999. */
  72000. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72001. }
  72002. /**
  72003. * Defines an optimization used to turn render targets off
  72004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72005. */
  72006. export class RenderTargetsOptimization extends SceneOptimization {
  72007. /**
  72008. * Gets a string describing the action executed by the current optimization
  72009. * @return description string
  72010. */
  72011. getDescription(): string;
  72012. /**
  72013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72014. * @param scene defines the current scene where to apply this optimization
  72015. * @param optimizer defines the current optimizer
  72016. * @returns true if everything that can be done was applied
  72017. */
  72018. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72019. }
  72020. /**
  72021. * Defines an optimization used to merge meshes with compatible materials
  72022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72023. */
  72024. export class MergeMeshesOptimization extends SceneOptimization {
  72025. private static _UpdateSelectionTree;
  72026. /**
  72027. * Gets or sets a boolean which defines if optimization octree has to be updated
  72028. */
  72029. static get UpdateSelectionTree(): boolean;
  72030. /**
  72031. * Gets or sets a boolean which defines if optimization octree has to be updated
  72032. */
  72033. static set UpdateSelectionTree(value: boolean);
  72034. /**
  72035. * Gets a string describing the action executed by the current optimization
  72036. * @return description string
  72037. */
  72038. getDescription(): string;
  72039. private _canBeMerged;
  72040. /**
  72041. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72042. * @param scene defines the current scene where to apply this optimization
  72043. * @param optimizer defines the current optimizer
  72044. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72045. * @returns true if everything that can be done was applied
  72046. */
  72047. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72048. }
  72049. /**
  72050. * Defines a list of options used by SceneOptimizer
  72051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72052. */
  72053. export class SceneOptimizerOptions {
  72054. /**
  72055. * Defines the target frame rate to reach (60 by default)
  72056. */
  72057. targetFrameRate: number;
  72058. /**
  72059. * Defines the interval between two checkes (2000ms by default)
  72060. */
  72061. trackerDuration: number;
  72062. /**
  72063. * Gets the list of optimizations to apply
  72064. */
  72065. optimizations: SceneOptimization[];
  72066. /**
  72067. * Creates a new list of options used by SceneOptimizer
  72068. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72069. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72070. */
  72071. constructor(
  72072. /**
  72073. * Defines the target frame rate to reach (60 by default)
  72074. */
  72075. targetFrameRate?: number,
  72076. /**
  72077. * Defines the interval between two checkes (2000ms by default)
  72078. */
  72079. trackerDuration?: number);
  72080. /**
  72081. * Add a new optimization
  72082. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72083. * @returns the current SceneOptimizerOptions
  72084. */
  72085. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72086. /**
  72087. * Add a new custom optimization
  72088. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72089. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72090. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72091. * @returns the current SceneOptimizerOptions
  72092. */
  72093. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72094. /**
  72095. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72096. * @param targetFrameRate defines the target frame rate (60 by default)
  72097. * @returns a SceneOptimizerOptions object
  72098. */
  72099. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72100. /**
  72101. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72102. * @param targetFrameRate defines the target frame rate (60 by default)
  72103. * @returns a SceneOptimizerOptions object
  72104. */
  72105. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72106. /**
  72107. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72108. * @param targetFrameRate defines the target frame rate (60 by default)
  72109. * @returns a SceneOptimizerOptions object
  72110. */
  72111. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72112. }
  72113. /**
  72114. * Class used to run optimizations in order to reach a target frame rate
  72115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72116. */
  72117. export class SceneOptimizer implements IDisposable {
  72118. private _isRunning;
  72119. private _options;
  72120. private _scene;
  72121. private _currentPriorityLevel;
  72122. private _targetFrameRate;
  72123. private _trackerDuration;
  72124. private _currentFrameRate;
  72125. private _sceneDisposeObserver;
  72126. private _improvementMode;
  72127. /**
  72128. * Defines an observable called when the optimizer reaches the target frame rate
  72129. */
  72130. onSuccessObservable: Observable<SceneOptimizer>;
  72131. /**
  72132. * Defines an observable called when the optimizer enables an optimization
  72133. */
  72134. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72135. /**
  72136. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72137. */
  72138. onFailureObservable: Observable<SceneOptimizer>;
  72139. /**
  72140. * Gets a boolean indicating if the optimizer is in improvement mode
  72141. */
  72142. get isInImprovementMode(): boolean;
  72143. /**
  72144. * Gets the current priority level (0 at start)
  72145. */
  72146. get currentPriorityLevel(): number;
  72147. /**
  72148. * Gets the current frame rate checked by the SceneOptimizer
  72149. */
  72150. get currentFrameRate(): number;
  72151. /**
  72152. * Gets or sets the current target frame rate (60 by default)
  72153. */
  72154. get targetFrameRate(): number;
  72155. /**
  72156. * Gets or sets the current target frame rate (60 by default)
  72157. */
  72158. set targetFrameRate(value: number);
  72159. /**
  72160. * Gets or sets the current interval between two checks (every 2000ms by default)
  72161. */
  72162. get trackerDuration(): number;
  72163. /**
  72164. * Gets or sets the current interval between two checks (every 2000ms by default)
  72165. */
  72166. set trackerDuration(value: number);
  72167. /**
  72168. * Gets the list of active optimizations
  72169. */
  72170. get optimizations(): SceneOptimization[];
  72171. /**
  72172. * Creates a new SceneOptimizer
  72173. * @param scene defines the scene to work on
  72174. * @param options defines the options to use with the SceneOptimizer
  72175. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72176. * @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)
  72177. */
  72178. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72179. /**
  72180. * Stops the current optimizer
  72181. */
  72182. stop(): void;
  72183. /**
  72184. * Reset the optimizer to initial step (current priority level = 0)
  72185. */
  72186. reset(): void;
  72187. /**
  72188. * Start the optimizer. By default it will try to reach a specific framerate
  72189. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72190. */
  72191. start(): void;
  72192. private _checkCurrentState;
  72193. /**
  72194. * Release all resources
  72195. */
  72196. dispose(): void;
  72197. /**
  72198. * Helper function to create a SceneOptimizer with one single line of code
  72199. * @param scene defines the scene to work on
  72200. * @param options defines the options to use with the SceneOptimizer
  72201. * @param onSuccess defines a callback to call on success
  72202. * @param onFailure defines a callback to call on failure
  72203. * @returns the new SceneOptimizer object
  72204. */
  72205. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72206. }
  72207. }
  72208. declare module "babylonjs/Misc/sceneSerializer" {
  72209. import { Scene } from "babylonjs/scene";
  72210. /**
  72211. * Class used to serialize a scene into a string
  72212. */
  72213. export class SceneSerializer {
  72214. /**
  72215. * Clear cache used by a previous serialization
  72216. */
  72217. static ClearCache(): void;
  72218. /**
  72219. * Serialize a scene into a JSON compatible object
  72220. * @param scene defines the scene to serialize
  72221. * @returns a JSON compatible object
  72222. */
  72223. static Serialize(scene: Scene): any;
  72224. /**
  72225. * Serialize a mesh into a JSON compatible object
  72226. * @param toSerialize defines the mesh to serialize
  72227. * @param withParents defines if parents must be serialized as well
  72228. * @param withChildren defines if children must be serialized as well
  72229. * @returns a JSON compatible object
  72230. */
  72231. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72232. }
  72233. }
  72234. declare module "babylonjs/Misc/textureTools" {
  72235. import { Texture } from "babylonjs/Materials/Textures/texture";
  72236. /**
  72237. * Class used to host texture specific utilities
  72238. */
  72239. export class TextureTools {
  72240. /**
  72241. * Uses the GPU to create a copy texture rescaled at a given size
  72242. * @param texture Texture to copy from
  72243. * @param width defines the desired width
  72244. * @param height defines the desired height
  72245. * @param useBilinearMode defines if bilinear mode has to be used
  72246. * @return the generated texture
  72247. */
  72248. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72249. }
  72250. }
  72251. declare module "babylonjs/Misc/videoRecorder" {
  72252. import { Nullable } from "babylonjs/types";
  72253. import { Engine } from "babylonjs/Engines/engine";
  72254. /**
  72255. * This represents the different options available for the video capture.
  72256. */
  72257. export interface VideoRecorderOptions {
  72258. /** Defines the mime type of the video. */
  72259. mimeType: string;
  72260. /** Defines the FPS the video should be recorded at. */
  72261. fps: number;
  72262. /** Defines the chunk size for the recording data. */
  72263. recordChunckSize: number;
  72264. /** The audio tracks to attach to the recording. */
  72265. audioTracks?: MediaStreamTrack[];
  72266. }
  72267. /**
  72268. * This can help with recording videos from BabylonJS.
  72269. * This is based on the available WebRTC functionalities of the browser.
  72270. *
  72271. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72272. */
  72273. export class VideoRecorder {
  72274. private static readonly _defaultOptions;
  72275. /**
  72276. * Returns whether or not the VideoRecorder is available in your browser.
  72277. * @param engine Defines the Babylon Engine.
  72278. * @returns true if supported otherwise false.
  72279. */
  72280. static IsSupported(engine: Engine): boolean;
  72281. private readonly _options;
  72282. private _canvas;
  72283. private _mediaRecorder;
  72284. private _recordedChunks;
  72285. private _fileName;
  72286. private _resolve;
  72287. private _reject;
  72288. /**
  72289. * True when a recording is already in progress.
  72290. */
  72291. get isRecording(): boolean;
  72292. /**
  72293. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72294. * @param engine Defines the BabylonJS Engine you wish to record.
  72295. * @param options Defines options that can be used to customize the capture.
  72296. */
  72297. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72298. /**
  72299. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72300. */
  72301. stopRecording(): void;
  72302. /**
  72303. * Starts recording the canvas for a max duration specified in parameters.
  72304. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72305. * If null no automatic download will start and you can rely on the promise to get the data back.
  72306. * @param maxDuration Defines the maximum recording time in seconds.
  72307. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72308. * @return A promise callback at the end of the recording with the video data in Blob.
  72309. */
  72310. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72311. /**
  72312. * Releases internal resources used during the recording.
  72313. */
  72314. dispose(): void;
  72315. private _handleDataAvailable;
  72316. private _handleError;
  72317. private _handleStop;
  72318. }
  72319. }
  72320. declare module "babylonjs/Misc/screenshotTools" {
  72321. import { Camera } from "babylonjs/Cameras/camera";
  72322. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72323. import { Engine } from "babylonjs/Engines/engine";
  72324. /**
  72325. * Class containing a set of static utilities functions for screenshots
  72326. */
  72327. export class ScreenshotTools {
  72328. /**
  72329. * Captures a screenshot of the current rendering
  72330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72331. * @param engine defines the rendering engine
  72332. * @param camera defines the source camera
  72333. * @param size This parameter can be set to a single number or to an object with the
  72334. * following (optional) properties: precision, width, height. If a single number is passed,
  72335. * it will be used for both width and height. If an object is passed, the screenshot size
  72336. * will be derived from the parameters. The precision property is a multiplier allowing
  72337. * rendering at a higher or lower resolution
  72338. * @param successCallback defines the callback receives a single parameter which contains the
  72339. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72340. * src parameter of an <img> to display it
  72341. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72342. * Check your browser for supported MIME types
  72343. */
  72344. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72345. /**
  72346. * Captures a screenshot of the current rendering
  72347. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72348. * @param engine defines the rendering engine
  72349. * @param camera defines the source camera
  72350. * @param size This parameter can be set to a single number or to an object with the
  72351. * following (optional) properties: precision, width, height. If a single number is passed,
  72352. * it will be used for both width and height. If an object is passed, the screenshot size
  72353. * will be derived from the parameters. The precision property is a multiplier allowing
  72354. * rendering at a higher or lower resolution
  72355. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72356. * Check your browser for supported MIME types
  72357. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72358. * to the src parameter of an <img> to display it
  72359. */
  72360. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72361. /**
  72362. * Generates an image screenshot from the specified camera.
  72363. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72364. * @param engine The engine to use for rendering
  72365. * @param camera The camera to use for rendering
  72366. * @param size This parameter can be set to a single number or to an object with the
  72367. * following (optional) properties: precision, width, height. If a single number is passed,
  72368. * it will be used for both width and height. If an object is passed, the screenshot size
  72369. * will be derived from the parameters. The precision property is a multiplier allowing
  72370. * rendering at a higher or lower resolution
  72371. * @param successCallback The callback receives a single parameter which contains the
  72372. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72373. * src parameter of an <img> to display it
  72374. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72375. * Check your browser for supported MIME types
  72376. * @param samples Texture samples (default: 1)
  72377. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72378. * @param fileName A name for for the downloaded file.
  72379. */
  72380. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72381. /**
  72382. * Generates an image screenshot from the specified camera.
  72383. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72384. * @param engine The engine to use for rendering
  72385. * @param camera The camera to use for rendering
  72386. * @param size This parameter can be set to a single number or to an object with the
  72387. * following (optional) properties: precision, width, height. If a single number is passed,
  72388. * it will be used for both width and height. If an object is passed, the screenshot size
  72389. * will be derived from the parameters. The precision property is a multiplier allowing
  72390. * rendering at a higher or lower resolution
  72391. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72392. * Check your browser for supported MIME types
  72393. * @param samples Texture samples (default: 1)
  72394. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72395. * @param fileName A name for for the downloaded file.
  72396. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72397. * to the src parameter of an <img> to display it
  72398. */
  72399. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72400. /**
  72401. * Gets height and width for screenshot size
  72402. * @private
  72403. */
  72404. private static _getScreenshotSize;
  72405. }
  72406. }
  72407. declare module "babylonjs/Misc/dataReader" {
  72408. /**
  72409. * Interface for a data buffer
  72410. */
  72411. export interface IDataBuffer {
  72412. /**
  72413. * Reads bytes from the data buffer.
  72414. * @param byteOffset The byte offset to read
  72415. * @param byteLength The byte length to read
  72416. * @returns A promise that resolves when the bytes are read
  72417. */
  72418. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72419. /**
  72420. * The byte length of the buffer.
  72421. */
  72422. readonly byteLength: number;
  72423. }
  72424. /**
  72425. * Utility class for reading from a data buffer
  72426. */
  72427. export class DataReader {
  72428. /**
  72429. * The data buffer associated with this data reader.
  72430. */
  72431. readonly buffer: IDataBuffer;
  72432. /**
  72433. * The current byte offset from the beginning of the data buffer.
  72434. */
  72435. byteOffset: number;
  72436. private _dataView;
  72437. private _dataByteOffset;
  72438. /**
  72439. * Constructor
  72440. * @param buffer The buffer to read
  72441. */
  72442. constructor(buffer: IDataBuffer);
  72443. /**
  72444. * Loads the given byte length.
  72445. * @param byteLength The byte length to load
  72446. * @returns A promise that resolves when the load is complete
  72447. */
  72448. loadAsync(byteLength: number): Promise<void>;
  72449. /**
  72450. * Read a unsigned 32-bit integer from the currently loaded data range.
  72451. * @returns The 32-bit integer read
  72452. */
  72453. readUint32(): number;
  72454. /**
  72455. * Read a byte array from the currently loaded data range.
  72456. * @param byteLength The byte length to read
  72457. * @returns The byte array read
  72458. */
  72459. readUint8Array(byteLength: number): Uint8Array;
  72460. /**
  72461. * Read a string from the currently loaded data range.
  72462. * @param byteLength The byte length to read
  72463. * @returns The string read
  72464. */
  72465. readString(byteLength: number): string;
  72466. /**
  72467. * Skips the given byte length the currently loaded data range.
  72468. * @param byteLength The byte length to skip
  72469. */
  72470. skipBytes(byteLength: number): void;
  72471. }
  72472. }
  72473. declare module "babylonjs/Misc/index" {
  72474. export * from "babylonjs/Misc/andOrNotEvaluator";
  72475. export * from "babylonjs/Misc/assetsManager";
  72476. export * from "babylonjs/Misc/basis";
  72477. export * from "babylonjs/Misc/dds";
  72478. export * from "babylonjs/Misc/decorators";
  72479. export * from "babylonjs/Misc/deferred";
  72480. export * from "babylonjs/Misc/environmentTextureTools";
  72481. export * from "babylonjs/Misc/meshExploder";
  72482. export * from "babylonjs/Misc/filesInput";
  72483. export * from "babylonjs/Misc/HighDynamicRange/index";
  72484. export * from "babylonjs/Misc/khronosTextureContainer";
  72485. export * from "babylonjs/Misc/observable";
  72486. export * from "babylonjs/Misc/performanceMonitor";
  72487. export * from "babylonjs/Misc/promise";
  72488. export * from "babylonjs/Misc/sceneOptimizer";
  72489. export * from "babylonjs/Misc/sceneSerializer";
  72490. export * from "babylonjs/Misc/smartArray";
  72491. export * from "babylonjs/Misc/stringDictionary";
  72492. export * from "babylonjs/Misc/tags";
  72493. export * from "babylonjs/Misc/textureTools";
  72494. export * from "babylonjs/Misc/tga";
  72495. export * from "babylonjs/Misc/tools";
  72496. export * from "babylonjs/Misc/videoRecorder";
  72497. export * from "babylonjs/Misc/virtualJoystick";
  72498. export * from "babylonjs/Misc/workerPool";
  72499. export * from "babylonjs/Misc/logger";
  72500. export * from "babylonjs/Misc/typeStore";
  72501. export * from "babylonjs/Misc/filesInputStore";
  72502. export * from "babylonjs/Misc/deepCopier";
  72503. export * from "babylonjs/Misc/pivotTools";
  72504. export * from "babylonjs/Misc/precisionDate";
  72505. export * from "babylonjs/Misc/screenshotTools";
  72506. export * from "babylonjs/Misc/typeStore";
  72507. export * from "babylonjs/Misc/webRequest";
  72508. export * from "babylonjs/Misc/iInspectable";
  72509. export * from "babylonjs/Misc/brdfTextureTools";
  72510. export * from "babylonjs/Misc/rgbdTextureTools";
  72511. export * from "babylonjs/Misc/gradients";
  72512. export * from "babylonjs/Misc/perfCounter";
  72513. export * from "babylonjs/Misc/fileRequest";
  72514. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72515. export * from "babylonjs/Misc/retryStrategy";
  72516. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72517. export * from "babylonjs/Misc/canvasGenerator";
  72518. export * from "babylonjs/Misc/fileTools";
  72519. export * from "babylonjs/Misc/stringTools";
  72520. export * from "babylonjs/Misc/dataReader";
  72521. export * from "babylonjs/Misc/minMaxReducer";
  72522. export * from "babylonjs/Misc/depthReducer";
  72523. }
  72524. declare module "babylonjs/index" {
  72525. export * from "babylonjs/abstractScene";
  72526. export * from "babylonjs/Actions/index";
  72527. export * from "babylonjs/Animations/index";
  72528. export * from "babylonjs/assetContainer";
  72529. export * from "babylonjs/Audio/index";
  72530. export * from "babylonjs/Behaviors/index";
  72531. export * from "babylonjs/Bones/index";
  72532. export * from "babylonjs/Cameras/index";
  72533. export * from "babylonjs/Collisions/index";
  72534. export * from "babylonjs/Culling/index";
  72535. export * from "babylonjs/Debug/index";
  72536. export * from "babylonjs/Engines/index";
  72537. export * from "babylonjs/Events/index";
  72538. export * from "babylonjs/Gamepads/index";
  72539. export * from "babylonjs/Gizmos/index";
  72540. export * from "babylonjs/Helpers/index";
  72541. export * from "babylonjs/Instrumentation/index";
  72542. export * from "babylonjs/Layers/index";
  72543. export * from "babylonjs/LensFlares/index";
  72544. export * from "babylonjs/Lights/index";
  72545. export * from "babylonjs/Loading/index";
  72546. export * from "babylonjs/Materials/index";
  72547. export * from "babylonjs/Maths/index";
  72548. export * from "babylonjs/Meshes/index";
  72549. export * from "babylonjs/Morph/index";
  72550. export * from "babylonjs/Navigation/index";
  72551. export * from "babylonjs/node";
  72552. export * from "babylonjs/Offline/index";
  72553. export * from "babylonjs/Particles/index";
  72554. export * from "babylonjs/Physics/index";
  72555. export * from "babylonjs/PostProcesses/index";
  72556. export * from "babylonjs/Probes/index";
  72557. export * from "babylonjs/Rendering/index";
  72558. export * from "babylonjs/scene";
  72559. export * from "babylonjs/sceneComponent";
  72560. export * from "babylonjs/Sprites/index";
  72561. export * from "babylonjs/States/index";
  72562. export * from "babylonjs/Misc/index";
  72563. export * from "babylonjs/types";
  72564. }
  72565. declare module "babylonjs/Animations/pathCursor" {
  72566. import { Vector3 } from "babylonjs/Maths/math.vector";
  72567. import { Path2 } from "babylonjs/Maths/math.path";
  72568. /**
  72569. * A cursor which tracks a point on a path
  72570. */
  72571. export class PathCursor {
  72572. private path;
  72573. /**
  72574. * Stores path cursor callbacks for when an onchange event is triggered
  72575. */
  72576. private _onchange;
  72577. /**
  72578. * The value of the path cursor
  72579. */
  72580. value: number;
  72581. /**
  72582. * The animation array of the path cursor
  72583. */
  72584. animations: Animation[];
  72585. /**
  72586. * Initializes the path cursor
  72587. * @param path The path to track
  72588. */
  72589. constructor(path: Path2);
  72590. /**
  72591. * Gets the cursor point on the path
  72592. * @returns A point on the path cursor at the cursor location
  72593. */
  72594. getPoint(): Vector3;
  72595. /**
  72596. * Moves the cursor ahead by the step amount
  72597. * @param step The amount to move the cursor forward
  72598. * @returns This path cursor
  72599. */
  72600. moveAhead(step?: number): PathCursor;
  72601. /**
  72602. * Moves the cursor behind by the step amount
  72603. * @param step The amount to move the cursor back
  72604. * @returns This path cursor
  72605. */
  72606. moveBack(step?: number): PathCursor;
  72607. /**
  72608. * Moves the cursor by the step amount
  72609. * If the step amount is greater than one, an exception is thrown
  72610. * @param step The amount to move the cursor
  72611. * @returns This path cursor
  72612. */
  72613. move(step: number): PathCursor;
  72614. /**
  72615. * Ensures that the value is limited between zero and one
  72616. * @returns This path cursor
  72617. */
  72618. private ensureLimits;
  72619. /**
  72620. * Runs onchange callbacks on change (used by the animation engine)
  72621. * @returns This path cursor
  72622. */
  72623. private raiseOnChange;
  72624. /**
  72625. * Executes a function on change
  72626. * @param f A path cursor onchange callback
  72627. * @returns This path cursor
  72628. */
  72629. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72630. }
  72631. }
  72632. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  72633. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  72634. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  72635. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  72636. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  72637. }
  72638. declare module "babylonjs/Engines/Processors/Expressions/index" {
  72639. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  72640. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  72641. }
  72642. declare module "babylonjs/Engines/Processors/index" {
  72643. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  72644. export * from "babylonjs/Engines/Processors/Expressions/index";
  72645. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  72646. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  72647. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  72648. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  72649. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  72650. export * from "babylonjs/Engines/Processors/shaderProcessor";
  72651. }
  72652. declare module "babylonjs/Legacy/legacy" {
  72653. import * as Babylon from "babylonjs/index";
  72654. export * from "babylonjs/index";
  72655. }
  72656. declare module "babylonjs/Shaders/blur.fragment" {
  72657. /** @hidden */
  72658. export var blurPixelShader: {
  72659. name: string;
  72660. shader: string;
  72661. };
  72662. }
  72663. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  72664. /** @hidden */
  72665. export var pointCloudVertexDeclaration: {
  72666. name: string;
  72667. shader: string;
  72668. };
  72669. }
  72670. declare module "babylonjs" {
  72671. export * from "babylonjs/Legacy/legacy";
  72672. }
  72673. declare module BABYLON {
  72674. /** Alias type for value that can be null */
  72675. export type Nullable<T> = T | null;
  72676. /**
  72677. * Alias type for number that are floats
  72678. * @ignorenaming
  72679. */
  72680. export type float = number;
  72681. /**
  72682. * Alias type for number that are doubles.
  72683. * @ignorenaming
  72684. */
  72685. export type double = number;
  72686. /**
  72687. * Alias type for number that are integer
  72688. * @ignorenaming
  72689. */
  72690. export type int = number;
  72691. /** Alias type for number array or Float32Array */
  72692. export type FloatArray = number[] | Float32Array;
  72693. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  72694. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  72695. /**
  72696. * Alias for types that can be used by a Buffer or VertexBuffer.
  72697. */
  72698. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  72699. /**
  72700. * Alias type for primitive types
  72701. * @ignorenaming
  72702. */
  72703. type Primitive = undefined | null | boolean | string | number | Function;
  72704. /**
  72705. * Type modifier to make all the properties of an object Readonly
  72706. */
  72707. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  72708. /**
  72709. * Type modifier to make all the properties of an object Readonly recursively
  72710. */
  72711. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  72712. /**
  72713. * Type modifier to make object properties readonly.
  72714. */
  72715. export type DeepImmutableObject<T> = {
  72716. readonly [K in keyof T]: DeepImmutable<T[K]>;
  72717. };
  72718. /** @hidden */
  72719. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  72720. }
  72721. }
  72722. declare module BABYLON {
  72723. /**
  72724. * A class serves as a medium between the observable and its observers
  72725. */
  72726. export class EventState {
  72727. /**
  72728. * Create a new EventState
  72729. * @param mask defines the mask associated with this state
  72730. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72731. * @param target defines the original target of the state
  72732. * @param currentTarget defines the current target of the state
  72733. */
  72734. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  72735. /**
  72736. * Initialize the current event state
  72737. * @param mask defines the mask associated with this state
  72738. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72739. * @param target defines the original target of the state
  72740. * @param currentTarget defines the current target of the state
  72741. * @returns the current event state
  72742. */
  72743. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72744. /**
  72745. * An Observer can set this property to true to prevent subsequent observers of being notified
  72746. */
  72747. skipNextObservers: boolean;
  72748. /**
  72749. * Get the mask value that were used to trigger the event corresponding to this EventState object
  72750. */
  72751. mask: number;
  72752. /**
  72753. * The object that originally notified the event
  72754. */
  72755. target?: any;
  72756. /**
  72757. * The current object in the bubbling phase
  72758. */
  72759. currentTarget?: any;
  72760. /**
  72761. * This will be populated with the return value of the last function that was executed.
  72762. * If it is the first function in the callback chain it will be the event data.
  72763. */
  72764. lastReturnValue?: any;
  72765. }
  72766. /**
  72767. * Represent an Observer registered to a given Observable object.
  72768. */
  72769. export class Observer<T> {
  72770. /**
  72771. * Defines the callback to call when the observer is notified
  72772. */
  72773. callback: (eventData: T, eventState: EventState) => void;
  72774. /**
  72775. * Defines the mask of the observer (used to filter notifications)
  72776. */
  72777. mask: number;
  72778. /**
  72779. * Defines the current scope used to restore the JS context
  72780. */
  72781. scope: any;
  72782. /** @hidden */
  72783. _willBeUnregistered: boolean;
  72784. /**
  72785. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  72786. */
  72787. unregisterOnNextCall: boolean;
  72788. /**
  72789. * Creates a new observer
  72790. * @param callback defines the callback to call when the observer is notified
  72791. * @param mask defines the mask of the observer (used to filter notifications)
  72792. * @param scope defines the current scope used to restore the JS context
  72793. */
  72794. constructor(
  72795. /**
  72796. * Defines the callback to call when the observer is notified
  72797. */
  72798. callback: (eventData: T, eventState: EventState) => void,
  72799. /**
  72800. * Defines the mask of the observer (used to filter notifications)
  72801. */
  72802. mask: number,
  72803. /**
  72804. * Defines the current scope used to restore the JS context
  72805. */
  72806. scope?: any);
  72807. }
  72808. /**
  72809. * Represent a list of observers registered to multiple Observables object.
  72810. */
  72811. export class MultiObserver<T> {
  72812. private _observers;
  72813. private _observables;
  72814. /**
  72815. * Release associated resources
  72816. */
  72817. dispose(): void;
  72818. /**
  72819. * Raise a callback when one of the observable will notify
  72820. * @param observables defines a list of observables to watch
  72821. * @param callback defines the callback to call on notification
  72822. * @param mask defines the mask used to filter notifications
  72823. * @param scope defines the current scope used to restore the JS context
  72824. * @returns the new MultiObserver
  72825. */
  72826. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  72827. }
  72828. /**
  72829. * The Observable class is a simple implementation of the Observable pattern.
  72830. *
  72831. * 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.
  72832. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  72833. * 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).
  72834. * 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.
  72835. */
  72836. export class Observable<T> {
  72837. private _observers;
  72838. private _eventState;
  72839. private _onObserverAdded;
  72840. /**
  72841. * Gets the list of observers
  72842. */
  72843. get observers(): Array<Observer<T>>;
  72844. /**
  72845. * Creates a new observable
  72846. * @param onObserverAdded defines a callback to call when a new observer is added
  72847. */
  72848. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  72849. /**
  72850. * Create a new Observer with the specified callback
  72851. * @param callback the callback that will be executed for that Observer
  72852. * @param mask the mask used to filter observers
  72853. * @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.
  72854. * @param scope optional scope for the callback to be called from
  72855. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  72856. * @returns the new observer created for the callback
  72857. */
  72858. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  72859. /**
  72860. * Create a new Observer with the specified callback and unregisters after the next notification
  72861. * @param callback the callback that will be executed for that Observer
  72862. * @returns the new observer created for the callback
  72863. */
  72864. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  72865. /**
  72866. * Remove an Observer from the Observable object
  72867. * @param observer the instance of the Observer to remove
  72868. * @returns false if it doesn't belong to this Observable
  72869. */
  72870. remove(observer: Nullable<Observer<T>>): boolean;
  72871. /**
  72872. * Remove a callback from the Observable object
  72873. * @param callback the callback to remove
  72874. * @param scope optional scope. If used only the callbacks with this scope will be removed
  72875. * @returns false if it doesn't belong to this Observable
  72876. */
  72877. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  72878. private _deferUnregister;
  72879. private _remove;
  72880. /**
  72881. * Moves the observable to the top of the observer list making it get called first when notified
  72882. * @param observer the observer to move
  72883. */
  72884. makeObserverTopPriority(observer: Observer<T>): void;
  72885. /**
  72886. * Moves the observable to the bottom of the observer list making it get called last when notified
  72887. * @param observer the observer to move
  72888. */
  72889. makeObserverBottomPriority(observer: Observer<T>): void;
  72890. /**
  72891. * Notify all Observers by calling their respective callback with the given data
  72892. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  72893. * @param eventData defines the data to send to all observers
  72894. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  72895. * @param target defines the original target of the state
  72896. * @param currentTarget defines the current target of the state
  72897. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  72898. */
  72899. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  72900. /**
  72901. * Calling this will execute each callback, expecting it to be a promise or return a value.
  72902. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  72903. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  72904. * and it is crucial that all callbacks will be executed.
  72905. * The order of the callbacks is kept, callbacks are not executed parallel.
  72906. *
  72907. * @param eventData The data to be sent to each callback
  72908. * @param mask is used to filter observers defaults to -1
  72909. * @param target defines the callback target (see EventState)
  72910. * @param currentTarget defines he current object in the bubbling phase
  72911. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  72912. */
  72913. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  72914. /**
  72915. * Notify a specific observer
  72916. * @param observer defines the observer to notify
  72917. * @param eventData defines the data to be sent to each callback
  72918. * @param mask is used to filter observers defaults to -1
  72919. */
  72920. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  72921. /**
  72922. * Gets a boolean indicating if the observable has at least one observer
  72923. * @returns true is the Observable has at least one Observer registered
  72924. */
  72925. hasObservers(): boolean;
  72926. /**
  72927. * Clear the list of observers
  72928. */
  72929. clear(): void;
  72930. /**
  72931. * Clone the current observable
  72932. * @returns a new observable
  72933. */
  72934. clone(): Observable<T>;
  72935. /**
  72936. * Does this observable handles observer registered with a given mask
  72937. * @param mask defines the mask to be tested
  72938. * @return whether or not one observer registered with the given mask is handeled
  72939. **/
  72940. hasSpecificMask(mask?: number): boolean;
  72941. }
  72942. }
  72943. declare module BABYLON {
  72944. /**
  72945. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  72946. * Babylon.js
  72947. */
  72948. export class DomManagement {
  72949. /**
  72950. * Checks if the window object exists
  72951. * @returns true if the window object exists
  72952. */
  72953. static IsWindowObjectExist(): boolean;
  72954. /**
  72955. * Checks if the navigator object exists
  72956. * @returns true if the navigator object exists
  72957. */
  72958. static IsNavigatorAvailable(): boolean;
  72959. /**
  72960. * Extracts text content from a DOM element hierarchy
  72961. * @param element defines the root element
  72962. * @returns a string
  72963. */
  72964. static GetDOMTextContent(element: HTMLElement): string;
  72965. }
  72966. }
  72967. declare module BABYLON {
  72968. /**
  72969. * Logger used througouht the application to allow configuration of
  72970. * the log level required for the messages.
  72971. */
  72972. export class Logger {
  72973. /**
  72974. * No log
  72975. */
  72976. static readonly NoneLogLevel: number;
  72977. /**
  72978. * Only message logs
  72979. */
  72980. static readonly MessageLogLevel: number;
  72981. /**
  72982. * Only warning logs
  72983. */
  72984. static readonly WarningLogLevel: number;
  72985. /**
  72986. * Only error logs
  72987. */
  72988. static readonly ErrorLogLevel: number;
  72989. /**
  72990. * All logs
  72991. */
  72992. static readonly AllLogLevel: number;
  72993. private static _LogCache;
  72994. /**
  72995. * Gets a value indicating the number of loading errors
  72996. * @ignorenaming
  72997. */
  72998. static errorsCount: number;
  72999. /**
  73000. * Callback called when a new log is added
  73001. */
  73002. static OnNewCacheEntry: (entry: string) => void;
  73003. private static _AddLogEntry;
  73004. private static _FormatMessage;
  73005. private static _LogDisabled;
  73006. private static _LogEnabled;
  73007. private static _WarnDisabled;
  73008. private static _WarnEnabled;
  73009. private static _ErrorDisabled;
  73010. private static _ErrorEnabled;
  73011. /**
  73012. * Log a message to the console
  73013. */
  73014. static Log: (message: string) => void;
  73015. /**
  73016. * Write a warning message to the console
  73017. */
  73018. static Warn: (message: string) => void;
  73019. /**
  73020. * Write an error message to the console
  73021. */
  73022. static Error: (message: string) => void;
  73023. /**
  73024. * Gets current log cache (list of logs)
  73025. */
  73026. static get LogCache(): string;
  73027. /**
  73028. * Clears the log cache
  73029. */
  73030. static ClearLogCache(): void;
  73031. /**
  73032. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73033. */
  73034. static set LogLevels(level: number);
  73035. }
  73036. }
  73037. declare module BABYLON {
  73038. /** @hidden */
  73039. export class _TypeStore {
  73040. /** @hidden */
  73041. static RegisteredTypes: {
  73042. [key: string]: Object;
  73043. };
  73044. /** @hidden */
  73045. static GetClass(fqdn: string): any;
  73046. }
  73047. }
  73048. declare module BABYLON {
  73049. /**
  73050. * Helper to manipulate strings
  73051. */
  73052. export class StringTools {
  73053. /**
  73054. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73055. * @param str Source string
  73056. * @param suffix Suffix to search for in the source string
  73057. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73058. */
  73059. static EndsWith(str: string, suffix: string): boolean;
  73060. /**
  73061. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73062. * @param str Source string
  73063. * @param suffix Suffix to search for in the source string
  73064. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73065. */
  73066. static StartsWith(str: string, suffix: string): boolean;
  73067. /**
  73068. * Decodes a buffer into a string
  73069. * @param buffer The buffer to decode
  73070. * @returns The decoded string
  73071. */
  73072. static Decode(buffer: Uint8Array | Uint16Array): string;
  73073. /**
  73074. * Encode a buffer to a base64 string
  73075. * @param buffer defines the buffer to encode
  73076. * @returns the encoded string
  73077. */
  73078. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73079. }
  73080. }
  73081. declare module BABYLON {
  73082. /**
  73083. * Class containing a set of static utilities functions for deep copy.
  73084. */
  73085. export class DeepCopier {
  73086. /**
  73087. * Tries to copy an object by duplicating every property
  73088. * @param source defines the source object
  73089. * @param destination defines the target object
  73090. * @param doNotCopyList defines a list of properties to avoid
  73091. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73092. */
  73093. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73094. }
  73095. }
  73096. declare module BABYLON {
  73097. /**
  73098. * Class containing a set of static utilities functions for precision date
  73099. */
  73100. export class PrecisionDate {
  73101. /**
  73102. * Gets either window.performance.now() if supported or Date.now() else
  73103. */
  73104. static get Now(): number;
  73105. }
  73106. }
  73107. declare module BABYLON {
  73108. /** @hidden */
  73109. export class _DevTools {
  73110. static WarnImport(name: string): string;
  73111. }
  73112. }
  73113. declare module BABYLON {
  73114. /**
  73115. * Interface used to define the mechanism to get data from the network
  73116. */
  73117. export interface IWebRequest {
  73118. /**
  73119. * Returns client's response url
  73120. */
  73121. responseURL: string;
  73122. /**
  73123. * Returns client's status
  73124. */
  73125. status: number;
  73126. /**
  73127. * Returns client's status as a text
  73128. */
  73129. statusText: string;
  73130. }
  73131. }
  73132. declare module BABYLON {
  73133. /**
  73134. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73135. */
  73136. export class WebRequest implements IWebRequest {
  73137. private _xhr;
  73138. /**
  73139. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73140. * i.e. when loading files, where the server/service expects an Authorization header
  73141. */
  73142. static CustomRequestHeaders: {
  73143. [key: string]: string;
  73144. };
  73145. /**
  73146. * Add callback functions in this array to update all the requests before they get sent to the network
  73147. */
  73148. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73149. private _injectCustomRequestHeaders;
  73150. /**
  73151. * Gets or sets a function to be called when loading progress changes
  73152. */
  73153. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73154. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73155. /**
  73156. * Returns client's state
  73157. */
  73158. get readyState(): number;
  73159. /**
  73160. * Returns client's status
  73161. */
  73162. get status(): number;
  73163. /**
  73164. * Returns client's status as a text
  73165. */
  73166. get statusText(): string;
  73167. /**
  73168. * Returns client's response
  73169. */
  73170. get response(): any;
  73171. /**
  73172. * Returns client's response url
  73173. */
  73174. get responseURL(): string;
  73175. /**
  73176. * Returns client's response as text
  73177. */
  73178. get responseText(): string;
  73179. /**
  73180. * Gets or sets the expected response type
  73181. */
  73182. get responseType(): XMLHttpRequestResponseType;
  73183. set responseType(value: XMLHttpRequestResponseType);
  73184. /** @hidden */
  73185. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73186. /** @hidden */
  73187. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73188. /**
  73189. * Cancels any network activity
  73190. */
  73191. abort(): void;
  73192. /**
  73193. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73194. * @param body defines an optional request body
  73195. */
  73196. send(body?: Document | BodyInit | null): void;
  73197. /**
  73198. * Sets the request method, request URL
  73199. * @param method defines the method to use (GET, POST, etc..)
  73200. * @param url defines the url to connect with
  73201. */
  73202. open(method: string, url: string): void;
  73203. /**
  73204. * Sets the value of a request header.
  73205. * @param name The name of the header whose value is to be set
  73206. * @param value The value to set as the body of the header
  73207. */
  73208. setRequestHeader(name: string, value: string): void;
  73209. /**
  73210. * Get the string containing the text of a particular header's value.
  73211. * @param name The name of the header
  73212. * @returns The string containing the text of the given header name
  73213. */
  73214. getResponseHeader(name: string): Nullable<string>;
  73215. }
  73216. }
  73217. declare module BABYLON {
  73218. /**
  73219. * File request interface
  73220. */
  73221. export interface IFileRequest {
  73222. /**
  73223. * Raised when the request is complete (success or error).
  73224. */
  73225. onCompleteObservable: Observable<IFileRequest>;
  73226. /**
  73227. * Aborts the request for a file.
  73228. */
  73229. abort: () => void;
  73230. }
  73231. }
  73232. declare module BABYLON {
  73233. /**
  73234. * Define options used to create a render target texture
  73235. */
  73236. export class RenderTargetCreationOptions {
  73237. /**
  73238. * Specifies is mipmaps must be generated
  73239. */
  73240. generateMipMaps?: boolean;
  73241. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73242. generateDepthBuffer?: boolean;
  73243. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73244. generateStencilBuffer?: boolean;
  73245. /** Defines texture type (int by default) */
  73246. type?: number;
  73247. /** Defines sampling mode (trilinear by default) */
  73248. samplingMode?: number;
  73249. /** Defines format (RGBA by default) */
  73250. format?: number;
  73251. }
  73252. }
  73253. declare module BABYLON {
  73254. /**
  73255. * @hidden
  73256. **/
  73257. export class _TimeToken {
  73258. _startTimeQuery: Nullable<WebGLQuery>;
  73259. _endTimeQuery: Nullable<WebGLQuery>;
  73260. _timeElapsedQuery: Nullable<WebGLQuery>;
  73261. _timeElapsedQueryEnded: boolean;
  73262. }
  73263. }
  73264. declare module BABYLON {
  73265. /** Defines the cross module used constants to avoid circular dependncies */
  73266. export class Constants {
  73267. /** Defines that alpha blending is disabled */
  73268. static readonly ALPHA_DISABLE: number;
  73269. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73270. static readonly ALPHA_ADD: number;
  73271. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73272. static readonly ALPHA_COMBINE: number;
  73273. /** Defines that alpha blending is DEST - SRC * DEST */
  73274. static readonly ALPHA_SUBTRACT: number;
  73275. /** Defines that alpha blending is SRC * DEST */
  73276. static readonly ALPHA_MULTIPLY: number;
  73277. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73278. static readonly ALPHA_MAXIMIZED: number;
  73279. /** Defines that alpha blending is SRC + DEST */
  73280. static readonly ALPHA_ONEONE: number;
  73281. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73282. static readonly ALPHA_PREMULTIPLIED: number;
  73283. /**
  73284. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73285. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73286. */
  73287. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73288. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73289. static readonly ALPHA_INTERPOLATE: number;
  73290. /**
  73291. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73292. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73293. */
  73294. static readonly ALPHA_SCREENMODE: number;
  73295. /**
  73296. * Defines that alpha blending is SRC + DST
  73297. * Alpha will be set to SRC ALPHA + DST ALPHA
  73298. */
  73299. static readonly ALPHA_ONEONE_ONEONE: number;
  73300. /**
  73301. * Defines that alpha blending is SRC * DST ALPHA + DST
  73302. * Alpha will be set to 0
  73303. */
  73304. static readonly ALPHA_ALPHATOCOLOR: number;
  73305. /**
  73306. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73307. */
  73308. static readonly ALPHA_REVERSEONEMINUS: number;
  73309. /**
  73310. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73311. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73312. */
  73313. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73314. /**
  73315. * Defines that alpha blending is SRC + DST
  73316. * Alpha will be set to SRC ALPHA
  73317. */
  73318. static readonly ALPHA_ONEONE_ONEZERO: number;
  73319. /**
  73320. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73321. * Alpha will be set to DST ALPHA
  73322. */
  73323. static readonly ALPHA_EXCLUSION: number;
  73324. /** Defines that alpha blending equation a SUM */
  73325. static readonly ALPHA_EQUATION_ADD: number;
  73326. /** Defines that alpha blending equation a SUBSTRACTION */
  73327. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73328. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73329. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73330. /** Defines that alpha blending equation a MAX operation */
  73331. static readonly ALPHA_EQUATION_MAX: number;
  73332. /** Defines that alpha blending equation a MIN operation */
  73333. static readonly ALPHA_EQUATION_MIN: number;
  73334. /**
  73335. * Defines that alpha blending equation a DARKEN operation:
  73336. * It takes the min of the src and sums the alpha channels.
  73337. */
  73338. static readonly ALPHA_EQUATION_DARKEN: number;
  73339. /** Defines that the ressource is not delayed*/
  73340. static readonly DELAYLOADSTATE_NONE: number;
  73341. /** Defines that the ressource was successfully delay loaded */
  73342. static readonly DELAYLOADSTATE_LOADED: number;
  73343. /** Defines that the ressource is currently delay loading */
  73344. static readonly DELAYLOADSTATE_LOADING: number;
  73345. /** Defines that the ressource is delayed and has not started loading */
  73346. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73347. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73348. static readonly NEVER: number;
  73349. /** 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 */
  73350. static readonly ALWAYS: number;
  73351. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73352. static readonly LESS: number;
  73353. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73354. static readonly EQUAL: number;
  73355. /** 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 */
  73356. static readonly LEQUAL: number;
  73357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73358. static readonly GREATER: number;
  73359. /** 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 */
  73360. static readonly GEQUAL: number;
  73361. /** 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 */
  73362. static readonly NOTEQUAL: number;
  73363. /** Passed to stencilOperation to specify that stencil value must be kept */
  73364. static readonly KEEP: number;
  73365. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73366. static readonly REPLACE: number;
  73367. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73368. static readonly INCR: number;
  73369. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73370. static readonly DECR: number;
  73371. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73372. static readonly INVERT: number;
  73373. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73374. static readonly INCR_WRAP: number;
  73375. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73376. static readonly DECR_WRAP: number;
  73377. /** Texture is not repeating outside of 0..1 UVs */
  73378. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73379. /** Texture is repeating outside of 0..1 UVs */
  73380. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73381. /** Texture is repeating and mirrored */
  73382. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73383. /** ALPHA */
  73384. static readonly TEXTUREFORMAT_ALPHA: number;
  73385. /** LUMINANCE */
  73386. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73387. /** LUMINANCE_ALPHA */
  73388. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73389. /** RGB */
  73390. static readonly TEXTUREFORMAT_RGB: number;
  73391. /** RGBA */
  73392. static readonly TEXTUREFORMAT_RGBA: number;
  73393. /** RED */
  73394. static readonly TEXTUREFORMAT_RED: number;
  73395. /** RED (2nd reference) */
  73396. static readonly TEXTUREFORMAT_R: number;
  73397. /** RG */
  73398. static readonly TEXTUREFORMAT_RG: number;
  73399. /** RED_INTEGER */
  73400. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73401. /** RED_INTEGER (2nd reference) */
  73402. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73403. /** RG_INTEGER */
  73404. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73405. /** RGB_INTEGER */
  73406. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73407. /** RGBA_INTEGER */
  73408. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73409. /** UNSIGNED_BYTE */
  73410. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73411. /** UNSIGNED_BYTE (2nd reference) */
  73412. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73413. /** FLOAT */
  73414. static readonly TEXTURETYPE_FLOAT: number;
  73415. /** HALF_FLOAT */
  73416. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73417. /** BYTE */
  73418. static readonly TEXTURETYPE_BYTE: number;
  73419. /** SHORT */
  73420. static readonly TEXTURETYPE_SHORT: number;
  73421. /** UNSIGNED_SHORT */
  73422. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73423. /** INT */
  73424. static readonly TEXTURETYPE_INT: number;
  73425. /** UNSIGNED_INT */
  73426. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73427. /** UNSIGNED_SHORT_4_4_4_4 */
  73428. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73429. /** UNSIGNED_SHORT_5_5_5_1 */
  73430. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73431. /** UNSIGNED_SHORT_5_6_5 */
  73432. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73433. /** UNSIGNED_INT_2_10_10_10_REV */
  73434. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73435. /** UNSIGNED_INT_24_8 */
  73436. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73437. /** UNSIGNED_INT_10F_11F_11F_REV */
  73438. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73439. /** UNSIGNED_INT_5_9_9_9_REV */
  73440. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73441. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73442. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73443. /** nearest is mag = nearest and min = nearest and no mip */
  73444. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73445. /** mag = nearest and min = nearest and mip = none */
  73446. static readonly TEXTURE_NEAREST_NEAREST: number;
  73447. /** Bilinear is mag = linear and min = linear and no mip */
  73448. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73449. /** mag = linear and min = linear and mip = none */
  73450. static readonly TEXTURE_LINEAR_LINEAR: number;
  73451. /** Trilinear is mag = linear and min = linear and mip = linear */
  73452. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73453. /** Trilinear is mag = linear and min = linear and mip = linear */
  73454. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73455. /** mag = nearest and min = nearest and mip = nearest */
  73456. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73457. /** mag = nearest and min = linear and mip = nearest */
  73458. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  73459. /** mag = nearest and min = linear and mip = linear */
  73460. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  73461. /** mag = nearest and min = linear and mip = none */
  73462. static readonly TEXTURE_NEAREST_LINEAR: number;
  73463. /** nearest is mag = nearest and min = nearest and mip = linear */
  73464. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  73465. /** mag = linear and min = nearest and mip = nearest */
  73466. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  73467. /** mag = linear and min = nearest and mip = linear */
  73468. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  73469. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73470. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  73471. /** mag = linear and min = nearest and mip = none */
  73472. static readonly TEXTURE_LINEAR_NEAREST: number;
  73473. /** Explicit coordinates mode */
  73474. static readonly TEXTURE_EXPLICIT_MODE: number;
  73475. /** Spherical coordinates mode */
  73476. static readonly TEXTURE_SPHERICAL_MODE: number;
  73477. /** Planar coordinates mode */
  73478. static readonly TEXTURE_PLANAR_MODE: number;
  73479. /** Cubic coordinates mode */
  73480. static readonly TEXTURE_CUBIC_MODE: number;
  73481. /** Projection coordinates mode */
  73482. static readonly TEXTURE_PROJECTION_MODE: number;
  73483. /** Skybox coordinates mode */
  73484. static readonly TEXTURE_SKYBOX_MODE: number;
  73485. /** Inverse Cubic coordinates mode */
  73486. static readonly TEXTURE_INVCUBIC_MODE: number;
  73487. /** Equirectangular coordinates mode */
  73488. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  73489. /** Equirectangular Fixed coordinates mode */
  73490. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  73491. /** Equirectangular Fixed Mirrored coordinates mode */
  73492. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73493. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  73494. static readonly SCALEMODE_FLOOR: number;
  73495. /** Defines that texture rescaling will look for the nearest power of 2 size */
  73496. static readonly SCALEMODE_NEAREST: number;
  73497. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  73498. static readonly SCALEMODE_CEILING: number;
  73499. /**
  73500. * The dirty texture flag value
  73501. */
  73502. static readonly MATERIAL_TextureDirtyFlag: number;
  73503. /**
  73504. * The dirty light flag value
  73505. */
  73506. static readonly MATERIAL_LightDirtyFlag: number;
  73507. /**
  73508. * The dirty fresnel flag value
  73509. */
  73510. static readonly MATERIAL_FresnelDirtyFlag: number;
  73511. /**
  73512. * The dirty attribute flag value
  73513. */
  73514. static readonly MATERIAL_AttributesDirtyFlag: number;
  73515. /**
  73516. * The dirty misc flag value
  73517. */
  73518. static readonly MATERIAL_MiscDirtyFlag: number;
  73519. /**
  73520. * The all dirty flag value
  73521. */
  73522. static readonly MATERIAL_AllDirtyFlag: number;
  73523. /**
  73524. * Returns the triangle fill mode
  73525. */
  73526. static readonly MATERIAL_TriangleFillMode: number;
  73527. /**
  73528. * Returns the wireframe mode
  73529. */
  73530. static readonly MATERIAL_WireFrameFillMode: number;
  73531. /**
  73532. * Returns the point fill mode
  73533. */
  73534. static readonly MATERIAL_PointFillMode: number;
  73535. /**
  73536. * Returns the point list draw mode
  73537. */
  73538. static readonly MATERIAL_PointListDrawMode: number;
  73539. /**
  73540. * Returns the line list draw mode
  73541. */
  73542. static readonly MATERIAL_LineListDrawMode: number;
  73543. /**
  73544. * Returns the line loop draw mode
  73545. */
  73546. static readonly MATERIAL_LineLoopDrawMode: number;
  73547. /**
  73548. * Returns the line strip draw mode
  73549. */
  73550. static readonly MATERIAL_LineStripDrawMode: number;
  73551. /**
  73552. * Returns the triangle strip draw mode
  73553. */
  73554. static readonly MATERIAL_TriangleStripDrawMode: number;
  73555. /**
  73556. * Returns the triangle fan draw mode
  73557. */
  73558. static readonly MATERIAL_TriangleFanDrawMode: number;
  73559. /**
  73560. * Stores the clock-wise side orientation
  73561. */
  73562. static readonly MATERIAL_ClockWiseSideOrientation: number;
  73563. /**
  73564. * Stores the counter clock-wise side orientation
  73565. */
  73566. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  73567. /**
  73568. * Nothing
  73569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73570. */
  73571. static readonly ACTION_NothingTrigger: number;
  73572. /**
  73573. * On pick
  73574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73575. */
  73576. static readonly ACTION_OnPickTrigger: number;
  73577. /**
  73578. * On left pick
  73579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73580. */
  73581. static readonly ACTION_OnLeftPickTrigger: number;
  73582. /**
  73583. * On right pick
  73584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73585. */
  73586. static readonly ACTION_OnRightPickTrigger: number;
  73587. /**
  73588. * On center pick
  73589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73590. */
  73591. static readonly ACTION_OnCenterPickTrigger: number;
  73592. /**
  73593. * On pick down
  73594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73595. */
  73596. static readonly ACTION_OnPickDownTrigger: number;
  73597. /**
  73598. * On double pick
  73599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73600. */
  73601. static readonly ACTION_OnDoublePickTrigger: number;
  73602. /**
  73603. * On pick up
  73604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73605. */
  73606. static readonly ACTION_OnPickUpTrigger: number;
  73607. /**
  73608. * On pick out.
  73609. * This trigger will only be raised if you also declared a OnPickDown
  73610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73611. */
  73612. static readonly ACTION_OnPickOutTrigger: number;
  73613. /**
  73614. * On long press
  73615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73616. */
  73617. static readonly ACTION_OnLongPressTrigger: number;
  73618. /**
  73619. * On pointer over
  73620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73621. */
  73622. static readonly ACTION_OnPointerOverTrigger: number;
  73623. /**
  73624. * On pointer out
  73625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73626. */
  73627. static readonly ACTION_OnPointerOutTrigger: number;
  73628. /**
  73629. * On every frame
  73630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73631. */
  73632. static readonly ACTION_OnEveryFrameTrigger: number;
  73633. /**
  73634. * On intersection enter
  73635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73636. */
  73637. static readonly ACTION_OnIntersectionEnterTrigger: number;
  73638. /**
  73639. * On intersection exit
  73640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73641. */
  73642. static readonly ACTION_OnIntersectionExitTrigger: number;
  73643. /**
  73644. * On key down
  73645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73646. */
  73647. static readonly ACTION_OnKeyDownTrigger: number;
  73648. /**
  73649. * On key up
  73650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73651. */
  73652. static readonly ACTION_OnKeyUpTrigger: number;
  73653. /**
  73654. * Billboard mode will only apply to Y axis
  73655. */
  73656. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  73657. /**
  73658. * Billboard mode will apply to all axes
  73659. */
  73660. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  73661. /**
  73662. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73663. */
  73664. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  73665. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  73666. * Test order :
  73667. * Is the bounding sphere outside the frustum ?
  73668. * If not, are the bounding box vertices outside the frustum ?
  73669. * It not, then the cullable object is in the frustum.
  73670. */
  73671. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  73672. /** Culling strategy : Bounding Sphere Only.
  73673. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  73674. * It's also less accurate than the standard because some not visible objects can still be selected.
  73675. * Test : is the bounding sphere outside the frustum ?
  73676. * If not, then the cullable object is in the frustum.
  73677. */
  73678. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  73679. /** Culling strategy : Optimistic Inclusion.
  73680. * This in an inclusion test first, then the standard exclusion test.
  73681. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  73682. * 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.
  73683. * Anyway, it's as accurate as the standard strategy.
  73684. * Test :
  73685. * Is the cullable object bounding sphere center in the frustum ?
  73686. * If not, apply the default culling strategy.
  73687. */
  73688. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  73689. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  73690. * This in an inclusion test first, then the bounding sphere only exclusion test.
  73691. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  73692. * 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.
  73693. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  73694. * Test :
  73695. * Is the cullable object bounding sphere center in the frustum ?
  73696. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  73697. */
  73698. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  73699. /**
  73700. * No logging while loading
  73701. */
  73702. static readonly SCENELOADER_NO_LOGGING: number;
  73703. /**
  73704. * Minimal logging while loading
  73705. */
  73706. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  73707. /**
  73708. * Summary logging while loading
  73709. */
  73710. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  73711. /**
  73712. * Detailled logging while loading
  73713. */
  73714. static readonly SCENELOADER_DETAILED_LOGGING: number;
  73715. }
  73716. }
  73717. declare module BABYLON {
  73718. /**
  73719. * This represents the required contract to create a new type of texture loader.
  73720. */
  73721. export interface IInternalTextureLoader {
  73722. /**
  73723. * Defines wether the loader supports cascade loading the different faces.
  73724. */
  73725. supportCascades: boolean;
  73726. /**
  73727. * This returns if the loader support the current file information.
  73728. * @param extension defines the file extension of the file being loaded
  73729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73730. * @param fallback defines the fallback internal texture if any
  73731. * @param isBase64 defines whether the texture is encoded as a base64
  73732. * @param isBuffer defines whether the texture data are stored as a buffer
  73733. * @returns true if the loader can load the specified file
  73734. */
  73735. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73736. /**
  73737. * Transform the url before loading if required.
  73738. * @param rootUrl the url of the texture
  73739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73740. * @returns the transformed texture
  73741. */
  73742. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73743. /**
  73744. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73745. * @param rootUrl the url of the texture
  73746. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73747. * @returns the fallback texture
  73748. */
  73749. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73750. /**
  73751. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73752. * @param data contains the texture data
  73753. * @param texture defines the BabylonJS internal texture
  73754. * @param createPolynomials will be true if polynomials have been requested
  73755. * @param onLoad defines the callback to trigger once the texture is ready
  73756. * @param onError defines the callback to trigger in case of error
  73757. */
  73758. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73759. /**
  73760. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73761. * @param data contains the texture data
  73762. * @param texture defines the BabylonJS internal texture
  73763. * @param callback defines the method to call once ready to upload
  73764. */
  73765. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73766. }
  73767. }
  73768. declare module BABYLON {
  73769. /**
  73770. * Class used to store and describe the pipeline context associated with an effect
  73771. */
  73772. export interface IPipelineContext {
  73773. /**
  73774. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  73775. */
  73776. isAsync: boolean;
  73777. /**
  73778. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  73779. */
  73780. isReady: boolean;
  73781. /** @hidden */
  73782. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  73783. }
  73784. }
  73785. declare module BABYLON {
  73786. /**
  73787. * Class used to store gfx data (like WebGLBuffer)
  73788. */
  73789. export class DataBuffer {
  73790. /**
  73791. * Gets or sets the number of objects referencing this buffer
  73792. */
  73793. references: number;
  73794. /** Gets or sets the size of the underlying buffer */
  73795. capacity: number;
  73796. /**
  73797. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  73798. */
  73799. is32Bits: boolean;
  73800. /**
  73801. * Gets the underlying buffer
  73802. */
  73803. get underlyingResource(): any;
  73804. }
  73805. }
  73806. declare module BABYLON {
  73807. /** @hidden */
  73808. export interface IShaderProcessor {
  73809. attributeProcessor?: (attribute: string) => string;
  73810. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  73811. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  73812. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  73813. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  73814. lineProcessor?: (line: string, isFragment: boolean) => string;
  73815. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73816. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73817. }
  73818. }
  73819. declare module BABYLON {
  73820. /** @hidden */
  73821. export interface ProcessingOptions {
  73822. defines: string[];
  73823. indexParameters: any;
  73824. isFragment: boolean;
  73825. shouldUseHighPrecisionShader: boolean;
  73826. supportsUniformBuffers: boolean;
  73827. shadersRepository: string;
  73828. includesShadersStore: {
  73829. [key: string]: string;
  73830. };
  73831. processor?: IShaderProcessor;
  73832. version: string;
  73833. platformName: string;
  73834. lookForClosingBracketForUniformBuffer?: boolean;
  73835. }
  73836. }
  73837. declare module BABYLON {
  73838. /** @hidden */
  73839. export class ShaderCodeNode {
  73840. line: string;
  73841. children: ShaderCodeNode[];
  73842. additionalDefineKey?: string;
  73843. additionalDefineValue?: string;
  73844. isValid(preprocessors: {
  73845. [key: string]: string;
  73846. }): boolean;
  73847. process(preprocessors: {
  73848. [key: string]: string;
  73849. }, options: ProcessingOptions): string;
  73850. }
  73851. }
  73852. declare module BABYLON {
  73853. /** @hidden */
  73854. export class ShaderCodeCursor {
  73855. private _lines;
  73856. lineIndex: number;
  73857. get currentLine(): string;
  73858. get canRead(): boolean;
  73859. set lines(value: string[]);
  73860. }
  73861. }
  73862. declare module BABYLON {
  73863. /** @hidden */
  73864. export class ShaderCodeConditionNode extends ShaderCodeNode {
  73865. process(preprocessors: {
  73866. [key: string]: string;
  73867. }, options: ProcessingOptions): string;
  73868. }
  73869. }
  73870. declare module BABYLON {
  73871. /** @hidden */
  73872. export class ShaderDefineExpression {
  73873. isTrue(preprocessors: {
  73874. [key: string]: string;
  73875. }): boolean;
  73876. }
  73877. }
  73878. declare module BABYLON {
  73879. /** @hidden */
  73880. export class ShaderCodeTestNode extends ShaderCodeNode {
  73881. testExpression: ShaderDefineExpression;
  73882. isValid(preprocessors: {
  73883. [key: string]: string;
  73884. }): boolean;
  73885. }
  73886. }
  73887. declare module BABYLON {
  73888. /** @hidden */
  73889. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  73890. define: string;
  73891. not: boolean;
  73892. constructor(define: string, not?: boolean);
  73893. isTrue(preprocessors: {
  73894. [key: string]: string;
  73895. }): boolean;
  73896. }
  73897. }
  73898. declare module BABYLON {
  73899. /** @hidden */
  73900. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  73901. leftOperand: ShaderDefineExpression;
  73902. rightOperand: ShaderDefineExpression;
  73903. isTrue(preprocessors: {
  73904. [key: string]: string;
  73905. }): boolean;
  73906. }
  73907. }
  73908. declare module BABYLON {
  73909. /** @hidden */
  73910. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  73911. leftOperand: ShaderDefineExpression;
  73912. rightOperand: ShaderDefineExpression;
  73913. isTrue(preprocessors: {
  73914. [key: string]: string;
  73915. }): boolean;
  73916. }
  73917. }
  73918. declare module BABYLON {
  73919. /** @hidden */
  73920. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  73921. define: string;
  73922. operand: string;
  73923. testValue: string;
  73924. constructor(define: string, operand: string, testValue: string);
  73925. isTrue(preprocessors: {
  73926. [key: string]: string;
  73927. }): boolean;
  73928. }
  73929. }
  73930. declare module BABYLON {
  73931. /**
  73932. * Class used to enable access to offline support
  73933. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  73934. */
  73935. export interface IOfflineProvider {
  73936. /**
  73937. * Gets a boolean indicating if scene must be saved in the database
  73938. */
  73939. enableSceneOffline: boolean;
  73940. /**
  73941. * Gets a boolean indicating if textures must be saved in the database
  73942. */
  73943. enableTexturesOffline: boolean;
  73944. /**
  73945. * Open the offline support and make it available
  73946. * @param successCallback defines the callback to call on success
  73947. * @param errorCallback defines the callback to call on error
  73948. */
  73949. open(successCallback: () => void, errorCallback: () => void): void;
  73950. /**
  73951. * Loads an image from the offline support
  73952. * @param url defines the url to load from
  73953. * @param image defines the target DOM image
  73954. */
  73955. loadImage(url: string, image: HTMLImageElement): void;
  73956. /**
  73957. * Loads a file from offline support
  73958. * @param url defines the URL to load from
  73959. * @param sceneLoaded defines a callback to call on success
  73960. * @param progressCallBack defines a callback to call when progress changed
  73961. * @param errorCallback defines a callback to call on error
  73962. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  73963. */
  73964. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  73965. }
  73966. }
  73967. declare module BABYLON {
  73968. /**
  73969. * Class used to help managing file picking and drag'n'drop
  73970. * File Storage
  73971. */
  73972. export class FilesInputStore {
  73973. /**
  73974. * List of files ready to be loaded
  73975. */
  73976. static FilesToLoad: {
  73977. [key: string]: File;
  73978. };
  73979. }
  73980. }
  73981. declare module BABYLON {
  73982. /**
  73983. * Class used to define a retry strategy when error happens while loading assets
  73984. */
  73985. export class RetryStrategy {
  73986. /**
  73987. * Function used to defines an exponential back off strategy
  73988. * @param maxRetries defines the maximum number of retries (3 by default)
  73989. * @param baseInterval defines the interval between retries
  73990. * @returns the strategy function to use
  73991. */
  73992. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  73993. }
  73994. }
  73995. declare module BABYLON {
  73996. /**
  73997. * @ignore
  73998. * Application error to support additional information when loading a file
  73999. */
  74000. export abstract class BaseError extends Error {
  74001. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74002. }
  74003. }
  74004. declare module BABYLON {
  74005. /** @ignore */
  74006. export class LoadFileError extends BaseError {
  74007. request?: WebRequest;
  74008. file?: File;
  74009. /**
  74010. * Creates a new LoadFileError
  74011. * @param message defines the message of the error
  74012. * @param request defines the optional web request
  74013. * @param file defines the optional file
  74014. */
  74015. constructor(message: string, object?: WebRequest | File);
  74016. }
  74017. /** @ignore */
  74018. export class RequestFileError extends BaseError {
  74019. request: WebRequest;
  74020. /**
  74021. * Creates a new LoadFileError
  74022. * @param message defines the message of the error
  74023. * @param request defines the optional web request
  74024. */
  74025. constructor(message: string, request: WebRequest);
  74026. }
  74027. /** @ignore */
  74028. export class ReadFileError extends BaseError {
  74029. file: File;
  74030. /**
  74031. * Creates a new ReadFileError
  74032. * @param message defines the message of the error
  74033. * @param file defines the optional file
  74034. */
  74035. constructor(message: string, file: File);
  74036. }
  74037. /**
  74038. * @hidden
  74039. */
  74040. export class FileTools {
  74041. /**
  74042. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74043. */
  74044. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74045. /**
  74046. * Gets or sets the base URL to use to load assets
  74047. */
  74048. static BaseUrl: string;
  74049. /**
  74050. * Default behaviour for cors in the application.
  74051. * It can be a string if the expected behavior is identical in the entire app.
  74052. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74053. */
  74054. static CorsBehavior: string | ((url: string | string[]) => string);
  74055. /**
  74056. * Gets or sets a function used to pre-process url before using them to load assets
  74057. */
  74058. static PreprocessUrl: (url: string) => string;
  74059. /**
  74060. * Removes unwanted characters from an url
  74061. * @param url defines the url to clean
  74062. * @returns the cleaned url
  74063. */
  74064. private static _CleanUrl;
  74065. /**
  74066. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74067. * @param url define the url we are trying
  74068. * @param element define the dom element where to configure the cors policy
  74069. */
  74070. static SetCorsBehavior(url: string | string[], element: {
  74071. crossOrigin: string | null;
  74072. }): void;
  74073. /**
  74074. * Loads an image as an HTMLImageElement.
  74075. * @param input url string, ArrayBuffer, or Blob to load
  74076. * @param onLoad callback called when the image successfully loads
  74077. * @param onError callback called when the image fails to load
  74078. * @param offlineProvider offline provider for caching
  74079. * @param mimeType optional mime type
  74080. * @returns the HTMLImageElement of the loaded image
  74081. */
  74082. 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>;
  74083. /**
  74084. * Reads a file from a File object
  74085. * @param file defines the file to load
  74086. * @param onSuccess defines the callback to call when data is loaded
  74087. * @param onProgress defines the callback to call during loading process
  74088. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74089. * @param onError defines the callback to call when an error occurs
  74090. * @returns a file request object
  74091. */
  74092. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74093. /**
  74094. * Loads a file from a url
  74095. * @param url url to load
  74096. * @param onSuccess callback called when the file successfully loads
  74097. * @param onProgress callback called while file is loading (if the server supports this mode)
  74098. * @param offlineProvider defines the offline provider for caching
  74099. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74100. * @param onError callback called when the file fails to load
  74101. * @returns a file request object
  74102. */
  74103. 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;
  74104. /**
  74105. * Loads a file
  74106. * @param url url to load
  74107. * @param onSuccess callback called when the file successfully loads
  74108. * @param onProgress callback called while file is loading (if the server supports this mode)
  74109. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74110. * @param onError callback called when the file fails to load
  74111. * @param onOpened callback called when the web request is opened
  74112. * @returns a file request object
  74113. */
  74114. 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;
  74115. /**
  74116. * Checks if the loaded document was accessed via `file:`-Protocol.
  74117. * @returns boolean
  74118. */
  74119. static IsFileURL(): boolean;
  74120. }
  74121. }
  74122. declare module BABYLON {
  74123. /** @hidden */
  74124. export class ShaderProcessor {
  74125. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74126. private static _ProcessPrecision;
  74127. private static _ExtractOperation;
  74128. private static _BuildSubExpression;
  74129. private static _BuildExpression;
  74130. private static _MoveCursorWithinIf;
  74131. private static _MoveCursor;
  74132. private static _EvaluatePreProcessors;
  74133. private static _PreparePreProcessors;
  74134. private static _ProcessShaderConversion;
  74135. private static _ProcessIncludes;
  74136. /**
  74137. * Loads a file from a url
  74138. * @param url url to load
  74139. * @param onSuccess callback called when the file successfully loads
  74140. * @param onProgress callback called while file is loading (if the server supports this mode)
  74141. * @param offlineProvider defines the offline provider for caching
  74142. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74143. * @param onError callback called when the file fails to load
  74144. * @returns a file request object
  74145. * @hidden
  74146. */
  74147. 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;
  74148. }
  74149. }
  74150. declare module BABYLON {
  74151. /**
  74152. * @hidden
  74153. */
  74154. export interface IColor4Like {
  74155. r: float;
  74156. g: float;
  74157. b: float;
  74158. a: float;
  74159. }
  74160. /**
  74161. * @hidden
  74162. */
  74163. export interface IColor3Like {
  74164. r: float;
  74165. g: float;
  74166. b: float;
  74167. }
  74168. /**
  74169. * @hidden
  74170. */
  74171. export interface IVector4Like {
  74172. x: float;
  74173. y: float;
  74174. z: float;
  74175. w: float;
  74176. }
  74177. /**
  74178. * @hidden
  74179. */
  74180. export interface IVector3Like {
  74181. x: float;
  74182. y: float;
  74183. z: float;
  74184. }
  74185. /**
  74186. * @hidden
  74187. */
  74188. export interface IVector2Like {
  74189. x: float;
  74190. y: float;
  74191. }
  74192. /**
  74193. * @hidden
  74194. */
  74195. export interface IMatrixLike {
  74196. toArray(): DeepImmutable<Float32Array>;
  74197. updateFlag: int;
  74198. }
  74199. /**
  74200. * @hidden
  74201. */
  74202. export interface IViewportLike {
  74203. x: float;
  74204. y: float;
  74205. width: float;
  74206. height: float;
  74207. }
  74208. /**
  74209. * @hidden
  74210. */
  74211. export interface IPlaneLike {
  74212. normal: IVector3Like;
  74213. d: float;
  74214. normalize(): void;
  74215. }
  74216. }
  74217. declare module BABYLON {
  74218. /**
  74219. * Interface used to define common properties for effect fallbacks
  74220. */
  74221. export interface IEffectFallbacks {
  74222. /**
  74223. * Removes the defines that should be removed when falling back.
  74224. * @param currentDefines defines the current define statements for the shader.
  74225. * @param effect defines the current effect we try to compile
  74226. * @returns The resulting defines with defines of the current rank removed.
  74227. */
  74228. reduce(currentDefines: string, effect: Effect): string;
  74229. /**
  74230. * Removes the fallback from the bound mesh.
  74231. */
  74232. unBindMesh(): void;
  74233. /**
  74234. * Checks to see if more fallbacks are still availible.
  74235. */
  74236. hasMoreFallbacks: boolean;
  74237. }
  74238. }
  74239. declare module BABYLON {
  74240. /**
  74241. * Class used to evalaute queries containing `and` and `or` operators
  74242. */
  74243. export class AndOrNotEvaluator {
  74244. /**
  74245. * Evaluate a query
  74246. * @param query defines the query to evaluate
  74247. * @param evaluateCallback defines the callback used to filter result
  74248. * @returns true if the query matches
  74249. */
  74250. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74251. private static _HandleParenthesisContent;
  74252. private static _SimplifyNegation;
  74253. }
  74254. }
  74255. declare module BABYLON {
  74256. /**
  74257. * Class used to store custom tags
  74258. */
  74259. export class Tags {
  74260. /**
  74261. * Adds support for tags on the given object
  74262. * @param obj defines the object to use
  74263. */
  74264. static EnableFor(obj: any): void;
  74265. /**
  74266. * Removes tags support
  74267. * @param obj defines the object to use
  74268. */
  74269. static DisableFor(obj: any): void;
  74270. /**
  74271. * Gets a boolean indicating if the given object has tags
  74272. * @param obj defines the object to use
  74273. * @returns a boolean
  74274. */
  74275. static HasTags(obj: any): boolean;
  74276. /**
  74277. * Gets the tags available on a given object
  74278. * @param obj defines the object to use
  74279. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74280. * @returns the tags
  74281. */
  74282. static GetTags(obj: any, asString?: boolean): any;
  74283. /**
  74284. * Adds tags to an object
  74285. * @param obj defines the object to use
  74286. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74287. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74288. */
  74289. static AddTagsTo(obj: any, tagsString: string): void;
  74290. /**
  74291. * @hidden
  74292. */
  74293. static _AddTagTo(obj: any, tag: string): void;
  74294. /**
  74295. * Removes specific tags from a specific object
  74296. * @param obj defines the object to use
  74297. * @param tagsString defines the tags to remove
  74298. */
  74299. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74300. /**
  74301. * @hidden
  74302. */
  74303. static _RemoveTagFrom(obj: any, tag: string): void;
  74304. /**
  74305. * Defines if tags hosted on an object match a given query
  74306. * @param obj defines the object to use
  74307. * @param tagsQuery defines the tag query
  74308. * @returns a boolean
  74309. */
  74310. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74311. }
  74312. }
  74313. declare module BABYLON {
  74314. /**
  74315. * Scalar computation library
  74316. */
  74317. export class Scalar {
  74318. /**
  74319. * Two pi constants convenient for computation.
  74320. */
  74321. static TwoPi: number;
  74322. /**
  74323. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74324. * @param a number
  74325. * @param b number
  74326. * @param epsilon (default = 1.401298E-45)
  74327. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74328. */
  74329. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74330. /**
  74331. * Returns a string : the upper case translation of the number i to hexadecimal.
  74332. * @param i number
  74333. * @returns the upper case translation of the number i to hexadecimal.
  74334. */
  74335. static ToHex(i: number): string;
  74336. /**
  74337. * Returns -1 if value is negative and +1 is value is positive.
  74338. * @param value the value
  74339. * @returns the value itself if it's equal to zero.
  74340. */
  74341. static Sign(value: number): number;
  74342. /**
  74343. * Returns the value itself if it's between min and max.
  74344. * Returns min if the value is lower than min.
  74345. * Returns max if the value is greater than max.
  74346. * @param value the value to clmap
  74347. * @param min the min value to clamp to (default: 0)
  74348. * @param max the max value to clamp to (default: 1)
  74349. * @returns the clamped value
  74350. */
  74351. static Clamp(value: number, min?: number, max?: number): number;
  74352. /**
  74353. * the log2 of value.
  74354. * @param value the value to compute log2 of
  74355. * @returns the log2 of value.
  74356. */
  74357. static Log2(value: number): number;
  74358. /**
  74359. * Loops the value, so that it is never larger than length and never smaller than 0.
  74360. *
  74361. * This is similar to the modulo operator but it works with floating point numbers.
  74362. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74363. * With t = 5 and length = 2.5, the result would be 0.0.
  74364. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74365. * @param value the value
  74366. * @param length the length
  74367. * @returns the looped value
  74368. */
  74369. static Repeat(value: number, length: number): number;
  74370. /**
  74371. * Normalize the value between 0.0 and 1.0 using min and max values
  74372. * @param value value to normalize
  74373. * @param min max to normalize between
  74374. * @param max min to normalize between
  74375. * @returns the normalized value
  74376. */
  74377. static Normalize(value: number, min: number, max: number): number;
  74378. /**
  74379. * Denormalize the value from 0.0 and 1.0 using min and max values
  74380. * @param normalized value to denormalize
  74381. * @param min max to denormalize between
  74382. * @param max min to denormalize between
  74383. * @returns the denormalized value
  74384. */
  74385. static Denormalize(normalized: number, min: number, max: number): number;
  74386. /**
  74387. * Calculates the shortest difference between two given angles given in degrees.
  74388. * @param current current angle in degrees
  74389. * @param target target angle in degrees
  74390. * @returns the delta
  74391. */
  74392. static DeltaAngle(current: number, target: number): number;
  74393. /**
  74394. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74395. * @param tx value
  74396. * @param length length
  74397. * @returns The returned value will move back and forth between 0 and length
  74398. */
  74399. static PingPong(tx: number, length: number): number;
  74400. /**
  74401. * Interpolates between min and max with smoothing at the limits.
  74402. *
  74403. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74404. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74405. * @param from from
  74406. * @param to to
  74407. * @param tx value
  74408. * @returns the smooth stepped value
  74409. */
  74410. static SmoothStep(from: number, to: number, tx: number): number;
  74411. /**
  74412. * Moves a value current towards target.
  74413. *
  74414. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74415. * Negative values of maxDelta pushes the value away from target.
  74416. * @param current current value
  74417. * @param target target value
  74418. * @param maxDelta max distance to move
  74419. * @returns resulting value
  74420. */
  74421. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74422. /**
  74423. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74424. *
  74425. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74426. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74427. * @param current current value
  74428. * @param target target value
  74429. * @param maxDelta max distance to move
  74430. * @returns resulting angle
  74431. */
  74432. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74433. /**
  74434. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74435. * @param start start value
  74436. * @param end target value
  74437. * @param amount amount to lerp between
  74438. * @returns the lerped value
  74439. */
  74440. static Lerp(start: number, end: number, amount: number): number;
  74441. /**
  74442. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74443. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74444. * @param start start value
  74445. * @param end target value
  74446. * @param amount amount to lerp between
  74447. * @returns the lerped value
  74448. */
  74449. static LerpAngle(start: number, end: number, amount: number): number;
  74450. /**
  74451. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74452. * @param a start value
  74453. * @param b target value
  74454. * @param value value between a and b
  74455. * @returns the inverseLerp value
  74456. */
  74457. static InverseLerp(a: number, b: number, value: number): number;
  74458. /**
  74459. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74460. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74461. * @param value1 spline value
  74462. * @param tangent1 spline value
  74463. * @param value2 spline value
  74464. * @param tangent2 spline value
  74465. * @param amount input value
  74466. * @returns hermite result
  74467. */
  74468. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74469. /**
  74470. * Returns a random float number between and min and max values
  74471. * @param min min value of random
  74472. * @param max max value of random
  74473. * @returns random value
  74474. */
  74475. static RandomRange(min: number, max: number): number;
  74476. /**
  74477. * This function returns percentage of a number in a given range.
  74478. *
  74479. * RangeToPercent(40,20,60) will return 0.5 (50%)
  74480. * RangeToPercent(34,0,100) will return 0.34 (34%)
  74481. * @param number to convert to percentage
  74482. * @param min min range
  74483. * @param max max range
  74484. * @returns the percentage
  74485. */
  74486. static RangeToPercent(number: number, min: number, max: number): number;
  74487. /**
  74488. * This function returns number that corresponds to the percentage in a given range.
  74489. *
  74490. * PercentToRange(0.34,0,100) will return 34.
  74491. * @param percent to convert to number
  74492. * @param min min range
  74493. * @param max max range
  74494. * @returns the number
  74495. */
  74496. static PercentToRange(percent: number, min: number, max: number): number;
  74497. /**
  74498. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  74499. * @param angle The angle to normalize in radian.
  74500. * @return The converted angle.
  74501. */
  74502. static NormalizeRadians(angle: number): number;
  74503. }
  74504. }
  74505. declare module BABYLON {
  74506. /**
  74507. * Constant used to convert a value to gamma space
  74508. * @ignorenaming
  74509. */
  74510. export const ToGammaSpace: number;
  74511. /**
  74512. * Constant used to convert a value to linear space
  74513. * @ignorenaming
  74514. */
  74515. export const ToLinearSpace = 2.2;
  74516. /**
  74517. * Constant used to define the minimal number value in Babylon.js
  74518. * @ignorenaming
  74519. */
  74520. let Epsilon: number;
  74521. }
  74522. declare module BABYLON {
  74523. /**
  74524. * Class used to represent a viewport on screen
  74525. */
  74526. export class Viewport {
  74527. /** viewport left coordinate */
  74528. x: number;
  74529. /** viewport top coordinate */
  74530. y: number;
  74531. /**viewport width */
  74532. width: number;
  74533. /** viewport height */
  74534. height: number;
  74535. /**
  74536. * Creates a Viewport object located at (x, y) and sized (width, height)
  74537. * @param x defines viewport left coordinate
  74538. * @param y defines viewport top coordinate
  74539. * @param width defines the viewport width
  74540. * @param height defines the viewport height
  74541. */
  74542. constructor(
  74543. /** viewport left coordinate */
  74544. x: number,
  74545. /** viewport top coordinate */
  74546. y: number,
  74547. /**viewport width */
  74548. width: number,
  74549. /** viewport height */
  74550. height: number);
  74551. /**
  74552. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74553. * @param renderWidth defines the rendering width
  74554. * @param renderHeight defines the rendering height
  74555. * @returns a new Viewport
  74556. */
  74557. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  74558. /**
  74559. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74560. * @param renderWidth defines the rendering width
  74561. * @param renderHeight defines the rendering height
  74562. * @param ref defines the target viewport
  74563. * @returns the current viewport
  74564. */
  74565. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  74566. /**
  74567. * Returns a new Viewport copied from the current one
  74568. * @returns a new Viewport
  74569. */
  74570. clone(): Viewport;
  74571. }
  74572. }
  74573. declare module BABYLON {
  74574. /**
  74575. * Class containing a set of static utilities functions for arrays.
  74576. */
  74577. export class ArrayTools {
  74578. /**
  74579. * Returns an array of the given size filled with element built from the given constructor and the paramters
  74580. * @param size the number of element to construct and put in the array
  74581. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  74582. * @returns a new array filled with new objects
  74583. */
  74584. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  74585. }
  74586. }
  74587. declare module BABYLON {
  74588. /**
  74589. * Class representing a vector containing 2 coordinates
  74590. */
  74591. export class Vector2 {
  74592. /** defines the first coordinate */
  74593. x: number;
  74594. /** defines the second coordinate */
  74595. y: number;
  74596. /**
  74597. * Creates a new Vector2 from the given x and y coordinates
  74598. * @param x defines the first coordinate
  74599. * @param y defines the second coordinate
  74600. */
  74601. constructor(
  74602. /** defines the first coordinate */
  74603. x?: number,
  74604. /** defines the second coordinate */
  74605. y?: number);
  74606. /**
  74607. * Gets a string with the Vector2 coordinates
  74608. * @returns a string with the Vector2 coordinates
  74609. */
  74610. toString(): string;
  74611. /**
  74612. * Gets class name
  74613. * @returns the string "Vector2"
  74614. */
  74615. getClassName(): string;
  74616. /**
  74617. * Gets current vector hash code
  74618. * @returns the Vector2 hash code as a number
  74619. */
  74620. getHashCode(): number;
  74621. /**
  74622. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  74623. * @param array defines the source array
  74624. * @param index defines the offset in source array
  74625. * @returns the current Vector2
  74626. */
  74627. toArray(array: FloatArray, index?: number): Vector2;
  74628. /**
  74629. * Copy the current vector to an array
  74630. * @returns a new array with 2 elements: the Vector2 coordinates.
  74631. */
  74632. asArray(): number[];
  74633. /**
  74634. * Sets the Vector2 coordinates with the given Vector2 coordinates
  74635. * @param source defines the source Vector2
  74636. * @returns the current updated Vector2
  74637. */
  74638. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  74639. /**
  74640. * Sets the Vector2 coordinates with the given floats
  74641. * @param x defines the first coordinate
  74642. * @param y defines the second coordinate
  74643. * @returns the current updated Vector2
  74644. */
  74645. copyFromFloats(x: number, y: number): Vector2;
  74646. /**
  74647. * Sets the Vector2 coordinates with the given floats
  74648. * @param x defines the first coordinate
  74649. * @param y defines the second coordinate
  74650. * @returns the current updated Vector2
  74651. */
  74652. set(x: number, y: number): Vector2;
  74653. /**
  74654. * Add another vector with the current one
  74655. * @param otherVector defines the other vector
  74656. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  74657. */
  74658. add(otherVector: DeepImmutable<Vector2>): Vector2;
  74659. /**
  74660. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  74661. * @param otherVector defines the other vector
  74662. * @param result defines the target vector
  74663. * @returns the unmodified current Vector2
  74664. */
  74665. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74666. /**
  74667. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  74668. * @param otherVector defines the other vector
  74669. * @returns the current updated Vector2
  74670. */
  74671. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74672. /**
  74673. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  74674. * @param otherVector defines the other vector
  74675. * @returns a new Vector2
  74676. */
  74677. addVector3(otherVector: Vector3): Vector2;
  74678. /**
  74679. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  74680. * @param otherVector defines the other vector
  74681. * @returns a new Vector2
  74682. */
  74683. subtract(otherVector: Vector2): Vector2;
  74684. /**
  74685. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  74686. * @param otherVector defines the other vector
  74687. * @param result defines the target vector
  74688. * @returns the unmodified current Vector2
  74689. */
  74690. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74691. /**
  74692. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  74693. * @param otherVector defines the other vector
  74694. * @returns the current updated Vector2
  74695. */
  74696. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74697. /**
  74698. * Multiplies in place the current Vector2 coordinates by the given ones
  74699. * @param otherVector defines the other vector
  74700. * @returns the current updated Vector2
  74701. */
  74702. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74703. /**
  74704. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  74705. * @param otherVector defines the other vector
  74706. * @returns a new Vector2
  74707. */
  74708. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  74709. /**
  74710. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  74711. * @param otherVector defines the other vector
  74712. * @param result defines the target vector
  74713. * @returns the unmodified current Vector2
  74714. */
  74715. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74716. /**
  74717. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  74718. * @param x defines the first coordinate
  74719. * @param y defines the second coordinate
  74720. * @returns a new Vector2
  74721. */
  74722. multiplyByFloats(x: number, y: number): Vector2;
  74723. /**
  74724. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  74725. * @param otherVector defines the other vector
  74726. * @returns a new Vector2
  74727. */
  74728. divide(otherVector: Vector2): Vector2;
  74729. /**
  74730. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  74731. * @param otherVector defines the other vector
  74732. * @param result defines the target vector
  74733. * @returns the unmodified current Vector2
  74734. */
  74735. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74736. /**
  74737. * Divides the current Vector2 coordinates by the given ones
  74738. * @param otherVector defines the other vector
  74739. * @returns the current updated Vector2
  74740. */
  74741. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74742. /**
  74743. * Gets a new Vector2 with current Vector2 negated coordinates
  74744. * @returns a new Vector2
  74745. */
  74746. negate(): Vector2;
  74747. /**
  74748. * Multiply the Vector2 coordinates by scale
  74749. * @param scale defines the scaling factor
  74750. * @returns the current updated Vector2
  74751. */
  74752. scaleInPlace(scale: number): Vector2;
  74753. /**
  74754. * Returns a new Vector2 scaled by "scale" from the current Vector2
  74755. * @param scale defines the scaling factor
  74756. * @returns a new Vector2
  74757. */
  74758. scale(scale: number): Vector2;
  74759. /**
  74760. * Scale the current Vector2 values by a factor to a given Vector2
  74761. * @param scale defines the scale factor
  74762. * @param result defines the Vector2 object where to store the result
  74763. * @returns the unmodified current Vector2
  74764. */
  74765. scaleToRef(scale: number, result: Vector2): Vector2;
  74766. /**
  74767. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  74768. * @param scale defines the scale factor
  74769. * @param result defines the Vector2 object where to store the result
  74770. * @returns the unmodified current Vector2
  74771. */
  74772. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  74773. /**
  74774. * Gets a boolean if two vectors are equals
  74775. * @param otherVector defines the other vector
  74776. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  74777. */
  74778. equals(otherVector: DeepImmutable<Vector2>): boolean;
  74779. /**
  74780. * Gets a boolean if two vectors are equals (using an epsilon value)
  74781. * @param otherVector defines the other vector
  74782. * @param epsilon defines the minimal distance to consider equality
  74783. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  74784. */
  74785. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  74786. /**
  74787. * Gets a new Vector2 from current Vector2 floored values
  74788. * @returns a new Vector2
  74789. */
  74790. floor(): Vector2;
  74791. /**
  74792. * Gets a new Vector2 from current Vector2 floored values
  74793. * @returns a new Vector2
  74794. */
  74795. fract(): Vector2;
  74796. /**
  74797. * Gets the length of the vector
  74798. * @returns the vector length (float)
  74799. */
  74800. length(): number;
  74801. /**
  74802. * Gets the vector squared length
  74803. * @returns the vector squared length (float)
  74804. */
  74805. lengthSquared(): number;
  74806. /**
  74807. * Normalize the vector
  74808. * @returns the current updated Vector2
  74809. */
  74810. normalize(): Vector2;
  74811. /**
  74812. * Gets a new Vector2 copied from the Vector2
  74813. * @returns a new Vector2
  74814. */
  74815. clone(): Vector2;
  74816. /**
  74817. * Gets a new Vector2(0, 0)
  74818. * @returns a new Vector2
  74819. */
  74820. static Zero(): Vector2;
  74821. /**
  74822. * Gets a new Vector2(1, 1)
  74823. * @returns a new Vector2
  74824. */
  74825. static One(): Vector2;
  74826. /**
  74827. * Gets a new Vector2 set from the given index element of the given array
  74828. * @param array defines the data source
  74829. * @param offset defines the offset in the data source
  74830. * @returns a new Vector2
  74831. */
  74832. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  74833. /**
  74834. * Sets "result" from the given index element of the given array
  74835. * @param array defines the data source
  74836. * @param offset defines the offset in the data source
  74837. * @param result defines the target vector
  74838. */
  74839. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  74840. /**
  74841. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  74842. * @param value1 defines 1st point of control
  74843. * @param value2 defines 2nd point of control
  74844. * @param value3 defines 3rd point of control
  74845. * @param value4 defines 4th point of control
  74846. * @param amount defines the interpolation factor
  74847. * @returns a new Vector2
  74848. */
  74849. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  74850. /**
  74851. * 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".
  74852. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  74853. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  74854. * @param value defines the value to clamp
  74855. * @param min defines the lower limit
  74856. * @param max defines the upper limit
  74857. * @returns a new Vector2
  74858. */
  74859. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  74860. /**
  74861. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  74862. * @param value1 defines the 1st control point
  74863. * @param tangent1 defines the outgoing tangent
  74864. * @param value2 defines the 2nd control point
  74865. * @param tangent2 defines the incoming tangent
  74866. * @param amount defines the interpolation factor
  74867. * @returns a new Vector2
  74868. */
  74869. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  74870. /**
  74871. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  74872. * @param start defines the start vector
  74873. * @param end defines the end vector
  74874. * @param amount defines the interpolation factor
  74875. * @returns a new Vector2
  74876. */
  74877. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  74878. /**
  74879. * Gets the dot product of the vector "left" and the vector "right"
  74880. * @param left defines first vector
  74881. * @param right defines second vector
  74882. * @returns the dot product (float)
  74883. */
  74884. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  74885. /**
  74886. * Returns a new Vector2 equal to the normalized given vector
  74887. * @param vector defines the vector to normalize
  74888. * @returns a new Vector2
  74889. */
  74890. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  74891. /**
  74892. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  74893. * @param left defines 1st vector
  74894. * @param right defines 2nd vector
  74895. * @returns a new Vector2
  74896. */
  74897. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74898. /**
  74899. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  74900. * @param left defines 1st vector
  74901. * @param right defines 2nd vector
  74902. * @returns a new Vector2
  74903. */
  74904. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74905. /**
  74906. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  74907. * @param vector defines the vector to transform
  74908. * @param transformation defines the matrix to apply
  74909. * @returns a new Vector2
  74910. */
  74911. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  74912. /**
  74913. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  74914. * @param vector defines the vector to transform
  74915. * @param transformation defines the matrix to apply
  74916. * @param result defines the target vector
  74917. */
  74918. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  74919. /**
  74920. * Determines if a given vector is included in a triangle
  74921. * @param p defines the vector to test
  74922. * @param p0 defines 1st triangle point
  74923. * @param p1 defines 2nd triangle point
  74924. * @param p2 defines 3rd triangle point
  74925. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  74926. */
  74927. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  74928. /**
  74929. * Gets the distance between the vectors "value1" and "value2"
  74930. * @param value1 defines first vector
  74931. * @param value2 defines second vector
  74932. * @returns the distance between vectors
  74933. */
  74934. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74935. /**
  74936. * Returns the squared distance between the vectors "value1" and "value2"
  74937. * @param value1 defines first vector
  74938. * @param value2 defines second vector
  74939. * @returns the squared distance between vectors
  74940. */
  74941. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74942. /**
  74943. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  74944. * @param value1 defines first vector
  74945. * @param value2 defines second vector
  74946. * @returns a new Vector2
  74947. */
  74948. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  74949. /**
  74950. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  74951. * @param p defines the middle point
  74952. * @param segA defines one point of the segment
  74953. * @param segB defines the other point of the segment
  74954. * @returns the shortest distance
  74955. */
  74956. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  74957. }
  74958. /**
  74959. * Class used to store (x,y,z) vector representation
  74960. * A Vector3 is the main object used in 3D geometry
  74961. * It can represent etiher the coordinates of a point the space, either a direction
  74962. * Reminder: js uses a left handed forward facing system
  74963. */
  74964. export class Vector3 {
  74965. /**
  74966. * Defines the first coordinates (on X axis)
  74967. */
  74968. x: number;
  74969. /**
  74970. * Defines the second coordinates (on Y axis)
  74971. */
  74972. y: number;
  74973. /**
  74974. * Defines the third coordinates (on Z axis)
  74975. */
  74976. z: number;
  74977. private static _UpReadOnly;
  74978. private static _ZeroReadOnly;
  74979. /**
  74980. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  74981. * @param x defines the first coordinates (on X axis)
  74982. * @param y defines the second coordinates (on Y axis)
  74983. * @param z defines the third coordinates (on Z axis)
  74984. */
  74985. constructor(
  74986. /**
  74987. * Defines the first coordinates (on X axis)
  74988. */
  74989. x?: number,
  74990. /**
  74991. * Defines the second coordinates (on Y axis)
  74992. */
  74993. y?: number,
  74994. /**
  74995. * Defines the third coordinates (on Z axis)
  74996. */
  74997. z?: number);
  74998. /**
  74999. * Creates a string representation of the Vector3
  75000. * @returns a string with the Vector3 coordinates.
  75001. */
  75002. toString(): string;
  75003. /**
  75004. * Gets the class name
  75005. * @returns the string "Vector3"
  75006. */
  75007. getClassName(): string;
  75008. /**
  75009. * Creates the Vector3 hash code
  75010. * @returns a number which tends to be unique between Vector3 instances
  75011. */
  75012. getHashCode(): number;
  75013. /**
  75014. * Creates an array containing three elements : the coordinates of the Vector3
  75015. * @returns a new array of numbers
  75016. */
  75017. asArray(): number[];
  75018. /**
  75019. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75020. * @param array defines the destination array
  75021. * @param index defines the offset in the destination array
  75022. * @returns the current Vector3
  75023. */
  75024. toArray(array: FloatArray, index?: number): Vector3;
  75025. /**
  75026. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75027. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75028. */
  75029. toQuaternion(): Quaternion;
  75030. /**
  75031. * Adds the given vector to the current Vector3
  75032. * @param otherVector defines the second operand
  75033. * @returns the current updated Vector3
  75034. */
  75035. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75036. /**
  75037. * Adds the given coordinates to the current Vector3
  75038. * @param x defines the x coordinate of the operand
  75039. * @param y defines the y coordinate of the operand
  75040. * @param z defines the z coordinate of the operand
  75041. * @returns the current updated Vector3
  75042. */
  75043. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75044. /**
  75045. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75046. * @param otherVector defines the second operand
  75047. * @returns the resulting Vector3
  75048. */
  75049. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75050. /**
  75051. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75052. * @param otherVector defines the second operand
  75053. * @param result defines the Vector3 object where to store the result
  75054. * @returns the current Vector3
  75055. */
  75056. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75057. /**
  75058. * Subtract the given vector from the current Vector3
  75059. * @param otherVector defines the second operand
  75060. * @returns the current updated Vector3
  75061. */
  75062. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75063. /**
  75064. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75065. * @param otherVector defines the second operand
  75066. * @returns the resulting Vector3
  75067. */
  75068. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75069. /**
  75070. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75071. * @param otherVector defines the second operand
  75072. * @param result defines the Vector3 object where to store the result
  75073. * @returns the current Vector3
  75074. */
  75075. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75076. /**
  75077. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75078. * @param x defines the x coordinate of the operand
  75079. * @param y defines the y coordinate of the operand
  75080. * @param z defines the z coordinate of the operand
  75081. * @returns the resulting Vector3
  75082. */
  75083. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75084. /**
  75085. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75086. * @param x defines the x coordinate of the operand
  75087. * @param y defines the y coordinate of the operand
  75088. * @param z defines the z coordinate of the operand
  75089. * @param result defines the Vector3 object where to store the result
  75090. * @returns the current Vector3
  75091. */
  75092. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75093. /**
  75094. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75095. * @returns a new Vector3
  75096. */
  75097. negate(): Vector3;
  75098. /**
  75099. * Negate this vector in place
  75100. * @returns this
  75101. */
  75102. negateInPlace(): Vector3;
  75103. /**
  75104. * Multiplies the Vector3 coordinates by the float "scale"
  75105. * @param scale defines the multiplier factor
  75106. * @returns the current updated Vector3
  75107. */
  75108. scaleInPlace(scale: number): Vector3;
  75109. /**
  75110. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75111. * @param scale defines the multiplier factor
  75112. * @returns a new Vector3
  75113. */
  75114. scale(scale: number): Vector3;
  75115. /**
  75116. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75117. * @param scale defines the multiplier factor
  75118. * @param result defines the Vector3 object where to store the result
  75119. * @returns the current Vector3
  75120. */
  75121. scaleToRef(scale: number, result: Vector3): Vector3;
  75122. /**
  75123. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75124. * @param scale defines the scale factor
  75125. * @param result defines the Vector3 object where to store the result
  75126. * @returns the unmodified current Vector3
  75127. */
  75128. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75129. /**
  75130. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75131. * @param otherVector defines the second operand
  75132. * @returns true if both vectors are equals
  75133. */
  75134. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75135. /**
  75136. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75137. * @param otherVector defines the second operand
  75138. * @param epsilon defines the minimal distance to define values as equals
  75139. * @returns true if both vectors are distant less than epsilon
  75140. */
  75141. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75142. /**
  75143. * Returns true if the current Vector3 coordinates equals the given floats
  75144. * @param x defines the x coordinate of the operand
  75145. * @param y defines the y coordinate of the operand
  75146. * @param z defines the z coordinate of the operand
  75147. * @returns true if both vectors are equals
  75148. */
  75149. equalsToFloats(x: number, y: number, z: number): boolean;
  75150. /**
  75151. * Multiplies the current Vector3 coordinates by the given ones
  75152. * @param otherVector defines the second operand
  75153. * @returns the current updated Vector3
  75154. */
  75155. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75156. /**
  75157. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75158. * @param otherVector defines the second operand
  75159. * @returns the new Vector3
  75160. */
  75161. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75162. /**
  75163. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75164. * @param otherVector defines the second operand
  75165. * @param result defines the Vector3 object where to store the result
  75166. * @returns the current Vector3
  75167. */
  75168. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75169. /**
  75170. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75171. * @param x defines the x coordinate of the operand
  75172. * @param y defines the y coordinate of the operand
  75173. * @param z defines the z coordinate of the operand
  75174. * @returns the new Vector3
  75175. */
  75176. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75177. /**
  75178. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75179. * @param otherVector defines the second operand
  75180. * @returns the new Vector3
  75181. */
  75182. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75183. /**
  75184. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75185. * @param otherVector defines the second operand
  75186. * @param result defines the Vector3 object where to store the result
  75187. * @returns the current Vector3
  75188. */
  75189. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75190. /**
  75191. * Divides the current Vector3 coordinates by the given ones.
  75192. * @param otherVector defines the second operand
  75193. * @returns the current updated Vector3
  75194. */
  75195. divideInPlace(otherVector: Vector3): Vector3;
  75196. /**
  75197. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75198. * @param other defines the second operand
  75199. * @returns the current updated Vector3
  75200. */
  75201. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75202. /**
  75203. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75204. * @param other defines the second operand
  75205. * @returns the current updated Vector3
  75206. */
  75207. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75208. /**
  75209. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75210. * @param x defines the x coordinate of the operand
  75211. * @param y defines the y coordinate of the operand
  75212. * @param z defines the z coordinate of the operand
  75213. * @returns the current updated Vector3
  75214. */
  75215. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75216. /**
  75217. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75218. * @param x defines the x coordinate of the operand
  75219. * @param y defines the y coordinate of the operand
  75220. * @param z defines the z coordinate of the operand
  75221. * @returns the current updated Vector3
  75222. */
  75223. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75224. /**
  75225. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75226. * Check if is non uniform within a certain amount of decimal places to account for this
  75227. * @param epsilon the amount the values can differ
  75228. * @returns if the the vector is non uniform to a certain number of decimal places
  75229. */
  75230. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75231. /**
  75232. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75233. */
  75234. get isNonUniform(): boolean;
  75235. /**
  75236. * Gets a new Vector3 from current Vector3 floored values
  75237. * @returns a new Vector3
  75238. */
  75239. floor(): Vector3;
  75240. /**
  75241. * Gets a new Vector3 from current Vector3 floored values
  75242. * @returns a new Vector3
  75243. */
  75244. fract(): Vector3;
  75245. /**
  75246. * Gets the length of the Vector3
  75247. * @returns the length of the Vector3
  75248. */
  75249. length(): number;
  75250. /**
  75251. * Gets the squared length of the Vector3
  75252. * @returns squared length of the Vector3
  75253. */
  75254. lengthSquared(): number;
  75255. /**
  75256. * Normalize the current Vector3.
  75257. * Please note that this is an in place operation.
  75258. * @returns the current updated Vector3
  75259. */
  75260. normalize(): Vector3;
  75261. /**
  75262. * Reorders the x y z properties of the vector in place
  75263. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75264. * @returns the current updated vector
  75265. */
  75266. reorderInPlace(order: string): this;
  75267. /**
  75268. * Rotates the vector around 0,0,0 by a quaternion
  75269. * @param quaternion the rotation quaternion
  75270. * @param result vector to store the result
  75271. * @returns the resulting vector
  75272. */
  75273. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75274. /**
  75275. * Rotates a vector around a given point
  75276. * @param quaternion the rotation quaternion
  75277. * @param point the point to rotate around
  75278. * @param result vector to store the result
  75279. * @returns the resulting vector
  75280. */
  75281. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75282. /**
  75283. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75284. * The cross product is then orthogonal to both current and "other"
  75285. * @param other defines the right operand
  75286. * @returns the cross product
  75287. */
  75288. cross(other: Vector3): Vector3;
  75289. /**
  75290. * Normalize the current Vector3 with the given input length.
  75291. * Please note that this is an in place operation.
  75292. * @param len the length of the vector
  75293. * @returns the current updated Vector3
  75294. */
  75295. normalizeFromLength(len: number): Vector3;
  75296. /**
  75297. * Normalize the current Vector3 to a new vector
  75298. * @returns the new Vector3
  75299. */
  75300. normalizeToNew(): Vector3;
  75301. /**
  75302. * Normalize the current Vector3 to the reference
  75303. * @param reference define the Vector3 to update
  75304. * @returns the updated Vector3
  75305. */
  75306. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75307. /**
  75308. * Creates a new Vector3 copied from the current Vector3
  75309. * @returns the new Vector3
  75310. */
  75311. clone(): Vector3;
  75312. /**
  75313. * Copies the given vector coordinates to the current Vector3 ones
  75314. * @param source defines the source Vector3
  75315. * @returns the current updated Vector3
  75316. */
  75317. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75318. /**
  75319. * Copies the given floats to the current Vector3 coordinates
  75320. * @param x defines the x coordinate of the operand
  75321. * @param y defines the y coordinate of the operand
  75322. * @param z defines the z coordinate of the operand
  75323. * @returns the current updated Vector3
  75324. */
  75325. copyFromFloats(x: number, y: number, z: number): Vector3;
  75326. /**
  75327. * Copies the given floats to the current Vector3 coordinates
  75328. * @param x defines the x coordinate of the operand
  75329. * @param y defines the y coordinate of the operand
  75330. * @param z defines the z coordinate of the operand
  75331. * @returns the current updated Vector3
  75332. */
  75333. set(x: number, y: number, z: number): Vector3;
  75334. /**
  75335. * Copies the given float to the current Vector3 coordinates
  75336. * @param v defines the x, y and z coordinates of the operand
  75337. * @returns the current updated Vector3
  75338. */
  75339. setAll(v: number): Vector3;
  75340. /**
  75341. * Get the clip factor between two vectors
  75342. * @param vector0 defines the first operand
  75343. * @param vector1 defines the second operand
  75344. * @param axis defines the axis to use
  75345. * @param size defines the size along the axis
  75346. * @returns the clip factor
  75347. */
  75348. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75349. /**
  75350. * Get angle between two vectors
  75351. * @param vector0 angle between vector0 and vector1
  75352. * @param vector1 angle between vector0 and vector1
  75353. * @param normal direction of the normal
  75354. * @return the angle between vector0 and vector1
  75355. */
  75356. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75357. /**
  75358. * Returns a new Vector3 set from the index "offset" of the given array
  75359. * @param array defines the source array
  75360. * @param offset defines the offset in the source array
  75361. * @returns the new Vector3
  75362. */
  75363. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75364. /**
  75365. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75366. * @param array defines the source array
  75367. * @param offset defines the offset in the source array
  75368. * @returns the new Vector3
  75369. * @deprecated Please use FromArray instead.
  75370. */
  75371. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75372. /**
  75373. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75374. * @param array defines the source array
  75375. * @param offset defines the offset in the source array
  75376. * @param result defines the Vector3 where to store the result
  75377. */
  75378. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75379. /**
  75380. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75381. * @param array defines the source array
  75382. * @param offset defines the offset in the source array
  75383. * @param result defines the Vector3 where to store the result
  75384. * @deprecated Please use FromArrayToRef instead.
  75385. */
  75386. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75387. /**
  75388. * Sets the given vector "result" with the given floats.
  75389. * @param x defines the x coordinate of the source
  75390. * @param y defines the y coordinate of the source
  75391. * @param z defines the z coordinate of the source
  75392. * @param result defines the Vector3 where to store the result
  75393. */
  75394. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75395. /**
  75396. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75397. * @returns a new empty Vector3
  75398. */
  75399. static Zero(): Vector3;
  75400. /**
  75401. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75402. * @returns a new unit Vector3
  75403. */
  75404. static One(): Vector3;
  75405. /**
  75406. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75407. * @returns a new up Vector3
  75408. */
  75409. static Up(): Vector3;
  75410. /**
  75411. * Gets a up Vector3 that must not be updated
  75412. */
  75413. static get UpReadOnly(): DeepImmutable<Vector3>;
  75414. /**
  75415. * Gets a zero Vector3 that must not be updated
  75416. */
  75417. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75418. /**
  75419. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75420. * @returns a new down Vector3
  75421. */
  75422. static Down(): Vector3;
  75423. /**
  75424. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75425. * @returns a new forward Vector3
  75426. */
  75427. static Forward(): Vector3;
  75428. /**
  75429. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75430. * @returns a new forward Vector3
  75431. */
  75432. static Backward(): Vector3;
  75433. /**
  75434. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75435. * @returns a new right Vector3
  75436. */
  75437. static Right(): Vector3;
  75438. /**
  75439. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75440. * @returns a new left Vector3
  75441. */
  75442. static Left(): Vector3;
  75443. /**
  75444. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75445. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75446. * @param vector defines the Vector3 to transform
  75447. * @param transformation defines the transformation matrix
  75448. * @returns the transformed Vector3
  75449. */
  75450. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75451. /**
  75452. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75453. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75454. * @param vector defines the Vector3 to transform
  75455. * @param transformation defines the transformation matrix
  75456. * @param result defines the Vector3 where to store the result
  75457. */
  75458. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75459. /**
  75460. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  75461. * This method computes tranformed coordinates only, not transformed direction vectors
  75462. * @param x define the x coordinate of the source vector
  75463. * @param y define the y coordinate of the source vector
  75464. * @param z define the z coordinate of the source vector
  75465. * @param transformation defines the transformation matrix
  75466. * @param result defines the Vector3 where to store the result
  75467. */
  75468. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75469. /**
  75470. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  75471. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75472. * @param vector defines the Vector3 to transform
  75473. * @param transformation defines the transformation matrix
  75474. * @returns the new Vector3
  75475. */
  75476. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75477. /**
  75478. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  75479. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75480. * @param vector defines the Vector3 to transform
  75481. * @param transformation defines the transformation matrix
  75482. * @param result defines the Vector3 where to store the result
  75483. */
  75484. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75485. /**
  75486. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  75487. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75488. * @param x define the x coordinate of the source vector
  75489. * @param y define the y coordinate of the source vector
  75490. * @param z define the z coordinate of the source vector
  75491. * @param transformation defines the transformation matrix
  75492. * @param result defines the Vector3 where to store the result
  75493. */
  75494. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75495. /**
  75496. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  75497. * @param value1 defines the first control point
  75498. * @param value2 defines the second control point
  75499. * @param value3 defines the third control point
  75500. * @param value4 defines the fourth control point
  75501. * @param amount defines the amount on the spline to use
  75502. * @returns the new Vector3
  75503. */
  75504. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  75505. /**
  75506. * 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"
  75507. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75508. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75509. * @param value defines the current value
  75510. * @param min defines the lower range value
  75511. * @param max defines the upper range value
  75512. * @returns the new Vector3
  75513. */
  75514. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  75515. /**
  75516. * 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"
  75517. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75518. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75519. * @param value defines the current value
  75520. * @param min defines the lower range value
  75521. * @param max defines the upper range value
  75522. * @param result defines the Vector3 where to store the result
  75523. */
  75524. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  75525. /**
  75526. * Checks if a given vector is inside a specific range
  75527. * @param v defines the vector to test
  75528. * @param min defines the minimum range
  75529. * @param max defines the maximum range
  75530. */
  75531. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  75532. /**
  75533. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  75534. * @param value1 defines the first control point
  75535. * @param tangent1 defines the first tangent vector
  75536. * @param value2 defines the second control point
  75537. * @param tangent2 defines the second tangent vector
  75538. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  75539. * @returns the new Vector3
  75540. */
  75541. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  75542. /**
  75543. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  75544. * @param start defines the start value
  75545. * @param end defines the end value
  75546. * @param amount max defines amount between both (between 0 and 1)
  75547. * @returns the new Vector3
  75548. */
  75549. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  75550. /**
  75551. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  75552. * @param start defines the start value
  75553. * @param end defines the end value
  75554. * @param amount max defines amount between both (between 0 and 1)
  75555. * @param result defines the Vector3 where to store the result
  75556. */
  75557. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  75558. /**
  75559. * Returns the dot product (float) between the vectors "left" and "right"
  75560. * @param left defines the left operand
  75561. * @param right defines the right operand
  75562. * @returns the dot product
  75563. */
  75564. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  75565. /**
  75566. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  75567. * The cross product is then orthogonal to both "left" and "right"
  75568. * @param left defines the left operand
  75569. * @param right defines the right operand
  75570. * @returns the cross product
  75571. */
  75572. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75573. /**
  75574. * Sets the given vector "result" with the cross product of "left" and "right"
  75575. * The cross product is then orthogonal to both "left" and "right"
  75576. * @param left defines the left operand
  75577. * @param right defines the right operand
  75578. * @param result defines the Vector3 where to store the result
  75579. */
  75580. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  75581. /**
  75582. * Returns a new Vector3 as the normalization of the given vector
  75583. * @param vector defines the Vector3 to normalize
  75584. * @returns the new Vector3
  75585. */
  75586. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  75587. /**
  75588. * Sets the given vector "result" with the normalization of the given first vector
  75589. * @param vector defines the Vector3 to normalize
  75590. * @param result defines the Vector3 where to store the result
  75591. */
  75592. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  75593. /**
  75594. * Project a Vector3 onto screen space
  75595. * @param vector defines the Vector3 to project
  75596. * @param world defines the world matrix to use
  75597. * @param transform defines the transform (view x projection) matrix to use
  75598. * @param viewport defines the screen viewport to use
  75599. * @returns the new Vector3
  75600. */
  75601. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  75602. /** @hidden */
  75603. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  75604. /**
  75605. * Unproject from screen space to object space
  75606. * @param source defines the screen space Vector3 to use
  75607. * @param viewportWidth defines the current width of the viewport
  75608. * @param viewportHeight defines the current height of the viewport
  75609. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75610. * @param transform defines the transform (view x projection) matrix to use
  75611. * @returns the new Vector3
  75612. */
  75613. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  75614. /**
  75615. * Unproject from screen space to object space
  75616. * @param source defines the screen space Vector3 to use
  75617. * @param viewportWidth defines the current width of the viewport
  75618. * @param viewportHeight defines the current height of the viewport
  75619. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75620. * @param view defines the view matrix to use
  75621. * @param projection defines the projection matrix to use
  75622. * @returns the new Vector3
  75623. */
  75624. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  75625. /**
  75626. * Unproject from screen space to object space
  75627. * @param source defines the screen space Vector3 to use
  75628. * @param viewportWidth defines the current width of the viewport
  75629. * @param viewportHeight defines the current height of the viewport
  75630. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75631. * @param view defines the view matrix to use
  75632. * @param projection defines the projection matrix to use
  75633. * @param result defines the Vector3 where to store the result
  75634. */
  75635. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75636. /**
  75637. * Unproject from screen space to object space
  75638. * @param sourceX defines the screen space x coordinate to use
  75639. * @param sourceY defines the screen space y coordinate to use
  75640. * @param sourceZ defines the screen space z coordinate to use
  75641. * @param viewportWidth defines the current width of the viewport
  75642. * @param viewportHeight defines the current height of the viewport
  75643. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75644. * @param view defines the view matrix to use
  75645. * @param projection defines the projection matrix to use
  75646. * @param result defines the Vector3 where to store the result
  75647. */
  75648. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75649. /**
  75650. * Gets the minimal coordinate values between two Vector3
  75651. * @param left defines the first operand
  75652. * @param right defines the second operand
  75653. * @returns the new Vector3
  75654. */
  75655. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75656. /**
  75657. * Gets the maximal coordinate values between two Vector3
  75658. * @param left defines the first operand
  75659. * @param right defines the second operand
  75660. * @returns the new Vector3
  75661. */
  75662. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75663. /**
  75664. * Returns the distance between the vectors "value1" and "value2"
  75665. * @param value1 defines the first operand
  75666. * @param value2 defines the second operand
  75667. * @returns the distance
  75668. */
  75669. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75670. /**
  75671. * Returns the squared distance between the vectors "value1" and "value2"
  75672. * @param value1 defines the first operand
  75673. * @param value2 defines the second operand
  75674. * @returns the squared distance
  75675. */
  75676. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75677. /**
  75678. * Returns a new Vector3 located at the center between "value1" and "value2"
  75679. * @param value1 defines the first operand
  75680. * @param value2 defines the second operand
  75681. * @returns the new Vector3
  75682. */
  75683. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  75684. /**
  75685. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  75686. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  75687. * to something in order to rotate it from its local system to the given target system
  75688. * Note: axis1, axis2 and axis3 are normalized during this operation
  75689. * @param axis1 defines the first axis
  75690. * @param axis2 defines the second axis
  75691. * @param axis3 defines the third axis
  75692. * @returns a new Vector3
  75693. */
  75694. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  75695. /**
  75696. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  75697. * @param axis1 defines the first axis
  75698. * @param axis2 defines the second axis
  75699. * @param axis3 defines the third axis
  75700. * @param ref defines the Vector3 where to store the result
  75701. */
  75702. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  75703. }
  75704. /**
  75705. * Vector4 class created for EulerAngle class conversion to Quaternion
  75706. */
  75707. export class Vector4 {
  75708. /** x value of the vector */
  75709. x: number;
  75710. /** y value of the vector */
  75711. y: number;
  75712. /** z value of the vector */
  75713. z: number;
  75714. /** w value of the vector */
  75715. w: number;
  75716. /**
  75717. * Creates a Vector4 object from the given floats.
  75718. * @param x x value of the vector
  75719. * @param y y value of the vector
  75720. * @param z z value of the vector
  75721. * @param w w value of the vector
  75722. */
  75723. constructor(
  75724. /** x value of the vector */
  75725. x: number,
  75726. /** y value of the vector */
  75727. y: number,
  75728. /** z value of the vector */
  75729. z: number,
  75730. /** w value of the vector */
  75731. w: number);
  75732. /**
  75733. * Returns the string with the Vector4 coordinates.
  75734. * @returns a string containing all the vector values
  75735. */
  75736. toString(): string;
  75737. /**
  75738. * Returns the string "Vector4".
  75739. * @returns "Vector4"
  75740. */
  75741. getClassName(): string;
  75742. /**
  75743. * Returns the Vector4 hash code.
  75744. * @returns a unique hash code
  75745. */
  75746. getHashCode(): number;
  75747. /**
  75748. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  75749. * @returns the resulting array
  75750. */
  75751. asArray(): number[];
  75752. /**
  75753. * Populates the given array from the given index with the Vector4 coordinates.
  75754. * @param array array to populate
  75755. * @param index index of the array to start at (default: 0)
  75756. * @returns the Vector4.
  75757. */
  75758. toArray(array: FloatArray, index?: number): Vector4;
  75759. /**
  75760. * Adds the given vector to the current Vector4.
  75761. * @param otherVector the vector to add
  75762. * @returns the updated Vector4.
  75763. */
  75764. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75765. /**
  75766. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  75767. * @param otherVector the vector to add
  75768. * @returns the resulting vector
  75769. */
  75770. add(otherVector: DeepImmutable<Vector4>): Vector4;
  75771. /**
  75772. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  75773. * @param otherVector the vector to add
  75774. * @param result the vector to store the result
  75775. * @returns the current Vector4.
  75776. */
  75777. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75778. /**
  75779. * Subtract in place the given vector from the current Vector4.
  75780. * @param otherVector the vector to subtract
  75781. * @returns the updated Vector4.
  75782. */
  75783. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75784. /**
  75785. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  75786. * @param otherVector the vector to add
  75787. * @returns the new vector with the result
  75788. */
  75789. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  75790. /**
  75791. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  75792. * @param otherVector the vector to subtract
  75793. * @param result the vector to store the result
  75794. * @returns the current Vector4.
  75795. */
  75796. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75797. /**
  75798. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75799. */
  75800. /**
  75801. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75802. * @param x value to subtract
  75803. * @param y value to subtract
  75804. * @param z value to subtract
  75805. * @param w value to subtract
  75806. * @returns new vector containing the result
  75807. */
  75808. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75809. /**
  75810. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75811. * @param x value to subtract
  75812. * @param y value to subtract
  75813. * @param z value to subtract
  75814. * @param w value to subtract
  75815. * @param result the vector to store the result in
  75816. * @returns the current Vector4.
  75817. */
  75818. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  75819. /**
  75820. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  75821. * @returns a new vector with the negated values
  75822. */
  75823. negate(): Vector4;
  75824. /**
  75825. * Multiplies the current Vector4 coordinates by scale (float).
  75826. * @param scale the number to scale with
  75827. * @returns the updated Vector4.
  75828. */
  75829. scaleInPlace(scale: number): Vector4;
  75830. /**
  75831. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  75832. * @param scale the number to scale with
  75833. * @returns a new vector with the result
  75834. */
  75835. scale(scale: number): Vector4;
  75836. /**
  75837. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  75838. * @param scale the number to scale with
  75839. * @param result a vector to store the result in
  75840. * @returns the current Vector4.
  75841. */
  75842. scaleToRef(scale: number, result: Vector4): Vector4;
  75843. /**
  75844. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  75845. * @param scale defines the scale factor
  75846. * @param result defines the Vector4 object where to store the result
  75847. * @returns the unmodified current Vector4
  75848. */
  75849. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  75850. /**
  75851. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  75852. * @param otherVector the vector to compare against
  75853. * @returns true if they are equal
  75854. */
  75855. equals(otherVector: DeepImmutable<Vector4>): boolean;
  75856. /**
  75857. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  75858. * @param otherVector vector to compare against
  75859. * @param epsilon (Default: very small number)
  75860. * @returns true if they are equal
  75861. */
  75862. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  75863. /**
  75864. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  75865. * @param x x value to compare against
  75866. * @param y y value to compare against
  75867. * @param z z value to compare against
  75868. * @param w w value to compare against
  75869. * @returns true if equal
  75870. */
  75871. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  75872. /**
  75873. * Multiplies in place the current Vector4 by the given one.
  75874. * @param otherVector vector to multiple with
  75875. * @returns the updated Vector4.
  75876. */
  75877. multiplyInPlace(otherVector: Vector4): Vector4;
  75878. /**
  75879. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  75880. * @param otherVector vector to multiple with
  75881. * @returns resulting new vector
  75882. */
  75883. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  75884. /**
  75885. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  75886. * @param otherVector vector to multiple with
  75887. * @param result vector to store the result
  75888. * @returns the current Vector4.
  75889. */
  75890. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75891. /**
  75892. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  75893. * @param x x value multiply with
  75894. * @param y y value multiply with
  75895. * @param z z value multiply with
  75896. * @param w w value multiply with
  75897. * @returns resulting new vector
  75898. */
  75899. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  75900. /**
  75901. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  75902. * @param otherVector vector to devide with
  75903. * @returns resulting new vector
  75904. */
  75905. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  75906. /**
  75907. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  75908. * @param otherVector vector to devide with
  75909. * @param result vector to store the result
  75910. * @returns the current Vector4.
  75911. */
  75912. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75913. /**
  75914. * Divides the current Vector3 coordinates by the given ones.
  75915. * @param otherVector vector to devide with
  75916. * @returns the updated Vector3.
  75917. */
  75918. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75919. /**
  75920. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  75921. * @param other defines the second operand
  75922. * @returns the current updated Vector4
  75923. */
  75924. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75925. /**
  75926. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  75927. * @param other defines the second operand
  75928. * @returns the current updated Vector4
  75929. */
  75930. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75931. /**
  75932. * Gets a new Vector4 from current Vector4 floored values
  75933. * @returns a new Vector4
  75934. */
  75935. floor(): Vector4;
  75936. /**
  75937. * Gets a new Vector4 from current Vector3 floored values
  75938. * @returns a new Vector4
  75939. */
  75940. fract(): Vector4;
  75941. /**
  75942. * Returns the Vector4 length (float).
  75943. * @returns the length
  75944. */
  75945. length(): number;
  75946. /**
  75947. * Returns the Vector4 squared length (float).
  75948. * @returns the length squared
  75949. */
  75950. lengthSquared(): number;
  75951. /**
  75952. * Normalizes in place the Vector4.
  75953. * @returns the updated Vector4.
  75954. */
  75955. normalize(): Vector4;
  75956. /**
  75957. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  75958. * @returns this converted to a new vector3
  75959. */
  75960. toVector3(): Vector3;
  75961. /**
  75962. * Returns a new Vector4 copied from the current one.
  75963. * @returns the new cloned vector
  75964. */
  75965. clone(): Vector4;
  75966. /**
  75967. * Updates the current Vector4 with the given one coordinates.
  75968. * @param source the source vector to copy from
  75969. * @returns the updated Vector4.
  75970. */
  75971. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  75972. /**
  75973. * Updates the current Vector4 coordinates with the given floats.
  75974. * @param x float to copy from
  75975. * @param y float to copy from
  75976. * @param z float to copy from
  75977. * @param w float to copy from
  75978. * @returns the updated Vector4.
  75979. */
  75980. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75981. /**
  75982. * Updates the current Vector4 coordinates with the given floats.
  75983. * @param x float to set from
  75984. * @param y float to set from
  75985. * @param z float to set from
  75986. * @param w float to set from
  75987. * @returns the updated Vector4.
  75988. */
  75989. set(x: number, y: number, z: number, w: number): Vector4;
  75990. /**
  75991. * Copies the given float to the current Vector3 coordinates
  75992. * @param v defines the x, y, z and w coordinates of the operand
  75993. * @returns the current updated Vector3
  75994. */
  75995. setAll(v: number): Vector4;
  75996. /**
  75997. * Returns a new Vector4 set from the starting index of the given array.
  75998. * @param array the array to pull values from
  75999. * @param offset the offset into the array to start at
  76000. * @returns the new vector
  76001. */
  76002. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76003. /**
  76004. * Updates the given vector "result" from the starting index of the given array.
  76005. * @param array the array to pull values from
  76006. * @param offset the offset into the array to start at
  76007. * @param result the vector to store the result in
  76008. */
  76009. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76010. /**
  76011. * Updates the given vector "result" from the starting index of the given Float32Array.
  76012. * @param array the array to pull values from
  76013. * @param offset the offset into the array to start at
  76014. * @param result the vector to store the result in
  76015. */
  76016. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76017. /**
  76018. * Updates the given vector "result" coordinates from the given floats.
  76019. * @param x float to set from
  76020. * @param y float to set from
  76021. * @param z float to set from
  76022. * @param w float to set from
  76023. * @param result the vector to the floats in
  76024. */
  76025. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76026. /**
  76027. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76028. * @returns the new vector
  76029. */
  76030. static Zero(): Vector4;
  76031. /**
  76032. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76033. * @returns the new vector
  76034. */
  76035. static One(): Vector4;
  76036. /**
  76037. * Returns a new normalized Vector4 from the given one.
  76038. * @param vector the vector to normalize
  76039. * @returns the vector
  76040. */
  76041. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76042. /**
  76043. * Updates the given vector "result" from the normalization of the given one.
  76044. * @param vector the vector to normalize
  76045. * @param result the vector to store the result in
  76046. */
  76047. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76048. /**
  76049. * Returns a vector with the minimum values from the left and right vectors
  76050. * @param left left vector to minimize
  76051. * @param right right vector to minimize
  76052. * @returns a new vector with the minimum of the left and right vector values
  76053. */
  76054. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76055. /**
  76056. * Returns a vector with the maximum values from the left and right vectors
  76057. * @param left left vector to maximize
  76058. * @param right right vector to maximize
  76059. * @returns a new vector with the maximum of the left and right vector values
  76060. */
  76061. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76062. /**
  76063. * Returns the distance (float) between the vectors "value1" and "value2".
  76064. * @param value1 value to calulate the distance between
  76065. * @param value2 value to calulate the distance between
  76066. * @return the distance between the two vectors
  76067. */
  76068. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76069. /**
  76070. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76071. * @param value1 value to calulate the distance between
  76072. * @param value2 value to calulate the distance between
  76073. * @return the distance between the two vectors squared
  76074. */
  76075. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76076. /**
  76077. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76078. * @param value1 value to calulate the center between
  76079. * @param value2 value to calulate the center between
  76080. * @return the center between the two vectors
  76081. */
  76082. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76083. /**
  76084. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76085. * This methods computes transformed normalized direction vectors only.
  76086. * @param vector the vector to transform
  76087. * @param transformation the transformation matrix to apply
  76088. * @returns the new vector
  76089. */
  76090. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76091. /**
  76092. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76093. * This methods computes transformed normalized direction vectors only.
  76094. * @param vector the vector to transform
  76095. * @param transformation the transformation matrix to apply
  76096. * @param result the vector to store the result in
  76097. */
  76098. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76099. /**
  76100. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76101. * This methods computes transformed normalized direction vectors only.
  76102. * @param x value to transform
  76103. * @param y value to transform
  76104. * @param z value to transform
  76105. * @param w value to transform
  76106. * @param transformation the transformation matrix to apply
  76107. * @param result the vector to store the results in
  76108. */
  76109. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76110. /**
  76111. * Creates a new Vector4 from a Vector3
  76112. * @param source defines the source data
  76113. * @param w defines the 4th component (default is 0)
  76114. * @returns a new Vector4
  76115. */
  76116. static FromVector3(source: Vector3, w?: number): Vector4;
  76117. }
  76118. /**
  76119. * Class used to store quaternion data
  76120. * @see https://en.wikipedia.org/wiki/Quaternion
  76121. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76122. */
  76123. export class Quaternion {
  76124. /** defines the first component (0 by default) */
  76125. x: number;
  76126. /** defines the second component (0 by default) */
  76127. y: number;
  76128. /** defines the third component (0 by default) */
  76129. z: number;
  76130. /** defines the fourth component (1.0 by default) */
  76131. w: number;
  76132. /**
  76133. * Creates a new Quaternion from the given floats
  76134. * @param x defines the first component (0 by default)
  76135. * @param y defines the second component (0 by default)
  76136. * @param z defines the third component (0 by default)
  76137. * @param w defines the fourth component (1.0 by default)
  76138. */
  76139. constructor(
  76140. /** defines the first component (0 by default) */
  76141. x?: number,
  76142. /** defines the second component (0 by default) */
  76143. y?: number,
  76144. /** defines the third component (0 by default) */
  76145. z?: number,
  76146. /** defines the fourth component (1.0 by default) */
  76147. w?: number);
  76148. /**
  76149. * Gets a string representation for the current quaternion
  76150. * @returns a string with the Quaternion coordinates
  76151. */
  76152. toString(): string;
  76153. /**
  76154. * Gets the class name of the quaternion
  76155. * @returns the string "Quaternion"
  76156. */
  76157. getClassName(): string;
  76158. /**
  76159. * Gets a hash code for this quaternion
  76160. * @returns the quaternion hash code
  76161. */
  76162. getHashCode(): number;
  76163. /**
  76164. * Copy the quaternion to an array
  76165. * @returns a new array populated with 4 elements from the quaternion coordinates
  76166. */
  76167. asArray(): number[];
  76168. /**
  76169. * Check if two quaternions are equals
  76170. * @param otherQuaternion defines the second operand
  76171. * @return true if the current quaternion and the given one coordinates are strictly equals
  76172. */
  76173. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76174. /**
  76175. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76176. * @param otherQuaternion defines the other quaternion
  76177. * @param epsilon defines the minimal distance to consider equality
  76178. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76179. */
  76180. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76181. /**
  76182. * Clone the current quaternion
  76183. * @returns a new quaternion copied from the current one
  76184. */
  76185. clone(): Quaternion;
  76186. /**
  76187. * Copy a quaternion to the current one
  76188. * @param other defines the other quaternion
  76189. * @returns the updated current quaternion
  76190. */
  76191. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76192. /**
  76193. * Updates the current quaternion with the given float coordinates
  76194. * @param x defines the x coordinate
  76195. * @param y defines the y coordinate
  76196. * @param z defines the z coordinate
  76197. * @param w defines the w coordinate
  76198. * @returns the updated current quaternion
  76199. */
  76200. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76201. /**
  76202. * Updates the current quaternion from the given float coordinates
  76203. * @param x defines the x coordinate
  76204. * @param y defines the y coordinate
  76205. * @param z defines the z coordinate
  76206. * @param w defines the w coordinate
  76207. * @returns the updated current quaternion
  76208. */
  76209. set(x: number, y: number, z: number, w: number): Quaternion;
  76210. /**
  76211. * Adds two quaternions
  76212. * @param other defines the second operand
  76213. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76214. */
  76215. add(other: DeepImmutable<Quaternion>): Quaternion;
  76216. /**
  76217. * Add a quaternion to the current one
  76218. * @param other defines the quaternion to add
  76219. * @returns the current quaternion
  76220. */
  76221. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76222. /**
  76223. * Subtract two quaternions
  76224. * @param other defines the second operand
  76225. * @returns a new quaternion as the subtraction result of the given one from the current one
  76226. */
  76227. subtract(other: Quaternion): Quaternion;
  76228. /**
  76229. * Multiplies the current quaternion by a scale factor
  76230. * @param value defines the scale factor
  76231. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76232. */
  76233. scale(value: number): Quaternion;
  76234. /**
  76235. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76236. * @param scale defines the scale factor
  76237. * @param result defines the Quaternion object where to store the result
  76238. * @returns the unmodified current quaternion
  76239. */
  76240. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76241. /**
  76242. * Multiplies in place the current quaternion by a scale factor
  76243. * @param value defines the scale factor
  76244. * @returns the current modified quaternion
  76245. */
  76246. scaleInPlace(value: number): Quaternion;
  76247. /**
  76248. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76249. * @param scale defines the scale factor
  76250. * @param result defines the Quaternion object where to store the result
  76251. * @returns the unmodified current quaternion
  76252. */
  76253. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76254. /**
  76255. * Multiplies two quaternions
  76256. * @param q1 defines the second operand
  76257. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76258. */
  76259. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76260. /**
  76261. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76262. * @param q1 defines the second operand
  76263. * @param result defines the target quaternion
  76264. * @returns the current quaternion
  76265. */
  76266. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76267. /**
  76268. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76269. * @param q1 defines the second operand
  76270. * @returns the currentupdated quaternion
  76271. */
  76272. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76273. /**
  76274. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76275. * @param ref defines the target quaternion
  76276. * @returns the current quaternion
  76277. */
  76278. conjugateToRef(ref: Quaternion): Quaternion;
  76279. /**
  76280. * Conjugates in place (1-q) the current quaternion
  76281. * @returns the current updated quaternion
  76282. */
  76283. conjugateInPlace(): Quaternion;
  76284. /**
  76285. * Conjugates in place (1-q) the current quaternion
  76286. * @returns a new quaternion
  76287. */
  76288. conjugate(): Quaternion;
  76289. /**
  76290. * Gets length of current quaternion
  76291. * @returns the quaternion length (float)
  76292. */
  76293. length(): number;
  76294. /**
  76295. * Normalize in place the current quaternion
  76296. * @returns the current updated quaternion
  76297. */
  76298. normalize(): Quaternion;
  76299. /**
  76300. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76301. * @param order is a reserved parameter and is ignore for now
  76302. * @returns a new Vector3 containing the Euler angles
  76303. */
  76304. toEulerAngles(order?: string): Vector3;
  76305. /**
  76306. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76307. * @param result defines the vector which will be filled with the Euler angles
  76308. * @param order is a reserved parameter and is ignore for now
  76309. * @returns the current unchanged quaternion
  76310. */
  76311. toEulerAnglesToRef(result: Vector3): Quaternion;
  76312. /**
  76313. * Updates the given rotation matrix with the current quaternion values
  76314. * @param result defines the target matrix
  76315. * @returns the current unchanged quaternion
  76316. */
  76317. toRotationMatrix(result: Matrix): Quaternion;
  76318. /**
  76319. * Updates the current quaternion from the given rotation matrix values
  76320. * @param matrix defines the source matrix
  76321. * @returns the current updated quaternion
  76322. */
  76323. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76324. /**
  76325. * Creates a new quaternion from a rotation matrix
  76326. * @param matrix defines the source matrix
  76327. * @returns a new quaternion created from the given rotation matrix values
  76328. */
  76329. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76330. /**
  76331. * Updates the given quaternion with the given rotation matrix values
  76332. * @param matrix defines the source matrix
  76333. * @param result defines the target quaternion
  76334. */
  76335. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76336. /**
  76337. * Returns the dot product (float) between the quaternions "left" and "right"
  76338. * @param left defines the left operand
  76339. * @param right defines the right operand
  76340. * @returns the dot product
  76341. */
  76342. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76343. /**
  76344. * Checks if the two quaternions are close to each other
  76345. * @param quat0 defines the first quaternion to check
  76346. * @param quat1 defines the second quaternion to check
  76347. * @returns true if the two quaternions are close to each other
  76348. */
  76349. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76350. /**
  76351. * Creates an empty quaternion
  76352. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76353. */
  76354. static Zero(): Quaternion;
  76355. /**
  76356. * Inverse a given quaternion
  76357. * @param q defines the source quaternion
  76358. * @returns a new quaternion as the inverted current quaternion
  76359. */
  76360. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76361. /**
  76362. * Inverse a given quaternion
  76363. * @param q defines the source quaternion
  76364. * @param result the quaternion the result will be stored in
  76365. * @returns the result quaternion
  76366. */
  76367. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76368. /**
  76369. * Creates an identity quaternion
  76370. * @returns the identity quaternion
  76371. */
  76372. static Identity(): Quaternion;
  76373. /**
  76374. * Gets a boolean indicating if the given quaternion is identity
  76375. * @param quaternion defines the quaternion to check
  76376. * @returns true if the quaternion is identity
  76377. */
  76378. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76379. /**
  76380. * Creates a quaternion from a rotation around an axis
  76381. * @param axis defines the axis to use
  76382. * @param angle defines the angle to use
  76383. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76384. */
  76385. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76386. /**
  76387. * Creates a rotation around an axis and stores it into the given quaternion
  76388. * @param axis defines the axis to use
  76389. * @param angle defines the angle to use
  76390. * @param result defines the target quaternion
  76391. * @returns the target quaternion
  76392. */
  76393. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76394. /**
  76395. * Creates a new quaternion from data stored into an array
  76396. * @param array defines the data source
  76397. * @param offset defines the offset in the source array where the data starts
  76398. * @returns a new quaternion
  76399. */
  76400. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76401. /**
  76402. * Create a quaternion from Euler rotation angles
  76403. * @param x Pitch
  76404. * @param y Yaw
  76405. * @param z Roll
  76406. * @returns the new Quaternion
  76407. */
  76408. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76409. /**
  76410. * Updates a quaternion from Euler rotation angles
  76411. * @param x Pitch
  76412. * @param y Yaw
  76413. * @param z Roll
  76414. * @param result the quaternion to store the result
  76415. * @returns the updated quaternion
  76416. */
  76417. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76418. /**
  76419. * Create a quaternion from Euler rotation vector
  76420. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76421. * @returns the new Quaternion
  76422. */
  76423. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76424. /**
  76425. * Updates a quaternion from Euler rotation vector
  76426. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76427. * @param result the quaternion to store the result
  76428. * @returns the updated quaternion
  76429. */
  76430. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76431. /**
  76432. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76433. * @param yaw defines the rotation around Y axis
  76434. * @param pitch defines the rotation around X axis
  76435. * @param roll defines the rotation around Z axis
  76436. * @returns the new quaternion
  76437. */
  76438. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76439. /**
  76440. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76441. * @param yaw defines the rotation around Y axis
  76442. * @param pitch defines the rotation around X axis
  76443. * @param roll defines the rotation around Z axis
  76444. * @param result defines the target quaternion
  76445. */
  76446. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  76447. /**
  76448. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  76449. * @param alpha defines the rotation around first axis
  76450. * @param beta defines the rotation around second axis
  76451. * @param gamma defines the rotation around third axis
  76452. * @returns the new quaternion
  76453. */
  76454. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  76455. /**
  76456. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  76457. * @param alpha defines the rotation around first axis
  76458. * @param beta defines the rotation around second axis
  76459. * @param gamma defines the rotation around third axis
  76460. * @param result defines the target quaternion
  76461. */
  76462. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  76463. /**
  76464. * 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)
  76465. * @param axis1 defines the first axis
  76466. * @param axis2 defines the second axis
  76467. * @param axis3 defines the third axis
  76468. * @returns the new quaternion
  76469. */
  76470. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  76471. /**
  76472. * 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
  76473. * @param axis1 defines the first axis
  76474. * @param axis2 defines the second axis
  76475. * @param axis3 defines the third axis
  76476. * @param ref defines the target quaternion
  76477. */
  76478. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  76479. /**
  76480. * Interpolates between two quaternions
  76481. * @param left defines first quaternion
  76482. * @param right defines second quaternion
  76483. * @param amount defines the gradient to use
  76484. * @returns the new interpolated quaternion
  76485. */
  76486. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76487. /**
  76488. * Interpolates between two quaternions and stores it into a target quaternion
  76489. * @param left defines first quaternion
  76490. * @param right defines second quaternion
  76491. * @param amount defines the gradient to use
  76492. * @param result defines the target quaternion
  76493. */
  76494. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  76495. /**
  76496. * Interpolate between two quaternions using Hermite interpolation
  76497. * @param value1 defines first quaternion
  76498. * @param tangent1 defines the incoming tangent
  76499. * @param value2 defines second quaternion
  76500. * @param tangent2 defines the outgoing tangent
  76501. * @param amount defines the target quaternion
  76502. * @returns the new interpolated quaternion
  76503. */
  76504. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76505. }
  76506. /**
  76507. * Class used to store matrix data (4x4)
  76508. */
  76509. export class Matrix {
  76510. private static _updateFlagSeed;
  76511. private static _identityReadOnly;
  76512. private _isIdentity;
  76513. private _isIdentityDirty;
  76514. private _isIdentity3x2;
  76515. private _isIdentity3x2Dirty;
  76516. /**
  76517. * Gets the update flag of the matrix which is an unique number for the matrix.
  76518. * It will be incremented every time the matrix data change.
  76519. * You can use it to speed the comparison between two versions of the same matrix.
  76520. */
  76521. updateFlag: number;
  76522. private readonly _m;
  76523. /**
  76524. * Gets the internal data of the matrix
  76525. */
  76526. get m(): DeepImmutable<Float32Array>;
  76527. /** @hidden */
  76528. _markAsUpdated(): void;
  76529. /** @hidden */
  76530. private _updateIdentityStatus;
  76531. /**
  76532. * Creates an empty matrix (filled with zeros)
  76533. */
  76534. constructor();
  76535. /**
  76536. * Check if the current matrix is identity
  76537. * @returns true is the matrix is the identity matrix
  76538. */
  76539. isIdentity(): boolean;
  76540. /**
  76541. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  76542. * @returns true is the matrix is the identity matrix
  76543. */
  76544. isIdentityAs3x2(): boolean;
  76545. /**
  76546. * Gets the determinant of the matrix
  76547. * @returns the matrix determinant
  76548. */
  76549. determinant(): number;
  76550. /**
  76551. * Returns the matrix as a Float32Array
  76552. * @returns the matrix underlying array
  76553. */
  76554. toArray(): DeepImmutable<Float32Array>;
  76555. /**
  76556. * Returns the matrix as a Float32Array
  76557. * @returns the matrix underlying array.
  76558. */
  76559. asArray(): DeepImmutable<Float32Array>;
  76560. /**
  76561. * Inverts the current matrix in place
  76562. * @returns the current inverted matrix
  76563. */
  76564. invert(): Matrix;
  76565. /**
  76566. * Sets all the matrix elements to zero
  76567. * @returns the current matrix
  76568. */
  76569. reset(): Matrix;
  76570. /**
  76571. * Adds the current matrix with a second one
  76572. * @param other defines the matrix to add
  76573. * @returns a new matrix as the addition of the current matrix and the given one
  76574. */
  76575. add(other: DeepImmutable<Matrix>): Matrix;
  76576. /**
  76577. * Sets the given matrix "result" to the addition of the current matrix and the given one
  76578. * @param other defines the matrix to add
  76579. * @param result defines the target matrix
  76580. * @returns the current matrix
  76581. */
  76582. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76583. /**
  76584. * Adds in place the given matrix to the current matrix
  76585. * @param other defines the second operand
  76586. * @returns the current updated matrix
  76587. */
  76588. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  76589. /**
  76590. * Sets the given matrix to the current inverted Matrix
  76591. * @param other defines the target matrix
  76592. * @returns the unmodified current matrix
  76593. */
  76594. invertToRef(other: Matrix): Matrix;
  76595. /**
  76596. * add a value at the specified position in the current Matrix
  76597. * @param index the index of the value within the matrix. between 0 and 15.
  76598. * @param value the value to be added
  76599. * @returns the current updated matrix
  76600. */
  76601. addAtIndex(index: number, value: number): Matrix;
  76602. /**
  76603. * mutiply the specified position in the current Matrix by a value
  76604. * @param index the index of the value within the matrix. between 0 and 15.
  76605. * @param value the value to be added
  76606. * @returns the current updated matrix
  76607. */
  76608. multiplyAtIndex(index: number, value: number): Matrix;
  76609. /**
  76610. * Inserts the translation vector (using 3 floats) in the current matrix
  76611. * @param x defines the 1st component of the translation
  76612. * @param y defines the 2nd component of the translation
  76613. * @param z defines the 3rd component of the translation
  76614. * @returns the current updated matrix
  76615. */
  76616. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76617. /**
  76618. * Adds the translation vector (using 3 floats) in the current matrix
  76619. * @param x defines the 1st component of the translation
  76620. * @param y defines the 2nd component of the translation
  76621. * @param z defines the 3rd component of the translation
  76622. * @returns the current updated matrix
  76623. */
  76624. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76625. /**
  76626. * Inserts the translation vector in the current matrix
  76627. * @param vector3 defines the translation to insert
  76628. * @returns the current updated matrix
  76629. */
  76630. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  76631. /**
  76632. * Gets the translation value of the current matrix
  76633. * @returns a new Vector3 as the extracted translation from the matrix
  76634. */
  76635. getTranslation(): Vector3;
  76636. /**
  76637. * Fill a Vector3 with the extracted translation from the matrix
  76638. * @param result defines the Vector3 where to store the translation
  76639. * @returns the current matrix
  76640. */
  76641. getTranslationToRef(result: Vector3): Matrix;
  76642. /**
  76643. * Remove rotation and scaling part from the matrix
  76644. * @returns the updated matrix
  76645. */
  76646. removeRotationAndScaling(): Matrix;
  76647. /**
  76648. * Multiply two matrices
  76649. * @param other defines the second operand
  76650. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  76651. */
  76652. multiply(other: DeepImmutable<Matrix>): Matrix;
  76653. /**
  76654. * Copy the current matrix from the given one
  76655. * @param other defines the source matrix
  76656. * @returns the current updated matrix
  76657. */
  76658. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  76659. /**
  76660. * Populates the given array from the starting index with the current matrix values
  76661. * @param array defines the target array
  76662. * @param offset defines the offset in the target array where to start storing values
  76663. * @returns the current matrix
  76664. */
  76665. copyToArray(array: Float32Array, offset?: number): Matrix;
  76666. /**
  76667. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  76668. * @param other defines the second operand
  76669. * @param result defines the matrix where to store the multiplication
  76670. * @returns the current matrix
  76671. */
  76672. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76673. /**
  76674. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  76675. * @param other defines the second operand
  76676. * @param result defines the array where to store the multiplication
  76677. * @param offset defines the offset in the target array where to start storing values
  76678. * @returns the current matrix
  76679. */
  76680. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  76681. /**
  76682. * Check equality between this matrix and a second one
  76683. * @param value defines the second matrix to compare
  76684. * @returns true is the current matrix and the given one values are strictly equal
  76685. */
  76686. equals(value: DeepImmutable<Matrix>): boolean;
  76687. /**
  76688. * Clone the current matrix
  76689. * @returns a new matrix from the current matrix
  76690. */
  76691. clone(): Matrix;
  76692. /**
  76693. * Returns the name of the current matrix class
  76694. * @returns the string "Matrix"
  76695. */
  76696. getClassName(): string;
  76697. /**
  76698. * Gets the hash code of the current matrix
  76699. * @returns the hash code
  76700. */
  76701. getHashCode(): number;
  76702. /**
  76703. * Decomposes the current Matrix into a translation, rotation and scaling components
  76704. * @param scale defines the scale vector3 given as a reference to update
  76705. * @param rotation defines the rotation quaternion given as a reference to update
  76706. * @param translation defines the translation vector3 given as a reference to update
  76707. * @returns true if operation was successful
  76708. */
  76709. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  76710. /**
  76711. * Gets specific row of the matrix
  76712. * @param index defines the number of the row to get
  76713. * @returns the index-th row of the current matrix as a new Vector4
  76714. */
  76715. getRow(index: number): Nullable<Vector4>;
  76716. /**
  76717. * Sets the index-th row of the current matrix to the vector4 values
  76718. * @param index defines the number of the row to set
  76719. * @param row defines the target vector4
  76720. * @returns the updated current matrix
  76721. */
  76722. setRow(index: number, row: Vector4): Matrix;
  76723. /**
  76724. * Compute the transpose of the matrix
  76725. * @returns the new transposed matrix
  76726. */
  76727. transpose(): Matrix;
  76728. /**
  76729. * Compute the transpose of the matrix and store it in a given matrix
  76730. * @param result defines the target matrix
  76731. * @returns the current matrix
  76732. */
  76733. transposeToRef(result: Matrix): Matrix;
  76734. /**
  76735. * Sets the index-th row of the current matrix with the given 4 x float values
  76736. * @param index defines the row index
  76737. * @param x defines the x component to set
  76738. * @param y defines the y component to set
  76739. * @param z defines the z component to set
  76740. * @param w defines the w component to set
  76741. * @returns the updated current matrix
  76742. */
  76743. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  76744. /**
  76745. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  76746. * @param scale defines the scale factor
  76747. * @returns a new matrix
  76748. */
  76749. scale(scale: number): Matrix;
  76750. /**
  76751. * Scale the current matrix values by a factor to a given result matrix
  76752. * @param scale defines the scale factor
  76753. * @param result defines the matrix to store the result
  76754. * @returns the current matrix
  76755. */
  76756. scaleToRef(scale: number, result: Matrix): Matrix;
  76757. /**
  76758. * Scale the current matrix values by a factor and add the result to a given matrix
  76759. * @param scale defines the scale factor
  76760. * @param result defines the Matrix to store the result
  76761. * @returns the current matrix
  76762. */
  76763. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  76764. /**
  76765. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  76766. * @param ref matrix to store the result
  76767. */
  76768. toNormalMatrix(ref: Matrix): void;
  76769. /**
  76770. * Gets only rotation part of the current matrix
  76771. * @returns a new matrix sets to the extracted rotation matrix from the current one
  76772. */
  76773. getRotationMatrix(): Matrix;
  76774. /**
  76775. * Extracts the rotation matrix from the current one and sets it as the given "result"
  76776. * @param result defines the target matrix to store data to
  76777. * @returns the current matrix
  76778. */
  76779. getRotationMatrixToRef(result: Matrix): Matrix;
  76780. /**
  76781. * Toggles model matrix from being right handed to left handed in place and vice versa
  76782. */
  76783. toggleModelMatrixHandInPlace(): void;
  76784. /**
  76785. * Toggles projection matrix from being right handed to left handed in place and vice versa
  76786. */
  76787. toggleProjectionMatrixHandInPlace(): void;
  76788. /**
  76789. * Creates a matrix from an array
  76790. * @param array defines the source array
  76791. * @param offset defines an offset in the source array
  76792. * @returns a new Matrix set from the starting index of the given array
  76793. */
  76794. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  76795. /**
  76796. * Copy the content of an array into a given matrix
  76797. * @param array defines the source array
  76798. * @param offset defines an offset in the source array
  76799. * @param result defines the target matrix
  76800. */
  76801. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  76802. /**
  76803. * Stores an array into a matrix after having multiplied each component by a given factor
  76804. * @param array defines the source array
  76805. * @param offset defines the offset in the source array
  76806. * @param scale defines the scaling factor
  76807. * @param result defines the target matrix
  76808. */
  76809. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  76810. /**
  76811. * Gets an identity matrix that must not be updated
  76812. */
  76813. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  76814. /**
  76815. * Stores a list of values (16) inside a given matrix
  76816. * @param initialM11 defines 1st value of 1st row
  76817. * @param initialM12 defines 2nd value of 1st row
  76818. * @param initialM13 defines 3rd value of 1st row
  76819. * @param initialM14 defines 4th value of 1st row
  76820. * @param initialM21 defines 1st value of 2nd row
  76821. * @param initialM22 defines 2nd value of 2nd row
  76822. * @param initialM23 defines 3rd value of 2nd row
  76823. * @param initialM24 defines 4th value of 2nd row
  76824. * @param initialM31 defines 1st value of 3rd row
  76825. * @param initialM32 defines 2nd value of 3rd row
  76826. * @param initialM33 defines 3rd value of 3rd row
  76827. * @param initialM34 defines 4th value of 3rd row
  76828. * @param initialM41 defines 1st value of 4th row
  76829. * @param initialM42 defines 2nd value of 4th row
  76830. * @param initialM43 defines 3rd value of 4th row
  76831. * @param initialM44 defines 4th value of 4th row
  76832. * @param result defines the target matrix
  76833. */
  76834. 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;
  76835. /**
  76836. * Creates new matrix from a list of values (16)
  76837. * @param initialM11 defines 1st value of 1st row
  76838. * @param initialM12 defines 2nd value of 1st row
  76839. * @param initialM13 defines 3rd value of 1st row
  76840. * @param initialM14 defines 4th value of 1st row
  76841. * @param initialM21 defines 1st value of 2nd row
  76842. * @param initialM22 defines 2nd value of 2nd row
  76843. * @param initialM23 defines 3rd value of 2nd row
  76844. * @param initialM24 defines 4th value of 2nd row
  76845. * @param initialM31 defines 1st value of 3rd row
  76846. * @param initialM32 defines 2nd value of 3rd row
  76847. * @param initialM33 defines 3rd value of 3rd row
  76848. * @param initialM34 defines 4th value of 3rd row
  76849. * @param initialM41 defines 1st value of 4th row
  76850. * @param initialM42 defines 2nd value of 4th row
  76851. * @param initialM43 defines 3rd value of 4th row
  76852. * @param initialM44 defines 4th value of 4th row
  76853. * @returns the new matrix
  76854. */
  76855. 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;
  76856. /**
  76857. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76858. * @param scale defines the scale vector3
  76859. * @param rotation defines the rotation quaternion
  76860. * @param translation defines the translation vector3
  76861. * @returns a new matrix
  76862. */
  76863. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  76864. /**
  76865. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76866. * @param scale defines the scale vector3
  76867. * @param rotation defines the rotation quaternion
  76868. * @param translation defines the translation vector3
  76869. * @param result defines the target matrix
  76870. */
  76871. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  76872. /**
  76873. * Creates a new identity matrix
  76874. * @returns a new identity matrix
  76875. */
  76876. static Identity(): Matrix;
  76877. /**
  76878. * Creates a new identity matrix and stores the result in a given matrix
  76879. * @param result defines the target matrix
  76880. */
  76881. static IdentityToRef(result: Matrix): void;
  76882. /**
  76883. * Creates a new zero matrix
  76884. * @returns a new zero matrix
  76885. */
  76886. static Zero(): Matrix;
  76887. /**
  76888. * Creates a new rotation matrix for "angle" radians around the X axis
  76889. * @param angle defines the angle (in radians) to use
  76890. * @return the new matrix
  76891. */
  76892. static RotationX(angle: number): Matrix;
  76893. /**
  76894. * Creates a new matrix as the invert of a given matrix
  76895. * @param source defines the source matrix
  76896. * @returns the new matrix
  76897. */
  76898. static Invert(source: DeepImmutable<Matrix>): Matrix;
  76899. /**
  76900. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  76901. * @param angle defines the angle (in radians) to use
  76902. * @param result defines the target matrix
  76903. */
  76904. static RotationXToRef(angle: number, result: Matrix): void;
  76905. /**
  76906. * Creates a new rotation matrix for "angle" radians around the Y axis
  76907. * @param angle defines the angle (in radians) to use
  76908. * @return the new matrix
  76909. */
  76910. static RotationY(angle: number): Matrix;
  76911. /**
  76912. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  76913. * @param angle defines the angle (in radians) to use
  76914. * @param result defines the target matrix
  76915. */
  76916. static RotationYToRef(angle: number, result: Matrix): void;
  76917. /**
  76918. * Creates a new rotation matrix for "angle" radians around the Z axis
  76919. * @param angle defines the angle (in radians) to use
  76920. * @return the new matrix
  76921. */
  76922. static RotationZ(angle: number): Matrix;
  76923. /**
  76924. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  76925. * @param angle defines the angle (in radians) to use
  76926. * @param result defines the target matrix
  76927. */
  76928. static RotationZToRef(angle: number, result: Matrix): void;
  76929. /**
  76930. * Creates a new rotation matrix for "angle" radians around the given axis
  76931. * @param axis defines the axis to use
  76932. * @param angle defines the angle (in radians) to use
  76933. * @return the new matrix
  76934. */
  76935. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  76936. /**
  76937. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  76938. * @param axis defines the axis to use
  76939. * @param angle defines the angle (in radians) to use
  76940. * @param result defines the target matrix
  76941. */
  76942. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  76943. /**
  76944. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  76945. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  76946. * @param from defines the vector to align
  76947. * @param to defines the vector to align to
  76948. * @param result defines the target matrix
  76949. */
  76950. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  76951. /**
  76952. * Creates a rotation matrix
  76953. * @param yaw defines the yaw angle in radians (Y axis)
  76954. * @param pitch defines the pitch angle in radians (X axis)
  76955. * @param roll defines the roll angle in radians (X axis)
  76956. * @returns the new rotation matrix
  76957. */
  76958. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  76959. /**
  76960. * Creates a rotation matrix and stores it in a given matrix
  76961. * @param yaw defines the yaw angle in radians (Y axis)
  76962. * @param pitch defines the pitch angle in radians (X axis)
  76963. * @param roll defines the roll angle in radians (X axis)
  76964. * @param result defines the target matrix
  76965. */
  76966. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  76967. /**
  76968. * Creates a scaling matrix
  76969. * @param x defines the scale factor on X axis
  76970. * @param y defines the scale factor on Y axis
  76971. * @param z defines the scale factor on Z axis
  76972. * @returns the new matrix
  76973. */
  76974. static Scaling(x: number, y: number, z: number): Matrix;
  76975. /**
  76976. * Creates a scaling matrix and stores it in a given matrix
  76977. * @param x defines the scale factor on X axis
  76978. * @param y defines the scale factor on Y axis
  76979. * @param z defines the scale factor on Z axis
  76980. * @param result defines the target matrix
  76981. */
  76982. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  76983. /**
  76984. * Creates a translation matrix
  76985. * @param x defines the translation on X axis
  76986. * @param y defines the translation on Y axis
  76987. * @param z defines the translationon Z axis
  76988. * @returns the new matrix
  76989. */
  76990. static Translation(x: number, y: number, z: number): Matrix;
  76991. /**
  76992. * Creates a translation matrix and stores it in a given matrix
  76993. * @param x defines the translation on X axis
  76994. * @param y defines the translation on Y axis
  76995. * @param z defines the translationon Z axis
  76996. * @param result defines the target matrix
  76997. */
  76998. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  76999. /**
  77000. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77001. * @param startValue defines the start value
  77002. * @param endValue defines the end value
  77003. * @param gradient defines the gradient factor
  77004. * @returns the new matrix
  77005. */
  77006. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77007. /**
  77008. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77009. * @param startValue defines the start value
  77010. * @param endValue defines the end value
  77011. * @param gradient defines the gradient factor
  77012. * @param result defines the Matrix object where to store data
  77013. */
  77014. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77015. /**
  77016. * Builds a new matrix whose values are computed by:
  77017. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77018. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77019. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77020. * @param startValue defines the first matrix
  77021. * @param endValue defines the second matrix
  77022. * @param gradient defines the gradient between the two matrices
  77023. * @returns the new matrix
  77024. */
  77025. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77026. /**
  77027. * Update a matrix to values which are computed by:
  77028. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77029. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77030. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77031. * @param startValue defines the first matrix
  77032. * @param endValue defines the second matrix
  77033. * @param gradient defines the gradient between the two matrices
  77034. * @param result defines the target matrix
  77035. */
  77036. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77037. /**
  77038. * 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"
  77039. * This function works in left handed mode
  77040. * @param eye defines the final position of the entity
  77041. * @param target defines where the entity should look at
  77042. * @param up defines the up vector for the entity
  77043. * @returns the new matrix
  77044. */
  77045. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77046. /**
  77047. * 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".
  77048. * This function works in left handed mode
  77049. * @param eye defines the final position of the entity
  77050. * @param target defines where the entity should look at
  77051. * @param up defines the up vector for the entity
  77052. * @param result defines the target matrix
  77053. */
  77054. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77055. /**
  77056. * 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"
  77057. * This function works in right handed mode
  77058. * @param eye defines the final position of the entity
  77059. * @param target defines where the entity should look at
  77060. * @param up defines the up vector for the entity
  77061. * @returns the new matrix
  77062. */
  77063. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77064. /**
  77065. * 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".
  77066. * This function works in right handed mode
  77067. * @param eye defines the final position of the entity
  77068. * @param target defines where the entity should look at
  77069. * @param up defines the up vector for the entity
  77070. * @param result defines the target matrix
  77071. */
  77072. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77073. /**
  77074. * Create a left-handed orthographic projection matrix
  77075. * @param width defines the viewport width
  77076. * @param height defines the viewport height
  77077. * @param znear defines the near clip plane
  77078. * @param zfar defines the far clip plane
  77079. * @returns a new matrix as a left-handed orthographic projection matrix
  77080. */
  77081. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77082. /**
  77083. * Store a left-handed orthographic projection to a given matrix
  77084. * @param width defines the viewport width
  77085. * @param height defines the viewport height
  77086. * @param znear defines the near clip plane
  77087. * @param zfar defines the far clip plane
  77088. * @param result defines the target matrix
  77089. */
  77090. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77091. /**
  77092. * Create a left-handed orthographic projection matrix
  77093. * @param left defines the viewport left coordinate
  77094. * @param right defines the viewport right coordinate
  77095. * @param bottom defines the viewport bottom coordinate
  77096. * @param top defines the viewport top coordinate
  77097. * @param znear defines the near clip plane
  77098. * @param zfar defines the far clip plane
  77099. * @returns a new matrix as a left-handed orthographic projection matrix
  77100. */
  77101. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77102. /**
  77103. * Stores a left-handed orthographic projection into a given matrix
  77104. * @param left defines the viewport left coordinate
  77105. * @param right defines the viewport right coordinate
  77106. * @param bottom defines the viewport bottom coordinate
  77107. * @param top defines the viewport top coordinate
  77108. * @param znear defines the near clip plane
  77109. * @param zfar defines the far clip plane
  77110. * @param result defines the target matrix
  77111. */
  77112. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77113. /**
  77114. * Creates a right-handed orthographic projection matrix
  77115. * @param left defines the viewport left coordinate
  77116. * @param right defines the viewport right coordinate
  77117. * @param bottom defines the viewport bottom coordinate
  77118. * @param top defines the viewport top coordinate
  77119. * @param znear defines the near clip plane
  77120. * @param zfar defines the far clip plane
  77121. * @returns a new matrix as a right-handed orthographic projection matrix
  77122. */
  77123. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77124. /**
  77125. * Stores a right-handed orthographic projection into a given matrix
  77126. * @param left defines the viewport left coordinate
  77127. * @param right defines the viewport right coordinate
  77128. * @param bottom defines the viewport bottom coordinate
  77129. * @param top defines the viewport top coordinate
  77130. * @param znear defines the near clip plane
  77131. * @param zfar defines the far clip plane
  77132. * @param result defines the target matrix
  77133. */
  77134. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77135. /**
  77136. * Creates a left-handed perspective projection matrix
  77137. * @param width defines the viewport width
  77138. * @param height defines the viewport height
  77139. * @param znear defines the near clip plane
  77140. * @param zfar defines the far clip plane
  77141. * @returns a new matrix as a left-handed perspective projection matrix
  77142. */
  77143. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77144. /**
  77145. * Creates a left-handed perspective projection matrix
  77146. * @param fov defines the horizontal field of view
  77147. * @param aspect defines the aspect ratio
  77148. * @param znear defines the near clip plane
  77149. * @param zfar defines the far clip plane
  77150. * @returns a new matrix as a left-handed perspective projection matrix
  77151. */
  77152. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77153. /**
  77154. * Stores a left-handed perspective projection into a given matrix
  77155. * @param fov defines the horizontal field of view
  77156. * @param aspect defines the aspect ratio
  77157. * @param znear defines the near clip plane
  77158. * @param zfar defines the far clip plane
  77159. * @param result defines the target matrix
  77160. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77161. */
  77162. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77163. /**
  77164. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77165. * @param fov defines the horizontal field of view
  77166. * @param aspect defines the aspect ratio
  77167. * @param znear defines the near clip plane
  77168. * @param zfar not used as infinity is used as far clip
  77169. * @param result defines the target matrix
  77170. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77171. */
  77172. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77173. /**
  77174. * Creates a right-handed perspective projection matrix
  77175. * @param fov defines the horizontal field of view
  77176. * @param aspect defines the aspect ratio
  77177. * @param znear defines the near clip plane
  77178. * @param zfar defines the far clip plane
  77179. * @returns a new matrix as a right-handed perspective projection matrix
  77180. */
  77181. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77182. /**
  77183. * Stores a right-handed perspective projection into a given matrix
  77184. * @param fov defines the horizontal field of view
  77185. * @param aspect defines the aspect ratio
  77186. * @param znear defines the near clip plane
  77187. * @param zfar defines the far clip plane
  77188. * @param result defines the target matrix
  77189. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77190. */
  77191. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77192. /**
  77193. * Stores a right-handed perspective projection into a given matrix
  77194. * @param fov defines the horizontal field of view
  77195. * @param aspect defines the aspect ratio
  77196. * @param znear defines the near clip plane
  77197. * @param zfar not used as infinity is used as far clip
  77198. * @param result defines the target matrix
  77199. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77200. */
  77201. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77202. /**
  77203. * Stores a perspective projection for WebVR info a given matrix
  77204. * @param fov defines the field of view
  77205. * @param znear defines the near clip plane
  77206. * @param zfar defines the far clip plane
  77207. * @param result defines the target matrix
  77208. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77209. */
  77210. static PerspectiveFovWebVRToRef(fov: {
  77211. upDegrees: number;
  77212. downDegrees: number;
  77213. leftDegrees: number;
  77214. rightDegrees: number;
  77215. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77216. /**
  77217. * Computes a complete transformation matrix
  77218. * @param viewport defines the viewport to use
  77219. * @param world defines the world matrix
  77220. * @param view defines the view matrix
  77221. * @param projection defines the projection matrix
  77222. * @param zmin defines the near clip plane
  77223. * @param zmax defines the far clip plane
  77224. * @returns the transformation matrix
  77225. */
  77226. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77227. /**
  77228. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77229. * @param matrix defines the matrix to use
  77230. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77231. */
  77232. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77233. /**
  77234. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77235. * @param matrix defines the matrix to use
  77236. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77237. */
  77238. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77239. /**
  77240. * Compute the transpose of a given matrix
  77241. * @param matrix defines the matrix to transpose
  77242. * @returns the new matrix
  77243. */
  77244. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77245. /**
  77246. * Compute the transpose of a matrix and store it in a target matrix
  77247. * @param matrix defines the matrix to transpose
  77248. * @param result defines the target matrix
  77249. */
  77250. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77251. /**
  77252. * Computes a reflection matrix from a plane
  77253. * @param plane defines the reflection plane
  77254. * @returns a new matrix
  77255. */
  77256. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77257. /**
  77258. * Computes a reflection matrix from a plane
  77259. * @param plane defines the reflection plane
  77260. * @param result defines the target matrix
  77261. */
  77262. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77263. /**
  77264. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77265. * @param xaxis defines the value of the 1st axis
  77266. * @param yaxis defines the value of the 2nd axis
  77267. * @param zaxis defines the value of the 3rd axis
  77268. * @param result defines the target matrix
  77269. */
  77270. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77271. /**
  77272. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77273. * @param quat defines the quaternion to use
  77274. * @param result defines the target matrix
  77275. */
  77276. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77277. }
  77278. /**
  77279. * @hidden
  77280. */
  77281. export class TmpVectors {
  77282. static Vector2: Vector2[];
  77283. static Vector3: Vector3[];
  77284. static Vector4: Vector4[];
  77285. static Quaternion: Quaternion[];
  77286. static Matrix: Matrix[];
  77287. }
  77288. }
  77289. declare module BABYLON {
  77290. /**
  77291. * Defines potential orientation for back face culling
  77292. */
  77293. export enum Orientation {
  77294. /**
  77295. * Clockwise
  77296. */
  77297. CW = 0,
  77298. /** Counter clockwise */
  77299. CCW = 1
  77300. }
  77301. /** Class used to represent a Bezier curve */
  77302. export class BezierCurve {
  77303. /**
  77304. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77305. * @param t defines the time
  77306. * @param x1 defines the left coordinate on X axis
  77307. * @param y1 defines the left coordinate on Y axis
  77308. * @param x2 defines the right coordinate on X axis
  77309. * @param y2 defines the right coordinate on Y axis
  77310. * @returns the interpolated value
  77311. */
  77312. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77313. }
  77314. /**
  77315. * Defines angle representation
  77316. */
  77317. export class Angle {
  77318. private _radians;
  77319. /**
  77320. * Creates an Angle object of "radians" radians (float).
  77321. * @param radians the angle in radians
  77322. */
  77323. constructor(radians: number);
  77324. /**
  77325. * Get value in degrees
  77326. * @returns the Angle value in degrees (float)
  77327. */
  77328. degrees(): number;
  77329. /**
  77330. * Get value in radians
  77331. * @returns the Angle value in radians (float)
  77332. */
  77333. radians(): number;
  77334. /**
  77335. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77336. * @param a defines first vector
  77337. * @param b defines second vector
  77338. * @returns a new Angle
  77339. */
  77340. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77341. /**
  77342. * Gets a new Angle object from the given float in radians
  77343. * @param radians defines the angle value in radians
  77344. * @returns a new Angle
  77345. */
  77346. static FromRadians(radians: number): Angle;
  77347. /**
  77348. * Gets a new Angle object from the given float in degrees
  77349. * @param degrees defines the angle value in degrees
  77350. * @returns a new Angle
  77351. */
  77352. static FromDegrees(degrees: number): Angle;
  77353. }
  77354. /**
  77355. * This represents an arc in a 2d space.
  77356. */
  77357. export class Arc2 {
  77358. /** Defines the start point of the arc */
  77359. startPoint: Vector2;
  77360. /** Defines the mid point of the arc */
  77361. midPoint: Vector2;
  77362. /** Defines the end point of the arc */
  77363. endPoint: Vector2;
  77364. /**
  77365. * Defines the center point of the arc.
  77366. */
  77367. centerPoint: Vector2;
  77368. /**
  77369. * Defines the radius of the arc.
  77370. */
  77371. radius: number;
  77372. /**
  77373. * Defines the angle of the arc (from mid point to end point).
  77374. */
  77375. angle: Angle;
  77376. /**
  77377. * Defines the start angle of the arc (from start point to middle point).
  77378. */
  77379. startAngle: Angle;
  77380. /**
  77381. * Defines the orientation of the arc (clock wise/counter clock wise).
  77382. */
  77383. orientation: Orientation;
  77384. /**
  77385. * Creates an Arc object from the three given points : start, middle and end.
  77386. * @param startPoint Defines the start point of the arc
  77387. * @param midPoint Defines the midlle point of the arc
  77388. * @param endPoint Defines the end point of the arc
  77389. */
  77390. constructor(
  77391. /** Defines the start point of the arc */
  77392. startPoint: Vector2,
  77393. /** Defines the mid point of the arc */
  77394. midPoint: Vector2,
  77395. /** Defines the end point of the arc */
  77396. endPoint: Vector2);
  77397. }
  77398. /**
  77399. * Represents a 2D path made up of multiple 2D points
  77400. */
  77401. export class Path2 {
  77402. private _points;
  77403. private _length;
  77404. /**
  77405. * If the path start and end point are the same
  77406. */
  77407. closed: boolean;
  77408. /**
  77409. * Creates a Path2 object from the starting 2D coordinates x and y.
  77410. * @param x the starting points x value
  77411. * @param y the starting points y value
  77412. */
  77413. constructor(x: number, y: number);
  77414. /**
  77415. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77416. * @param x the added points x value
  77417. * @param y the added points y value
  77418. * @returns the updated Path2.
  77419. */
  77420. addLineTo(x: number, y: number): Path2;
  77421. /**
  77422. * 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.
  77423. * @param midX middle point x value
  77424. * @param midY middle point y value
  77425. * @param endX end point x value
  77426. * @param endY end point y value
  77427. * @param numberOfSegments (default: 36)
  77428. * @returns the updated Path2.
  77429. */
  77430. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77431. /**
  77432. * Closes the Path2.
  77433. * @returns the Path2.
  77434. */
  77435. close(): Path2;
  77436. /**
  77437. * Gets the sum of the distance between each sequential point in the path
  77438. * @returns the Path2 total length (float).
  77439. */
  77440. length(): number;
  77441. /**
  77442. * Gets the points which construct the path
  77443. * @returns the Path2 internal array of points.
  77444. */
  77445. getPoints(): Vector2[];
  77446. /**
  77447. * Retreives the point at the distance aways from the starting point
  77448. * @param normalizedLengthPosition the length along the path to retreive the point from
  77449. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77450. */
  77451. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  77452. /**
  77453. * Creates a new path starting from an x and y position
  77454. * @param x starting x value
  77455. * @param y starting y value
  77456. * @returns a new Path2 starting at the coordinates (x, y).
  77457. */
  77458. static StartingAt(x: number, y: number): Path2;
  77459. }
  77460. /**
  77461. * Represents a 3D path made up of multiple 3D points
  77462. */
  77463. export class Path3D {
  77464. /**
  77465. * an array of Vector3, the curve axis of the Path3D
  77466. */
  77467. path: Vector3[];
  77468. private _curve;
  77469. private _distances;
  77470. private _tangents;
  77471. private _normals;
  77472. private _binormals;
  77473. private _raw;
  77474. private _alignTangentsWithPath;
  77475. private readonly _pointAtData;
  77476. /**
  77477. * new Path3D(path, normal, raw)
  77478. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77479. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77480. * @param path an array of Vector3, the curve axis of the Path3D
  77481. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77482. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77483. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  77484. */
  77485. constructor(
  77486. /**
  77487. * an array of Vector3, the curve axis of the Path3D
  77488. */
  77489. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  77490. /**
  77491. * Returns the Path3D array of successive Vector3 designing its curve.
  77492. * @returns the Path3D array of successive Vector3 designing its curve.
  77493. */
  77494. getCurve(): Vector3[];
  77495. /**
  77496. * Returns the Path3D array of successive Vector3 designing its curve.
  77497. * @returns the Path3D array of successive Vector3 designing its curve.
  77498. */
  77499. getPoints(): Vector3[];
  77500. /**
  77501. * @returns the computed length (float) of the path.
  77502. */
  77503. length(): number;
  77504. /**
  77505. * Returns an array populated with tangent vectors on each Path3D curve point.
  77506. * @returns an array populated with tangent vectors on each Path3D curve point.
  77507. */
  77508. getTangents(): Vector3[];
  77509. /**
  77510. * Returns an array populated with normal vectors on each Path3D curve point.
  77511. * @returns an array populated with normal vectors on each Path3D curve point.
  77512. */
  77513. getNormals(): Vector3[];
  77514. /**
  77515. * Returns an array populated with binormal vectors on each Path3D curve point.
  77516. * @returns an array populated with binormal vectors on each Path3D curve point.
  77517. */
  77518. getBinormals(): Vector3[];
  77519. /**
  77520. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77521. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77522. */
  77523. getDistances(): number[];
  77524. /**
  77525. * Returns an interpolated point along this path
  77526. * @param position the position of the point along this path, from 0.0 to 1.0
  77527. * @returns a new Vector3 as the point
  77528. */
  77529. getPointAt(position: number): Vector3;
  77530. /**
  77531. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77532. * @param position the position of the point along this path, from 0.0 to 1.0
  77533. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  77534. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  77535. */
  77536. getTangentAt(position: number, interpolated?: boolean): Vector3;
  77537. /**
  77538. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77539. * @param position the position of the point along this path, from 0.0 to 1.0
  77540. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  77541. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  77542. */
  77543. getNormalAt(position: number, interpolated?: boolean): Vector3;
  77544. /**
  77545. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  77546. * @param position the position of the point along this path, from 0.0 to 1.0
  77547. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  77548. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  77549. */
  77550. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  77551. /**
  77552. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  77553. * @param position the position of the point along this path, from 0.0 to 1.0
  77554. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  77555. */
  77556. getDistanceAt(position: number): number;
  77557. /**
  77558. * Returns the array index of the previous point of an interpolated point along this path
  77559. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77560. * @returns the array index
  77561. */
  77562. getPreviousPointIndexAt(position: number): number;
  77563. /**
  77564. * 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)
  77565. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77566. * @returns the sub position
  77567. */
  77568. getSubPositionAt(position: number): number;
  77569. /**
  77570. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  77571. * @param target the vector of which to get the closest position to
  77572. * @returns the position of the closest virtual point on this path to the target vector
  77573. */
  77574. getClosestPositionTo(target: Vector3): number;
  77575. /**
  77576. * Returns a sub path (slice) of this path
  77577. * @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
  77578. * @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
  77579. * @returns a sub path (slice) of this path
  77580. */
  77581. slice(start?: number, end?: number): Path3D;
  77582. /**
  77583. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77584. * @param path path which all values are copied into the curves points
  77585. * @param firstNormal which should be projected onto the curve
  77586. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  77587. * @returns the same object updated.
  77588. */
  77589. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  77590. private _compute;
  77591. private _getFirstNonNullVector;
  77592. private _getLastNonNullVector;
  77593. private _normalVector;
  77594. /**
  77595. * Updates the point at data for an interpolated point along this curve
  77596. * @param position the position of the point along this curve, from 0.0 to 1.0
  77597. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  77598. * @returns the (updated) point at data
  77599. */
  77600. private _updatePointAtData;
  77601. /**
  77602. * Updates the point at data from the specified parameters
  77603. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  77604. * @param point the interpolated point
  77605. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  77606. */
  77607. private _setPointAtData;
  77608. /**
  77609. * Updates the point at interpolation matrix for the tangents, normals and binormals
  77610. */
  77611. private _updateInterpolationMatrix;
  77612. }
  77613. /**
  77614. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77615. * A Curve3 is designed from a series of successive Vector3.
  77616. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77617. */
  77618. export class Curve3 {
  77619. private _points;
  77620. private _length;
  77621. /**
  77622. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77623. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77624. * @param v1 (Vector3) the control point
  77625. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77626. * @param nbPoints (integer) the wanted number of points in the curve
  77627. * @returns the created Curve3
  77628. */
  77629. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77630. /**
  77631. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77632. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77633. * @param v1 (Vector3) the first control point
  77634. * @param v2 (Vector3) the second control point
  77635. * @param v3 (Vector3) the end point of the Cubic Bezier
  77636. * @param nbPoints (integer) the wanted number of points in the curve
  77637. * @returns the created Curve3
  77638. */
  77639. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77640. /**
  77641. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77642. * @param p1 (Vector3) the origin point of the Hermite Spline
  77643. * @param t1 (Vector3) the tangent vector at the origin point
  77644. * @param p2 (Vector3) the end point of the Hermite Spline
  77645. * @param t2 (Vector3) the tangent vector at the end point
  77646. * @param nbPoints (integer) the wanted number of points in the curve
  77647. * @returns the created Curve3
  77648. */
  77649. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77650. /**
  77651. * Returns a Curve3 object along a CatmullRom Spline curve :
  77652. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77653. * @param nbPoints (integer) the wanted number of points between each curve control points
  77654. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77655. * @returns the created Curve3
  77656. */
  77657. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  77658. /**
  77659. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77660. * A Curve3 is designed from a series of successive Vector3.
  77661. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77662. * @param points points which make up the curve
  77663. */
  77664. constructor(points: Vector3[]);
  77665. /**
  77666. * @returns the Curve3 stored array of successive Vector3
  77667. */
  77668. getPoints(): Vector3[];
  77669. /**
  77670. * @returns the computed length (float) of the curve.
  77671. */
  77672. length(): number;
  77673. /**
  77674. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77675. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77676. * curveA and curveB keep unchanged.
  77677. * @param curve the curve to continue from this curve
  77678. * @returns the newly constructed curve
  77679. */
  77680. continue(curve: DeepImmutable<Curve3>): Curve3;
  77681. private _computeLength;
  77682. }
  77683. }
  77684. declare module BABYLON {
  77685. /**
  77686. * This represents the main contract an easing function should follow.
  77687. * Easing functions are used throughout the animation system.
  77688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77689. */
  77690. export interface IEasingFunction {
  77691. /**
  77692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  77693. * of the easing function.
  77694. * The link below provides some of the most common examples of easing functions.
  77695. * @see https://easings.net/
  77696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77697. * @returns the corresponding value on the curve defined by the easing function
  77698. */
  77699. ease(gradient: number): number;
  77700. }
  77701. /**
  77702. * Base class used for every default easing function.
  77703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77704. */
  77705. export class EasingFunction implements IEasingFunction {
  77706. /**
  77707. * Interpolation follows the mathematical formula associated with the easing function.
  77708. */
  77709. static readonly EASINGMODE_EASEIN: number;
  77710. /**
  77711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  77712. */
  77713. static readonly EASINGMODE_EASEOUT: number;
  77714. /**
  77715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  77716. */
  77717. static readonly EASINGMODE_EASEINOUT: number;
  77718. private _easingMode;
  77719. /**
  77720. * Sets the easing mode of the current function.
  77721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  77722. */
  77723. setEasingMode(easingMode: number): void;
  77724. /**
  77725. * Gets the current easing mode.
  77726. * @returns the easing mode
  77727. */
  77728. getEasingMode(): number;
  77729. /**
  77730. * @hidden
  77731. */
  77732. easeInCore(gradient: number): number;
  77733. /**
  77734. * Given an input gradient between 0 and 1, this returns the corresponding value
  77735. * of the easing function.
  77736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77737. * @returns the corresponding value on the curve defined by the easing function
  77738. */
  77739. ease(gradient: number): number;
  77740. }
  77741. /**
  77742. * Easing function with a circle shape (see link below).
  77743. * @see https://easings.net/#easeInCirc
  77744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77745. */
  77746. export class CircleEase extends EasingFunction implements IEasingFunction {
  77747. /** @hidden */
  77748. easeInCore(gradient: number): number;
  77749. }
  77750. /**
  77751. * Easing function with a ease back shape (see link below).
  77752. * @see https://easings.net/#easeInBack
  77753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77754. */
  77755. export class BackEase extends EasingFunction implements IEasingFunction {
  77756. /** Defines the amplitude of the function */
  77757. amplitude: number;
  77758. /**
  77759. * Instantiates a back ease easing
  77760. * @see https://easings.net/#easeInBack
  77761. * @param amplitude Defines the amplitude of the function
  77762. */
  77763. constructor(
  77764. /** Defines the amplitude of the function */
  77765. amplitude?: number);
  77766. /** @hidden */
  77767. easeInCore(gradient: number): number;
  77768. }
  77769. /**
  77770. * Easing function with a bouncing shape (see link below).
  77771. * @see https://easings.net/#easeInBounce
  77772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77773. */
  77774. export class BounceEase extends EasingFunction implements IEasingFunction {
  77775. /** Defines the number of bounces */
  77776. bounces: number;
  77777. /** Defines the amplitude of the bounce */
  77778. bounciness: number;
  77779. /**
  77780. * Instantiates a bounce easing
  77781. * @see https://easings.net/#easeInBounce
  77782. * @param bounces Defines the number of bounces
  77783. * @param bounciness Defines the amplitude of the bounce
  77784. */
  77785. constructor(
  77786. /** Defines the number of bounces */
  77787. bounces?: number,
  77788. /** Defines the amplitude of the bounce */
  77789. bounciness?: number);
  77790. /** @hidden */
  77791. easeInCore(gradient: number): number;
  77792. }
  77793. /**
  77794. * Easing function with a power of 3 shape (see link below).
  77795. * @see https://easings.net/#easeInCubic
  77796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77797. */
  77798. export class CubicEase extends EasingFunction implements IEasingFunction {
  77799. /** @hidden */
  77800. easeInCore(gradient: number): number;
  77801. }
  77802. /**
  77803. * Easing function with an elastic shape (see link below).
  77804. * @see https://easings.net/#easeInElastic
  77805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77806. */
  77807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  77808. /** Defines the number of oscillations*/
  77809. oscillations: number;
  77810. /** Defines the amplitude of the oscillations*/
  77811. springiness: number;
  77812. /**
  77813. * Instantiates an elastic easing function
  77814. * @see https://easings.net/#easeInElastic
  77815. * @param oscillations Defines the number of oscillations
  77816. * @param springiness Defines the amplitude of the oscillations
  77817. */
  77818. constructor(
  77819. /** Defines the number of oscillations*/
  77820. oscillations?: number,
  77821. /** Defines the amplitude of the oscillations*/
  77822. springiness?: number);
  77823. /** @hidden */
  77824. easeInCore(gradient: number): number;
  77825. }
  77826. /**
  77827. * Easing function with an exponential shape (see link below).
  77828. * @see https://easings.net/#easeInExpo
  77829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77830. */
  77831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  77832. /** Defines the exponent of the function */
  77833. exponent: number;
  77834. /**
  77835. * Instantiates an exponential easing function
  77836. * @see https://easings.net/#easeInExpo
  77837. * @param exponent Defines the exponent of the function
  77838. */
  77839. constructor(
  77840. /** Defines the exponent of the function */
  77841. exponent?: number);
  77842. /** @hidden */
  77843. easeInCore(gradient: number): number;
  77844. }
  77845. /**
  77846. * Easing function with a power shape (see link below).
  77847. * @see https://easings.net/#easeInQuad
  77848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77849. */
  77850. export class PowerEase extends EasingFunction implements IEasingFunction {
  77851. /** Defines the power of the function */
  77852. power: number;
  77853. /**
  77854. * Instantiates an power base easing function
  77855. * @see https://easings.net/#easeInQuad
  77856. * @param power Defines the power of the function
  77857. */
  77858. constructor(
  77859. /** Defines the power of the function */
  77860. power?: number);
  77861. /** @hidden */
  77862. easeInCore(gradient: number): number;
  77863. }
  77864. /**
  77865. * Easing function with a power of 2 shape (see link below).
  77866. * @see https://easings.net/#easeInQuad
  77867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77868. */
  77869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  77870. /** @hidden */
  77871. easeInCore(gradient: number): number;
  77872. }
  77873. /**
  77874. * Easing function with a power of 4 shape (see link below).
  77875. * @see https://easings.net/#easeInQuart
  77876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77877. */
  77878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  77879. /** @hidden */
  77880. easeInCore(gradient: number): number;
  77881. }
  77882. /**
  77883. * Easing function with a power of 5 shape (see link below).
  77884. * @see https://easings.net/#easeInQuint
  77885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77886. */
  77887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  77888. /** @hidden */
  77889. easeInCore(gradient: number): number;
  77890. }
  77891. /**
  77892. * Easing function with a sin shape (see link below).
  77893. * @see https://easings.net/#easeInSine
  77894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77895. */
  77896. export class SineEase extends EasingFunction implements IEasingFunction {
  77897. /** @hidden */
  77898. easeInCore(gradient: number): number;
  77899. }
  77900. /**
  77901. * Easing function with a bezier shape (see link below).
  77902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77904. */
  77905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  77906. /** Defines the x component of the start tangent in the bezier curve */
  77907. x1: number;
  77908. /** Defines the y component of the start tangent in the bezier curve */
  77909. y1: number;
  77910. /** Defines the x component of the end tangent in the bezier curve */
  77911. x2: number;
  77912. /** Defines the y component of the end tangent in the bezier curve */
  77913. y2: number;
  77914. /**
  77915. * Instantiates a bezier function
  77916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77917. * @param x1 Defines the x component of the start tangent in the bezier curve
  77918. * @param y1 Defines the y component of the start tangent in the bezier curve
  77919. * @param x2 Defines the x component of the end tangent in the bezier curve
  77920. * @param y2 Defines the y component of the end tangent in the bezier curve
  77921. */
  77922. constructor(
  77923. /** Defines the x component of the start tangent in the bezier curve */
  77924. x1?: number,
  77925. /** Defines the y component of the start tangent in the bezier curve */
  77926. y1?: number,
  77927. /** Defines the x component of the end tangent in the bezier curve */
  77928. x2?: number,
  77929. /** Defines the y component of the end tangent in the bezier curve */
  77930. y2?: number);
  77931. /** @hidden */
  77932. easeInCore(gradient: number): number;
  77933. }
  77934. }
  77935. declare module BABYLON {
  77936. /**
  77937. * Class used to hold a RBG color
  77938. */
  77939. export class Color3 {
  77940. /**
  77941. * Defines the red component (between 0 and 1, default is 0)
  77942. */
  77943. r: number;
  77944. /**
  77945. * Defines the green component (between 0 and 1, default is 0)
  77946. */
  77947. g: number;
  77948. /**
  77949. * Defines the blue component (between 0 and 1, default is 0)
  77950. */
  77951. b: number;
  77952. /**
  77953. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  77954. * @param r defines the red component (between 0 and 1, default is 0)
  77955. * @param g defines the green component (between 0 and 1, default is 0)
  77956. * @param b defines the blue component (between 0 and 1, default is 0)
  77957. */
  77958. constructor(
  77959. /**
  77960. * Defines the red component (between 0 and 1, default is 0)
  77961. */
  77962. r?: number,
  77963. /**
  77964. * Defines the green component (between 0 and 1, default is 0)
  77965. */
  77966. g?: number,
  77967. /**
  77968. * Defines the blue component (between 0 and 1, default is 0)
  77969. */
  77970. b?: number);
  77971. /**
  77972. * Creates a string with the Color3 current values
  77973. * @returns the string representation of the Color3 object
  77974. */
  77975. toString(): string;
  77976. /**
  77977. * Returns the string "Color3"
  77978. * @returns "Color3"
  77979. */
  77980. getClassName(): string;
  77981. /**
  77982. * Compute the Color3 hash code
  77983. * @returns an unique number that can be used to hash Color3 objects
  77984. */
  77985. getHashCode(): number;
  77986. /**
  77987. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  77988. * @param array defines the array where to store the r,g,b components
  77989. * @param index defines an optional index in the target array to define where to start storing values
  77990. * @returns the current Color3 object
  77991. */
  77992. toArray(array: FloatArray, index?: number): Color3;
  77993. /**
  77994. * Returns a new Color4 object from the current Color3 and the given alpha
  77995. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  77996. * @returns a new Color4 object
  77997. */
  77998. toColor4(alpha?: number): Color4;
  77999. /**
  78000. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78001. * @returns the new array
  78002. */
  78003. asArray(): number[];
  78004. /**
  78005. * Returns the luminance value
  78006. * @returns a float value
  78007. */
  78008. toLuminance(): number;
  78009. /**
  78010. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78011. * @param otherColor defines the second operand
  78012. * @returns the new Color3 object
  78013. */
  78014. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78015. /**
  78016. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78017. * @param otherColor defines the second operand
  78018. * @param result defines the Color3 object where to store the result
  78019. * @returns the current Color3
  78020. */
  78021. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78022. /**
  78023. * Determines equality between Color3 objects
  78024. * @param otherColor defines the second operand
  78025. * @returns true if the rgb values are equal to the given ones
  78026. */
  78027. equals(otherColor: DeepImmutable<Color3>): boolean;
  78028. /**
  78029. * Determines equality between the current Color3 object and a set of r,b,g values
  78030. * @param r defines the red component to check
  78031. * @param g defines the green component to check
  78032. * @param b defines the blue component to check
  78033. * @returns true if the rgb values are equal to the given ones
  78034. */
  78035. equalsFloats(r: number, g: number, b: number): boolean;
  78036. /**
  78037. * Multiplies in place each rgb value by scale
  78038. * @param scale defines the scaling factor
  78039. * @returns the updated Color3
  78040. */
  78041. scale(scale: number): Color3;
  78042. /**
  78043. * Multiplies the rgb values by scale and stores the result into "result"
  78044. * @param scale defines the scaling factor
  78045. * @param result defines the Color3 object where to store the result
  78046. * @returns the unmodified current Color3
  78047. */
  78048. scaleToRef(scale: number, result: Color3): Color3;
  78049. /**
  78050. * Scale the current Color3 values by a factor and add the result to a given Color3
  78051. * @param scale defines the scale factor
  78052. * @param result defines color to store the result into
  78053. * @returns the unmodified current Color3
  78054. */
  78055. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78056. /**
  78057. * Clamps the rgb values by the min and max values and stores the result into "result"
  78058. * @param min defines minimum clamping value (default is 0)
  78059. * @param max defines maximum clamping value (default is 1)
  78060. * @param result defines color to store the result into
  78061. * @returns the original Color3
  78062. */
  78063. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78064. /**
  78065. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78066. * @param otherColor defines the second operand
  78067. * @returns the new Color3
  78068. */
  78069. add(otherColor: DeepImmutable<Color3>): Color3;
  78070. /**
  78071. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78072. * @param otherColor defines the second operand
  78073. * @param result defines Color3 object to store the result into
  78074. * @returns the unmodified current Color3
  78075. */
  78076. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78077. /**
  78078. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78079. * @param otherColor defines the second operand
  78080. * @returns the new Color3
  78081. */
  78082. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78083. /**
  78084. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78085. * @param otherColor defines the second operand
  78086. * @param result defines Color3 object to store the result into
  78087. * @returns the unmodified current Color3
  78088. */
  78089. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78090. /**
  78091. * Copy the current object
  78092. * @returns a new Color3 copied the current one
  78093. */
  78094. clone(): Color3;
  78095. /**
  78096. * Copies the rgb values from the source in the current Color3
  78097. * @param source defines the source Color3 object
  78098. * @returns the updated Color3 object
  78099. */
  78100. copyFrom(source: DeepImmutable<Color3>): Color3;
  78101. /**
  78102. * Updates the Color3 rgb values from the given floats
  78103. * @param r defines the red component to read from
  78104. * @param g defines the green component to read from
  78105. * @param b defines the blue component to read from
  78106. * @returns the current Color3 object
  78107. */
  78108. copyFromFloats(r: number, g: number, b: number): Color3;
  78109. /**
  78110. * Updates the Color3 rgb values from the given floats
  78111. * @param r defines the red component to read from
  78112. * @param g defines the green component to read from
  78113. * @param b defines the blue component to read from
  78114. * @returns the current Color3 object
  78115. */
  78116. set(r: number, g: number, b: number): Color3;
  78117. /**
  78118. * Compute the Color3 hexadecimal code as a string
  78119. * @returns a string containing the hexadecimal representation of the Color3 object
  78120. */
  78121. toHexString(): string;
  78122. /**
  78123. * Computes a new Color3 converted from the current one to linear space
  78124. * @returns a new Color3 object
  78125. */
  78126. toLinearSpace(): Color3;
  78127. /**
  78128. * Converts current color in rgb space to HSV values
  78129. * @returns a new color3 representing the HSV values
  78130. */
  78131. toHSV(): Color3;
  78132. /**
  78133. * Converts current color in rgb space to HSV values
  78134. * @param result defines the Color3 where to store the HSV values
  78135. */
  78136. toHSVToRef(result: Color3): void;
  78137. /**
  78138. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78139. * @param convertedColor defines the Color3 object where to store the linear space version
  78140. * @returns the unmodified Color3
  78141. */
  78142. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78143. /**
  78144. * Computes a new Color3 converted from the current one to gamma space
  78145. * @returns a new Color3 object
  78146. */
  78147. toGammaSpace(): Color3;
  78148. /**
  78149. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78150. * @param convertedColor defines the Color3 object where to store the gamma space version
  78151. * @returns the unmodified Color3
  78152. */
  78153. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78154. private static _BlackReadOnly;
  78155. /**
  78156. * Convert Hue, saturation and value to a Color3 (RGB)
  78157. * @param hue defines the hue
  78158. * @param saturation defines the saturation
  78159. * @param value defines the value
  78160. * @param result defines the Color3 where to store the RGB values
  78161. */
  78162. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78163. /**
  78164. * Creates a new Color3 from the string containing valid hexadecimal values
  78165. * @param hex defines a string containing valid hexadecimal values
  78166. * @returns a new Color3 object
  78167. */
  78168. static FromHexString(hex: string): Color3;
  78169. /**
  78170. * Creates a new Color3 from the starting index of the given array
  78171. * @param array defines the source array
  78172. * @param offset defines an offset in the source array
  78173. * @returns a new Color3 object
  78174. */
  78175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78176. /**
  78177. * Creates a new Color3 from integer values (< 256)
  78178. * @param r defines the red component to read from (value between 0 and 255)
  78179. * @param g defines the green component to read from (value between 0 and 255)
  78180. * @param b defines the blue component to read from (value between 0 and 255)
  78181. * @returns a new Color3 object
  78182. */
  78183. static FromInts(r: number, g: number, b: number): Color3;
  78184. /**
  78185. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78186. * @param start defines the start Color3 value
  78187. * @param end defines the end Color3 value
  78188. * @param amount defines the gradient value between start and end
  78189. * @returns a new Color3 object
  78190. */
  78191. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78192. /**
  78193. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78194. * @param left defines the start value
  78195. * @param right defines the end value
  78196. * @param amount defines the gradient factor
  78197. * @param result defines the Color3 object where to store the result
  78198. */
  78199. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78200. /**
  78201. * Returns a Color3 value containing a red color
  78202. * @returns a new Color3 object
  78203. */
  78204. static Red(): Color3;
  78205. /**
  78206. * Returns a Color3 value containing a green color
  78207. * @returns a new Color3 object
  78208. */
  78209. static Green(): Color3;
  78210. /**
  78211. * Returns a Color3 value containing a blue color
  78212. * @returns a new Color3 object
  78213. */
  78214. static Blue(): Color3;
  78215. /**
  78216. * Returns a Color3 value containing a black color
  78217. * @returns a new Color3 object
  78218. */
  78219. static Black(): Color3;
  78220. /**
  78221. * Gets a Color3 value containing a black color that must not be updated
  78222. */
  78223. static get BlackReadOnly(): DeepImmutable<Color3>;
  78224. /**
  78225. * Returns a Color3 value containing a white color
  78226. * @returns a new Color3 object
  78227. */
  78228. static White(): Color3;
  78229. /**
  78230. * Returns a Color3 value containing a purple color
  78231. * @returns a new Color3 object
  78232. */
  78233. static Purple(): Color3;
  78234. /**
  78235. * Returns a Color3 value containing a magenta color
  78236. * @returns a new Color3 object
  78237. */
  78238. static Magenta(): Color3;
  78239. /**
  78240. * Returns a Color3 value containing a yellow color
  78241. * @returns a new Color3 object
  78242. */
  78243. static Yellow(): Color3;
  78244. /**
  78245. * Returns a Color3 value containing a gray color
  78246. * @returns a new Color3 object
  78247. */
  78248. static Gray(): Color3;
  78249. /**
  78250. * Returns a Color3 value containing a teal color
  78251. * @returns a new Color3 object
  78252. */
  78253. static Teal(): Color3;
  78254. /**
  78255. * Returns a Color3 value containing a random color
  78256. * @returns a new Color3 object
  78257. */
  78258. static Random(): Color3;
  78259. }
  78260. /**
  78261. * Class used to hold a RBGA color
  78262. */
  78263. export class Color4 {
  78264. /**
  78265. * Defines the red component (between 0 and 1, default is 0)
  78266. */
  78267. r: number;
  78268. /**
  78269. * Defines the green component (between 0 and 1, default is 0)
  78270. */
  78271. g: number;
  78272. /**
  78273. * Defines the blue component (between 0 and 1, default is 0)
  78274. */
  78275. b: number;
  78276. /**
  78277. * Defines the alpha component (between 0 and 1, default is 1)
  78278. */
  78279. a: number;
  78280. /**
  78281. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78282. * @param r defines the red component (between 0 and 1, default is 0)
  78283. * @param g defines the green component (between 0 and 1, default is 0)
  78284. * @param b defines the blue component (between 0 and 1, default is 0)
  78285. * @param a defines the alpha component (between 0 and 1, default is 1)
  78286. */
  78287. constructor(
  78288. /**
  78289. * Defines the red component (between 0 and 1, default is 0)
  78290. */
  78291. r?: number,
  78292. /**
  78293. * Defines the green component (between 0 and 1, default is 0)
  78294. */
  78295. g?: number,
  78296. /**
  78297. * Defines the blue component (between 0 and 1, default is 0)
  78298. */
  78299. b?: number,
  78300. /**
  78301. * Defines the alpha component (between 0 and 1, default is 1)
  78302. */
  78303. a?: number);
  78304. /**
  78305. * Adds in place the given Color4 values to the current Color4 object
  78306. * @param right defines the second operand
  78307. * @returns the current updated Color4 object
  78308. */
  78309. addInPlace(right: DeepImmutable<Color4>): Color4;
  78310. /**
  78311. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78312. * @returns the new array
  78313. */
  78314. asArray(): number[];
  78315. /**
  78316. * Stores from the starting index in the given array the Color4 successive values
  78317. * @param array defines the array where to store the r,g,b components
  78318. * @param index defines an optional index in the target array to define where to start storing values
  78319. * @returns the current Color4 object
  78320. */
  78321. toArray(array: number[], index?: number): Color4;
  78322. /**
  78323. * Determines equality between Color4 objects
  78324. * @param otherColor defines the second operand
  78325. * @returns true if the rgba values are equal to the given ones
  78326. */
  78327. equals(otherColor: DeepImmutable<Color4>): boolean;
  78328. /**
  78329. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78330. * @param right defines the second operand
  78331. * @returns a new Color4 object
  78332. */
  78333. add(right: DeepImmutable<Color4>): Color4;
  78334. /**
  78335. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78336. * @param right defines the second operand
  78337. * @returns a new Color4 object
  78338. */
  78339. subtract(right: DeepImmutable<Color4>): Color4;
  78340. /**
  78341. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78342. * @param right defines the second operand
  78343. * @param result defines the Color4 object where to store the result
  78344. * @returns the current Color4 object
  78345. */
  78346. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78347. /**
  78348. * Creates a new Color4 with the current Color4 values multiplied by scale
  78349. * @param scale defines the scaling factor to apply
  78350. * @returns a new Color4 object
  78351. */
  78352. scale(scale: number): Color4;
  78353. /**
  78354. * Multiplies the current Color4 values by scale and stores the result in "result"
  78355. * @param scale defines the scaling factor to apply
  78356. * @param result defines the Color4 object where to store the result
  78357. * @returns the current unmodified Color4
  78358. */
  78359. scaleToRef(scale: number, result: Color4): Color4;
  78360. /**
  78361. * Scale the current Color4 values by a factor and add the result to a given Color4
  78362. * @param scale defines the scale factor
  78363. * @param result defines the Color4 object where to store the result
  78364. * @returns the unmodified current Color4
  78365. */
  78366. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78367. /**
  78368. * Clamps the rgb values by the min and max values and stores the result into "result"
  78369. * @param min defines minimum clamping value (default is 0)
  78370. * @param max defines maximum clamping value (default is 1)
  78371. * @param result defines color to store the result into.
  78372. * @returns the cuurent Color4
  78373. */
  78374. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78375. /**
  78376. * Multipy an Color4 value by another and return a new Color4 object
  78377. * @param color defines the Color4 value to multiply by
  78378. * @returns a new Color4 object
  78379. */
  78380. multiply(color: Color4): Color4;
  78381. /**
  78382. * Multipy a Color4 value by another and push the result in a reference value
  78383. * @param color defines the Color4 value to multiply by
  78384. * @param result defines the Color4 to fill the result in
  78385. * @returns the result Color4
  78386. */
  78387. multiplyToRef(color: Color4, result: Color4): Color4;
  78388. /**
  78389. * Creates a string with the Color4 current values
  78390. * @returns the string representation of the Color4 object
  78391. */
  78392. toString(): string;
  78393. /**
  78394. * Returns the string "Color4"
  78395. * @returns "Color4"
  78396. */
  78397. getClassName(): string;
  78398. /**
  78399. * Compute the Color4 hash code
  78400. * @returns an unique number that can be used to hash Color4 objects
  78401. */
  78402. getHashCode(): number;
  78403. /**
  78404. * Creates a new Color4 copied from the current one
  78405. * @returns a new Color4 object
  78406. */
  78407. clone(): Color4;
  78408. /**
  78409. * Copies the given Color4 values into the current one
  78410. * @param source defines the source Color4 object
  78411. * @returns the current updated Color4 object
  78412. */
  78413. copyFrom(source: Color4): Color4;
  78414. /**
  78415. * Copies the given float values into the current one
  78416. * @param r defines the red component to read from
  78417. * @param g defines the green component to read from
  78418. * @param b defines the blue component to read from
  78419. * @param a defines the alpha component to read from
  78420. * @returns the current updated Color4 object
  78421. */
  78422. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78423. /**
  78424. * Copies the given float values into the current one
  78425. * @param r defines the red component to read from
  78426. * @param g defines the green component to read from
  78427. * @param b defines the blue component to read from
  78428. * @param a defines the alpha component to read from
  78429. * @returns the current updated Color4 object
  78430. */
  78431. set(r: number, g: number, b: number, a: number): Color4;
  78432. /**
  78433. * Compute the Color4 hexadecimal code as a string
  78434. * @returns a string containing the hexadecimal representation of the Color4 object
  78435. */
  78436. toHexString(): string;
  78437. /**
  78438. * Computes a new Color4 converted from the current one to linear space
  78439. * @returns a new Color4 object
  78440. */
  78441. toLinearSpace(): Color4;
  78442. /**
  78443. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78444. * @param convertedColor defines the Color4 object where to store the linear space version
  78445. * @returns the unmodified Color4
  78446. */
  78447. toLinearSpaceToRef(convertedColor: Color4): Color4;
  78448. /**
  78449. * Computes a new Color4 converted from the current one to gamma space
  78450. * @returns a new Color4 object
  78451. */
  78452. toGammaSpace(): Color4;
  78453. /**
  78454. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  78455. * @param convertedColor defines the Color4 object where to store the gamma space version
  78456. * @returns the unmodified Color4
  78457. */
  78458. toGammaSpaceToRef(convertedColor: Color4): Color4;
  78459. /**
  78460. * Creates a new Color4 from the string containing valid hexadecimal values
  78461. * @param hex defines a string containing valid hexadecimal values
  78462. * @returns a new Color4 object
  78463. */
  78464. static FromHexString(hex: string): Color4;
  78465. /**
  78466. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78467. * @param left defines the start value
  78468. * @param right defines the end value
  78469. * @param amount defines the gradient factor
  78470. * @returns a new Color4 object
  78471. */
  78472. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  78473. /**
  78474. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78475. * @param left defines the start value
  78476. * @param right defines the end value
  78477. * @param amount defines the gradient factor
  78478. * @param result defines the Color4 object where to store data
  78479. */
  78480. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  78481. /**
  78482. * Creates a new Color4 from a Color3 and an alpha value
  78483. * @param color3 defines the source Color3 to read from
  78484. * @param alpha defines the alpha component (1.0 by default)
  78485. * @returns a new Color4 object
  78486. */
  78487. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  78488. /**
  78489. * Creates a new Color4 from the starting index element of the given array
  78490. * @param array defines the source array to read from
  78491. * @param offset defines the offset in the source array
  78492. * @returns a new Color4 object
  78493. */
  78494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  78495. /**
  78496. * Creates a new Color3 from integer values (< 256)
  78497. * @param r defines the red component to read from (value between 0 and 255)
  78498. * @param g defines the green component to read from (value between 0 and 255)
  78499. * @param b defines the blue component to read from (value between 0 and 255)
  78500. * @param a defines the alpha component to read from (value between 0 and 255)
  78501. * @returns a new Color3 object
  78502. */
  78503. static FromInts(r: number, g: number, b: number, a: number): Color4;
  78504. /**
  78505. * Check the content of a given array and convert it to an array containing RGBA data
  78506. * If the original array was already containing count * 4 values then it is returned directly
  78507. * @param colors defines the array to check
  78508. * @param count defines the number of RGBA data to expect
  78509. * @returns an array containing count * 4 values (RGBA)
  78510. */
  78511. static CheckColors4(colors: number[], count: number): number[];
  78512. }
  78513. /**
  78514. * @hidden
  78515. */
  78516. export class TmpColors {
  78517. static Color3: Color3[];
  78518. static Color4: Color4[];
  78519. }
  78520. }
  78521. declare module BABYLON {
  78522. /**
  78523. * Defines an interface which represents an animation key frame
  78524. */
  78525. export interface IAnimationKey {
  78526. /**
  78527. * Frame of the key frame
  78528. */
  78529. frame: number;
  78530. /**
  78531. * Value at the specifies key frame
  78532. */
  78533. value: any;
  78534. /**
  78535. * The input tangent for the cubic hermite spline
  78536. */
  78537. inTangent?: any;
  78538. /**
  78539. * The output tangent for the cubic hermite spline
  78540. */
  78541. outTangent?: any;
  78542. /**
  78543. * The animation interpolation type
  78544. */
  78545. interpolation?: AnimationKeyInterpolation;
  78546. }
  78547. /**
  78548. * Enum for the animation key frame interpolation type
  78549. */
  78550. export enum AnimationKeyInterpolation {
  78551. /**
  78552. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  78553. */
  78554. STEP = 1
  78555. }
  78556. }
  78557. declare module BABYLON {
  78558. /**
  78559. * Represents the range of an animation
  78560. */
  78561. export class AnimationRange {
  78562. /**The name of the animation range**/
  78563. name: string;
  78564. /**The starting frame of the animation */
  78565. from: number;
  78566. /**The ending frame of the animation*/
  78567. to: number;
  78568. /**
  78569. * Initializes the range of an animation
  78570. * @param name The name of the animation range
  78571. * @param from The starting frame of the animation
  78572. * @param to The ending frame of the animation
  78573. */
  78574. constructor(
  78575. /**The name of the animation range**/
  78576. name: string,
  78577. /**The starting frame of the animation */
  78578. from: number,
  78579. /**The ending frame of the animation*/
  78580. to: number);
  78581. /**
  78582. * Makes a copy of the animation range
  78583. * @returns A copy of the animation range
  78584. */
  78585. clone(): AnimationRange;
  78586. }
  78587. }
  78588. declare module BABYLON {
  78589. /**
  78590. * Composed of a frame, and an action function
  78591. */
  78592. export class AnimationEvent {
  78593. /** The frame for which the event is triggered **/
  78594. frame: number;
  78595. /** The event to perform when triggered **/
  78596. action: (currentFrame: number) => void;
  78597. /** Specifies if the event should be triggered only once**/
  78598. onlyOnce?: boolean | undefined;
  78599. /**
  78600. * Specifies if the animation event is done
  78601. */
  78602. isDone: boolean;
  78603. /**
  78604. * Initializes the animation event
  78605. * @param frame The frame for which the event is triggered
  78606. * @param action The event to perform when triggered
  78607. * @param onlyOnce Specifies if the event should be triggered only once
  78608. */
  78609. constructor(
  78610. /** The frame for which the event is triggered **/
  78611. frame: number,
  78612. /** The event to perform when triggered **/
  78613. action: (currentFrame: number) => void,
  78614. /** Specifies if the event should be triggered only once**/
  78615. onlyOnce?: boolean | undefined);
  78616. /** @hidden */
  78617. _clone(): AnimationEvent;
  78618. }
  78619. }
  78620. declare module BABYLON {
  78621. /**
  78622. * Interface used to define a behavior
  78623. */
  78624. export interface Behavior<T> {
  78625. /** gets or sets behavior's name */
  78626. name: string;
  78627. /**
  78628. * Function called when the behavior needs to be initialized (after attaching it to a target)
  78629. */
  78630. init(): void;
  78631. /**
  78632. * Called when the behavior is attached to a target
  78633. * @param target defines the target where the behavior is attached to
  78634. */
  78635. attach(target: T): void;
  78636. /**
  78637. * Called when the behavior is detached from its target
  78638. */
  78639. detach(): void;
  78640. }
  78641. /**
  78642. * Interface implemented by classes supporting behaviors
  78643. */
  78644. export interface IBehaviorAware<T> {
  78645. /**
  78646. * Attach a behavior
  78647. * @param behavior defines the behavior to attach
  78648. * @returns the current host
  78649. */
  78650. addBehavior(behavior: Behavior<T>): T;
  78651. /**
  78652. * Remove a behavior from the current object
  78653. * @param behavior defines the behavior to detach
  78654. * @returns the current host
  78655. */
  78656. removeBehavior(behavior: Behavior<T>): T;
  78657. /**
  78658. * Gets a behavior using its name to search
  78659. * @param name defines the name to search
  78660. * @returns the behavior or null if not found
  78661. */
  78662. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  78663. }
  78664. }
  78665. declare module BABYLON {
  78666. /**
  78667. * Defines an array and its length.
  78668. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  78669. */
  78670. export interface ISmartArrayLike<T> {
  78671. /**
  78672. * The data of the array.
  78673. */
  78674. data: Array<T>;
  78675. /**
  78676. * The active length of the array.
  78677. */
  78678. length: number;
  78679. }
  78680. /**
  78681. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78682. */
  78683. export class SmartArray<T> implements ISmartArrayLike<T> {
  78684. /**
  78685. * The full set of data from the array.
  78686. */
  78687. data: Array<T>;
  78688. /**
  78689. * The active length of the array.
  78690. */
  78691. length: number;
  78692. protected _id: number;
  78693. /**
  78694. * Instantiates a Smart Array.
  78695. * @param capacity defines the default capacity of the array.
  78696. */
  78697. constructor(capacity: number);
  78698. /**
  78699. * Pushes a value at the end of the active data.
  78700. * @param value defines the object to push in the array.
  78701. */
  78702. push(value: T): void;
  78703. /**
  78704. * Iterates over the active data and apply the lambda to them.
  78705. * @param func defines the action to apply on each value.
  78706. */
  78707. forEach(func: (content: T) => void): void;
  78708. /**
  78709. * Sorts the full sets of data.
  78710. * @param compareFn defines the comparison function to apply.
  78711. */
  78712. sort(compareFn: (a: T, b: T) => number): void;
  78713. /**
  78714. * Resets the active data to an empty array.
  78715. */
  78716. reset(): void;
  78717. /**
  78718. * Releases all the data from the array as well as the array.
  78719. */
  78720. dispose(): void;
  78721. /**
  78722. * Concats the active data with a given array.
  78723. * @param array defines the data to concatenate with.
  78724. */
  78725. concat(array: any): void;
  78726. /**
  78727. * Returns the position of a value in the active data.
  78728. * @param value defines the value to find the index for
  78729. * @returns the index if found in the active data otherwise -1
  78730. */
  78731. indexOf(value: T): number;
  78732. /**
  78733. * Returns whether an element is part of the active data.
  78734. * @param value defines the value to look for
  78735. * @returns true if found in the active data otherwise false
  78736. */
  78737. contains(value: T): boolean;
  78738. private static _GlobalId;
  78739. }
  78740. /**
  78741. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78742. * The data in this array can only be present once
  78743. */
  78744. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  78745. private _duplicateId;
  78746. /**
  78747. * Pushes a value at the end of the active data.
  78748. * THIS DOES NOT PREVENT DUPPLICATE DATA
  78749. * @param value defines the object to push in the array.
  78750. */
  78751. push(value: T): void;
  78752. /**
  78753. * Pushes a value at the end of the active data.
  78754. * If the data is already present, it won t be added again
  78755. * @param value defines the object to push in the array.
  78756. * @returns true if added false if it was already present
  78757. */
  78758. pushNoDuplicate(value: T): boolean;
  78759. /**
  78760. * Resets the active data to an empty array.
  78761. */
  78762. reset(): void;
  78763. /**
  78764. * Concats the active data with a given array.
  78765. * This ensures no dupplicate will be present in the result.
  78766. * @param array defines the data to concatenate with.
  78767. */
  78768. concatWithNoDuplicate(array: any): void;
  78769. }
  78770. }
  78771. declare module BABYLON {
  78772. /**
  78773. * @ignore
  78774. * This is a list of all the different input types that are available in the application.
  78775. * Fo instance: ArcRotateCameraGamepadInput...
  78776. */
  78777. export var CameraInputTypes: {};
  78778. /**
  78779. * This is the contract to implement in order to create a new input class.
  78780. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  78781. */
  78782. export interface ICameraInput<TCamera extends Camera> {
  78783. /**
  78784. * Defines the camera the input is attached to.
  78785. */
  78786. camera: Nullable<TCamera>;
  78787. /**
  78788. * Gets the class name of the current intput.
  78789. * @returns the class name
  78790. */
  78791. getClassName(): string;
  78792. /**
  78793. * Get the friendly name associated with the input class.
  78794. * @returns the input friendly name
  78795. */
  78796. getSimpleName(): string;
  78797. /**
  78798. * Attach the input controls to a specific dom element to get the input from.
  78799. * @param element Defines the element the controls should be listened from
  78800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78801. */
  78802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78803. /**
  78804. * Detach the current controls from the specified dom element.
  78805. * @param element Defines the element to stop listening the inputs from
  78806. */
  78807. detachControl(element: Nullable<HTMLElement>): void;
  78808. /**
  78809. * Update the current camera state depending on the inputs that have been used this frame.
  78810. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78811. */
  78812. checkInputs?: () => void;
  78813. }
  78814. /**
  78815. * Represents a map of input types to input instance or input index to input instance.
  78816. */
  78817. export interface CameraInputsMap<TCamera extends Camera> {
  78818. /**
  78819. * Accessor to the input by input type.
  78820. */
  78821. [name: string]: ICameraInput<TCamera>;
  78822. /**
  78823. * Accessor to the input by input index.
  78824. */
  78825. [idx: number]: ICameraInput<TCamera>;
  78826. }
  78827. /**
  78828. * This represents the input manager used within a camera.
  78829. * It helps dealing with all the different kind of input attached to a camera.
  78830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78831. */
  78832. export class CameraInputsManager<TCamera extends Camera> {
  78833. /**
  78834. * Defines the list of inputs attahed to the camera.
  78835. */
  78836. attached: CameraInputsMap<TCamera>;
  78837. /**
  78838. * Defines the dom element the camera is collecting inputs from.
  78839. * This is null if the controls have not been attached.
  78840. */
  78841. attachedElement: Nullable<HTMLElement>;
  78842. /**
  78843. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78844. */
  78845. noPreventDefault: boolean;
  78846. /**
  78847. * Defined the camera the input manager belongs to.
  78848. */
  78849. camera: TCamera;
  78850. /**
  78851. * Update the current camera state depending on the inputs that have been used this frame.
  78852. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78853. */
  78854. checkInputs: () => void;
  78855. /**
  78856. * Instantiate a new Camera Input Manager.
  78857. * @param camera Defines the camera the input manager blongs to
  78858. */
  78859. constructor(camera: TCamera);
  78860. /**
  78861. * Add an input method to a camera
  78862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78863. * @param input camera input method
  78864. */
  78865. add(input: ICameraInput<TCamera>): void;
  78866. /**
  78867. * Remove a specific input method from a camera
  78868. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  78869. * @param inputToRemove camera input method
  78870. */
  78871. remove(inputToRemove: ICameraInput<TCamera>): void;
  78872. /**
  78873. * Remove a specific input type from a camera
  78874. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  78875. * @param inputType the type of the input to remove
  78876. */
  78877. removeByType(inputType: string): void;
  78878. private _addCheckInputs;
  78879. /**
  78880. * Attach the input controls to the currently attached dom element to listen the events from.
  78881. * @param input Defines the input to attach
  78882. */
  78883. attachInput(input: ICameraInput<TCamera>): void;
  78884. /**
  78885. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  78886. * @param element Defines the dom element to collect the events from
  78887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78888. */
  78889. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  78890. /**
  78891. * Detach the current manager inputs controls from a specific dom element.
  78892. * @param element Defines the dom element to collect the events from
  78893. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  78894. */
  78895. detachElement(element: HTMLElement, disconnect?: boolean): void;
  78896. /**
  78897. * Rebuild the dynamic inputCheck function from the current list of
  78898. * defined inputs in the manager.
  78899. */
  78900. rebuildInputCheck(): void;
  78901. /**
  78902. * Remove all attached input methods from a camera
  78903. */
  78904. clear(): void;
  78905. /**
  78906. * Serialize the current input manager attached to a camera.
  78907. * This ensures than once parsed,
  78908. * the input associated to the camera will be identical to the current ones
  78909. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  78910. */
  78911. serialize(serializedCamera: any): void;
  78912. /**
  78913. * Parses an input manager serialized JSON to restore the previous list of inputs
  78914. * and states associated to a camera.
  78915. * @param parsedCamera Defines the JSON to parse
  78916. */
  78917. parse(parsedCamera: any): void;
  78918. }
  78919. }
  78920. declare module BABYLON {
  78921. /**
  78922. * Class used to store data that will be store in GPU memory
  78923. */
  78924. export class Buffer {
  78925. private _engine;
  78926. private _buffer;
  78927. /** @hidden */
  78928. _data: Nullable<DataArray>;
  78929. private _updatable;
  78930. private _instanced;
  78931. private _divisor;
  78932. /**
  78933. * Gets the byte stride.
  78934. */
  78935. readonly byteStride: number;
  78936. /**
  78937. * Constructor
  78938. * @param engine the engine
  78939. * @param data the data to use for this buffer
  78940. * @param updatable whether the data is updatable
  78941. * @param stride the stride (optional)
  78942. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  78943. * @param instanced whether the buffer is instanced (optional)
  78944. * @param useBytes set to true if the stride in in bytes (optional)
  78945. * @param divisor sets an optional divisor for instances (1 by default)
  78946. */
  78947. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  78948. /**
  78949. * Create a new VertexBuffer based on the current buffer
  78950. * @param kind defines the vertex buffer kind (position, normal, etc.)
  78951. * @param offset defines offset in the buffer (0 by default)
  78952. * @param size defines the size in floats of attributes (position is 3 for instance)
  78953. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  78954. * @param instanced defines if the vertex buffer contains indexed data
  78955. * @param useBytes defines if the offset and stride are in bytes *
  78956. * @param divisor sets an optional divisor for instances (1 by default)
  78957. * @returns the new vertex buffer
  78958. */
  78959. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  78960. /**
  78961. * Gets a boolean indicating if the Buffer is updatable?
  78962. * @returns true if the buffer is updatable
  78963. */
  78964. isUpdatable(): boolean;
  78965. /**
  78966. * Gets current buffer's data
  78967. * @returns a DataArray or null
  78968. */
  78969. getData(): Nullable<DataArray>;
  78970. /**
  78971. * Gets underlying native buffer
  78972. * @returns underlying native buffer
  78973. */
  78974. getBuffer(): Nullable<DataBuffer>;
  78975. /**
  78976. * Gets the stride in float32 units (i.e. byte stride / 4).
  78977. * May not be an integer if the byte stride is not divisible by 4.
  78978. * @returns the stride in float32 units
  78979. * @deprecated Please use byteStride instead.
  78980. */
  78981. getStrideSize(): number;
  78982. /**
  78983. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  78984. * @param data defines the data to store
  78985. */
  78986. create(data?: Nullable<DataArray>): void;
  78987. /** @hidden */
  78988. _rebuild(): void;
  78989. /**
  78990. * Update current buffer data
  78991. * @param data defines the data to store
  78992. */
  78993. update(data: DataArray): void;
  78994. /**
  78995. * Updates the data directly.
  78996. * @param data the new data
  78997. * @param offset the new offset
  78998. * @param vertexCount the vertex count (optional)
  78999. * @param useBytes set to true if the offset is in bytes
  79000. */
  79001. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79002. /**
  79003. * Release all resources
  79004. */
  79005. dispose(): void;
  79006. }
  79007. /**
  79008. * Specialized buffer used to store vertex data
  79009. */
  79010. export class VertexBuffer {
  79011. /** @hidden */
  79012. _buffer: Buffer;
  79013. private _kind;
  79014. private _size;
  79015. private _ownsBuffer;
  79016. private _instanced;
  79017. private _instanceDivisor;
  79018. /**
  79019. * The byte type.
  79020. */
  79021. static readonly BYTE: number;
  79022. /**
  79023. * The unsigned byte type.
  79024. */
  79025. static readonly UNSIGNED_BYTE: number;
  79026. /**
  79027. * The short type.
  79028. */
  79029. static readonly SHORT: number;
  79030. /**
  79031. * The unsigned short type.
  79032. */
  79033. static readonly UNSIGNED_SHORT: number;
  79034. /**
  79035. * The integer type.
  79036. */
  79037. static readonly INT: number;
  79038. /**
  79039. * The unsigned integer type.
  79040. */
  79041. static readonly UNSIGNED_INT: number;
  79042. /**
  79043. * The float type.
  79044. */
  79045. static readonly FLOAT: number;
  79046. /**
  79047. * Gets or sets the instance divisor when in instanced mode
  79048. */
  79049. get instanceDivisor(): number;
  79050. set instanceDivisor(value: number);
  79051. /**
  79052. * Gets the byte stride.
  79053. */
  79054. readonly byteStride: number;
  79055. /**
  79056. * Gets the byte offset.
  79057. */
  79058. readonly byteOffset: number;
  79059. /**
  79060. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79061. */
  79062. readonly normalized: boolean;
  79063. /**
  79064. * Gets the data type of each component in the array.
  79065. */
  79066. readonly type: number;
  79067. /**
  79068. * Constructor
  79069. * @param engine the engine
  79070. * @param data the data to use for this vertex buffer
  79071. * @param kind the vertex buffer kind
  79072. * @param updatable whether the data is updatable
  79073. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79074. * @param stride the stride (optional)
  79075. * @param instanced whether the buffer is instanced (optional)
  79076. * @param offset the offset of the data (optional)
  79077. * @param size the number of components (optional)
  79078. * @param type the type of the component (optional)
  79079. * @param normalized whether the data contains normalized data (optional)
  79080. * @param useBytes set to true if stride and offset are in bytes (optional)
  79081. * @param divisor defines the instance divisor to use (1 by default)
  79082. */
  79083. 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);
  79084. /** @hidden */
  79085. _rebuild(): void;
  79086. /**
  79087. * Returns the kind of the VertexBuffer (string)
  79088. * @returns a string
  79089. */
  79090. getKind(): string;
  79091. /**
  79092. * Gets a boolean indicating if the VertexBuffer is updatable?
  79093. * @returns true if the buffer is updatable
  79094. */
  79095. isUpdatable(): boolean;
  79096. /**
  79097. * Gets current buffer's data
  79098. * @returns a DataArray or null
  79099. */
  79100. getData(): Nullable<DataArray>;
  79101. /**
  79102. * Gets underlying native buffer
  79103. * @returns underlying native buffer
  79104. */
  79105. getBuffer(): Nullable<DataBuffer>;
  79106. /**
  79107. * Gets the stride in float32 units (i.e. byte stride / 4).
  79108. * May not be an integer if the byte stride is not divisible by 4.
  79109. * @returns the stride in float32 units
  79110. * @deprecated Please use byteStride instead.
  79111. */
  79112. getStrideSize(): number;
  79113. /**
  79114. * Returns the offset as a multiple of the type byte length.
  79115. * @returns the offset in bytes
  79116. * @deprecated Please use byteOffset instead.
  79117. */
  79118. getOffset(): number;
  79119. /**
  79120. * Returns the number of components per vertex attribute (integer)
  79121. * @returns the size in float
  79122. */
  79123. getSize(): number;
  79124. /**
  79125. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79126. * @returns true if this buffer is instanced
  79127. */
  79128. getIsInstanced(): boolean;
  79129. /**
  79130. * Returns the instancing divisor, zero for non-instanced (integer).
  79131. * @returns a number
  79132. */
  79133. getInstanceDivisor(): number;
  79134. /**
  79135. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79136. * @param data defines the data to store
  79137. */
  79138. create(data?: DataArray): void;
  79139. /**
  79140. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79141. * This function will create a new buffer if the current one is not updatable
  79142. * @param data defines the data to store
  79143. */
  79144. update(data: DataArray): void;
  79145. /**
  79146. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79147. * Returns the directly updated WebGLBuffer.
  79148. * @param data the new data
  79149. * @param offset the new offset
  79150. * @param useBytes set to true if the offset is in bytes
  79151. */
  79152. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79153. /**
  79154. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79155. */
  79156. dispose(): void;
  79157. /**
  79158. * Enumerates each value of this vertex buffer as numbers.
  79159. * @param count the number of values to enumerate
  79160. * @param callback the callback function called for each value
  79161. */
  79162. forEach(count: number, callback: (value: number, index: number) => void): void;
  79163. /**
  79164. * Positions
  79165. */
  79166. static readonly PositionKind: string;
  79167. /**
  79168. * Normals
  79169. */
  79170. static readonly NormalKind: string;
  79171. /**
  79172. * Tangents
  79173. */
  79174. static readonly TangentKind: string;
  79175. /**
  79176. * Texture coordinates
  79177. */
  79178. static readonly UVKind: string;
  79179. /**
  79180. * Texture coordinates 2
  79181. */
  79182. static readonly UV2Kind: string;
  79183. /**
  79184. * Texture coordinates 3
  79185. */
  79186. static readonly UV3Kind: string;
  79187. /**
  79188. * Texture coordinates 4
  79189. */
  79190. static readonly UV4Kind: string;
  79191. /**
  79192. * Texture coordinates 5
  79193. */
  79194. static readonly UV5Kind: string;
  79195. /**
  79196. * Texture coordinates 6
  79197. */
  79198. static readonly UV6Kind: string;
  79199. /**
  79200. * Colors
  79201. */
  79202. static readonly ColorKind: string;
  79203. /**
  79204. * Matrix indices (for bones)
  79205. */
  79206. static readonly MatricesIndicesKind: string;
  79207. /**
  79208. * Matrix weights (for bones)
  79209. */
  79210. static readonly MatricesWeightsKind: string;
  79211. /**
  79212. * Additional matrix indices (for bones)
  79213. */
  79214. static readonly MatricesIndicesExtraKind: string;
  79215. /**
  79216. * Additional matrix weights (for bones)
  79217. */
  79218. static readonly MatricesWeightsExtraKind: string;
  79219. /**
  79220. * Deduces the stride given a kind.
  79221. * @param kind The kind string to deduce
  79222. * @returns The deduced stride
  79223. */
  79224. static DeduceStride(kind: string): number;
  79225. /**
  79226. * Gets the byte length of the given type.
  79227. * @param type the type
  79228. * @returns the number of bytes
  79229. */
  79230. static GetTypeByteLength(type: number): number;
  79231. /**
  79232. * Enumerates each value of the given parameters as numbers.
  79233. * @param data the data to enumerate
  79234. * @param byteOffset the byte offset of the data
  79235. * @param byteStride the byte stride of the data
  79236. * @param componentCount the number of components per element
  79237. * @param componentType the type of the component
  79238. * @param count the number of values to enumerate
  79239. * @param normalized whether the data is normalized
  79240. * @param callback the callback function called for each value
  79241. */
  79242. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79243. private static _GetFloatValue;
  79244. }
  79245. }
  79246. declare module BABYLON {
  79247. /**
  79248. * @hidden
  79249. */
  79250. export class IntersectionInfo {
  79251. bu: Nullable<number>;
  79252. bv: Nullable<number>;
  79253. distance: number;
  79254. faceId: number;
  79255. subMeshId: number;
  79256. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79257. }
  79258. }
  79259. declare module BABYLON {
  79260. /**
  79261. * Represens a plane by the equation ax + by + cz + d = 0
  79262. */
  79263. export class Plane {
  79264. private static _TmpMatrix;
  79265. /**
  79266. * Normal of the plane (a,b,c)
  79267. */
  79268. normal: Vector3;
  79269. /**
  79270. * d component of the plane
  79271. */
  79272. d: number;
  79273. /**
  79274. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79275. * @param a a component of the plane
  79276. * @param b b component of the plane
  79277. * @param c c component of the plane
  79278. * @param d d component of the plane
  79279. */
  79280. constructor(a: number, b: number, c: number, d: number);
  79281. /**
  79282. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79283. */
  79284. asArray(): number[];
  79285. /**
  79286. * @returns a new plane copied from the current Plane.
  79287. */
  79288. clone(): Plane;
  79289. /**
  79290. * @returns the string "Plane".
  79291. */
  79292. getClassName(): string;
  79293. /**
  79294. * @returns the Plane hash code.
  79295. */
  79296. getHashCode(): number;
  79297. /**
  79298. * Normalize the current Plane in place.
  79299. * @returns the updated Plane.
  79300. */
  79301. normalize(): Plane;
  79302. /**
  79303. * Applies a transformation the plane and returns the result
  79304. * @param transformation the transformation matrix to be applied to the plane
  79305. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79306. */
  79307. transform(transformation: DeepImmutable<Matrix>): Plane;
  79308. /**
  79309. * Calcualtte the dot product between the point and the plane normal
  79310. * @param point point to calculate the dot product with
  79311. * @returns the dot product (float) of the point coordinates and the plane normal.
  79312. */
  79313. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79314. /**
  79315. * Updates the current Plane from the plane defined by the three given points.
  79316. * @param point1 one of the points used to contruct the plane
  79317. * @param point2 one of the points used to contruct the plane
  79318. * @param point3 one of the points used to contruct the plane
  79319. * @returns the updated Plane.
  79320. */
  79321. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79322. /**
  79323. * Checks if the plane is facing a given direction
  79324. * @param direction the direction to check if the plane is facing
  79325. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79326. * @returns True is the vector "direction" is the same side than the plane normal.
  79327. */
  79328. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79329. /**
  79330. * Calculates the distance to a point
  79331. * @param point point to calculate distance to
  79332. * @returns the signed distance (float) from the given point to the Plane.
  79333. */
  79334. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79335. /**
  79336. * Creates a plane from an array
  79337. * @param array the array to create a plane from
  79338. * @returns a new Plane from the given array.
  79339. */
  79340. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79341. /**
  79342. * Creates a plane from three points
  79343. * @param point1 point used to create the plane
  79344. * @param point2 point used to create the plane
  79345. * @param point3 point used to create the plane
  79346. * @returns a new Plane defined by the three given points.
  79347. */
  79348. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79349. /**
  79350. * Creates a plane from an origin point and a normal
  79351. * @param origin origin of the plane to be constructed
  79352. * @param normal normal of the plane to be constructed
  79353. * @returns a new Plane the normal vector to this plane at the given origin point.
  79354. * Note : the vector "normal" is updated because normalized.
  79355. */
  79356. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79357. /**
  79358. * Calculates the distance from a plane and a point
  79359. * @param origin origin of the plane to be constructed
  79360. * @param normal normal of the plane to be constructed
  79361. * @param point point to calculate distance to
  79362. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79363. */
  79364. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79365. }
  79366. }
  79367. declare module BABYLON {
  79368. /**
  79369. * Class used to store bounding sphere information
  79370. */
  79371. export class BoundingSphere {
  79372. /**
  79373. * Gets the center of the bounding sphere in local space
  79374. */
  79375. readonly center: Vector3;
  79376. /**
  79377. * Radius of the bounding sphere in local space
  79378. */
  79379. radius: number;
  79380. /**
  79381. * Gets the center of the bounding sphere in world space
  79382. */
  79383. readonly centerWorld: Vector3;
  79384. /**
  79385. * Radius of the bounding sphere in world space
  79386. */
  79387. radiusWorld: number;
  79388. /**
  79389. * Gets the minimum vector in local space
  79390. */
  79391. readonly minimum: Vector3;
  79392. /**
  79393. * Gets the maximum vector in local space
  79394. */
  79395. readonly maximum: Vector3;
  79396. private _worldMatrix;
  79397. private static readonly TmpVector3;
  79398. /**
  79399. * Creates a new bounding sphere
  79400. * @param min defines the minimum vector (in local space)
  79401. * @param max defines the maximum vector (in local space)
  79402. * @param worldMatrix defines the new world matrix
  79403. */
  79404. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79405. /**
  79406. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79407. * @param min defines the new minimum vector (in local space)
  79408. * @param max defines the new maximum vector (in local space)
  79409. * @param worldMatrix defines the new world matrix
  79410. */
  79411. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79412. /**
  79413. * Scale the current bounding sphere by applying a scale factor
  79414. * @param factor defines the scale factor to apply
  79415. * @returns the current bounding box
  79416. */
  79417. scale(factor: number): BoundingSphere;
  79418. /**
  79419. * Gets the world matrix of the bounding box
  79420. * @returns a matrix
  79421. */
  79422. getWorldMatrix(): DeepImmutable<Matrix>;
  79423. /** @hidden */
  79424. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79425. /**
  79426. * Tests if the bounding sphere is intersecting the frustum planes
  79427. * @param frustumPlanes defines the frustum planes to test
  79428. * @returns true if there is an intersection
  79429. */
  79430. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79431. /**
  79432. * Tests if the bounding sphere center is in between the frustum planes.
  79433. * Used for optimistic fast inclusion.
  79434. * @param frustumPlanes defines the frustum planes to test
  79435. * @returns true if the sphere center is in between the frustum planes
  79436. */
  79437. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79438. /**
  79439. * Tests if a point is inside the bounding sphere
  79440. * @param point defines the point to test
  79441. * @returns true if the point is inside the bounding sphere
  79442. */
  79443. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79444. /**
  79445. * Checks if two sphere intersct
  79446. * @param sphere0 sphere 0
  79447. * @param sphere1 sphere 1
  79448. * @returns true if the speres intersect
  79449. */
  79450. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  79451. }
  79452. }
  79453. declare module BABYLON {
  79454. /**
  79455. * Class used to store bounding box information
  79456. */
  79457. export class BoundingBox implements ICullable {
  79458. /**
  79459. * Gets the 8 vectors representing the bounding box in local space
  79460. */
  79461. readonly vectors: Vector3[];
  79462. /**
  79463. * Gets the center of the bounding box in local space
  79464. */
  79465. readonly center: Vector3;
  79466. /**
  79467. * Gets the center of the bounding box in world space
  79468. */
  79469. readonly centerWorld: Vector3;
  79470. /**
  79471. * Gets the extend size in local space
  79472. */
  79473. readonly extendSize: Vector3;
  79474. /**
  79475. * Gets the extend size in world space
  79476. */
  79477. readonly extendSizeWorld: Vector3;
  79478. /**
  79479. * Gets the OBB (object bounding box) directions
  79480. */
  79481. readonly directions: Vector3[];
  79482. /**
  79483. * Gets the 8 vectors representing the bounding box in world space
  79484. */
  79485. readonly vectorsWorld: Vector3[];
  79486. /**
  79487. * Gets the minimum vector in world space
  79488. */
  79489. readonly minimumWorld: Vector3;
  79490. /**
  79491. * Gets the maximum vector in world space
  79492. */
  79493. readonly maximumWorld: Vector3;
  79494. /**
  79495. * Gets the minimum vector in local space
  79496. */
  79497. readonly minimum: Vector3;
  79498. /**
  79499. * Gets the maximum vector in local space
  79500. */
  79501. readonly maximum: Vector3;
  79502. private _worldMatrix;
  79503. private static readonly TmpVector3;
  79504. /**
  79505. * @hidden
  79506. */
  79507. _tag: number;
  79508. /**
  79509. * Creates a new bounding box
  79510. * @param min defines the minimum vector (in local space)
  79511. * @param max defines the maximum vector (in local space)
  79512. * @param worldMatrix defines the new world matrix
  79513. */
  79514. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79515. /**
  79516. * Recreates the entire bounding box from scratch as if we call the constructor in place
  79517. * @param min defines the new minimum vector (in local space)
  79518. * @param max defines the new maximum vector (in local space)
  79519. * @param worldMatrix defines the new world matrix
  79520. */
  79521. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79522. /**
  79523. * Scale the current bounding box by applying a scale factor
  79524. * @param factor defines the scale factor to apply
  79525. * @returns the current bounding box
  79526. */
  79527. scale(factor: number): BoundingBox;
  79528. /**
  79529. * Gets the world matrix of the bounding box
  79530. * @returns a matrix
  79531. */
  79532. getWorldMatrix(): DeepImmutable<Matrix>;
  79533. /** @hidden */
  79534. _update(world: DeepImmutable<Matrix>): void;
  79535. /**
  79536. * Tests if the bounding box is intersecting the frustum planes
  79537. * @param frustumPlanes defines the frustum planes to test
  79538. * @returns true if there is an intersection
  79539. */
  79540. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79541. /**
  79542. * Tests if the bounding box is entirely inside the frustum planes
  79543. * @param frustumPlanes defines the frustum planes to test
  79544. * @returns true if there is an inclusion
  79545. */
  79546. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79547. /**
  79548. * Tests if a point is inside the bounding box
  79549. * @param point defines the point to test
  79550. * @returns true if the point is inside the bounding box
  79551. */
  79552. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79553. /**
  79554. * Tests if the bounding box intersects with a bounding sphere
  79555. * @param sphere defines the sphere to test
  79556. * @returns true if there is an intersection
  79557. */
  79558. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  79559. /**
  79560. * Tests if the bounding box intersects with a box defined by a min and max vectors
  79561. * @param min defines the min vector to use
  79562. * @param max defines the max vector to use
  79563. * @returns true if there is an intersection
  79564. */
  79565. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  79566. /**
  79567. * Tests if two bounding boxes are intersections
  79568. * @param box0 defines the first box to test
  79569. * @param box1 defines the second box to test
  79570. * @returns true if there is an intersection
  79571. */
  79572. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  79573. /**
  79574. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  79575. * @param minPoint defines the minimum vector of the bounding box
  79576. * @param maxPoint defines the maximum vector of the bounding box
  79577. * @param sphereCenter defines the sphere center
  79578. * @param sphereRadius defines the sphere radius
  79579. * @returns true if there is an intersection
  79580. */
  79581. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  79582. /**
  79583. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  79584. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79585. * @param frustumPlanes defines the frustum planes to test
  79586. * @return true if there is an inclusion
  79587. */
  79588. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79589. /**
  79590. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  79591. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79592. * @param frustumPlanes defines the frustum planes to test
  79593. * @return true if there is an intersection
  79594. */
  79595. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79596. }
  79597. }
  79598. declare module BABYLON {
  79599. /** @hidden */
  79600. export class Collider {
  79601. /** Define if a collision was found */
  79602. collisionFound: boolean;
  79603. /**
  79604. * Define last intersection point in local space
  79605. */
  79606. intersectionPoint: Vector3;
  79607. /**
  79608. * Define last collided mesh
  79609. */
  79610. collidedMesh: Nullable<AbstractMesh>;
  79611. private _collisionPoint;
  79612. private _planeIntersectionPoint;
  79613. private _tempVector;
  79614. private _tempVector2;
  79615. private _tempVector3;
  79616. private _tempVector4;
  79617. private _edge;
  79618. private _baseToVertex;
  79619. private _destinationPoint;
  79620. private _slidePlaneNormal;
  79621. private _displacementVector;
  79622. /** @hidden */
  79623. _radius: Vector3;
  79624. /** @hidden */
  79625. _retry: number;
  79626. private _velocity;
  79627. private _basePoint;
  79628. private _epsilon;
  79629. /** @hidden */
  79630. _velocityWorldLength: number;
  79631. /** @hidden */
  79632. _basePointWorld: Vector3;
  79633. private _velocityWorld;
  79634. private _normalizedVelocity;
  79635. /** @hidden */
  79636. _initialVelocity: Vector3;
  79637. /** @hidden */
  79638. _initialPosition: Vector3;
  79639. private _nearestDistance;
  79640. private _collisionMask;
  79641. get collisionMask(): number;
  79642. set collisionMask(mask: number);
  79643. /**
  79644. * Gets the plane normal used to compute the sliding response (in local space)
  79645. */
  79646. get slidePlaneNormal(): Vector3;
  79647. /** @hidden */
  79648. _initialize(source: Vector3, dir: Vector3, e: number): void;
  79649. /** @hidden */
  79650. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  79651. /** @hidden */
  79652. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  79653. /** @hidden */
  79654. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79655. /** @hidden */
  79656. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79657. /** @hidden */
  79658. _getResponse(pos: Vector3, vel: Vector3): void;
  79659. }
  79660. }
  79661. declare module BABYLON {
  79662. /**
  79663. * Interface for cullable objects
  79664. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  79665. */
  79666. export interface ICullable {
  79667. /**
  79668. * Checks if the object or part of the object is in the frustum
  79669. * @param frustumPlanes Camera near/planes
  79670. * @returns true if the object is in frustum otherwise false
  79671. */
  79672. isInFrustum(frustumPlanes: Plane[]): boolean;
  79673. /**
  79674. * Checks if a cullable object (mesh...) is in the camera frustum
  79675. * Unlike isInFrustum this cheks the full bounding box
  79676. * @param frustumPlanes Camera near/planes
  79677. * @returns true if the object is in frustum otherwise false
  79678. */
  79679. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79680. }
  79681. /**
  79682. * Info for a bounding data of a mesh
  79683. */
  79684. export class BoundingInfo implements ICullable {
  79685. /**
  79686. * Bounding box for the mesh
  79687. */
  79688. readonly boundingBox: BoundingBox;
  79689. /**
  79690. * Bounding sphere for the mesh
  79691. */
  79692. readonly boundingSphere: BoundingSphere;
  79693. private _isLocked;
  79694. private static readonly TmpVector3;
  79695. /**
  79696. * Constructs bounding info
  79697. * @param minimum min vector of the bounding box/sphere
  79698. * @param maximum max vector of the bounding box/sphere
  79699. * @param worldMatrix defines the new world matrix
  79700. */
  79701. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79702. /**
  79703. * Recreates the entire bounding info from scratch as if we call the constructor in place
  79704. * @param min defines the new minimum vector (in local space)
  79705. * @param max defines the new maximum vector (in local space)
  79706. * @param worldMatrix defines the new world matrix
  79707. */
  79708. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79709. /**
  79710. * min vector of the bounding box/sphere
  79711. */
  79712. get minimum(): Vector3;
  79713. /**
  79714. * max vector of the bounding box/sphere
  79715. */
  79716. get maximum(): Vector3;
  79717. /**
  79718. * If the info is locked and won't be updated to avoid perf overhead
  79719. */
  79720. get isLocked(): boolean;
  79721. set isLocked(value: boolean);
  79722. /**
  79723. * Updates the bounding sphere and box
  79724. * @param world world matrix to be used to update
  79725. */
  79726. update(world: DeepImmutable<Matrix>): void;
  79727. /**
  79728. * Recreate the bounding info to be centered around a specific point given a specific extend.
  79729. * @param center New center of the bounding info
  79730. * @param extend New extend of the bounding info
  79731. * @returns the current bounding info
  79732. */
  79733. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  79734. /**
  79735. * Scale the current bounding info by applying a scale factor
  79736. * @param factor defines the scale factor to apply
  79737. * @returns the current bounding info
  79738. */
  79739. scale(factor: number): BoundingInfo;
  79740. /**
  79741. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  79742. * @param frustumPlanes defines the frustum to test
  79743. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  79744. * @returns true if the bounding info is in the frustum planes
  79745. */
  79746. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  79747. /**
  79748. * Gets the world distance between the min and max points of the bounding box
  79749. */
  79750. get diagonalLength(): number;
  79751. /**
  79752. * Checks if a cullable object (mesh...) is in the camera frustum
  79753. * Unlike isInFrustum this cheks the full bounding box
  79754. * @param frustumPlanes Camera near/planes
  79755. * @returns true if the object is in frustum otherwise false
  79756. */
  79757. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79758. /** @hidden */
  79759. _checkCollision(collider: Collider): boolean;
  79760. /**
  79761. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  79762. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79763. * @param point the point to check intersection with
  79764. * @returns if the point intersects
  79765. */
  79766. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79767. /**
  79768. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  79769. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79770. * @param boundingInfo the bounding info to check intersection with
  79771. * @param precise if the intersection should be done using OBB
  79772. * @returns if the bounding info intersects
  79773. */
  79774. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  79775. }
  79776. }
  79777. declare module BABYLON {
  79778. /**
  79779. * Extracts minimum and maximum values from a list of indexed positions
  79780. * @param positions defines the positions to use
  79781. * @param indices defines the indices to the positions
  79782. * @param indexStart defines the start index
  79783. * @param indexCount defines the end index
  79784. * @param bias defines bias value to add to the result
  79785. * @return minimum and maximum values
  79786. */
  79787. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  79788. minimum: Vector3;
  79789. maximum: Vector3;
  79790. };
  79791. /**
  79792. * Extracts minimum and maximum values from a list of positions
  79793. * @param positions defines the positions to use
  79794. * @param start defines the start index in the positions array
  79795. * @param count defines the number of positions to handle
  79796. * @param bias defines bias value to add to the result
  79797. * @param stride defines the stride size to use (distance between two positions in the positions array)
  79798. * @return minimum and maximum values
  79799. */
  79800. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  79801. minimum: Vector3;
  79802. maximum: Vector3;
  79803. };
  79804. }
  79805. declare module BABYLON {
  79806. /** @hidden */
  79807. export class WebGLDataBuffer extends DataBuffer {
  79808. private _buffer;
  79809. constructor(resource: WebGLBuffer);
  79810. get underlyingResource(): any;
  79811. }
  79812. }
  79813. declare module BABYLON {
  79814. /** @hidden */
  79815. export class WebGLPipelineContext implements IPipelineContext {
  79816. engine: ThinEngine;
  79817. program: Nullable<WebGLProgram>;
  79818. context?: WebGLRenderingContext;
  79819. vertexShader?: WebGLShader;
  79820. fragmentShader?: WebGLShader;
  79821. isParallelCompiled: boolean;
  79822. onCompiled?: () => void;
  79823. transformFeedback?: WebGLTransformFeedback | null;
  79824. vertexCompilationError: Nullable<string>;
  79825. fragmentCompilationError: Nullable<string>;
  79826. programLinkError: Nullable<string>;
  79827. programValidationError: Nullable<string>;
  79828. get isAsync(): boolean;
  79829. get isReady(): boolean;
  79830. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  79831. }
  79832. }
  79833. declare module BABYLON {
  79834. interface ThinEngine {
  79835. /**
  79836. * Create an uniform buffer
  79837. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79838. * @param elements defines the content of the uniform buffer
  79839. * @returns the webGL uniform buffer
  79840. */
  79841. createUniformBuffer(elements: FloatArray): DataBuffer;
  79842. /**
  79843. * Create a dynamic uniform buffer
  79844. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79845. * @param elements defines the content of the uniform buffer
  79846. * @returns the webGL uniform buffer
  79847. */
  79848. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  79849. /**
  79850. * Update an existing uniform buffer
  79851. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79852. * @param uniformBuffer defines the target uniform buffer
  79853. * @param elements defines the content to update
  79854. * @param offset defines the offset in the uniform buffer where update should start
  79855. * @param count defines the size of the data to update
  79856. */
  79857. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  79858. /**
  79859. * Bind an uniform buffer to the current webGL context
  79860. * @param buffer defines the buffer to bind
  79861. */
  79862. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  79863. /**
  79864. * Bind a buffer to the current webGL context at a given location
  79865. * @param buffer defines the buffer to bind
  79866. * @param location defines the index where to bind the buffer
  79867. */
  79868. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  79869. /**
  79870. * Bind a specific block at a given index in a specific shader program
  79871. * @param pipelineContext defines the pipeline context to use
  79872. * @param blockName defines the block name
  79873. * @param index defines the index where to bind the block
  79874. */
  79875. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  79876. }
  79877. }
  79878. declare module BABYLON {
  79879. /**
  79880. * Uniform buffer objects.
  79881. *
  79882. * Handles blocks of uniform on the GPU.
  79883. *
  79884. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79885. *
  79886. * For more information, please refer to :
  79887. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79888. */
  79889. export class UniformBuffer {
  79890. private _engine;
  79891. private _buffer;
  79892. private _data;
  79893. private _bufferData;
  79894. private _dynamic?;
  79895. private _uniformLocations;
  79896. private _uniformSizes;
  79897. private _uniformLocationPointer;
  79898. private _needSync;
  79899. private _noUBO;
  79900. private _currentEffect;
  79901. /** @hidden */
  79902. _alreadyBound: boolean;
  79903. private static _MAX_UNIFORM_SIZE;
  79904. private static _tempBuffer;
  79905. /**
  79906. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  79907. * This is dynamic to allow compat with webgl 1 and 2.
  79908. * You will need to pass the name of the uniform as well as the value.
  79909. */
  79910. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  79911. /**
  79912. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  79913. * This is dynamic to allow compat with webgl 1 and 2.
  79914. * You will need to pass the name of the uniform as well as the value.
  79915. */
  79916. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  79917. /**
  79918. * Lambda to Update a single float in a uniform buffer.
  79919. * This is dynamic to allow compat with webgl 1 and 2.
  79920. * You will need to pass the name of the uniform as well as the value.
  79921. */
  79922. updateFloat: (name: string, x: number) => void;
  79923. /**
  79924. * Lambda to Update a vec2 of float in a uniform buffer.
  79925. * This is dynamic to allow compat with webgl 1 and 2.
  79926. * You will need to pass the name of the uniform as well as the value.
  79927. */
  79928. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  79929. /**
  79930. * Lambda to Update a vec3 of float in a uniform buffer.
  79931. * This is dynamic to allow compat with webgl 1 and 2.
  79932. * You will need to pass the name of the uniform as well as the value.
  79933. */
  79934. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  79935. /**
  79936. * Lambda to Update a vec4 of float in a uniform buffer.
  79937. * This is dynamic to allow compat with webgl 1 and 2.
  79938. * You will need to pass the name of the uniform as well as the value.
  79939. */
  79940. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  79941. /**
  79942. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  79943. * This is dynamic to allow compat with webgl 1 and 2.
  79944. * You will need to pass the name of the uniform as well as the value.
  79945. */
  79946. updateMatrix: (name: string, mat: Matrix) => void;
  79947. /**
  79948. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  79949. * This is dynamic to allow compat with webgl 1 and 2.
  79950. * You will need to pass the name of the uniform as well as the value.
  79951. */
  79952. updateVector3: (name: string, vector: Vector3) => void;
  79953. /**
  79954. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  79955. * This is dynamic to allow compat with webgl 1 and 2.
  79956. * You will need to pass the name of the uniform as well as the value.
  79957. */
  79958. updateVector4: (name: string, vector: Vector4) => void;
  79959. /**
  79960. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  79961. * This is dynamic to allow compat with webgl 1 and 2.
  79962. * You will need to pass the name of the uniform as well as the value.
  79963. */
  79964. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  79965. /**
  79966. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  79967. * This is dynamic to allow compat with webgl 1 and 2.
  79968. * You will need to pass the name of the uniform as well as the value.
  79969. */
  79970. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  79971. /**
  79972. * Instantiates a new Uniform buffer objects.
  79973. *
  79974. * Handles blocks of uniform on the GPU.
  79975. *
  79976. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79977. *
  79978. * For more information, please refer to :
  79979. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79980. * @param engine Define the engine the buffer is associated with
  79981. * @param data Define the data contained in the buffer
  79982. * @param dynamic Define if the buffer is updatable
  79983. */
  79984. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  79985. /**
  79986. * Indicates if the buffer is using the WebGL2 UBO implementation,
  79987. * or just falling back on setUniformXXX calls.
  79988. */
  79989. get useUbo(): boolean;
  79990. /**
  79991. * Indicates if the WebGL underlying uniform buffer is in sync
  79992. * with the javascript cache data.
  79993. */
  79994. get isSync(): boolean;
  79995. /**
  79996. * Indicates if the WebGL underlying uniform buffer is dynamic.
  79997. * Also, a dynamic UniformBuffer will disable cache verification and always
  79998. * update the underlying WebGL uniform buffer to the GPU.
  79999. * @returns if Dynamic, otherwise false
  80000. */
  80001. isDynamic(): boolean;
  80002. /**
  80003. * The data cache on JS side.
  80004. * @returns the underlying data as a float array
  80005. */
  80006. getData(): Float32Array;
  80007. /**
  80008. * The underlying WebGL Uniform buffer.
  80009. * @returns the webgl buffer
  80010. */
  80011. getBuffer(): Nullable<DataBuffer>;
  80012. /**
  80013. * std140 layout specifies how to align data within an UBO structure.
  80014. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80015. * for specs.
  80016. */
  80017. private _fillAlignment;
  80018. /**
  80019. * Adds an uniform in the buffer.
  80020. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80021. * for the layout to be correct !
  80022. * @param name Name of the uniform, as used in the uniform block in the shader.
  80023. * @param size Data size, or data directly.
  80024. */
  80025. addUniform(name: string, size: number | number[]): void;
  80026. /**
  80027. * Adds a Matrix 4x4 to the uniform buffer.
  80028. * @param name Name of the uniform, as used in the uniform block in the shader.
  80029. * @param mat A 4x4 matrix.
  80030. */
  80031. addMatrix(name: string, mat: Matrix): void;
  80032. /**
  80033. * Adds a vec2 to the uniform buffer.
  80034. * @param name Name of the uniform, as used in the uniform block in the shader.
  80035. * @param x Define the x component value of the vec2
  80036. * @param y Define the y component value of the vec2
  80037. */
  80038. addFloat2(name: string, x: number, y: number): void;
  80039. /**
  80040. * Adds a vec3 to the uniform buffer.
  80041. * @param name Name of the uniform, as used in the uniform block in the shader.
  80042. * @param x Define the x component value of the vec3
  80043. * @param y Define the y component value of the vec3
  80044. * @param z Define the z component value of the vec3
  80045. */
  80046. addFloat3(name: string, x: number, y: number, z: number): void;
  80047. /**
  80048. * Adds a vec3 to the uniform buffer.
  80049. * @param name Name of the uniform, as used in the uniform block in the shader.
  80050. * @param color Define the vec3 from a Color
  80051. */
  80052. addColor3(name: string, color: Color3): void;
  80053. /**
  80054. * Adds a vec4 to the uniform buffer.
  80055. * @param name Name of the uniform, as used in the uniform block in the shader.
  80056. * @param color Define the rgb components from a Color
  80057. * @param alpha Define the a component of the vec4
  80058. */
  80059. addColor4(name: string, color: Color3, alpha: number): void;
  80060. /**
  80061. * Adds a vec3 to the uniform buffer.
  80062. * @param name Name of the uniform, as used in the uniform block in the shader.
  80063. * @param vector Define the vec3 components from a Vector
  80064. */
  80065. addVector3(name: string, vector: Vector3): void;
  80066. /**
  80067. * Adds a Matrix 3x3 to the uniform buffer.
  80068. * @param name Name of the uniform, as used in the uniform block in the shader.
  80069. */
  80070. addMatrix3x3(name: string): void;
  80071. /**
  80072. * Adds a Matrix 2x2 to the uniform buffer.
  80073. * @param name Name of the uniform, as used in the uniform block in the shader.
  80074. */
  80075. addMatrix2x2(name: string): void;
  80076. /**
  80077. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80078. */
  80079. create(): void;
  80080. /** @hidden */
  80081. _rebuild(): void;
  80082. /**
  80083. * Updates the WebGL Uniform Buffer on the GPU.
  80084. * If the `dynamic` flag is set to true, no cache comparison is done.
  80085. * Otherwise, the buffer will be updated only if the cache differs.
  80086. */
  80087. update(): void;
  80088. /**
  80089. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80090. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80091. * @param data Define the flattened data
  80092. * @param size Define the size of the data.
  80093. */
  80094. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80095. private _valueCache;
  80096. private _cacheMatrix;
  80097. private _updateMatrix3x3ForUniform;
  80098. private _updateMatrix3x3ForEffect;
  80099. private _updateMatrix2x2ForEffect;
  80100. private _updateMatrix2x2ForUniform;
  80101. private _updateFloatForEffect;
  80102. private _updateFloatForUniform;
  80103. private _updateFloat2ForEffect;
  80104. private _updateFloat2ForUniform;
  80105. private _updateFloat3ForEffect;
  80106. private _updateFloat3ForUniform;
  80107. private _updateFloat4ForEffect;
  80108. private _updateFloat4ForUniform;
  80109. private _updateMatrixForEffect;
  80110. private _updateMatrixForUniform;
  80111. private _updateVector3ForEffect;
  80112. private _updateVector3ForUniform;
  80113. private _updateVector4ForEffect;
  80114. private _updateVector4ForUniform;
  80115. private _updateColor3ForEffect;
  80116. private _updateColor3ForUniform;
  80117. private _updateColor4ForEffect;
  80118. private _updateColor4ForUniform;
  80119. /**
  80120. * Sets a sampler uniform on the effect.
  80121. * @param name Define the name of the sampler.
  80122. * @param texture Define the texture to set in the sampler
  80123. */
  80124. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80125. /**
  80126. * Directly updates the value of the uniform in the cache AND on the GPU.
  80127. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80128. * @param data Define the flattened data
  80129. */
  80130. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80131. /**
  80132. * Binds this uniform buffer to an effect.
  80133. * @param effect Define the effect to bind the buffer to
  80134. * @param name Name of the uniform block in the shader.
  80135. */
  80136. bindToEffect(effect: Effect, name: string): void;
  80137. /**
  80138. * Disposes the uniform buffer.
  80139. */
  80140. dispose(): void;
  80141. }
  80142. }
  80143. declare module BABYLON {
  80144. /**
  80145. * Enum that determines the text-wrapping mode to use.
  80146. */
  80147. export enum InspectableType {
  80148. /**
  80149. * Checkbox for booleans
  80150. */
  80151. Checkbox = 0,
  80152. /**
  80153. * Sliders for numbers
  80154. */
  80155. Slider = 1,
  80156. /**
  80157. * Vector3
  80158. */
  80159. Vector3 = 2,
  80160. /**
  80161. * Quaternions
  80162. */
  80163. Quaternion = 3,
  80164. /**
  80165. * Color3
  80166. */
  80167. Color3 = 4,
  80168. /**
  80169. * String
  80170. */
  80171. String = 5
  80172. }
  80173. /**
  80174. * Interface used to define custom inspectable properties.
  80175. * This interface is used by the inspector to display custom property grids
  80176. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80177. */
  80178. export interface IInspectable {
  80179. /**
  80180. * Gets the label to display
  80181. */
  80182. label: string;
  80183. /**
  80184. * Gets the name of the property to edit
  80185. */
  80186. propertyName: string;
  80187. /**
  80188. * Gets the type of the editor to use
  80189. */
  80190. type: InspectableType;
  80191. /**
  80192. * Gets the minimum value of the property when using in "slider" mode
  80193. */
  80194. min?: number;
  80195. /**
  80196. * Gets the maximum value of the property when using in "slider" mode
  80197. */
  80198. max?: number;
  80199. /**
  80200. * Gets the setp to use when using in "slider" mode
  80201. */
  80202. step?: number;
  80203. }
  80204. }
  80205. declare module BABYLON {
  80206. /**
  80207. * Class used to provide helper for timing
  80208. */
  80209. export class TimingTools {
  80210. /**
  80211. * Polyfill for setImmediate
  80212. * @param action defines the action to execute after the current execution block
  80213. */
  80214. static SetImmediate(action: () => void): void;
  80215. }
  80216. }
  80217. declare module BABYLON {
  80218. /**
  80219. * Class used to enable instatition of objects by class name
  80220. */
  80221. export class InstantiationTools {
  80222. /**
  80223. * Use this object to register external classes like custom textures or material
  80224. * to allow the laoders to instantiate them
  80225. */
  80226. static RegisteredExternalClasses: {
  80227. [key: string]: Object;
  80228. };
  80229. /**
  80230. * Tries to instantiate a new object from a given class name
  80231. * @param className defines the class name to instantiate
  80232. * @returns the new object or null if the system was not able to do the instantiation
  80233. */
  80234. static Instantiate(className: string): any;
  80235. }
  80236. }
  80237. declare module BABYLON {
  80238. /**
  80239. * Define options used to create a depth texture
  80240. */
  80241. export class DepthTextureCreationOptions {
  80242. /** Specifies whether or not a stencil should be allocated in the texture */
  80243. generateStencil?: boolean;
  80244. /** Specifies whether or not bilinear filtering is enable on the texture */
  80245. bilinearFiltering?: boolean;
  80246. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80247. comparisonFunction?: number;
  80248. /** Specifies if the created texture is a cube texture */
  80249. isCube?: boolean;
  80250. }
  80251. }
  80252. declare module BABYLON {
  80253. interface ThinEngine {
  80254. /**
  80255. * Creates a depth stencil cube texture.
  80256. * This is only available in WebGL 2.
  80257. * @param size The size of face edge in the cube texture.
  80258. * @param options The options defining the cube texture.
  80259. * @returns The cube texture
  80260. */
  80261. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80262. /**
  80263. * Creates a cube texture
  80264. * @param rootUrl defines the url where the files to load is located
  80265. * @param scene defines the current scene
  80266. * @param files defines the list of files to load (1 per face)
  80267. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80268. * @param onLoad defines an optional callback raised when the texture is loaded
  80269. * @param onError defines an optional callback raised if there is an issue to load the texture
  80270. * @param format defines the format of the data
  80271. * @param forcedExtension defines the extension to use to pick the right loader
  80272. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80273. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80274. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80275. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80276. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80277. * @returns the cube texture as an InternalTexture
  80278. */
  80279. 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;
  80280. /**
  80281. * Creates a cube texture
  80282. * @param rootUrl defines the url where the files to load is located
  80283. * @param scene defines the current scene
  80284. * @param files defines the list of files to load (1 per face)
  80285. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80286. * @param onLoad defines an optional callback raised when the texture is loaded
  80287. * @param onError defines an optional callback raised if there is an issue to load the texture
  80288. * @param format defines the format of the data
  80289. * @param forcedExtension defines the extension to use to pick the right loader
  80290. * @returns the cube texture as an InternalTexture
  80291. */
  80292. 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;
  80293. /**
  80294. * Creates a cube texture
  80295. * @param rootUrl defines the url where the files to load is located
  80296. * @param scene defines the current scene
  80297. * @param files defines the list of files to load (1 per face)
  80298. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80299. * @param onLoad defines an optional callback raised when the texture is loaded
  80300. * @param onError defines an optional callback raised if there is an issue to load the texture
  80301. * @param format defines the format of the data
  80302. * @param forcedExtension defines the extension to use to pick the right loader
  80303. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80304. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80305. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80306. * @returns the cube texture as an InternalTexture
  80307. */
  80308. 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;
  80309. /** @hidden */
  80310. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80311. /** @hidden */
  80312. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80313. /** @hidden */
  80314. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80315. /** @hidden */
  80316. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80317. /**
  80318. * @hidden
  80319. */
  80320. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80321. }
  80322. }
  80323. declare module BABYLON {
  80324. /**
  80325. * Class for creating a cube texture
  80326. */
  80327. export class CubeTexture extends BaseTexture {
  80328. private _delayedOnLoad;
  80329. /**
  80330. * The url of the texture
  80331. */
  80332. url: string;
  80333. /**
  80334. * Gets or sets the center of the bounding box associated with the cube texture.
  80335. * It must define where the camera used to render the texture was set
  80336. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80337. */
  80338. boundingBoxPosition: Vector3;
  80339. private _boundingBoxSize;
  80340. /**
  80341. * Gets or sets the size of the bounding box associated with the cube texture
  80342. * When defined, the cubemap will switch to local mode
  80343. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80344. * @example https://www.babylonjs-playground.com/#RNASML
  80345. */
  80346. set boundingBoxSize(value: Vector3);
  80347. /**
  80348. * Returns the bounding box size
  80349. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80350. */
  80351. get boundingBoxSize(): Vector3;
  80352. protected _rotationY: number;
  80353. /**
  80354. * Sets texture matrix rotation angle around Y axis in radians.
  80355. */
  80356. set rotationY(value: number);
  80357. /**
  80358. * Gets texture matrix rotation angle around Y axis radians.
  80359. */
  80360. get rotationY(): number;
  80361. /**
  80362. * Are mip maps generated for this texture or not.
  80363. */
  80364. get noMipmap(): boolean;
  80365. private _noMipmap;
  80366. private _files;
  80367. protected _forcedExtension: Nullable<string>;
  80368. private _extensions;
  80369. private _textureMatrix;
  80370. private _format;
  80371. private _createPolynomials;
  80372. /** @hidden */
  80373. _prefiltered: boolean;
  80374. /**
  80375. * Creates a cube texture from an array of image urls
  80376. * @param files defines an array of image urls
  80377. * @param scene defines the hosting scene
  80378. * @param noMipmap specifies if mip maps are not used
  80379. * @returns a cube texture
  80380. */
  80381. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80382. /**
  80383. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80384. * @param url defines the url of the prefiltered texture
  80385. * @param scene defines the scene the texture is attached to
  80386. * @param forcedExtension defines the extension of the file if different from the url
  80387. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80388. * @return the prefiltered texture
  80389. */
  80390. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80391. /**
  80392. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80393. * as prefiltered data.
  80394. * @param rootUrl defines the url of the texture or the root name of the six images
  80395. * @param scene defines the scene the texture is attached to
  80396. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80397. * @param noMipmap defines if mipmaps should be created or not
  80398. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80399. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80400. * @param onError defines a callback triggered in case of error during load
  80401. * @param format defines the internal format to use for the texture once loaded
  80402. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80403. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80404. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80405. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80406. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80407. * @return the cube texture
  80408. */
  80409. 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);
  80410. /**
  80411. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80412. */
  80413. get isPrefiltered(): boolean;
  80414. /**
  80415. * Get the current class name of the texture useful for serialization or dynamic coding.
  80416. * @returns "CubeTexture"
  80417. */
  80418. getClassName(): string;
  80419. /**
  80420. * Update the url (and optional buffer) of this texture if url was null during construction.
  80421. * @param url the url of the texture
  80422. * @param forcedExtension defines the extension to use
  80423. * @param onLoad callback called when the texture is loaded (defaults to null)
  80424. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80425. */
  80426. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80427. /**
  80428. * Delays loading of the cube texture
  80429. * @param forcedExtension defines the extension to use
  80430. */
  80431. delayLoad(forcedExtension?: string): void;
  80432. /**
  80433. * Returns the reflection texture matrix
  80434. * @returns the reflection texture matrix
  80435. */
  80436. getReflectionTextureMatrix(): Matrix;
  80437. /**
  80438. * Sets the reflection texture matrix
  80439. * @param value Reflection texture matrix
  80440. */
  80441. setReflectionTextureMatrix(value: Matrix): void;
  80442. /**
  80443. * Parses text to create a cube texture
  80444. * @param parsedTexture define the serialized text to read from
  80445. * @param scene defines the hosting scene
  80446. * @param rootUrl defines the root url of the cube texture
  80447. * @returns a cube texture
  80448. */
  80449. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  80450. /**
  80451. * Makes a clone, or deep copy, of the cube texture
  80452. * @returns a new cube texture
  80453. */
  80454. clone(): CubeTexture;
  80455. }
  80456. }
  80457. declare module BABYLON {
  80458. /**
  80459. * Manages the defines for the Material
  80460. */
  80461. export class MaterialDefines {
  80462. /** @hidden */
  80463. protected _keys: string[];
  80464. private _isDirty;
  80465. /** @hidden */
  80466. _renderId: number;
  80467. /** @hidden */
  80468. _areLightsDirty: boolean;
  80469. /** @hidden */
  80470. _areLightsDisposed: boolean;
  80471. /** @hidden */
  80472. _areAttributesDirty: boolean;
  80473. /** @hidden */
  80474. _areTexturesDirty: boolean;
  80475. /** @hidden */
  80476. _areFresnelDirty: boolean;
  80477. /** @hidden */
  80478. _areMiscDirty: boolean;
  80479. /** @hidden */
  80480. _areImageProcessingDirty: boolean;
  80481. /** @hidden */
  80482. _normals: boolean;
  80483. /** @hidden */
  80484. _uvs: boolean;
  80485. /** @hidden */
  80486. _needNormals: boolean;
  80487. /** @hidden */
  80488. _needUVs: boolean;
  80489. [id: string]: any;
  80490. /**
  80491. * Specifies if the material needs to be re-calculated
  80492. */
  80493. get isDirty(): boolean;
  80494. /**
  80495. * Marks the material to indicate that it has been re-calculated
  80496. */
  80497. markAsProcessed(): void;
  80498. /**
  80499. * Marks the material to indicate that it needs to be re-calculated
  80500. */
  80501. markAsUnprocessed(): void;
  80502. /**
  80503. * Marks the material to indicate all of its defines need to be re-calculated
  80504. */
  80505. markAllAsDirty(): void;
  80506. /**
  80507. * Marks the material to indicate that image processing needs to be re-calculated
  80508. */
  80509. markAsImageProcessingDirty(): void;
  80510. /**
  80511. * Marks the material to indicate the lights need to be re-calculated
  80512. * @param disposed Defines whether the light is dirty due to dispose or not
  80513. */
  80514. markAsLightDirty(disposed?: boolean): void;
  80515. /**
  80516. * Marks the attribute state as changed
  80517. */
  80518. markAsAttributesDirty(): void;
  80519. /**
  80520. * Marks the texture state as changed
  80521. */
  80522. markAsTexturesDirty(): void;
  80523. /**
  80524. * Marks the fresnel state as changed
  80525. */
  80526. markAsFresnelDirty(): void;
  80527. /**
  80528. * Marks the misc state as changed
  80529. */
  80530. markAsMiscDirty(): void;
  80531. /**
  80532. * Rebuilds the material defines
  80533. */
  80534. rebuild(): void;
  80535. /**
  80536. * Specifies if two material defines are equal
  80537. * @param other - A material define instance to compare to
  80538. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  80539. */
  80540. isEqual(other: MaterialDefines): boolean;
  80541. /**
  80542. * Clones this instance's defines to another instance
  80543. * @param other - material defines to clone values to
  80544. */
  80545. cloneTo(other: MaterialDefines): void;
  80546. /**
  80547. * Resets the material define values
  80548. */
  80549. reset(): void;
  80550. /**
  80551. * Converts the material define values to a string
  80552. * @returns - String of material define information
  80553. */
  80554. toString(): string;
  80555. }
  80556. }
  80557. declare module BABYLON {
  80558. /**
  80559. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  80560. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  80561. * 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;
  80562. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  80563. */
  80564. export class ColorCurves {
  80565. private _dirty;
  80566. private _tempColor;
  80567. private _globalCurve;
  80568. private _highlightsCurve;
  80569. private _midtonesCurve;
  80570. private _shadowsCurve;
  80571. private _positiveCurve;
  80572. private _negativeCurve;
  80573. private _globalHue;
  80574. private _globalDensity;
  80575. private _globalSaturation;
  80576. private _globalExposure;
  80577. /**
  80578. * Gets the global Hue value.
  80579. * 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).
  80580. */
  80581. get globalHue(): number;
  80582. /**
  80583. * Sets the global Hue value.
  80584. * 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).
  80585. */
  80586. set globalHue(value: number);
  80587. /**
  80588. * Gets the global Density value.
  80589. * 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.
  80590. * Values less than zero provide a filter of opposite hue.
  80591. */
  80592. get globalDensity(): number;
  80593. /**
  80594. * Sets the global Density value.
  80595. * 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.
  80596. * Values less than zero provide a filter of opposite hue.
  80597. */
  80598. set globalDensity(value: number);
  80599. /**
  80600. * Gets the global Saturation value.
  80601. * 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.
  80602. */
  80603. get globalSaturation(): number;
  80604. /**
  80605. * Sets the global Saturation value.
  80606. * 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.
  80607. */
  80608. set globalSaturation(value: number);
  80609. /**
  80610. * Gets the global Exposure value.
  80611. * 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.
  80612. */
  80613. get globalExposure(): number;
  80614. /**
  80615. * Sets the global Exposure value.
  80616. * 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.
  80617. */
  80618. set globalExposure(value: number);
  80619. private _highlightsHue;
  80620. private _highlightsDensity;
  80621. private _highlightsSaturation;
  80622. private _highlightsExposure;
  80623. /**
  80624. * Gets the highlights Hue value.
  80625. * 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).
  80626. */
  80627. get highlightsHue(): number;
  80628. /**
  80629. * Sets the highlights Hue value.
  80630. * 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).
  80631. */
  80632. set highlightsHue(value: number);
  80633. /**
  80634. * Gets the highlights Density value.
  80635. * 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.
  80636. * Values less than zero provide a filter of opposite hue.
  80637. */
  80638. get highlightsDensity(): number;
  80639. /**
  80640. * Sets the highlights Density value.
  80641. * 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.
  80642. * Values less than zero provide a filter of opposite hue.
  80643. */
  80644. set highlightsDensity(value: number);
  80645. /**
  80646. * Gets the highlights Saturation value.
  80647. * 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.
  80648. */
  80649. get highlightsSaturation(): number;
  80650. /**
  80651. * Sets the highlights Saturation value.
  80652. * 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.
  80653. */
  80654. set highlightsSaturation(value: number);
  80655. /**
  80656. * Gets the highlights Exposure value.
  80657. * 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.
  80658. */
  80659. get highlightsExposure(): number;
  80660. /**
  80661. * Sets the highlights Exposure value.
  80662. * 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.
  80663. */
  80664. set highlightsExposure(value: number);
  80665. private _midtonesHue;
  80666. private _midtonesDensity;
  80667. private _midtonesSaturation;
  80668. private _midtonesExposure;
  80669. /**
  80670. * Gets the midtones Hue value.
  80671. * 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).
  80672. */
  80673. get midtonesHue(): number;
  80674. /**
  80675. * Sets the midtones Hue value.
  80676. * 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).
  80677. */
  80678. set midtonesHue(value: number);
  80679. /**
  80680. * Gets the midtones Density value.
  80681. * 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.
  80682. * Values less than zero provide a filter of opposite hue.
  80683. */
  80684. get midtonesDensity(): number;
  80685. /**
  80686. * Sets the midtones Density value.
  80687. * 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.
  80688. * Values less than zero provide a filter of opposite hue.
  80689. */
  80690. set midtonesDensity(value: number);
  80691. /**
  80692. * Gets the midtones Saturation value.
  80693. * 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.
  80694. */
  80695. get midtonesSaturation(): number;
  80696. /**
  80697. * Sets the midtones Saturation value.
  80698. * 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.
  80699. */
  80700. set midtonesSaturation(value: number);
  80701. /**
  80702. * Gets the midtones Exposure value.
  80703. * 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.
  80704. */
  80705. get midtonesExposure(): number;
  80706. /**
  80707. * Sets the midtones Exposure value.
  80708. * 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.
  80709. */
  80710. set midtonesExposure(value: number);
  80711. private _shadowsHue;
  80712. private _shadowsDensity;
  80713. private _shadowsSaturation;
  80714. private _shadowsExposure;
  80715. /**
  80716. * Gets the shadows Hue value.
  80717. * 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).
  80718. */
  80719. get shadowsHue(): number;
  80720. /**
  80721. * Sets the shadows Hue value.
  80722. * 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).
  80723. */
  80724. set shadowsHue(value: number);
  80725. /**
  80726. * Gets the shadows Density value.
  80727. * 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.
  80728. * Values less than zero provide a filter of opposite hue.
  80729. */
  80730. get shadowsDensity(): number;
  80731. /**
  80732. * Sets the shadows Density value.
  80733. * 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.
  80734. * Values less than zero provide a filter of opposite hue.
  80735. */
  80736. set shadowsDensity(value: number);
  80737. /**
  80738. * Gets the shadows Saturation value.
  80739. * 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.
  80740. */
  80741. get shadowsSaturation(): number;
  80742. /**
  80743. * Sets the shadows Saturation value.
  80744. * 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.
  80745. */
  80746. set shadowsSaturation(value: number);
  80747. /**
  80748. * Gets the shadows Exposure value.
  80749. * 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.
  80750. */
  80751. get shadowsExposure(): number;
  80752. /**
  80753. * Sets the shadows Exposure value.
  80754. * 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.
  80755. */
  80756. set shadowsExposure(value: number);
  80757. /**
  80758. * Returns the class name
  80759. * @returns The class name
  80760. */
  80761. getClassName(): string;
  80762. /**
  80763. * Binds the color curves to the shader.
  80764. * @param colorCurves The color curve to bind
  80765. * @param effect The effect to bind to
  80766. * @param positiveUniform The positive uniform shader parameter
  80767. * @param neutralUniform The neutral uniform shader parameter
  80768. * @param negativeUniform The negative uniform shader parameter
  80769. */
  80770. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  80771. /**
  80772. * Prepare the list of uniforms associated with the ColorCurves effects.
  80773. * @param uniformsList The list of uniforms used in the effect
  80774. */
  80775. static PrepareUniforms(uniformsList: string[]): void;
  80776. /**
  80777. * Returns color grading data based on a hue, density, saturation and exposure value.
  80778. * @param filterHue The hue of the color filter.
  80779. * @param filterDensity The density of the color filter.
  80780. * @param saturation The saturation.
  80781. * @param exposure The exposure.
  80782. * @param result The result data container.
  80783. */
  80784. private getColorGradingDataToRef;
  80785. /**
  80786. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  80787. * @param value The input slider value in range [-100,100].
  80788. * @returns Adjusted value.
  80789. */
  80790. private static applyColorGradingSliderNonlinear;
  80791. /**
  80792. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  80793. * @param hue The hue (H) input.
  80794. * @param saturation The saturation (S) input.
  80795. * @param brightness The brightness (B) input.
  80796. * @result An RGBA color represented as Vector4.
  80797. */
  80798. private static fromHSBToRef;
  80799. /**
  80800. * Returns a value clamped between min and max
  80801. * @param value The value to clamp
  80802. * @param min The minimum of value
  80803. * @param max The maximum of value
  80804. * @returns The clamped value.
  80805. */
  80806. private static clamp;
  80807. /**
  80808. * Clones the current color curve instance.
  80809. * @return The cloned curves
  80810. */
  80811. clone(): ColorCurves;
  80812. /**
  80813. * Serializes the current color curve instance to a json representation.
  80814. * @return a JSON representation
  80815. */
  80816. serialize(): any;
  80817. /**
  80818. * Parses the color curve from a json representation.
  80819. * @param source the JSON source to parse
  80820. * @return The parsed curves
  80821. */
  80822. static Parse(source: any): ColorCurves;
  80823. }
  80824. }
  80825. declare module BABYLON {
  80826. /**
  80827. * Interface to follow in your material defines to integrate easily the
  80828. * Image proccessing functions.
  80829. * @hidden
  80830. */
  80831. export interface IImageProcessingConfigurationDefines {
  80832. IMAGEPROCESSING: boolean;
  80833. VIGNETTE: boolean;
  80834. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80835. VIGNETTEBLENDMODEOPAQUE: boolean;
  80836. TONEMAPPING: boolean;
  80837. TONEMAPPING_ACES: boolean;
  80838. CONTRAST: boolean;
  80839. EXPOSURE: boolean;
  80840. COLORCURVES: boolean;
  80841. COLORGRADING: boolean;
  80842. COLORGRADING3D: boolean;
  80843. SAMPLER3DGREENDEPTH: boolean;
  80844. SAMPLER3DBGRMAP: boolean;
  80845. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80846. }
  80847. /**
  80848. * @hidden
  80849. */
  80850. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  80851. IMAGEPROCESSING: boolean;
  80852. VIGNETTE: boolean;
  80853. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80854. VIGNETTEBLENDMODEOPAQUE: boolean;
  80855. TONEMAPPING: boolean;
  80856. TONEMAPPING_ACES: boolean;
  80857. CONTRAST: boolean;
  80858. COLORCURVES: boolean;
  80859. COLORGRADING: boolean;
  80860. COLORGRADING3D: boolean;
  80861. SAMPLER3DGREENDEPTH: boolean;
  80862. SAMPLER3DBGRMAP: boolean;
  80863. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80864. EXPOSURE: boolean;
  80865. constructor();
  80866. }
  80867. /**
  80868. * This groups together the common properties used for image processing either in direct forward pass
  80869. * or through post processing effect depending on the use of the image processing pipeline in your scene
  80870. * or not.
  80871. */
  80872. export class ImageProcessingConfiguration {
  80873. /**
  80874. * Default tone mapping applied in BabylonJS.
  80875. */
  80876. static readonly TONEMAPPING_STANDARD: number;
  80877. /**
  80878. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  80879. * to other engines rendering to increase portability.
  80880. */
  80881. static readonly TONEMAPPING_ACES: number;
  80882. /**
  80883. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  80884. */
  80885. colorCurves: Nullable<ColorCurves>;
  80886. private _colorCurvesEnabled;
  80887. /**
  80888. * Gets wether the color curves effect is enabled.
  80889. */
  80890. get colorCurvesEnabled(): boolean;
  80891. /**
  80892. * Sets wether the color curves effect is enabled.
  80893. */
  80894. set colorCurvesEnabled(value: boolean);
  80895. private _colorGradingTexture;
  80896. /**
  80897. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80898. */
  80899. get colorGradingTexture(): Nullable<BaseTexture>;
  80900. /**
  80901. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80902. */
  80903. set colorGradingTexture(value: Nullable<BaseTexture>);
  80904. private _colorGradingEnabled;
  80905. /**
  80906. * Gets wether the color grading effect is enabled.
  80907. */
  80908. get colorGradingEnabled(): boolean;
  80909. /**
  80910. * Sets wether the color grading effect is enabled.
  80911. */
  80912. set colorGradingEnabled(value: boolean);
  80913. private _colorGradingWithGreenDepth;
  80914. /**
  80915. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  80916. */
  80917. get colorGradingWithGreenDepth(): boolean;
  80918. /**
  80919. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  80920. */
  80921. set colorGradingWithGreenDepth(value: boolean);
  80922. private _colorGradingBGR;
  80923. /**
  80924. * Gets wether the color grading texture contains BGR values.
  80925. */
  80926. get colorGradingBGR(): boolean;
  80927. /**
  80928. * Sets wether the color grading texture contains BGR values.
  80929. */
  80930. set colorGradingBGR(value: boolean);
  80931. /** @hidden */
  80932. _exposure: number;
  80933. /**
  80934. * Gets the Exposure used in the effect.
  80935. */
  80936. get exposure(): number;
  80937. /**
  80938. * Sets the Exposure used in the effect.
  80939. */
  80940. set exposure(value: number);
  80941. private _toneMappingEnabled;
  80942. /**
  80943. * Gets wether the tone mapping effect is enabled.
  80944. */
  80945. get toneMappingEnabled(): boolean;
  80946. /**
  80947. * Sets wether the tone mapping effect is enabled.
  80948. */
  80949. set toneMappingEnabled(value: boolean);
  80950. private _toneMappingType;
  80951. /**
  80952. * Gets the type of tone mapping effect.
  80953. */
  80954. get toneMappingType(): number;
  80955. /**
  80956. * Sets the type of tone mapping effect used in BabylonJS.
  80957. */
  80958. set toneMappingType(value: number);
  80959. protected _contrast: number;
  80960. /**
  80961. * Gets the contrast used in the effect.
  80962. */
  80963. get contrast(): number;
  80964. /**
  80965. * Sets the contrast used in the effect.
  80966. */
  80967. set contrast(value: number);
  80968. /**
  80969. * Vignette stretch size.
  80970. */
  80971. vignetteStretch: number;
  80972. /**
  80973. * Vignette centre X Offset.
  80974. */
  80975. vignetteCentreX: number;
  80976. /**
  80977. * Vignette centre Y Offset.
  80978. */
  80979. vignetteCentreY: number;
  80980. /**
  80981. * Vignette weight or intensity of the vignette effect.
  80982. */
  80983. vignetteWeight: number;
  80984. /**
  80985. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  80986. * if vignetteEnabled is set to true.
  80987. */
  80988. vignetteColor: Color4;
  80989. /**
  80990. * Camera field of view used by the Vignette effect.
  80991. */
  80992. vignetteCameraFov: number;
  80993. private _vignetteBlendMode;
  80994. /**
  80995. * Gets the vignette blend mode allowing different kind of effect.
  80996. */
  80997. get vignetteBlendMode(): number;
  80998. /**
  80999. * Sets the vignette blend mode allowing different kind of effect.
  81000. */
  81001. set vignetteBlendMode(value: number);
  81002. private _vignetteEnabled;
  81003. /**
  81004. * Gets wether the vignette effect is enabled.
  81005. */
  81006. get vignetteEnabled(): boolean;
  81007. /**
  81008. * Sets wether the vignette effect is enabled.
  81009. */
  81010. set vignetteEnabled(value: boolean);
  81011. private _applyByPostProcess;
  81012. /**
  81013. * Gets wether the image processing is applied through a post process or not.
  81014. */
  81015. get applyByPostProcess(): boolean;
  81016. /**
  81017. * Sets wether the image processing is applied through a post process or not.
  81018. */
  81019. set applyByPostProcess(value: boolean);
  81020. private _isEnabled;
  81021. /**
  81022. * Gets wether the image processing is enabled or not.
  81023. */
  81024. get isEnabled(): boolean;
  81025. /**
  81026. * Sets wether the image processing is enabled or not.
  81027. */
  81028. set isEnabled(value: boolean);
  81029. /**
  81030. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81031. */
  81032. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81033. /**
  81034. * Method called each time the image processing information changes requires to recompile the effect.
  81035. */
  81036. protected _updateParameters(): void;
  81037. /**
  81038. * Gets the current class name.
  81039. * @return "ImageProcessingConfiguration"
  81040. */
  81041. getClassName(): string;
  81042. /**
  81043. * Prepare the list of uniforms associated with the Image Processing effects.
  81044. * @param uniforms The list of uniforms used in the effect
  81045. * @param defines the list of defines currently in use
  81046. */
  81047. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81048. /**
  81049. * Prepare the list of samplers associated with the Image Processing effects.
  81050. * @param samplersList The list of uniforms used in the effect
  81051. * @param defines the list of defines currently in use
  81052. */
  81053. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81054. /**
  81055. * Prepare the list of defines associated to the shader.
  81056. * @param defines the list of defines to complete
  81057. * @param forPostProcess Define if we are currently in post process mode or not
  81058. */
  81059. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81060. /**
  81061. * Returns true if all the image processing information are ready.
  81062. * @returns True if ready, otherwise, false
  81063. */
  81064. isReady(): boolean;
  81065. /**
  81066. * Binds the image processing to the shader.
  81067. * @param effect The effect to bind to
  81068. * @param overrideAspectRatio Override the aspect ratio of the effect
  81069. */
  81070. bind(effect: Effect, overrideAspectRatio?: number): void;
  81071. /**
  81072. * Clones the current image processing instance.
  81073. * @return The cloned image processing
  81074. */
  81075. clone(): ImageProcessingConfiguration;
  81076. /**
  81077. * Serializes the current image processing instance to a json representation.
  81078. * @return a JSON representation
  81079. */
  81080. serialize(): any;
  81081. /**
  81082. * Parses the image processing from a json representation.
  81083. * @param source the JSON source to parse
  81084. * @return The parsed image processing
  81085. */
  81086. static Parse(source: any): ImageProcessingConfiguration;
  81087. private static _VIGNETTEMODE_MULTIPLY;
  81088. private static _VIGNETTEMODE_OPAQUE;
  81089. /**
  81090. * Used to apply the vignette as a mix with the pixel color.
  81091. */
  81092. static get VIGNETTEMODE_MULTIPLY(): number;
  81093. /**
  81094. * Used to apply the vignette as a replacement of the pixel color.
  81095. */
  81096. static get VIGNETTEMODE_OPAQUE(): number;
  81097. }
  81098. }
  81099. declare module BABYLON {
  81100. /** @hidden */
  81101. export var postprocessVertexShader: {
  81102. name: string;
  81103. shader: string;
  81104. };
  81105. }
  81106. declare module BABYLON {
  81107. interface ThinEngine {
  81108. /**
  81109. * Creates a new render target texture
  81110. * @param size defines the size of the texture
  81111. * @param options defines the options used to create the texture
  81112. * @returns a new render target texture stored in an InternalTexture
  81113. */
  81114. createRenderTargetTexture(size: number | {
  81115. width: number;
  81116. height: number;
  81117. layers?: number;
  81118. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81119. /**
  81120. * Creates a depth stencil texture.
  81121. * This is only available in WebGL 2 or with the depth texture extension available.
  81122. * @param size The size of face edge in the texture.
  81123. * @param options The options defining the texture.
  81124. * @returns The texture
  81125. */
  81126. createDepthStencilTexture(size: number | {
  81127. width: number;
  81128. height: number;
  81129. layers?: number;
  81130. }, options: DepthTextureCreationOptions): InternalTexture;
  81131. /** @hidden */
  81132. _createDepthStencilTexture(size: number | {
  81133. width: number;
  81134. height: number;
  81135. layers?: number;
  81136. }, options: DepthTextureCreationOptions): InternalTexture;
  81137. }
  81138. }
  81139. declare module BABYLON {
  81140. /** Defines supported spaces */
  81141. export enum Space {
  81142. /** Local (object) space */
  81143. LOCAL = 0,
  81144. /** World space */
  81145. WORLD = 1,
  81146. /** Bone space */
  81147. BONE = 2
  81148. }
  81149. /** Defines the 3 main axes */
  81150. export class Axis {
  81151. /** X axis */
  81152. static X: Vector3;
  81153. /** Y axis */
  81154. static Y: Vector3;
  81155. /** Z axis */
  81156. static Z: Vector3;
  81157. }
  81158. }
  81159. declare module BABYLON {
  81160. /**
  81161. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81162. * This is the base of the follow, arc rotate cameras and Free camera
  81163. * @see http://doc.babylonjs.com/features/cameras
  81164. */
  81165. export class TargetCamera extends Camera {
  81166. private static _RigCamTransformMatrix;
  81167. private static _TargetTransformMatrix;
  81168. private static _TargetFocalPoint;
  81169. /**
  81170. * Define the current direction the camera is moving to
  81171. */
  81172. cameraDirection: Vector3;
  81173. /**
  81174. * Define the current rotation the camera is rotating to
  81175. */
  81176. cameraRotation: Vector2;
  81177. /**
  81178. * When set, the up vector of the camera will be updated by the rotation of the camera
  81179. */
  81180. updateUpVectorFromRotation: boolean;
  81181. private _tmpQuaternion;
  81182. /**
  81183. * Define the current rotation of the camera
  81184. */
  81185. rotation: Vector3;
  81186. /**
  81187. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81188. */
  81189. rotationQuaternion: Quaternion;
  81190. /**
  81191. * Define the current speed of the camera
  81192. */
  81193. speed: number;
  81194. /**
  81195. * Add constraint to the camera to prevent it to move freely in all directions and
  81196. * around all axis.
  81197. */
  81198. noRotationConstraint: boolean;
  81199. /**
  81200. * Define the current target of the camera as an object or a position.
  81201. */
  81202. lockedTarget: any;
  81203. /** @hidden */
  81204. _currentTarget: Vector3;
  81205. /** @hidden */
  81206. _initialFocalDistance: number;
  81207. /** @hidden */
  81208. _viewMatrix: Matrix;
  81209. /** @hidden */
  81210. _camMatrix: Matrix;
  81211. /** @hidden */
  81212. _cameraTransformMatrix: Matrix;
  81213. /** @hidden */
  81214. _cameraRotationMatrix: Matrix;
  81215. /** @hidden */
  81216. _referencePoint: Vector3;
  81217. /** @hidden */
  81218. _transformedReferencePoint: Vector3;
  81219. protected _globalCurrentTarget: Vector3;
  81220. protected _globalCurrentUpVector: Vector3;
  81221. /** @hidden */
  81222. _reset: () => void;
  81223. private _defaultUp;
  81224. /**
  81225. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81226. * This is the base of the follow, arc rotate cameras and Free camera
  81227. * @see http://doc.babylonjs.com/features/cameras
  81228. * @param name Defines the name of the camera in the scene
  81229. * @param position Defines the start position of the camera in the scene
  81230. * @param scene Defines the scene the camera belongs to
  81231. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81232. */
  81233. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81234. /**
  81235. * Gets the position in front of the camera at a given distance.
  81236. * @param distance The distance from the camera we want the position to be
  81237. * @returns the position
  81238. */
  81239. getFrontPosition(distance: number): Vector3;
  81240. /** @hidden */
  81241. _getLockedTargetPosition(): Nullable<Vector3>;
  81242. private _storedPosition;
  81243. private _storedRotation;
  81244. private _storedRotationQuaternion;
  81245. /**
  81246. * Store current camera state of the camera (fov, position, rotation, etc..)
  81247. * @returns the camera
  81248. */
  81249. storeState(): Camera;
  81250. /**
  81251. * Restored camera state. You must call storeState() first
  81252. * @returns whether it was successful or not
  81253. * @hidden
  81254. */
  81255. _restoreStateValues(): boolean;
  81256. /** @hidden */
  81257. _initCache(): void;
  81258. /** @hidden */
  81259. _updateCache(ignoreParentClass?: boolean): void;
  81260. /** @hidden */
  81261. _isSynchronizedViewMatrix(): boolean;
  81262. /** @hidden */
  81263. _computeLocalCameraSpeed(): number;
  81264. /**
  81265. * Defines the target the camera should look at.
  81266. * @param target Defines the new target as a Vector or a mesh
  81267. */
  81268. setTarget(target: Vector3): void;
  81269. /**
  81270. * Return the current target position of the camera. This value is expressed in local space.
  81271. * @returns the target position
  81272. */
  81273. getTarget(): Vector3;
  81274. /** @hidden */
  81275. _decideIfNeedsToMove(): boolean;
  81276. /** @hidden */
  81277. _updatePosition(): void;
  81278. /** @hidden */
  81279. _checkInputs(): void;
  81280. protected _updateCameraRotationMatrix(): void;
  81281. /**
  81282. * 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)
  81283. * @returns the current camera
  81284. */
  81285. private _rotateUpVectorWithCameraRotationMatrix;
  81286. private _cachedRotationZ;
  81287. private _cachedQuaternionRotationZ;
  81288. /** @hidden */
  81289. _getViewMatrix(): Matrix;
  81290. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81291. /**
  81292. * @hidden
  81293. */
  81294. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81295. /**
  81296. * @hidden
  81297. */
  81298. _updateRigCameras(): void;
  81299. private _getRigCamPositionAndTarget;
  81300. /**
  81301. * Gets the current object class name.
  81302. * @return the class name
  81303. */
  81304. getClassName(): string;
  81305. }
  81306. }
  81307. declare module BABYLON {
  81308. /**
  81309. * Gather the list of keyboard event types as constants.
  81310. */
  81311. export class KeyboardEventTypes {
  81312. /**
  81313. * The keydown event is fired when a key becomes active (pressed).
  81314. */
  81315. static readonly KEYDOWN: number;
  81316. /**
  81317. * The keyup event is fired when a key has been released.
  81318. */
  81319. static readonly KEYUP: number;
  81320. }
  81321. /**
  81322. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81323. */
  81324. export class KeyboardInfo {
  81325. /**
  81326. * Defines the type of event (KeyboardEventTypes)
  81327. */
  81328. type: number;
  81329. /**
  81330. * Defines the related dom event
  81331. */
  81332. event: KeyboardEvent;
  81333. /**
  81334. * Instantiates a new keyboard info.
  81335. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81336. * @param type Defines the type of event (KeyboardEventTypes)
  81337. * @param event Defines the related dom event
  81338. */
  81339. constructor(
  81340. /**
  81341. * Defines the type of event (KeyboardEventTypes)
  81342. */
  81343. type: number,
  81344. /**
  81345. * Defines the related dom event
  81346. */
  81347. event: KeyboardEvent);
  81348. }
  81349. /**
  81350. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81351. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81352. */
  81353. export class KeyboardInfoPre extends KeyboardInfo {
  81354. /**
  81355. * Defines the type of event (KeyboardEventTypes)
  81356. */
  81357. type: number;
  81358. /**
  81359. * Defines the related dom event
  81360. */
  81361. event: KeyboardEvent;
  81362. /**
  81363. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81364. */
  81365. skipOnPointerObservable: boolean;
  81366. /**
  81367. * Instantiates a new keyboard pre info.
  81368. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81369. * @param type Defines the type of event (KeyboardEventTypes)
  81370. * @param event Defines the related dom event
  81371. */
  81372. constructor(
  81373. /**
  81374. * Defines the type of event (KeyboardEventTypes)
  81375. */
  81376. type: number,
  81377. /**
  81378. * Defines the related dom event
  81379. */
  81380. event: KeyboardEvent);
  81381. }
  81382. }
  81383. declare module BABYLON {
  81384. /**
  81385. * Manage the keyboard inputs to control the movement of a free camera.
  81386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81387. */
  81388. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81389. /**
  81390. * Defines the camera the input is attached to.
  81391. */
  81392. camera: FreeCamera;
  81393. /**
  81394. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81395. */
  81396. keysUp: number[];
  81397. /**
  81398. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81399. */
  81400. keysDown: number[];
  81401. /**
  81402. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81403. */
  81404. keysLeft: number[];
  81405. /**
  81406. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81407. */
  81408. keysRight: number[];
  81409. private _keys;
  81410. private _onCanvasBlurObserver;
  81411. private _onKeyboardObserver;
  81412. private _engine;
  81413. private _scene;
  81414. /**
  81415. * Attach the input controls to a specific dom element to get the input from.
  81416. * @param element Defines the element the controls should be listened from
  81417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81418. */
  81419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81420. /**
  81421. * Detach the current controls from the specified dom element.
  81422. * @param element Defines the element to stop listening the inputs from
  81423. */
  81424. detachControl(element: Nullable<HTMLElement>): void;
  81425. /**
  81426. * Update the current camera state depending on the inputs that have been used this frame.
  81427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81428. */
  81429. checkInputs(): void;
  81430. /**
  81431. * Gets the class name of the current intput.
  81432. * @returns the class name
  81433. */
  81434. getClassName(): string;
  81435. /** @hidden */
  81436. _onLostFocus(): void;
  81437. /**
  81438. * Get the friendly name associated with the input class.
  81439. * @returns the input friendly name
  81440. */
  81441. getSimpleName(): string;
  81442. }
  81443. }
  81444. declare module BABYLON {
  81445. /**
  81446. * Interface describing all the common properties and methods a shadow light needs to implement.
  81447. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  81448. * as well as binding the different shadow properties to the effects.
  81449. */
  81450. export interface IShadowLight extends Light {
  81451. /**
  81452. * The light id in the scene (used in scene.findLighById for instance)
  81453. */
  81454. id: string;
  81455. /**
  81456. * The position the shdow will be casted from.
  81457. */
  81458. position: Vector3;
  81459. /**
  81460. * In 2d mode (needCube being false), the direction used to cast the shadow.
  81461. */
  81462. direction: Vector3;
  81463. /**
  81464. * The transformed position. Position of the light in world space taking parenting in account.
  81465. */
  81466. transformedPosition: Vector3;
  81467. /**
  81468. * The transformed direction. Direction of the light in world space taking parenting in account.
  81469. */
  81470. transformedDirection: Vector3;
  81471. /**
  81472. * The friendly name of the light in the scene.
  81473. */
  81474. name: string;
  81475. /**
  81476. * Defines the shadow projection clipping minimum z value.
  81477. */
  81478. shadowMinZ: number;
  81479. /**
  81480. * Defines the shadow projection clipping maximum z value.
  81481. */
  81482. shadowMaxZ: number;
  81483. /**
  81484. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81485. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81486. */
  81487. computeTransformedInformation(): boolean;
  81488. /**
  81489. * Gets the scene the light belongs to.
  81490. * @returns The scene
  81491. */
  81492. getScene(): Scene;
  81493. /**
  81494. * Callback defining a custom Projection Matrix Builder.
  81495. * This can be used to override the default projection matrix computation.
  81496. */
  81497. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81498. /**
  81499. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81500. * @param matrix The materix to updated with the projection information
  81501. * @param viewMatrix The transform matrix of the light
  81502. * @param renderList The list of mesh to render in the map
  81503. * @returns The current light
  81504. */
  81505. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81506. /**
  81507. * Gets the current depth scale used in ESM.
  81508. * @returns The scale
  81509. */
  81510. getDepthScale(): number;
  81511. /**
  81512. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81513. * @returns true if a cube texture needs to be use
  81514. */
  81515. needCube(): boolean;
  81516. /**
  81517. * Detects if the projection matrix requires to be recomputed this frame.
  81518. * @returns true if it requires to be recomputed otherwise, false.
  81519. */
  81520. needProjectionMatrixCompute(): boolean;
  81521. /**
  81522. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81523. */
  81524. forceProjectionMatrixCompute(): void;
  81525. /**
  81526. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81527. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81528. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81529. */
  81530. getShadowDirection(faceIndex?: number): Vector3;
  81531. /**
  81532. * Gets the minZ used for shadow according to both the scene and the light.
  81533. * @param activeCamera The camera we are returning the min for
  81534. * @returns the depth min z
  81535. */
  81536. getDepthMinZ(activeCamera: Camera): number;
  81537. /**
  81538. * Gets the maxZ used for shadow according to both the scene and the light.
  81539. * @param activeCamera The camera we are returning the max for
  81540. * @returns the depth max z
  81541. */
  81542. getDepthMaxZ(activeCamera: Camera): number;
  81543. }
  81544. /**
  81545. * Base implementation IShadowLight
  81546. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  81547. */
  81548. export abstract class ShadowLight extends Light implements IShadowLight {
  81549. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  81550. protected _position: Vector3;
  81551. protected _setPosition(value: Vector3): void;
  81552. /**
  81553. * Sets the position the shadow will be casted from. Also use as the light position for both
  81554. * point and spot lights.
  81555. */
  81556. get position(): Vector3;
  81557. /**
  81558. * Sets the position the shadow will be casted from. Also use as the light position for both
  81559. * point and spot lights.
  81560. */
  81561. set position(value: Vector3);
  81562. protected _direction: Vector3;
  81563. protected _setDirection(value: Vector3): void;
  81564. /**
  81565. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  81566. * Also use as the light direction on spot and directional lights.
  81567. */
  81568. get direction(): Vector3;
  81569. /**
  81570. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  81571. * Also use as the light direction on spot and directional lights.
  81572. */
  81573. set direction(value: Vector3);
  81574. protected _shadowMinZ: number;
  81575. /**
  81576. * Gets the shadow projection clipping minimum z value.
  81577. */
  81578. get shadowMinZ(): number;
  81579. /**
  81580. * Sets the shadow projection clipping minimum z value.
  81581. */
  81582. set shadowMinZ(value: number);
  81583. protected _shadowMaxZ: number;
  81584. /**
  81585. * Sets the shadow projection clipping maximum z value.
  81586. */
  81587. get shadowMaxZ(): number;
  81588. /**
  81589. * Gets the shadow projection clipping maximum z value.
  81590. */
  81591. set shadowMaxZ(value: number);
  81592. /**
  81593. * Callback defining a custom Projection Matrix Builder.
  81594. * This can be used to override the default projection matrix computation.
  81595. */
  81596. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81597. /**
  81598. * The transformed position. Position of the light in world space taking parenting in account.
  81599. */
  81600. transformedPosition: Vector3;
  81601. /**
  81602. * The transformed direction. Direction of the light in world space taking parenting in account.
  81603. */
  81604. transformedDirection: Vector3;
  81605. private _needProjectionMatrixCompute;
  81606. /**
  81607. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81608. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81609. */
  81610. computeTransformedInformation(): boolean;
  81611. /**
  81612. * Return the depth scale used for the shadow map.
  81613. * @returns the depth scale.
  81614. */
  81615. getDepthScale(): number;
  81616. /**
  81617. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81618. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81619. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81620. */
  81621. getShadowDirection(faceIndex?: number): Vector3;
  81622. /**
  81623. * Returns the ShadowLight absolute position in the World.
  81624. * @returns the position vector in world space
  81625. */
  81626. getAbsolutePosition(): Vector3;
  81627. /**
  81628. * Sets the ShadowLight direction toward the passed target.
  81629. * @param target The point to target in local space
  81630. * @returns the updated ShadowLight direction
  81631. */
  81632. setDirectionToTarget(target: Vector3): Vector3;
  81633. /**
  81634. * Returns the light rotation in euler definition.
  81635. * @returns the x y z rotation in local space.
  81636. */
  81637. getRotation(): Vector3;
  81638. /**
  81639. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81640. * @returns true if a cube texture needs to be use
  81641. */
  81642. needCube(): boolean;
  81643. /**
  81644. * Detects if the projection matrix requires to be recomputed this frame.
  81645. * @returns true if it requires to be recomputed otherwise, false.
  81646. */
  81647. needProjectionMatrixCompute(): boolean;
  81648. /**
  81649. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81650. */
  81651. forceProjectionMatrixCompute(): void;
  81652. /** @hidden */
  81653. _initCache(): void;
  81654. /** @hidden */
  81655. _isSynchronized(): boolean;
  81656. /**
  81657. * Computes the world matrix of the node
  81658. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81659. * @returns the world matrix
  81660. */
  81661. computeWorldMatrix(force?: boolean): Matrix;
  81662. /**
  81663. * Gets the minZ used for shadow according to both the scene and the light.
  81664. * @param activeCamera The camera we are returning the min for
  81665. * @returns the depth min z
  81666. */
  81667. getDepthMinZ(activeCamera: Camera): number;
  81668. /**
  81669. * Gets the maxZ used for shadow according to both the scene and the light.
  81670. * @param activeCamera The camera we are returning the max for
  81671. * @returns the depth max z
  81672. */
  81673. getDepthMaxZ(activeCamera: Camera): number;
  81674. /**
  81675. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81676. * @param matrix The materix to updated with the projection information
  81677. * @param viewMatrix The transform matrix of the light
  81678. * @param renderList The list of mesh to render in the map
  81679. * @returns The current light
  81680. */
  81681. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81682. }
  81683. }
  81684. declare module BABYLON {
  81685. /**
  81686. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  81687. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  81688. */
  81689. export class EffectFallbacks implements IEffectFallbacks {
  81690. private _defines;
  81691. private _currentRank;
  81692. private _maxRank;
  81693. private _mesh;
  81694. /**
  81695. * Removes the fallback from the bound mesh.
  81696. */
  81697. unBindMesh(): void;
  81698. /**
  81699. * Adds a fallback on the specified property.
  81700. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81701. * @param define The name of the define in the shader
  81702. */
  81703. addFallback(rank: number, define: string): void;
  81704. /**
  81705. * Sets the mesh to use CPU skinning when needing to fallback.
  81706. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81707. * @param mesh The mesh to use the fallbacks.
  81708. */
  81709. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  81710. /**
  81711. * Checks to see if more fallbacks are still availible.
  81712. */
  81713. get hasMoreFallbacks(): boolean;
  81714. /**
  81715. * Removes the defines that should be removed when falling back.
  81716. * @param currentDefines defines the current define statements for the shader.
  81717. * @param effect defines the current effect we try to compile
  81718. * @returns The resulting defines with defines of the current rank removed.
  81719. */
  81720. reduce(currentDefines: string, effect: Effect): string;
  81721. }
  81722. }
  81723. declare module BABYLON {
  81724. /**
  81725. * "Static Class" containing the most commonly used helper while dealing with material for
  81726. * rendering purpose.
  81727. *
  81728. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  81729. *
  81730. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  81731. */
  81732. export class MaterialHelper {
  81733. /**
  81734. * Bind the current view position to an effect.
  81735. * @param effect The effect to be bound
  81736. * @param scene The scene the eyes position is used from
  81737. */
  81738. static BindEyePosition(effect: Effect, scene: Scene): void;
  81739. /**
  81740. * Helps preparing the defines values about the UVs in used in the effect.
  81741. * UVs are shared as much as we can accross channels in the shaders.
  81742. * @param texture The texture we are preparing the UVs for
  81743. * @param defines The defines to update
  81744. * @param key The channel key "diffuse", "specular"... used in the shader
  81745. */
  81746. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  81747. /**
  81748. * Binds a texture matrix value to its corrsponding uniform
  81749. * @param texture The texture to bind the matrix for
  81750. * @param uniformBuffer The uniform buffer receivin the data
  81751. * @param key The channel key "diffuse", "specular"... used in the shader
  81752. */
  81753. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  81754. /**
  81755. * Gets the current status of the fog (should it be enabled?)
  81756. * @param mesh defines the mesh to evaluate for fog support
  81757. * @param scene defines the hosting scene
  81758. * @returns true if fog must be enabled
  81759. */
  81760. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  81761. /**
  81762. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  81763. * @param mesh defines the current mesh
  81764. * @param scene defines the current scene
  81765. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  81766. * @param pointsCloud defines if point cloud rendering has to be turned on
  81767. * @param fogEnabled defines if fog has to be turned on
  81768. * @param alphaTest defines if alpha testing has to be turned on
  81769. * @param defines defines the current list of defines
  81770. */
  81771. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  81772. /**
  81773. * Helper used to prepare the list of defines associated with frame values for shader compilation
  81774. * @param scene defines the current scene
  81775. * @param engine defines the current engine
  81776. * @param defines specifies the list of active defines
  81777. * @param useInstances defines if instances have to be turned on
  81778. * @param useClipPlane defines if clip plane have to be turned on
  81779. */
  81780. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  81781. /**
  81782. * Prepares the defines for bones
  81783. * @param mesh The mesh containing the geometry data we will draw
  81784. * @param defines The defines to update
  81785. */
  81786. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  81787. /**
  81788. * Prepares the defines for morph targets
  81789. * @param mesh The mesh containing the geometry data we will draw
  81790. * @param defines The defines to update
  81791. */
  81792. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  81793. /**
  81794. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  81795. * @param mesh The mesh containing the geometry data we will draw
  81796. * @param defines The defines to update
  81797. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  81798. * @param useBones Precise whether bones should be used or not (override mesh info)
  81799. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  81800. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  81801. * @returns false if defines are considered not dirty and have not been checked
  81802. */
  81803. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  81804. /**
  81805. * Prepares the defines related to multiview
  81806. * @param scene The scene we are intending to draw
  81807. * @param defines The defines to update
  81808. */
  81809. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  81810. /**
  81811. * Prepares the defines related to the light information passed in parameter
  81812. * @param scene The scene we are intending to draw
  81813. * @param mesh The mesh the effect is compiling for
  81814. * @param light The light the effect is compiling for
  81815. * @param lightIndex The index of the light
  81816. * @param defines The defines to update
  81817. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81818. * @param state Defines the current state regarding what is needed (normals, etc...)
  81819. */
  81820. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  81821. needNormals: boolean;
  81822. needRebuild: boolean;
  81823. shadowEnabled: boolean;
  81824. specularEnabled: boolean;
  81825. lightmapMode: boolean;
  81826. }): void;
  81827. /**
  81828. * Prepares the defines related to the light information passed in parameter
  81829. * @param scene The scene we are intending to draw
  81830. * @param mesh The mesh the effect is compiling for
  81831. * @param defines The defines to update
  81832. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81833. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  81834. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  81835. * @returns true if normals will be required for the rest of the effect
  81836. */
  81837. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  81838. /**
  81839. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  81840. * @param lightIndex defines the light index
  81841. * @param uniformsList The uniform list
  81842. * @param samplersList The sampler list
  81843. * @param projectedLightTexture defines if projected texture must be used
  81844. * @param uniformBuffersList defines an optional list of uniform buffers
  81845. */
  81846. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  81847. /**
  81848. * Prepares the uniforms and samplers list to be used in the effect
  81849. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  81850. * @param samplersList The sampler list
  81851. * @param defines The defines helping in the list generation
  81852. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  81853. */
  81854. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  81855. /**
  81856. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  81857. * @param defines The defines to update while falling back
  81858. * @param fallbacks The authorized effect fallbacks
  81859. * @param maxSimultaneousLights The maximum number of lights allowed
  81860. * @param rank the current rank of the Effect
  81861. * @returns The newly affected rank
  81862. */
  81863. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  81864. private static _TmpMorphInfluencers;
  81865. /**
  81866. * Prepares the list of attributes required for morph targets according to the effect defines.
  81867. * @param attribs The current list of supported attribs
  81868. * @param mesh The mesh to prepare the morph targets attributes for
  81869. * @param influencers The number of influencers
  81870. */
  81871. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  81872. /**
  81873. * Prepares the list of attributes required for morph targets according to the effect defines.
  81874. * @param attribs The current list of supported attribs
  81875. * @param mesh The mesh to prepare the morph targets attributes for
  81876. * @param defines The current Defines of the effect
  81877. */
  81878. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  81879. /**
  81880. * Prepares the list of attributes required for bones according to the effect defines.
  81881. * @param attribs The current list of supported attribs
  81882. * @param mesh The mesh to prepare the bones attributes for
  81883. * @param defines The current Defines of the effect
  81884. * @param fallbacks The current efffect fallback strategy
  81885. */
  81886. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  81887. /**
  81888. * Check and prepare the list of attributes required for instances according to the effect defines.
  81889. * @param attribs The current list of supported attribs
  81890. * @param defines The current MaterialDefines of the effect
  81891. */
  81892. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  81893. /**
  81894. * Add the list of attributes required for instances to the attribs array.
  81895. * @param attribs The current list of supported attribs
  81896. */
  81897. static PushAttributesForInstances(attribs: string[]): void;
  81898. /**
  81899. * Binds the light information to the effect.
  81900. * @param light The light containing the generator
  81901. * @param effect The effect we are binding the data to
  81902. * @param lightIndex The light index in the effect used to render
  81903. */
  81904. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  81905. /**
  81906. * Binds the lights information from the scene to the effect for the given mesh.
  81907. * @param light Light to bind
  81908. * @param lightIndex Light index
  81909. * @param scene The scene where the light belongs to
  81910. * @param effect The effect we are binding the data to
  81911. * @param useSpecular Defines if specular is supported
  81912. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81913. */
  81914. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  81915. /**
  81916. * Binds the lights information from the scene to the effect for the given mesh.
  81917. * @param scene The scene the lights belongs to
  81918. * @param mesh The mesh we are binding the information to render
  81919. * @param effect The effect we are binding the data to
  81920. * @param defines The generated defines for the effect
  81921. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  81922. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81923. */
  81924. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  81925. private static _tempFogColor;
  81926. /**
  81927. * Binds the fog information from the scene to the effect for the given mesh.
  81928. * @param scene The scene the lights belongs to
  81929. * @param mesh The mesh we are binding the information to render
  81930. * @param effect The effect we are binding the data to
  81931. * @param linearSpace Defines if the fog effect is applied in linear space
  81932. */
  81933. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  81934. /**
  81935. * Binds the bones information from the mesh to the effect.
  81936. * @param mesh The mesh we are binding the information to render
  81937. * @param effect The effect we are binding the data to
  81938. */
  81939. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  81940. /**
  81941. * Binds the morph targets information from the mesh to the effect.
  81942. * @param abstractMesh The mesh we are binding the information to render
  81943. * @param effect The effect we are binding the data to
  81944. */
  81945. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  81946. /**
  81947. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  81948. * @param defines The generated defines used in the effect
  81949. * @param effect The effect we are binding the data to
  81950. * @param scene The scene we are willing to render with logarithmic scale for
  81951. */
  81952. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  81953. /**
  81954. * Binds the clip plane information from the scene to the effect.
  81955. * @param scene The scene the clip plane information are extracted from
  81956. * @param effect The effect we are binding the data to
  81957. */
  81958. static BindClipPlane(effect: Effect, scene: Scene): void;
  81959. }
  81960. }
  81961. declare module BABYLON {
  81962. /** @hidden */
  81963. export var packingFunctions: {
  81964. name: string;
  81965. shader: string;
  81966. };
  81967. }
  81968. declare module BABYLON {
  81969. /** @hidden */
  81970. export var shadowMapPixelShader: {
  81971. name: string;
  81972. shader: string;
  81973. };
  81974. }
  81975. declare module BABYLON {
  81976. /** @hidden */
  81977. export var bonesDeclaration: {
  81978. name: string;
  81979. shader: string;
  81980. };
  81981. }
  81982. declare module BABYLON {
  81983. /** @hidden */
  81984. export var morphTargetsVertexGlobalDeclaration: {
  81985. name: string;
  81986. shader: string;
  81987. };
  81988. }
  81989. declare module BABYLON {
  81990. /** @hidden */
  81991. export var morphTargetsVertexDeclaration: {
  81992. name: string;
  81993. shader: string;
  81994. };
  81995. }
  81996. declare module BABYLON {
  81997. /** @hidden */
  81998. export var instancesDeclaration: {
  81999. name: string;
  82000. shader: string;
  82001. };
  82002. }
  82003. declare module BABYLON {
  82004. /** @hidden */
  82005. export var helperFunctions: {
  82006. name: string;
  82007. shader: string;
  82008. };
  82009. }
  82010. declare module BABYLON {
  82011. /** @hidden */
  82012. export var morphTargetsVertex: {
  82013. name: string;
  82014. shader: string;
  82015. };
  82016. }
  82017. declare module BABYLON {
  82018. /** @hidden */
  82019. export var instancesVertex: {
  82020. name: string;
  82021. shader: string;
  82022. };
  82023. }
  82024. declare module BABYLON {
  82025. /** @hidden */
  82026. export var bonesVertex: {
  82027. name: string;
  82028. shader: string;
  82029. };
  82030. }
  82031. declare module BABYLON {
  82032. /** @hidden */
  82033. export var shadowMapVertexShader: {
  82034. name: string;
  82035. shader: string;
  82036. };
  82037. }
  82038. declare module BABYLON {
  82039. /** @hidden */
  82040. export var depthBoxBlurPixelShader: {
  82041. name: string;
  82042. shader: string;
  82043. };
  82044. }
  82045. declare module BABYLON {
  82046. /**
  82047. * Defines the options associated with the creation of a custom shader for a shadow generator.
  82048. */
  82049. export interface ICustomShaderOptions {
  82050. /**
  82051. * Gets or sets the custom shader name to use
  82052. */
  82053. shaderName: string;
  82054. /**
  82055. * The list of attribute names used in the shader
  82056. */
  82057. attributes?: string[];
  82058. /**
  82059. * The list of unifrom names used in the shader
  82060. */
  82061. uniforms?: string[];
  82062. /**
  82063. * The list of sampler names used in the shader
  82064. */
  82065. samplers?: string[];
  82066. /**
  82067. * The list of defines used in the shader
  82068. */
  82069. defines?: string[];
  82070. }
  82071. /**
  82072. * Interface to implement to create a shadow generator compatible with BJS.
  82073. */
  82074. export interface IShadowGenerator {
  82075. /**
  82076. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82077. * @returns The render target texture if present otherwise, null
  82078. */
  82079. getShadowMap(): Nullable<RenderTargetTexture>;
  82080. /**
  82081. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82082. * @param subMesh The submesh we want to render in the shadow map
  82083. * @param useInstances Defines wether will draw in the map using instances
  82084. * @returns true if ready otherwise, false
  82085. */
  82086. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82087. /**
  82088. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82089. * @param defines Defines of the material we want to update
  82090. * @param lightIndex Index of the light in the enabled light list of the material
  82091. */
  82092. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  82093. /**
  82094. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82095. * defined in the generator but impacting the effect).
  82096. * It implies the unifroms available on the materials are the standard BJS ones.
  82097. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82098. * @param effect The effect we are binfing the information for
  82099. */
  82100. bindShadowLight(lightIndex: string, effect: Effect): void;
  82101. /**
  82102. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82103. * (eq to shadow prjection matrix * light transform matrix)
  82104. * @returns The transform matrix used to create the shadow map
  82105. */
  82106. getTransformMatrix(): Matrix;
  82107. /**
  82108. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82109. * Cube and 2D textures for instance.
  82110. */
  82111. recreateShadowMap(): void;
  82112. /**
  82113. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82114. * @param onCompiled Callback triggered at the and of the effects compilation
  82115. * @param options Sets of optional options forcing the compilation with different modes
  82116. */
  82117. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82118. useInstances: boolean;
  82119. }>): void;
  82120. /**
  82121. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82122. * @param options Sets of optional options forcing the compilation with different modes
  82123. * @returns A promise that resolves when the compilation completes
  82124. */
  82125. forceCompilationAsync(options?: Partial<{
  82126. useInstances: boolean;
  82127. }>): Promise<void>;
  82128. /**
  82129. * Serializes the shadow generator setup to a json object.
  82130. * @returns The serialized JSON object
  82131. */
  82132. serialize(): any;
  82133. /**
  82134. * Disposes the Shadow map and related Textures and effects.
  82135. */
  82136. dispose(): void;
  82137. }
  82138. /**
  82139. * Default implementation IShadowGenerator.
  82140. * This is the main object responsible of generating shadows in the framework.
  82141. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  82142. */
  82143. export class ShadowGenerator implements IShadowGenerator {
  82144. /**
  82145. * Shadow generator mode None: no filtering applied.
  82146. */
  82147. static readonly FILTER_NONE: number;
  82148. /**
  82149. * Shadow generator mode ESM: Exponential Shadow Mapping.
  82150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82151. */
  82152. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  82153. /**
  82154. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  82155. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  82156. */
  82157. static readonly FILTER_POISSONSAMPLING: number;
  82158. /**
  82159. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  82160. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82161. */
  82162. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  82163. /**
  82164. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  82165. * edge artifacts on steep falloff.
  82166. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82167. */
  82168. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  82169. /**
  82170. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  82171. * edge artifacts on steep falloff.
  82172. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82173. */
  82174. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  82175. /**
  82176. * Shadow generator mode PCF: Percentage Closer Filtering
  82177. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82178. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  82179. */
  82180. static readonly FILTER_PCF: number;
  82181. /**
  82182. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  82183. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82184. * Contact Hardening
  82185. */
  82186. static readonly FILTER_PCSS: number;
  82187. /**
  82188. * Reserved for PCF and PCSS
  82189. * Highest Quality.
  82190. *
  82191. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  82192. *
  82193. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  82194. */
  82195. static readonly QUALITY_HIGH: number;
  82196. /**
  82197. * Reserved for PCF and PCSS
  82198. * Good tradeoff for quality/perf cross devices
  82199. *
  82200. * Execute PCF on a 3*3 kernel.
  82201. *
  82202. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  82203. */
  82204. static readonly QUALITY_MEDIUM: number;
  82205. /**
  82206. * Reserved for PCF and PCSS
  82207. * The lowest quality but the fastest.
  82208. *
  82209. * Execute PCF on a 1*1 kernel.
  82210. *
  82211. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  82212. */
  82213. static readonly QUALITY_LOW: number;
  82214. /** Gets or sets the custom shader name to use */
  82215. customShaderOptions: ICustomShaderOptions;
  82216. /**
  82217. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  82218. */
  82219. onBeforeShadowMapRenderObservable: Observable<Effect>;
  82220. /**
  82221. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  82222. */
  82223. onAfterShadowMapRenderObservable: Observable<Effect>;
  82224. /**
  82225. * Observable triggered before a mesh is rendered in the shadow map.
  82226. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  82227. */
  82228. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  82229. /**
  82230. * Observable triggered after a mesh is rendered in the shadow map.
  82231. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  82232. */
  82233. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  82234. private _bias;
  82235. /**
  82236. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  82237. */
  82238. get bias(): number;
  82239. /**
  82240. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  82241. */
  82242. set bias(bias: number);
  82243. private _normalBias;
  82244. /**
  82245. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82246. */
  82247. get normalBias(): number;
  82248. /**
  82249. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82250. */
  82251. set normalBias(normalBias: number);
  82252. private _blurBoxOffset;
  82253. /**
  82254. * Gets the blur box offset: offset applied during the blur pass.
  82255. * Only useful if useKernelBlur = false
  82256. */
  82257. get blurBoxOffset(): number;
  82258. /**
  82259. * Sets the blur box offset: offset applied during the blur pass.
  82260. * Only useful if useKernelBlur = false
  82261. */
  82262. set blurBoxOffset(value: number);
  82263. private _blurScale;
  82264. /**
  82265. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  82266. * 2 means half of the size.
  82267. */
  82268. get blurScale(): number;
  82269. /**
  82270. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  82271. * 2 means half of the size.
  82272. */
  82273. set blurScale(value: number);
  82274. private _blurKernel;
  82275. /**
  82276. * Gets the blur kernel: kernel size of the blur pass.
  82277. * Only useful if useKernelBlur = true
  82278. */
  82279. get blurKernel(): number;
  82280. /**
  82281. * Sets the blur kernel: kernel size of the blur pass.
  82282. * Only useful if useKernelBlur = true
  82283. */
  82284. set blurKernel(value: number);
  82285. private _useKernelBlur;
  82286. /**
  82287. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  82288. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82289. */
  82290. get useKernelBlur(): boolean;
  82291. /**
  82292. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  82293. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82294. */
  82295. set useKernelBlur(value: boolean);
  82296. private _depthScale;
  82297. /**
  82298. * Gets the depth scale used in ESM mode.
  82299. */
  82300. get depthScale(): number;
  82301. /**
  82302. * Sets the depth scale used in ESM mode.
  82303. * This can override the scale stored on the light.
  82304. */
  82305. set depthScale(value: number);
  82306. private _filter;
  82307. /**
  82308. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  82309. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82310. */
  82311. get filter(): number;
  82312. /**
  82313. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  82314. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82315. */
  82316. set filter(value: number);
  82317. /**
  82318. * Gets if the current filter is set to Poisson Sampling.
  82319. */
  82320. get usePoissonSampling(): boolean;
  82321. /**
  82322. * Sets the current filter to Poisson Sampling.
  82323. */
  82324. set usePoissonSampling(value: boolean);
  82325. /**
  82326. * Gets if the current filter is set to ESM.
  82327. */
  82328. get useExponentialShadowMap(): boolean;
  82329. /**
  82330. * Sets the current filter is to ESM.
  82331. */
  82332. set useExponentialShadowMap(value: boolean);
  82333. /**
  82334. * Gets if the current filter is set to filtered ESM.
  82335. */
  82336. get useBlurExponentialShadowMap(): boolean;
  82337. /**
  82338. * Gets if the current filter is set to filtered ESM.
  82339. */
  82340. set useBlurExponentialShadowMap(value: boolean);
  82341. /**
  82342. * Gets if the current filter is set to "close ESM" (using the inverse of the
  82343. * exponential to prevent steep falloff artifacts).
  82344. */
  82345. get useCloseExponentialShadowMap(): boolean;
  82346. /**
  82347. * Sets the current filter to "close ESM" (using the inverse of the
  82348. * exponential to prevent steep falloff artifacts).
  82349. */
  82350. set useCloseExponentialShadowMap(value: boolean);
  82351. /**
  82352. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  82353. * exponential to prevent steep falloff artifacts).
  82354. */
  82355. get useBlurCloseExponentialShadowMap(): boolean;
  82356. /**
  82357. * Sets the current filter to filtered "close ESM" (using the inverse of the
  82358. * exponential to prevent steep falloff artifacts).
  82359. */
  82360. set useBlurCloseExponentialShadowMap(value: boolean);
  82361. /**
  82362. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  82363. */
  82364. get usePercentageCloserFiltering(): boolean;
  82365. /**
  82366. * Sets the current filter to "PCF" (percentage closer filtering).
  82367. */
  82368. set usePercentageCloserFiltering(value: boolean);
  82369. private _filteringQuality;
  82370. /**
  82371. * Gets the PCF or PCSS Quality.
  82372. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82373. */
  82374. get filteringQuality(): number;
  82375. /**
  82376. * Sets the PCF or PCSS Quality.
  82377. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82378. */
  82379. set filteringQuality(filteringQuality: number);
  82380. /**
  82381. * Gets if the current filter is set to "PCSS" (contact hardening).
  82382. */
  82383. get useContactHardeningShadow(): boolean;
  82384. /**
  82385. * Sets the current filter to "PCSS" (contact hardening).
  82386. */
  82387. set useContactHardeningShadow(value: boolean);
  82388. private _contactHardeningLightSizeUVRatio;
  82389. /**
  82390. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82391. * Using a ratio helps keeping shape stability independently of the map size.
  82392. *
  82393. * It does not account for the light projection as it was having too much
  82394. * instability during the light setup or during light position changes.
  82395. *
  82396. * Only valid if useContactHardeningShadow is true.
  82397. */
  82398. get contactHardeningLightSizeUVRatio(): number;
  82399. /**
  82400. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82401. * Using a ratio helps keeping shape stability independently of the map size.
  82402. *
  82403. * It does not account for the light projection as it was having too much
  82404. * instability during the light setup or during light position changes.
  82405. *
  82406. * Only valid if useContactHardeningShadow is true.
  82407. */
  82408. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  82409. private _darkness;
  82410. /** Gets or sets the actual darkness of a shadow */
  82411. get darkness(): number;
  82412. set darkness(value: number);
  82413. /**
  82414. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  82415. * 0 means strongest and 1 would means no shadow.
  82416. * @returns the darkness.
  82417. */
  82418. getDarkness(): number;
  82419. /**
  82420. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  82421. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  82422. * @returns the shadow generator allowing fluent coding.
  82423. */
  82424. setDarkness(darkness: number): ShadowGenerator;
  82425. private _transparencyShadow;
  82426. /** Gets or sets the ability to have transparent shadow */
  82427. get transparencyShadow(): boolean;
  82428. set transparencyShadow(value: boolean);
  82429. /**
  82430. * Sets the ability to have transparent shadow (boolean).
  82431. * @param transparent True if transparent else False
  82432. * @returns the shadow generator allowing fluent coding
  82433. */
  82434. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  82435. private _shadowMap;
  82436. private _shadowMap2;
  82437. /**
  82438. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82439. * @returns The render target texture if present otherwise, null
  82440. */
  82441. getShadowMap(): Nullable<RenderTargetTexture>;
  82442. /**
  82443. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  82444. * @returns The render target texture if the shadow map is present otherwise, null
  82445. */
  82446. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  82447. /**
  82448. * Gets the class name of that object
  82449. * @returns "ShadowGenerator"
  82450. */
  82451. getClassName(): string;
  82452. /**
  82453. * Helper function to add a mesh and its descendants to the list of shadow casters.
  82454. * @param mesh Mesh to add
  82455. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  82456. * @returns the Shadow Generator itself
  82457. */
  82458. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82459. /**
  82460. * Helper function to remove a mesh and its descendants from the list of shadow casters
  82461. * @param mesh Mesh to remove
  82462. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  82463. * @returns the Shadow Generator itself
  82464. */
  82465. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82466. /**
  82467. * Controls the extent to which the shadows fade out at the edge of the frustum
  82468. * Used only by directionals and spots
  82469. */
  82470. frustumEdgeFalloff: number;
  82471. private _light;
  82472. /**
  82473. * Returns the associated light object.
  82474. * @returns the light generating the shadow
  82475. */
  82476. getLight(): IShadowLight;
  82477. /**
  82478. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  82479. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  82480. * It might on the other hand introduce peter panning.
  82481. */
  82482. forceBackFacesOnly: boolean;
  82483. private _scene;
  82484. private _lightDirection;
  82485. private _effect;
  82486. private _viewMatrix;
  82487. private _projectionMatrix;
  82488. private _transformMatrix;
  82489. private _cachedPosition;
  82490. private _cachedDirection;
  82491. private _cachedDefines;
  82492. private _currentRenderID;
  82493. private _boxBlurPostprocess;
  82494. private _kernelBlurXPostprocess;
  82495. private _kernelBlurYPostprocess;
  82496. private _blurPostProcesses;
  82497. private _mapSize;
  82498. private _currentFaceIndex;
  82499. private _currentFaceIndexCache;
  82500. private _textureType;
  82501. private _defaultTextureMatrix;
  82502. private _storedUniqueId;
  82503. /** @hidden */
  82504. static _SceneComponentInitialization: (scene: Scene) => void;
  82505. /**
  82506. * Creates a ShadowGenerator object.
  82507. * A ShadowGenerator is the required tool to use the shadows.
  82508. * Each light casting shadows needs to use its own ShadowGenerator.
  82509. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  82510. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  82511. * @param light The light object generating the shadows.
  82512. * @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.
  82513. */
  82514. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  82515. private _initializeGenerator;
  82516. private _initializeShadowMap;
  82517. private _initializeBlurRTTAndPostProcesses;
  82518. private _renderForShadowMap;
  82519. private _renderSubMeshForShadowMap;
  82520. private _applyFilterValues;
  82521. /**
  82522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82523. * @param onCompiled Callback triggered at the and of the effects compilation
  82524. * @param options Sets of optional options forcing the compilation with different modes
  82525. */
  82526. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82527. useInstances: boolean;
  82528. }>): void;
  82529. /**
  82530. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82531. * @param options Sets of optional options forcing the compilation with different modes
  82532. * @returns A promise that resolves when the compilation completes
  82533. */
  82534. forceCompilationAsync(options?: Partial<{
  82535. useInstances: boolean;
  82536. }>): Promise<void>;
  82537. /**
  82538. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82539. * @param subMesh The submesh we want to render in the shadow map
  82540. * @param useInstances Defines wether will draw in the map using instances
  82541. * @returns true if ready otherwise, false
  82542. */
  82543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82544. /**
  82545. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82546. * @param defines Defines of the material we want to update
  82547. * @param lightIndex Index of the light in the enabled light list of the material
  82548. */
  82549. prepareDefines(defines: any, lightIndex: number): void;
  82550. /**
  82551. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82552. * defined in the generator but impacting the effect).
  82553. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82554. * @param effect The effect we are binfing the information for
  82555. */
  82556. bindShadowLight(lightIndex: string, effect: Effect): void;
  82557. /**
  82558. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82559. * (eq to shadow prjection matrix * light transform matrix)
  82560. * @returns The transform matrix used to create the shadow map
  82561. */
  82562. getTransformMatrix(): Matrix;
  82563. /**
  82564. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82565. * Cube and 2D textures for instance.
  82566. */
  82567. recreateShadowMap(): void;
  82568. private _disposeBlurPostProcesses;
  82569. private _disposeRTTandPostProcesses;
  82570. /**
  82571. * Disposes the ShadowGenerator.
  82572. * Returns nothing.
  82573. */
  82574. dispose(): void;
  82575. /**
  82576. * Serializes the shadow generator setup to a json object.
  82577. * @returns The serialized JSON object
  82578. */
  82579. serialize(): any;
  82580. /**
  82581. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  82582. * @param parsedShadowGenerator The JSON object to parse
  82583. * @param scene The scene to create the shadow map for
  82584. * @returns The parsed shadow generator
  82585. */
  82586. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  82587. }
  82588. }
  82589. declare module BABYLON {
  82590. /**
  82591. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  82592. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  82593. * 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.
  82594. */
  82595. export abstract class Light extends Node {
  82596. /**
  82597. * Falloff Default: light is falling off following the material specification:
  82598. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  82599. */
  82600. static readonly FALLOFF_DEFAULT: number;
  82601. /**
  82602. * Falloff Physical: light is falling off following the inverse squared distance law.
  82603. */
  82604. static readonly FALLOFF_PHYSICAL: number;
  82605. /**
  82606. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  82607. * to enhance interoperability with other engines.
  82608. */
  82609. static readonly FALLOFF_GLTF: number;
  82610. /**
  82611. * Falloff Standard: light is falling off like in the standard material
  82612. * to enhance interoperability with other materials.
  82613. */
  82614. static readonly FALLOFF_STANDARD: number;
  82615. /**
  82616. * If every light affecting the material is in this lightmapMode,
  82617. * material.lightmapTexture adds or multiplies
  82618. * (depends on material.useLightmapAsShadowmap)
  82619. * after every other light calculations.
  82620. */
  82621. static readonly LIGHTMAP_DEFAULT: number;
  82622. /**
  82623. * material.lightmapTexture as only diffuse lighting from this light
  82624. * adds only specular lighting from this light
  82625. * adds dynamic shadows
  82626. */
  82627. static readonly LIGHTMAP_SPECULAR: number;
  82628. /**
  82629. * material.lightmapTexture as only lighting
  82630. * no light calculation from this light
  82631. * only adds dynamic shadows from this light
  82632. */
  82633. static readonly LIGHTMAP_SHADOWSONLY: number;
  82634. /**
  82635. * Each light type uses the default quantity according to its type:
  82636. * point/spot lights use luminous intensity
  82637. * directional lights use illuminance
  82638. */
  82639. static readonly INTENSITYMODE_AUTOMATIC: number;
  82640. /**
  82641. * lumen (lm)
  82642. */
  82643. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  82644. /**
  82645. * candela (lm/sr)
  82646. */
  82647. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  82648. /**
  82649. * lux (lm/m^2)
  82650. */
  82651. static readonly INTENSITYMODE_ILLUMINANCE: number;
  82652. /**
  82653. * nit (cd/m^2)
  82654. */
  82655. static readonly INTENSITYMODE_LUMINANCE: number;
  82656. /**
  82657. * Light type const id of the point light.
  82658. */
  82659. static readonly LIGHTTYPEID_POINTLIGHT: number;
  82660. /**
  82661. * Light type const id of the directional light.
  82662. */
  82663. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  82664. /**
  82665. * Light type const id of the spot light.
  82666. */
  82667. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  82668. /**
  82669. * Light type const id of the hemispheric light.
  82670. */
  82671. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  82672. /**
  82673. * Diffuse gives the basic color to an object.
  82674. */
  82675. diffuse: Color3;
  82676. /**
  82677. * Specular produces a highlight color on an object.
  82678. * Note: This is note affecting PBR materials.
  82679. */
  82680. specular: Color3;
  82681. /**
  82682. * Defines the falloff type for this light. This lets overrriding how punctual light are
  82683. * falling off base on range or angle.
  82684. * This can be set to any values in Light.FALLOFF_x.
  82685. *
  82686. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  82687. * other types of materials.
  82688. */
  82689. falloffType: number;
  82690. /**
  82691. * Strength of the light.
  82692. * Note: By default it is define in the framework own unit.
  82693. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  82694. */
  82695. intensity: number;
  82696. private _range;
  82697. protected _inverseSquaredRange: number;
  82698. /**
  82699. * Defines how far from the source the light is impacting in scene units.
  82700. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82701. */
  82702. get range(): number;
  82703. /**
  82704. * Defines how far from the source the light is impacting in scene units.
  82705. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82706. */
  82707. set range(value: number);
  82708. /**
  82709. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  82710. * of light.
  82711. */
  82712. private _photometricScale;
  82713. private _intensityMode;
  82714. /**
  82715. * Gets the photometric scale used to interpret the intensity.
  82716. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82717. */
  82718. get intensityMode(): number;
  82719. /**
  82720. * Sets the photometric scale used to interpret the intensity.
  82721. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82722. */
  82723. set intensityMode(value: number);
  82724. private _radius;
  82725. /**
  82726. * Gets the light radius used by PBR Materials to simulate soft area lights.
  82727. */
  82728. get radius(): number;
  82729. /**
  82730. * sets the light radius used by PBR Materials to simulate soft area lights.
  82731. */
  82732. set radius(value: number);
  82733. private _renderPriority;
  82734. /**
  82735. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  82736. * exceeding the number allowed of the materials.
  82737. */
  82738. renderPriority: number;
  82739. private _shadowEnabled;
  82740. /**
  82741. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82742. * the current shadow generator.
  82743. */
  82744. get shadowEnabled(): boolean;
  82745. /**
  82746. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82747. * the current shadow generator.
  82748. */
  82749. set shadowEnabled(value: boolean);
  82750. private _includedOnlyMeshes;
  82751. /**
  82752. * Gets the only meshes impacted by this light.
  82753. */
  82754. get includedOnlyMeshes(): AbstractMesh[];
  82755. /**
  82756. * Sets the only meshes impacted by this light.
  82757. */
  82758. set includedOnlyMeshes(value: AbstractMesh[]);
  82759. private _excludedMeshes;
  82760. /**
  82761. * Gets the meshes not impacted by this light.
  82762. */
  82763. get excludedMeshes(): AbstractMesh[];
  82764. /**
  82765. * Sets the meshes not impacted by this light.
  82766. */
  82767. set excludedMeshes(value: AbstractMesh[]);
  82768. private _excludeWithLayerMask;
  82769. /**
  82770. * Gets the layer id use to find what meshes are not impacted by the light.
  82771. * Inactive if 0
  82772. */
  82773. get excludeWithLayerMask(): number;
  82774. /**
  82775. * Sets the layer id use to find what meshes are not impacted by the light.
  82776. * Inactive if 0
  82777. */
  82778. set excludeWithLayerMask(value: number);
  82779. private _includeOnlyWithLayerMask;
  82780. /**
  82781. * Gets the layer id use to find what meshes are impacted by the light.
  82782. * Inactive if 0
  82783. */
  82784. get includeOnlyWithLayerMask(): number;
  82785. /**
  82786. * Sets the layer id use to find what meshes are impacted by the light.
  82787. * Inactive if 0
  82788. */
  82789. set includeOnlyWithLayerMask(value: number);
  82790. private _lightmapMode;
  82791. /**
  82792. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82793. */
  82794. get lightmapMode(): number;
  82795. /**
  82796. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82797. */
  82798. set lightmapMode(value: number);
  82799. /**
  82800. * Shadow generator associted to the light.
  82801. * @hidden Internal use only.
  82802. */
  82803. _shadowGenerator: Nullable<IShadowGenerator>;
  82804. /**
  82805. * @hidden Internal use only.
  82806. */
  82807. _excludedMeshesIds: string[];
  82808. /**
  82809. * @hidden Internal use only.
  82810. */
  82811. _includedOnlyMeshesIds: string[];
  82812. /**
  82813. * The current light unifom buffer.
  82814. * @hidden Internal use only.
  82815. */
  82816. _uniformBuffer: UniformBuffer;
  82817. /** @hidden */
  82818. _renderId: number;
  82819. /**
  82820. * Creates a Light object in the scene.
  82821. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82822. * @param name The firendly name of the light
  82823. * @param scene The scene the light belongs too
  82824. */
  82825. constructor(name: string, scene: Scene);
  82826. protected abstract _buildUniformLayout(): void;
  82827. /**
  82828. * Sets the passed Effect "effect" with the Light information.
  82829. * @param effect The effect to update
  82830. * @param lightIndex The index of the light in the effect to update
  82831. * @returns The light
  82832. */
  82833. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  82834. /**
  82835. * Sets the passed Effect "effect" with the Light textures.
  82836. * @param effect The effect to update
  82837. * @param lightIndex The index of the light in the effect to update
  82838. * @returns The light
  82839. */
  82840. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  82841. /**
  82842. * Binds the lights information from the scene to the effect for the given mesh.
  82843. * @param lightIndex Light index
  82844. * @param scene The scene where the light belongs to
  82845. * @param effect The effect we are binding the data to
  82846. * @param useSpecular Defines if specular is supported
  82847. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82848. */
  82849. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82850. /**
  82851. * Sets the passed Effect "effect" with the Light information.
  82852. * @param effect The effect to update
  82853. * @param lightDataUniformName The uniform used to store light data (position or direction)
  82854. * @returns The light
  82855. */
  82856. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  82857. /**
  82858. * Returns the string "Light".
  82859. * @returns the class name
  82860. */
  82861. getClassName(): string;
  82862. /** @hidden */
  82863. readonly _isLight: boolean;
  82864. /**
  82865. * Converts the light information to a readable string for debug purpose.
  82866. * @param fullDetails Supports for multiple levels of logging within scene loading
  82867. * @returns the human readable light info
  82868. */
  82869. toString(fullDetails?: boolean): string;
  82870. /** @hidden */
  82871. protected _syncParentEnabledState(): void;
  82872. /**
  82873. * Set the enabled state of this node.
  82874. * @param value - the new enabled state
  82875. */
  82876. setEnabled(value: boolean): void;
  82877. /**
  82878. * Returns the Light associated shadow generator if any.
  82879. * @return the associated shadow generator.
  82880. */
  82881. getShadowGenerator(): Nullable<IShadowGenerator>;
  82882. /**
  82883. * Returns a Vector3, the absolute light position in the World.
  82884. * @returns the world space position of the light
  82885. */
  82886. getAbsolutePosition(): Vector3;
  82887. /**
  82888. * Specifies if the light will affect the passed mesh.
  82889. * @param mesh The mesh to test against the light
  82890. * @return true the mesh is affected otherwise, false.
  82891. */
  82892. canAffectMesh(mesh: AbstractMesh): boolean;
  82893. /**
  82894. * Sort function to order lights for rendering.
  82895. * @param a First Light object to compare to second.
  82896. * @param b Second Light object to compare first.
  82897. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  82898. */
  82899. static CompareLightsPriority(a: Light, b: Light): number;
  82900. /**
  82901. * Releases resources associated with this node.
  82902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82904. */
  82905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82906. /**
  82907. * Returns the light type ID (integer).
  82908. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82909. */
  82910. getTypeID(): number;
  82911. /**
  82912. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  82913. * @returns the scaled intensity in intensity mode unit
  82914. */
  82915. getScaledIntensity(): number;
  82916. /**
  82917. * Returns a new Light object, named "name", from the current one.
  82918. * @param name The name of the cloned light
  82919. * @returns the new created light
  82920. */
  82921. clone(name: string): Nullable<Light>;
  82922. /**
  82923. * Serializes the current light into a Serialization object.
  82924. * @returns the serialized object.
  82925. */
  82926. serialize(): any;
  82927. /**
  82928. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  82929. * This new light is named "name" and added to the passed scene.
  82930. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  82931. * @param name The friendly name of the light
  82932. * @param scene The scene the new light will belong to
  82933. * @returns the constructor function
  82934. */
  82935. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  82936. /**
  82937. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  82938. * @param parsedLight The JSON representation of the light
  82939. * @param scene The scene to create the parsed light in
  82940. * @returns the created light after parsing
  82941. */
  82942. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  82943. private _hookArrayForExcluded;
  82944. private _hookArrayForIncludedOnly;
  82945. private _resyncMeshes;
  82946. /**
  82947. * Forces the meshes to update their light related information in their rendering used effects
  82948. * @hidden Internal Use Only
  82949. */
  82950. _markMeshesAsLightDirty(): void;
  82951. /**
  82952. * Recomputes the cached photometric scale if needed.
  82953. */
  82954. private _computePhotometricScale;
  82955. /**
  82956. * Returns the Photometric Scale according to the light type and intensity mode.
  82957. */
  82958. private _getPhotometricScale;
  82959. /**
  82960. * Reorder the light in the scene according to their defined priority.
  82961. * @hidden Internal Use Only
  82962. */
  82963. _reorderLightsInScene(): void;
  82964. /**
  82965. * Prepares the list of defines specific to the light type.
  82966. * @param defines the list of defines
  82967. * @param lightIndex defines the index of the light for the effect
  82968. */
  82969. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82970. }
  82971. }
  82972. declare module BABYLON {
  82973. /**
  82974. * Interface used to define Action
  82975. */
  82976. export interface IAction {
  82977. /**
  82978. * Trigger for the action
  82979. */
  82980. trigger: number;
  82981. /** Options of the trigger */
  82982. triggerOptions: any;
  82983. /**
  82984. * Gets the trigger parameters
  82985. * @returns the trigger parameters
  82986. */
  82987. getTriggerParameter(): any;
  82988. /**
  82989. * Internal only - executes current action event
  82990. * @hidden
  82991. */
  82992. _executeCurrent(evt?: ActionEvent): void;
  82993. /**
  82994. * Serialize placeholder for child classes
  82995. * @param parent of child
  82996. * @returns the serialized object
  82997. */
  82998. serialize(parent: any): any;
  82999. /**
  83000. * Internal only
  83001. * @hidden
  83002. */
  83003. _prepare(): void;
  83004. /**
  83005. * Internal only - manager for action
  83006. * @hidden
  83007. */
  83008. _actionManager: AbstractActionManager;
  83009. /**
  83010. * Adds action to chain of actions, may be a DoNothingAction
  83011. * @param action defines the next action to execute
  83012. * @returns The action passed in
  83013. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83014. */
  83015. then(action: IAction): IAction;
  83016. }
  83017. /**
  83018. * The action to be carried out following a trigger
  83019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  83020. */
  83021. export class Action implements IAction {
  83022. /** the trigger, with or without parameters, for the action */
  83023. triggerOptions: any;
  83024. /**
  83025. * Trigger for the action
  83026. */
  83027. trigger: number;
  83028. /**
  83029. * Internal only - manager for action
  83030. * @hidden
  83031. */
  83032. _actionManager: ActionManager;
  83033. private _nextActiveAction;
  83034. private _child;
  83035. private _condition?;
  83036. private _triggerParameter;
  83037. /**
  83038. * An event triggered prior to action being executed.
  83039. */
  83040. onBeforeExecuteObservable: Observable<Action>;
  83041. /**
  83042. * Creates a new Action
  83043. * @param triggerOptions the trigger, with or without parameters, for the action
  83044. * @param condition an optional determinant of action
  83045. */
  83046. constructor(
  83047. /** the trigger, with or without parameters, for the action */
  83048. triggerOptions: any, condition?: Condition);
  83049. /**
  83050. * Internal only
  83051. * @hidden
  83052. */
  83053. _prepare(): void;
  83054. /**
  83055. * Gets the trigger parameters
  83056. * @returns the trigger parameters
  83057. */
  83058. getTriggerParameter(): any;
  83059. /**
  83060. * Internal only - executes current action event
  83061. * @hidden
  83062. */
  83063. _executeCurrent(evt?: ActionEvent): void;
  83064. /**
  83065. * Execute placeholder for child classes
  83066. * @param evt optional action event
  83067. */
  83068. execute(evt?: ActionEvent): void;
  83069. /**
  83070. * Skips to next active action
  83071. */
  83072. skipToNextActiveAction(): void;
  83073. /**
  83074. * Adds action to chain of actions, may be a DoNothingAction
  83075. * @param action defines the next action to execute
  83076. * @returns The action passed in
  83077. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83078. */
  83079. then(action: Action): Action;
  83080. /**
  83081. * Internal only
  83082. * @hidden
  83083. */
  83084. _getProperty(propertyPath: string): string;
  83085. /**
  83086. * Internal only
  83087. * @hidden
  83088. */
  83089. _getEffectiveTarget(target: any, propertyPath: string): any;
  83090. /**
  83091. * Serialize placeholder for child classes
  83092. * @param parent of child
  83093. * @returns the serialized object
  83094. */
  83095. serialize(parent: any): any;
  83096. /**
  83097. * Internal only called by serialize
  83098. * @hidden
  83099. */
  83100. protected _serialize(serializedAction: any, parent?: any): any;
  83101. /**
  83102. * Internal only
  83103. * @hidden
  83104. */
  83105. static _SerializeValueAsString: (value: any) => string;
  83106. /**
  83107. * Internal only
  83108. * @hidden
  83109. */
  83110. static _GetTargetProperty: (target: Node | Scene) => {
  83111. name: string;
  83112. targetType: string;
  83113. value: string;
  83114. };
  83115. }
  83116. }
  83117. declare module BABYLON {
  83118. /**
  83119. * A Condition applied to an Action
  83120. */
  83121. export class Condition {
  83122. /**
  83123. * Internal only - manager for action
  83124. * @hidden
  83125. */
  83126. _actionManager: ActionManager;
  83127. /**
  83128. * Internal only
  83129. * @hidden
  83130. */
  83131. _evaluationId: number;
  83132. /**
  83133. * Internal only
  83134. * @hidden
  83135. */
  83136. _currentResult: boolean;
  83137. /**
  83138. * Creates a new Condition
  83139. * @param actionManager the manager of the action the condition is applied to
  83140. */
  83141. constructor(actionManager: ActionManager);
  83142. /**
  83143. * Check if the current condition is valid
  83144. * @returns a boolean
  83145. */
  83146. isValid(): boolean;
  83147. /**
  83148. * Internal only
  83149. * @hidden
  83150. */
  83151. _getProperty(propertyPath: string): string;
  83152. /**
  83153. * Internal only
  83154. * @hidden
  83155. */
  83156. _getEffectiveTarget(target: any, propertyPath: string): any;
  83157. /**
  83158. * Serialize placeholder for child classes
  83159. * @returns the serialized object
  83160. */
  83161. serialize(): any;
  83162. /**
  83163. * Internal only
  83164. * @hidden
  83165. */
  83166. protected _serialize(serializedCondition: any): any;
  83167. }
  83168. /**
  83169. * Defines specific conditional operators as extensions of Condition
  83170. */
  83171. export class ValueCondition extends Condition {
  83172. /** path to specify the property of the target the conditional operator uses */
  83173. propertyPath: string;
  83174. /** the value compared by the conditional operator against the current value of the property */
  83175. value: any;
  83176. /** the conditional operator, default ValueCondition.IsEqual */
  83177. operator: number;
  83178. /**
  83179. * Internal only
  83180. * @hidden
  83181. */
  83182. private static _IsEqual;
  83183. /**
  83184. * Internal only
  83185. * @hidden
  83186. */
  83187. private static _IsDifferent;
  83188. /**
  83189. * Internal only
  83190. * @hidden
  83191. */
  83192. private static _IsGreater;
  83193. /**
  83194. * Internal only
  83195. * @hidden
  83196. */
  83197. private static _IsLesser;
  83198. /**
  83199. * returns the number for IsEqual
  83200. */
  83201. static get IsEqual(): number;
  83202. /**
  83203. * Returns the number for IsDifferent
  83204. */
  83205. static get IsDifferent(): number;
  83206. /**
  83207. * Returns the number for IsGreater
  83208. */
  83209. static get IsGreater(): number;
  83210. /**
  83211. * Returns the number for IsLesser
  83212. */
  83213. static get IsLesser(): number;
  83214. /**
  83215. * Internal only The action manager for the condition
  83216. * @hidden
  83217. */
  83218. _actionManager: ActionManager;
  83219. /**
  83220. * Internal only
  83221. * @hidden
  83222. */
  83223. private _target;
  83224. /**
  83225. * Internal only
  83226. * @hidden
  83227. */
  83228. private _effectiveTarget;
  83229. /**
  83230. * Internal only
  83231. * @hidden
  83232. */
  83233. private _property;
  83234. /**
  83235. * Creates a new ValueCondition
  83236. * @param actionManager manager for the action the condition applies to
  83237. * @param target for the action
  83238. * @param propertyPath path to specify the property of the target the conditional operator uses
  83239. * @param value the value compared by the conditional operator against the current value of the property
  83240. * @param operator the conditional operator, default ValueCondition.IsEqual
  83241. */
  83242. constructor(actionManager: ActionManager, target: any,
  83243. /** path to specify the property of the target the conditional operator uses */
  83244. propertyPath: string,
  83245. /** the value compared by the conditional operator against the current value of the property */
  83246. value: any,
  83247. /** the conditional operator, default ValueCondition.IsEqual */
  83248. operator?: number);
  83249. /**
  83250. * Compares the given value with the property value for the specified conditional operator
  83251. * @returns the result of the comparison
  83252. */
  83253. isValid(): boolean;
  83254. /**
  83255. * Serialize the ValueCondition into a JSON compatible object
  83256. * @returns serialization object
  83257. */
  83258. serialize(): any;
  83259. /**
  83260. * Gets the name of the conditional operator for the ValueCondition
  83261. * @param operator the conditional operator
  83262. * @returns the name
  83263. */
  83264. static GetOperatorName(operator: number): string;
  83265. }
  83266. /**
  83267. * Defines a predicate condition as an extension of Condition
  83268. */
  83269. export class PredicateCondition extends Condition {
  83270. /** defines the predicate function used to validate the condition */
  83271. predicate: () => boolean;
  83272. /**
  83273. * Internal only - manager for action
  83274. * @hidden
  83275. */
  83276. _actionManager: ActionManager;
  83277. /**
  83278. * Creates a new PredicateCondition
  83279. * @param actionManager manager for the action the condition applies to
  83280. * @param predicate defines the predicate function used to validate the condition
  83281. */
  83282. constructor(actionManager: ActionManager,
  83283. /** defines the predicate function used to validate the condition */
  83284. predicate: () => boolean);
  83285. /**
  83286. * @returns the validity of the predicate condition
  83287. */
  83288. isValid(): boolean;
  83289. }
  83290. /**
  83291. * Defines a state condition as an extension of Condition
  83292. */
  83293. export class StateCondition extends Condition {
  83294. /** Value to compare with target state */
  83295. value: string;
  83296. /**
  83297. * Internal only - manager for action
  83298. * @hidden
  83299. */
  83300. _actionManager: ActionManager;
  83301. /**
  83302. * Internal only
  83303. * @hidden
  83304. */
  83305. private _target;
  83306. /**
  83307. * Creates a new StateCondition
  83308. * @param actionManager manager for the action the condition applies to
  83309. * @param target of the condition
  83310. * @param value to compare with target state
  83311. */
  83312. constructor(actionManager: ActionManager, target: any,
  83313. /** Value to compare with target state */
  83314. value: string);
  83315. /**
  83316. * Gets a boolean indicating if the current condition is met
  83317. * @returns the validity of the state
  83318. */
  83319. isValid(): boolean;
  83320. /**
  83321. * Serialize the StateCondition into a JSON compatible object
  83322. * @returns serialization object
  83323. */
  83324. serialize(): any;
  83325. }
  83326. }
  83327. declare module BABYLON {
  83328. /**
  83329. * This defines an action responsible to toggle a boolean once triggered.
  83330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83331. */
  83332. export class SwitchBooleanAction extends Action {
  83333. /**
  83334. * The path to the boolean property in the target object
  83335. */
  83336. propertyPath: string;
  83337. private _target;
  83338. private _effectiveTarget;
  83339. private _property;
  83340. /**
  83341. * Instantiate the action
  83342. * @param triggerOptions defines the trigger options
  83343. * @param target defines the object containing the boolean
  83344. * @param propertyPath defines the path to the boolean property in the target object
  83345. * @param condition defines the trigger related conditions
  83346. */
  83347. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  83348. /** @hidden */
  83349. _prepare(): void;
  83350. /**
  83351. * Execute the action toggle the boolean value.
  83352. */
  83353. execute(): void;
  83354. /**
  83355. * Serializes the actions and its related information.
  83356. * @param parent defines the object to serialize in
  83357. * @returns the serialized object
  83358. */
  83359. serialize(parent: any): any;
  83360. }
  83361. /**
  83362. * This defines an action responsible to set a the state field of the target
  83363. * to a desired value once triggered.
  83364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83365. */
  83366. export class SetStateAction extends Action {
  83367. /**
  83368. * The value to store in the state field.
  83369. */
  83370. value: string;
  83371. private _target;
  83372. /**
  83373. * Instantiate the action
  83374. * @param triggerOptions defines the trigger options
  83375. * @param target defines the object containing the state property
  83376. * @param value defines the value to store in the state field
  83377. * @param condition defines the trigger related conditions
  83378. */
  83379. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  83380. /**
  83381. * Execute the action and store the value on the target state property.
  83382. */
  83383. execute(): void;
  83384. /**
  83385. * Serializes the actions and its related information.
  83386. * @param parent defines the object to serialize in
  83387. * @returns the serialized object
  83388. */
  83389. serialize(parent: any): any;
  83390. }
  83391. /**
  83392. * This defines an action responsible to set a property of the target
  83393. * to a desired value once triggered.
  83394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83395. */
  83396. export class SetValueAction extends Action {
  83397. /**
  83398. * The path of the property to set in the target.
  83399. */
  83400. propertyPath: string;
  83401. /**
  83402. * The value to set in the property
  83403. */
  83404. value: any;
  83405. private _target;
  83406. private _effectiveTarget;
  83407. private _property;
  83408. /**
  83409. * Instantiate the action
  83410. * @param triggerOptions defines the trigger options
  83411. * @param target defines the object containing the property
  83412. * @param propertyPath defines the path of the property to set in the target
  83413. * @param value defines the value to set in the property
  83414. * @param condition defines the trigger related conditions
  83415. */
  83416. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83417. /** @hidden */
  83418. _prepare(): void;
  83419. /**
  83420. * Execute the action and set the targetted property to the desired value.
  83421. */
  83422. execute(): void;
  83423. /**
  83424. * Serializes the actions and its related information.
  83425. * @param parent defines the object to serialize in
  83426. * @returns the serialized object
  83427. */
  83428. serialize(parent: any): any;
  83429. }
  83430. /**
  83431. * This defines an action responsible to increment the target value
  83432. * to a desired value once triggered.
  83433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83434. */
  83435. export class IncrementValueAction extends Action {
  83436. /**
  83437. * The path of the property to increment in the target.
  83438. */
  83439. propertyPath: string;
  83440. /**
  83441. * The value we should increment the property by.
  83442. */
  83443. value: any;
  83444. private _target;
  83445. private _effectiveTarget;
  83446. private _property;
  83447. /**
  83448. * Instantiate the action
  83449. * @param triggerOptions defines the trigger options
  83450. * @param target defines the object containing the property
  83451. * @param propertyPath defines the path of the property to increment in the target
  83452. * @param value defines the value value we should increment the property by
  83453. * @param condition defines the trigger related conditions
  83454. */
  83455. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83456. /** @hidden */
  83457. _prepare(): void;
  83458. /**
  83459. * Execute the action and increment the target of the value amount.
  83460. */
  83461. execute(): void;
  83462. /**
  83463. * Serializes the actions and its related information.
  83464. * @param parent defines the object to serialize in
  83465. * @returns the serialized object
  83466. */
  83467. serialize(parent: any): any;
  83468. }
  83469. /**
  83470. * This defines an action responsible to start an animation once triggered.
  83471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83472. */
  83473. export class PlayAnimationAction extends Action {
  83474. /**
  83475. * Where the animation should start (animation frame)
  83476. */
  83477. from: number;
  83478. /**
  83479. * Where the animation should stop (animation frame)
  83480. */
  83481. to: number;
  83482. /**
  83483. * Define if the animation should loop or stop after the first play.
  83484. */
  83485. loop?: boolean;
  83486. private _target;
  83487. /**
  83488. * Instantiate the action
  83489. * @param triggerOptions defines the trigger options
  83490. * @param target defines the target animation or animation name
  83491. * @param from defines from where the animation should start (animation frame)
  83492. * @param end defines where the animation should stop (animation frame)
  83493. * @param loop defines if the animation should loop or stop after the first play
  83494. * @param condition defines the trigger related conditions
  83495. */
  83496. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  83497. /** @hidden */
  83498. _prepare(): void;
  83499. /**
  83500. * Execute the action and play the animation.
  83501. */
  83502. execute(): void;
  83503. /**
  83504. * Serializes the actions and its related information.
  83505. * @param parent defines the object to serialize in
  83506. * @returns the serialized object
  83507. */
  83508. serialize(parent: any): any;
  83509. }
  83510. /**
  83511. * This defines an action responsible to stop an animation once triggered.
  83512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83513. */
  83514. export class StopAnimationAction extends Action {
  83515. private _target;
  83516. /**
  83517. * Instantiate the action
  83518. * @param triggerOptions defines the trigger options
  83519. * @param target defines the target animation or animation name
  83520. * @param condition defines the trigger related conditions
  83521. */
  83522. constructor(triggerOptions: any, target: any, condition?: Condition);
  83523. /** @hidden */
  83524. _prepare(): void;
  83525. /**
  83526. * Execute the action and stop the animation.
  83527. */
  83528. execute(): void;
  83529. /**
  83530. * Serializes the actions and its related information.
  83531. * @param parent defines the object to serialize in
  83532. * @returns the serialized object
  83533. */
  83534. serialize(parent: any): any;
  83535. }
  83536. /**
  83537. * This defines an action responsible that does nothing once triggered.
  83538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83539. */
  83540. export class DoNothingAction extends Action {
  83541. /**
  83542. * Instantiate the action
  83543. * @param triggerOptions defines the trigger options
  83544. * @param condition defines the trigger related conditions
  83545. */
  83546. constructor(triggerOptions?: any, condition?: Condition);
  83547. /**
  83548. * Execute the action and do nothing.
  83549. */
  83550. execute(): void;
  83551. /**
  83552. * Serializes the actions and its related information.
  83553. * @param parent defines the object to serialize in
  83554. * @returns the serialized object
  83555. */
  83556. serialize(parent: any): any;
  83557. }
  83558. /**
  83559. * This defines an action responsible to trigger several actions once triggered.
  83560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83561. */
  83562. export class CombineAction extends Action {
  83563. /**
  83564. * The list of aggregated animations to run.
  83565. */
  83566. children: Action[];
  83567. /**
  83568. * Instantiate the action
  83569. * @param triggerOptions defines the trigger options
  83570. * @param children defines the list of aggregated animations to run
  83571. * @param condition defines the trigger related conditions
  83572. */
  83573. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  83574. /** @hidden */
  83575. _prepare(): void;
  83576. /**
  83577. * Execute the action and executes all the aggregated actions.
  83578. */
  83579. execute(evt: ActionEvent): void;
  83580. /**
  83581. * Serializes the actions and its related information.
  83582. * @param parent defines the object to serialize in
  83583. * @returns the serialized object
  83584. */
  83585. serialize(parent: any): any;
  83586. }
  83587. /**
  83588. * This defines an action responsible to run code (external event) once triggered.
  83589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83590. */
  83591. export class ExecuteCodeAction extends Action {
  83592. /**
  83593. * The callback function to run.
  83594. */
  83595. func: (evt: ActionEvent) => void;
  83596. /**
  83597. * Instantiate the action
  83598. * @param triggerOptions defines the trigger options
  83599. * @param func defines the callback function to run
  83600. * @param condition defines the trigger related conditions
  83601. */
  83602. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  83603. /**
  83604. * Execute the action and run the attached code.
  83605. */
  83606. execute(evt: ActionEvent): void;
  83607. }
  83608. /**
  83609. * This defines an action responsible to set the parent property of the target once triggered.
  83610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83611. */
  83612. export class SetParentAction extends Action {
  83613. private _parent;
  83614. private _target;
  83615. /**
  83616. * Instantiate the action
  83617. * @param triggerOptions defines the trigger options
  83618. * @param target defines the target containing the parent property
  83619. * @param parent defines from where the animation should start (animation frame)
  83620. * @param condition defines the trigger related conditions
  83621. */
  83622. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  83623. /** @hidden */
  83624. _prepare(): void;
  83625. /**
  83626. * Execute the action and set the parent property.
  83627. */
  83628. execute(): void;
  83629. /**
  83630. * Serializes the actions and its related information.
  83631. * @param parent defines the object to serialize in
  83632. * @returns the serialized object
  83633. */
  83634. serialize(parent: any): any;
  83635. }
  83636. }
  83637. declare module BABYLON {
  83638. /**
  83639. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  83640. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  83641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83642. */
  83643. export class ActionManager extends AbstractActionManager {
  83644. /**
  83645. * Nothing
  83646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83647. */
  83648. static readonly NothingTrigger: number;
  83649. /**
  83650. * On pick
  83651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83652. */
  83653. static readonly OnPickTrigger: number;
  83654. /**
  83655. * On left pick
  83656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83657. */
  83658. static readonly OnLeftPickTrigger: number;
  83659. /**
  83660. * On right pick
  83661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83662. */
  83663. static readonly OnRightPickTrigger: number;
  83664. /**
  83665. * On center pick
  83666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83667. */
  83668. static readonly OnCenterPickTrigger: number;
  83669. /**
  83670. * On pick down
  83671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83672. */
  83673. static readonly OnPickDownTrigger: number;
  83674. /**
  83675. * On double pick
  83676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83677. */
  83678. static readonly OnDoublePickTrigger: number;
  83679. /**
  83680. * On pick up
  83681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83682. */
  83683. static readonly OnPickUpTrigger: number;
  83684. /**
  83685. * On pick out.
  83686. * This trigger will only be raised if you also declared a OnPickDown
  83687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83688. */
  83689. static readonly OnPickOutTrigger: number;
  83690. /**
  83691. * On long press
  83692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83693. */
  83694. static readonly OnLongPressTrigger: number;
  83695. /**
  83696. * On pointer over
  83697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83698. */
  83699. static readonly OnPointerOverTrigger: number;
  83700. /**
  83701. * On pointer out
  83702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83703. */
  83704. static readonly OnPointerOutTrigger: number;
  83705. /**
  83706. * On every frame
  83707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83708. */
  83709. static readonly OnEveryFrameTrigger: number;
  83710. /**
  83711. * On intersection enter
  83712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83713. */
  83714. static readonly OnIntersectionEnterTrigger: number;
  83715. /**
  83716. * On intersection exit
  83717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83718. */
  83719. static readonly OnIntersectionExitTrigger: number;
  83720. /**
  83721. * On key down
  83722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83723. */
  83724. static readonly OnKeyDownTrigger: number;
  83725. /**
  83726. * On key up
  83727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83728. */
  83729. static readonly OnKeyUpTrigger: number;
  83730. private _scene;
  83731. /**
  83732. * Creates a new action manager
  83733. * @param scene defines the hosting scene
  83734. */
  83735. constructor(scene: Scene);
  83736. /**
  83737. * Releases all associated resources
  83738. */
  83739. dispose(): void;
  83740. /**
  83741. * Gets hosting scene
  83742. * @returns the hosting scene
  83743. */
  83744. getScene(): Scene;
  83745. /**
  83746. * Does this action manager handles actions of any of the given triggers
  83747. * @param triggers defines the triggers to be tested
  83748. * @return a boolean indicating whether one (or more) of the triggers is handled
  83749. */
  83750. hasSpecificTriggers(triggers: number[]): boolean;
  83751. /**
  83752. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83753. * speed.
  83754. * @param triggerA defines the trigger to be tested
  83755. * @param triggerB defines the trigger to be tested
  83756. * @return a boolean indicating whether one (or more) of the triggers is handled
  83757. */
  83758. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83759. /**
  83760. * Does this action manager handles actions of a given trigger
  83761. * @param trigger defines the trigger to be tested
  83762. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83763. * @return whether the trigger is handled
  83764. */
  83765. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83766. /**
  83767. * Does this action manager has pointer triggers
  83768. */
  83769. get hasPointerTriggers(): boolean;
  83770. /**
  83771. * Does this action manager has pick triggers
  83772. */
  83773. get hasPickTriggers(): boolean;
  83774. /**
  83775. * Registers an action to this action manager
  83776. * @param action defines the action to be registered
  83777. * @return the action amended (prepared) after registration
  83778. */
  83779. registerAction(action: IAction): Nullable<IAction>;
  83780. /**
  83781. * Unregisters an action to this action manager
  83782. * @param action defines the action to be unregistered
  83783. * @return a boolean indicating whether the action has been unregistered
  83784. */
  83785. unregisterAction(action: IAction): Boolean;
  83786. /**
  83787. * Process a specific trigger
  83788. * @param trigger defines the trigger to process
  83789. * @param evt defines the event details to be processed
  83790. */
  83791. processTrigger(trigger: number, evt?: IActionEvent): void;
  83792. /** @hidden */
  83793. _getEffectiveTarget(target: any, propertyPath: string): any;
  83794. /** @hidden */
  83795. _getProperty(propertyPath: string): string;
  83796. /**
  83797. * Serialize this manager to a JSON object
  83798. * @param name defines the property name to store this manager
  83799. * @returns a JSON representation of this manager
  83800. */
  83801. serialize(name: string): any;
  83802. /**
  83803. * Creates a new ActionManager from a JSON data
  83804. * @param parsedActions defines the JSON data to read from
  83805. * @param object defines the hosting mesh
  83806. * @param scene defines the hosting scene
  83807. */
  83808. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  83809. /**
  83810. * Get a trigger name by index
  83811. * @param trigger defines the trigger index
  83812. * @returns a trigger name
  83813. */
  83814. static GetTriggerName(trigger: number): string;
  83815. }
  83816. }
  83817. declare module BABYLON {
  83818. /**
  83819. * Class representing a ray with position and direction
  83820. */
  83821. export class Ray {
  83822. /** origin point */
  83823. origin: Vector3;
  83824. /** direction */
  83825. direction: Vector3;
  83826. /** length of the ray */
  83827. length: number;
  83828. private static readonly TmpVector3;
  83829. private _tmpRay;
  83830. /**
  83831. * Creates a new ray
  83832. * @param origin origin point
  83833. * @param direction direction
  83834. * @param length length of the ray
  83835. */
  83836. constructor(
  83837. /** origin point */
  83838. origin: Vector3,
  83839. /** direction */
  83840. direction: Vector3,
  83841. /** length of the ray */
  83842. length?: number);
  83843. /**
  83844. * Checks if the ray intersects a box
  83845. * @param minimum bound of the box
  83846. * @param maximum bound of the box
  83847. * @param intersectionTreshold extra extend to be added to the box in all direction
  83848. * @returns if the box was hit
  83849. */
  83850. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83851. /**
  83852. * Checks if the ray intersects a box
  83853. * @param box the bounding box to check
  83854. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83855. * @returns if the box was hit
  83856. */
  83857. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83858. /**
  83859. * If the ray hits a sphere
  83860. * @param sphere the bounding sphere to check
  83861. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83862. * @returns true if it hits the sphere
  83863. */
  83864. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83865. /**
  83866. * If the ray hits a triange
  83867. * @param vertex0 triangle vertex
  83868. * @param vertex1 triangle vertex
  83869. * @param vertex2 triangle vertex
  83870. * @returns intersection information if hit
  83871. */
  83872. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83873. /**
  83874. * Checks if ray intersects a plane
  83875. * @param plane the plane to check
  83876. * @returns the distance away it was hit
  83877. */
  83878. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83879. /**
  83880. * Calculate the intercept of a ray on a given axis
  83881. * @param axis to check 'x' | 'y' | 'z'
  83882. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83883. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83884. */
  83885. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83886. /**
  83887. * Checks if ray intersects a mesh
  83888. * @param mesh the mesh to check
  83889. * @param fastCheck if only the bounding box should checked
  83890. * @returns picking info of the intersecton
  83891. */
  83892. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83893. /**
  83894. * Checks if ray intersects a mesh
  83895. * @param meshes the meshes to check
  83896. * @param fastCheck if only the bounding box should checked
  83897. * @param results array to store result in
  83898. * @returns Array of picking infos
  83899. */
  83900. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83901. private _comparePickingInfo;
  83902. private static smallnum;
  83903. private static rayl;
  83904. /**
  83905. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83906. * @param sega the first point of the segment to test the intersection against
  83907. * @param segb the second point of the segment to test the intersection against
  83908. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83909. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83910. */
  83911. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83912. /**
  83913. * Update the ray from viewport position
  83914. * @param x position
  83915. * @param y y position
  83916. * @param viewportWidth viewport width
  83917. * @param viewportHeight viewport height
  83918. * @param world world matrix
  83919. * @param view view matrix
  83920. * @param projection projection matrix
  83921. * @returns this ray updated
  83922. */
  83923. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83924. /**
  83925. * Creates a ray with origin and direction of 0,0,0
  83926. * @returns the new ray
  83927. */
  83928. static Zero(): Ray;
  83929. /**
  83930. * Creates a new ray from screen space and viewport
  83931. * @param x position
  83932. * @param y y position
  83933. * @param viewportWidth viewport width
  83934. * @param viewportHeight viewport height
  83935. * @param world world matrix
  83936. * @param view view matrix
  83937. * @param projection projection matrix
  83938. * @returns new ray
  83939. */
  83940. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83941. /**
  83942. * 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
  83943. * transformed to the given world matrix.
  83944. * @param origin The origin point
  83945. * @param end The end point
  83946. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83947. * @returns the new ray
  83948. */
  83949. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83950. /**
  83951. * Transforms a ray by a matrix
  83952. * @param ray ray to transform
  83953. * @param matrix matrix to apply
  83954. * @returns the resulting new ray
  83955. */
  83956. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83957. /**
  83958. * Transforms a ray by a matrix
  83959. * @param ray ray to transform
  83960. * @param matrix matrix to apply
  83961. * @param result ray to store result in
  83962. */
  83963. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83964. /**
  83965. * Unproject a ray from screen space to object space
  83966. * @param sourceX defines the screen space x coordinate to use
  83967. * @param sourceY defines the screen space y coordinate to use
  83968. * @param viewportWidth defines the current width of the viewport
  83969. * @param viewportHeight defines the current height of the viewport
  83970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83971. * @param view defines the view matrix to use
  83972. * @param projection defines the projection matrix to use
  83973. */
  83974. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83975. }
  83976. /**
  83977. * Type used to define predicate used to select faces when a mesh intersection is detected
  83978. */
  83979. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83980. interface Scene {
  83981. /** @hidden */
  83982. _tempPickingRay: Nullable<Ray>;
  83983. /** @hidden */
  83984. _cachedRayForTransform: Ray;
  83985. /** @hidden */
  83986. _pickWithRayInverseMatrix: Matrix;
  83987. /** @hidden */
  83988. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83989. /** @hidden */
  83990. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83991. }
  83992. }
  83993. declare module BABYLON {
  83994. /**
  83995. * Groups all the scene component constants in one place to ease maintenance.
  83996. * @hidden
  83997. */
  83998. export class SceneComponentConstants {
  83999. static readonly NAME_EFFECTLAYER: string;
  84000. static readonly NAME_LAYER: string;
  84001. static readonly NAME_LENSFLARESYSTEM: string;
  84002. static readonly NAME_BOUNDINGBOXRENDERER: string;
  84003. static readonly NAME_PARTICLESYSTEM: string;
  84004. static readonly NAME_GAMEPAD: string;
  84005. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  84006. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  84007. static readonly NAME_DEPTHRENDERER: string;
  84008. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  84009. static readonly NAME_SPRITE: string;
  84010. static readonly NAME_OUTLINERENDERER: string;
  84011. static readonly NAME_PROCEDURALTEXTURE: string;
  84012. static readonly NAME_SHADOWGENERATOR: string;
  84013. static readonly NAME_OCTREE: string;
  84014. static readonly NAME_PHYSICSENGINE: string;
  84015. static readonly NAME_AUDIO: string;
  84016. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  84017. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84018. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  84019. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84020. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  84021. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  84022. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  84023. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  84024. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  84025. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  84026. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  84027. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  84028. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  84029. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  84030. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  84031. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  84032. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  84033. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  84034. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  84035. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  84036. static readonly STEP_AFTERRENDER_AUDIO: number;
  84037. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  84038. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  84039. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  84040. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  84041. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  84042. static readonly STEP_POINTERMOVE_SPRITE: number;
  84043. static readonly STEP_POINTERDOWN_SPRITE: number;
  84044. static readonly STEP_POINTERUP_SPRITE: number;
  84045. }
  84046. /**
  84047. * This represents a scene component.
  84048. *
  84049. * This is used to decouple the dependency the scene is having on the different workloads like
  84050. * layers, post processes...
  84051. */
  84052. export interface ISceneComponent {
  84053. /**
  84054. * The name of the component. Each component must have a unique name.
  84055. */
  84056. name: string;
  84057. /**
  84058. * The scene the component belongs to.
  84059. */
  84060. scene: Scene;
  84061. /**
  84062. * Register the component to one instance of a scene.
  84063. */
  84064. register(): void;
  84065. /**
  84066. * Rebuilds the elements related to this component in case of
  84067. * context lost for instance.
  84068. */
  84069. rebuild(): void;
  84070. /**
  84071. * Disposes the component and the associated ressources.
  84072. */
  84073. dispose(): void;
  84074. }
  84075. /**
  84076. * This represents a SERIALIZABLE scene component.
  84077. *
  84078. * This extends Scene Component to add Serialization methods on top.
  84079. */
  84080. export interface ISceneSerializableComponent extends ISceneComponent {
  84081. /**
  84082. * Adds all the elements from the container to the scene
  84083. * @param container the container holding the elements
  84084. */
  84085. addFromContainer(container: AbstractScene): void;
  84086. /**
  84087. * Removes all the elements in the container from the scene
  84088. * @param container contains the elements to remove
  84089. * @param dispose if the removed element should be disposed (default: false)
  84090. */
  84091. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84092. /**
  84093. * Serializes the component data to the specified json object
  84094. * @param serializationObject The object to serialize to
  84095. */
  84096. serialize(serializationObject: any): void;
  84097. }
  84098. /**
  84099. * Strong typing of a Mesh related stage step action
  84100. */
  84101. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84102. /**
  84103. * Strong typing of a Evaluate Sub Mesh related stage step action
  84104. */
  84105. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84106. /**
  84107. * Strong typing of a Active Mesh related stage step action
  84108. */
  84109. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84110. /**
  84111. * Strong typing of a Camera related stage step action
  84112. */
  84113. export type CameraStageAction = (camera: Camera) => void;
  84114. /**
  84115. * Strong typing of a Camera Frame buffer related stage step action
  84116. */
  84117. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84118. /**
  84119. * Strong typing of a Render Target related stage step action
  84120. */
  84121. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84122. /**
  84123. * Strong typing of a RenderingGroup related stage step action
  84124. */
  84125. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84126. /**
  84127. * Strong typing of a Mesh Render related stage step action
  84128. */
  84129. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84130. /**
  84131. * Strong typing of a simple stage step action
  84132. */
  84133. export type SimpleStageAction = () => void;
  84134. /**
  84135. * Strong typing of a render target action.
  84136. */
  84137. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84138. /**
  84139. * Strong typing of a pointer move action.
  84140. */
  84141. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84142. /**
  84143. * Strong typing of a pointer up/down action.
  84144. */
  84145. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84146. /**
  84147. * Representation of a stage in the scene (Basically a list of ordered steps)
  84148. * @hidden
  84149. */
  84150. export class Stage<T extends Function> extends Array<{
  84151. index: number;
  84152. component: ISceneComponent;
  84153. action: T;
  84154. }> {
  84155. /**
  84156. * Hide ctor from the rest of the world.
  84157. * @param items The items to add.
  84158. */
  84159. private constructor();
  84160. /**
  84161. * Creates a new Stage.
  84162. * @returns A new instance of a Stage
  84163. */
  84164. static Create<T extends Function>(): Stage<T>;
  84165. /**
  84166. * Registers a step in an ordered way in the targeted stage.
  84167. * @param index Defines the position to register the step in
  84168. * @param component Defines the component attached to the step
  84169. * @param action Defines the action to launch during the step
  84170. */
  84171. registerStep(index: number, component: ISceneComponent, action: T): void;
  84172. /**
  84173. * Clears all the steps from the stage.
  84174. */
  84175. clear(): void;
  84176. }
  84177. }
  84178. declare module BABYLON {
  84179. interface Scene {
  84180. /** @hidden */
  84181. _pointerOverSprite: Nullable<Sprite>;
  84182. /** @hidden */
  84183. _pickedDownSprite: Nullable<Sprite>;
  84184. /** @hidden */
  84185. _tempSpritePickingRay: Nullable<Ray>;
  84186. /**
  84187. * All of the sprite managers added to this scene
  84188. * @see http://doc.babylonjs.com/babylon101/sprites
  84189. */
  84190. spriteManagers: Array<ISpriteManager>;
  84191. /**
  84192. * An event triggered when sprites rendering is about to start
  84193. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84194. */
  84195. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84196. /**
  84197. * An event triggered when sprites rendering is done
  84198. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84199. */
  84200. onAfterSpritesRenderingObservable: Observable<Scene>;
  84201. /** @hidden */
  84202. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84203. /** Launch a ray to try to pick a sprite in the scene
  84204. * @param x position on screen
  84205. * @param y position on screen
  84206. * @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
  84207. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84208. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84209. * @returns a PickingInfo
  84210. */
  84211. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84212. /** Use the given ray to pick a sprite in the scene
  84213. * @param ray The ray (in world space) to use to pick meshes
  84214. * @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
  84215. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84216. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84217. * @returns a PickingInfo
  84218. */
  84219. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84220. /** @hidden */
  84221. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84222. /** Launch a ray to try to pick sprites in the scene
  84223. * @param x position on screen
  84224. * @param y position on screen
  84225. * @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
  84226. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84227. * @returns a PickingInfo array
  84228. */
  84229. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84230. /** Use the given ray to pick sprites in the scene
  84231. * @param ray The ray (in world space) to use to pick meshes
  84232. * @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
  84233. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84234. * @returns a PickingInfo array
  84235. */
  84236. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84237. /**
  84238. * Force the sprite under the pointer
  84239. * @param sprite defines the sprite to use
  84240. */
  84241. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84242. /**
  84243. * Gets the sprite under the pointer
  84244. * @returns a Sprite or null if no sprite is under the pointer
  84245. */
  84246. getPointerOverSprite(): Nullable<Sprite>;
  84247. }
  84248. /**
  84249. * Defines the sprite scene component responsible to manage sprites
  84250. * in a given scene.
  84251. */
  84252. export class SpriteSceneComponent implements ISceneComponent {
  84253. /**
  84254. * The component name helpfull to identify the component in the list of scene components.
  84255. */
  84256. readonly name: string;
  84257. /**
  84258. * The scene the component belongs to.
  84259. */
  84260. scene: Scene;
  84261. /** @hidden */
  84262. private _spritePredicate;
  84263. /**
  84264. * Creates a new instance of the component for the given scene
  84265. * @param scene Defines the scene to register the component in
  84266. */
  84267. constructor(scene: Scene);
  84268. /**
  84269. * Registers the component in a given scene
  84270. */
  84271. register(): void;
  84272. /**
  84273. * Rebuilds the elements related to this component in case of
  84274. * context lost for instance.
  84275. */
  84276. rebuild(): void;
  84277. /**
  84278. * Disposes the component and the associated ressources.
  84279. */
  84280. dispose(): void;
  84281. private _pickSpriteButKeepRay;
  84282. private _pointerMove;
  84283. private _pointerDown;
  84284. private _pointerUp;
  84285. }
  84286. }
  84287. declare module BABYLON {
  84288. /** @hidden */
  84289. export var fogFragmentDeclaration: {
  84290. name: string;
  84291. shader: string;
  84292. };
  84293. }
  84294. declare module BABYLON {
  84295. /** @hidden */
  84296. export var fogFragment: {
  84297. name: string;
  84298. shader: string;
  84299. };
  84300. }
  84301. declare module BABYLON {
  84302. /** @hidden */
  84303. export var spritesPixelShader: {
  84304. name: string;
  84305. shader: string;
  84306. };
  84307. }
  84308. declare module BABYLON {
  84309. /** @hidden */
  84310. export var fogVertexDeclaration: {
  84311. name: string;
  84312. shader: string;
  84313. };
  84314. }
  84315. declare module BABYLON {
  84316. /** @hidden */
  84317. export var spritesVertexShader: {
  84318. name: string;
  84319. shader: string;
  84320. };
  84321. }
  84322. declare module BABYLON {
  84323. /**
  84324. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84325. */
  84326. export interface ISpriteManager extends IDisposable {
  84327. /**
  84328. * Restricts the camera to viewing objects with the same layerMask.
  84329. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84330. */
  84331. layerMask: number;
  84332. /**
  84333. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84334. */
  84335. isPickable: boolean;
  84336. /**
  84337. * Specifies the rendering group id for this mesh (0 by default)
  84338. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84339. */
  84340. renderingGroupId: number;
  84341. /**
  84342. * Defines the list of sprites managed by the manager.
  84343. */
  84344. sprites: Array<Sprite>;
  84345. /**
  84346. * Tests the intersection of a sprite with a specific ray.
  84347. * @param ray The ray we are sending to test the collision
  84348. * @param camera The camera space we are sending rays in
  84349. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84350. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84351. * @returns picking info or null.
  84352. */
  84353. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84354. /**
  84355. * Intersects the sprites with a ray
  84356. * @param ray defines the ray to intersect with
  84357. * @param camera defines the current active camera
  84358. * @param predicate defines a predicate used to select candidate sprites
  84359. * @returns null if no hit or a PickingInfo array
  84360. */
  84361. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84362. /**
  84363. * Renders the list of sprites on screen.
  84364. */
  84365. render(): void;
  84366. }
  84367. /**
  84368. * Class used to manage multiple sprites on the same spritesheet
  84369. * @see http://doc.babylonjs.com/babylon101/sprites
  84370. */
  84371. export class SpriteManager implements ISpriteManager {
  84372. /** defines the manager's name */
  84373. name: string;
  84374. /** Gets the list of sprites */
  84375. sprites: Sprite[];
  84376. /** Gets or sets the rendering group id (0 by default) */
  84377. renderingGroupId: number;
  84378. /** Gets or sets camera layer mask */
  84379. layerMask: number;
  84380. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84381. fogEnabled: boolean;
  84382. /** Gets or sets a boolean indicating if the sprites are pickable */
  84383. isPickable: boolean;
  84384. /** Defines the default width of a cell in the spritesheet */
  84385. cellWidth: number;
  84386. /** Defines the default height of a cell in the spritesheet */
  84387. cellHeight: number;
  84388. /** Associative array from JSON sprite data file */
  84389. private _cellData;
  84390. /** Array of sprite names from JSON sprite data file */
  84391. private _spriteMap;
  84392. /** True when packed cell data from JSON file is ready*/
  84393. private _packedAndReady;
  84394. /**
  84395. * An event triggered when the manager is disposed.
  84396. */
  84397. onDisposeObservable: Observable<SpriteManager>;
  84398. private _onDisposeObserver;
  84399. /**
  84400. * Callback called when the manager is disposed
  84401. */
  84402. set onDispose(callback: () => void);
  84403. private _capacity;
  84404. private _fromPacked;
  84405. private _spriteTexture;
  84406. private _epsilon;
  84407. private _scene;
  84408. private _vertexData;
  84409. private _buffer;
  84410. private _vertexBuffers;
  84411. private _indexBuffer;
  84412. private _effectBase;
  84413. private _effectFog;
  84414. /**
  84415. * Gets or sets the spritesheet texture
  84416. */
  84417. get texture(): Texture;
  84418. set texture(value: Texture);
  84419. /**
  84420. * Creates a new sprite manager
  84421. * @param name defines the manager's name
  84422. * @param imgUrl defines the sprite sheet url
  84423. * @param capacity defines the maximum allowed number of sprites
  84424. * @param cellSize defines the size of a sprite cell
  84425. * @param scene defines the hosting scene
  84426. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84427. * @param samplingMode defines the smapling mode to use with spritesheet
  84428. * @param fromPacked set to false; do not alter
  84429. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84430. */
  84431. constructor(
  84432. /** defines the manager's name */
  84433. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84434. private _makePacked;
  84435. private _appendSpriteVertex;
  84436. /**
  84437. * Intersects the sprites with a ray
  84438. * @param ray defines the ray to intersect with
  84439. * @param camera defines the current active camera
  84440. * @param predicate defines a predicate used to select candidate sprites
  84441. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84442. * @returns null if no hit or a PickingInfo
  84443. */
  84444. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84445. /**
  84446. * Intersects the sprites with a ray
  84447. * @param ray defines the ray to intersect with
  84448. * @param camera defines the current active camera
  84449. * @param predicate defines a predicate used to select candidate sprites
  84450. * @returns null if no hit or a PickingInfo array
  84451. */
  84452. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84453. /**
  84454. * Render all child sprites
  84455. */
  84456. render(): void;
  84457. /**
  84458. * Release associated resources
  84459. */
  84460. dispose(): void;
  84461. }
  84462. }
  84463. declare module BABYLON {
  84464. /**
  84465. * Class used to represent a sprite
  84466. * @see http://doc.babylonjs.com/babylon101/sprites
  84467. */
  84468. export class Sprite {
  84469. /** defines the name */
  84470. name: string;
  84471. /** Gets or sets the current world position */
  84472. position: Vector3;
  84473. /** Gets or sets the main color */
  84474. color: Color4;
  84475. /** Gets or sets the width */
  84476. width: number;
  84477. /** Gets or sets the height */
  84478. height: number;
  84479. /** Gets or sets rotation angle */
  84480. angle: number;
  84481. /** Gets or sets the cell index in the sprite sheet */
  84482. cellIndex: number;
  84483. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  84484. cellRef: string;
  84485. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  84486. invertU: number;
  84487. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  84488. invertV: number;
  84489. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  84490. disposeWhenFinishedAnimating: boolean;
  84491. /** Gets the list of attached animations */
  84492. animations: Animation[];
  84493. /** Gets or sets a boolean indicating if the sprite can be picked */
  84494. isPickable: boolean;
  84495. /**
  84496. * Gets or sets the associated action manager
  84497. */
  84498. actionManager: Nullable<ActionManager>;
  84499. private _animationStarted;
  84500. private _loopAnimation;
  84501. private _fromIndex;
  84502. private _toIndex;
  84503. private _delay;
  84504. private _direction;
  84505. private _manager;
  84506. private _time;
  84507. private _onAnimationEnd;
  84508. /**
  84509. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  84510. */
  84511. isVisible: boolean;
  84512. /**
  84513. * Gets or sets the sprite size
  84514. */
  84515. get size(): number;
  84516. set size(value: number);
  84517. /**
  84518. * Creates a new Sprite
  84519. * @param name defines the name
  84520. * @param manager defines the manager
  84521. */
  84522. constructor(
  84523. /** defines the name */
  84524. name: string, manager: ISpriteManager);
  84525. /**
  84526. * Starts an animation
  84527. * @param from defines the initial key
  84528. * @param to defines the end key
  84529. * @param loop defines if the animation must loop
  84530. * @param delay defines the start delay (in ms)
  84531. * @param onAnimationEnd defines a callback to call when animation ends
  84532. */
  84533. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  84534. /** Stops current animation (if any) */
  84535. stopAnimation(): void;
  84536. /** @hidden */
  84537. _animate(deltaTime: number): void;
  84538. /** Release associated resources */
  84539. dispose(): void;
  84540. }
  84541. }
  84542. declare module BABYLON {
  84543. /**
  84544. * Information about the result of picking within a scene
  84545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  84546. */
  84547. export class PickingInfo {
  84548. /** @hidden */
  84549. _pickingUnavailable: boolean;
  84550. /**
  84551. * If the pick collided with an object
  84552. */
  84553. hit: boolean;
  84554. /**
  84555. * Distance away where the pick collided
  84556. */
  84557. distance: number;
  84558. /**
  84559. * The location of pick collision
  84560. */
  84561. pickedPoint: Nullable<Vector3>;
  84562. /**
  84563. * The mesh corresponding the the pick collision
  84564. */
  84565. pickedMesh: Nullable<AbstractMesh>;
  84566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  84567. bu: number;
  84568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  84569. bv: number;
  84570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  84571. faceId: number;
  84572. /** Id of the the submesh that was picked */
  84573. subMeshId: number;
  84574. /** If a sprite was picked, this will be the sprite the pick collided with */
  84575. pickedSprite: Nullable<Sprite>;
  84576. /**
  84577. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  84578. */
  84579. originMesh: Nullable<AbstractMesh>;
  84580. /**
  84581. * The ray that was used to perform the picking.
  84582. */
  84583. ray: Nullable<Ray>;
  84584. /**
  84585. * Gets the normal correspodning to the face the pick collided with
  84586. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  84587. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  84588. * @returns The normal correspodning to the face the pick collided with
  84589. */
  84590. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  84591. /**
  84592. * Gets the texture coordinates of where the pick occured
  84593. * @returns the vector containing the coordnates of the texture
  84594. */
  84595. getTextureCoordinates(): Nullable<Vector2>;
  84596. }
  84597. }
  84598. declare module BABYLON {
  84599. /**
  84600. * Gather the list of pointer event types as constants.
  84601. */
  84602. export class PointerEventTypes {
  84603. /**
  84604. * 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.
  84605. */
  84606. static readonly POINTERDOWN: number;
  84607. /**
  84608. * The pointerup event is fired when a pointer is no longer active.
  84609. */
  84610. static readonly POINTERUP: number;
  84611. /**
  84612. * The pointermove event is fired when a pointer changes coordinates.
  84613. */
  84614. static readonly POINTERMOVE: number;
  84615. /**
  84616. * The pointerwheel event is fired when a mouse wheel has been rotated.
  84617. */
  84618. static readonly POINTERWHEEL: number;
  84619. /**
  84620. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  84621. */
  84622. static readonly POINTERPICK: number;
  84623. /**
  84624. * The pointertap event is fired when a the object has been touched and released without drag.
  84625. */
  84626. static readonly POINTERTAP: number;
  84627. /**
  84628. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  84629. */
  84630. static readonly POINTERDOUBLETAP: number;
  84631. }
  84632. /**
  84633. * Base class of pointer info types.
  84634. */
  84635. export class PointerInfoBase {
  84636. /**
  84637. * Defines the type of event (PointerEventTypes)
  84638. */
  84639. type: number;
  84640. /**
  84641. * Defines the related dom event
  84642. */
  84643. event: PointerEvent | MouseWheelEvent;
  84644. /**
  84645. * Instantiates the base class of pointers info.
  84646. * @param type Defines the type of event (PointerEventTypes)
  84647. * @param event Defines the related dom event
  84648. */
  84649. constructor(
  84650. /**
  84651. * Defines the type of event (PointerEventTypes)
  84652. */
  84653. type: number,
  84654. /**
  84655. * Defines the related dom event
  84656. */
  84657. event: PointerEvent | MouseWheelEvent);
  84658. }
  84659. /**
  84660. * This class is used to store pointer related info for the onPrePointerObservable event.
  84661. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  84662. */
  84663. export class PointerInfoPre extends PointerInfoBase {
  84664. /**
  84665. * Ray from a pointer if availible (eg. 6dof controller)
  84666. */
  84667. ray: Nullable<Ray>;
  84668. /**
  84669. * Defines the local position of the pointer on the canvas.
  84670. */
  84671. localPosition: Vector2;
  84672. /**
  84673. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  84674. */
  84675. skipOnPointerObservable: boolean;
  84676. /**
  84677. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  84678. * @param type Defines the type of event (PointerEventTypes)
  84679. * @param event Defines the related dom event
  84680. * @param localX Defines the local x coordinates of the pointer when the event occured
  84681. * @param localY Defines the local y coordinates of the pointer when the event occured
  84682. */
  84683. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  84684. }
  84685. /**
  84686. * This type contains all the data related to a pointer event in Babylon.js.
  84687. * 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.
  84688. */
  84689. export class PointerInfo extends PointerInfoBase {
  84690. /**
  84691. * Defines the picking info associated to the info (if any)\
  84692. */
  84693. pickInfo: Nullable<PickingInfo>;
  84694. /**
  84695. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  84696. * @param type Defines the type of event (PointerEventTypes)
  84697. * @param event Defines the related dom event
  84698. * @param pickInfo Defines the picking info associated to the info (if any)\
  84699. */
  84700. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  84701. /**
  84702. * Defines the picking info associated to the info (if any)\
  84703. */
  84704. pickInfo: Nullable<PickingInfo>);
  84705. }
  84706. /**
  84707. * Data relating to a touch event on the screen.
  84708. */
  84709. export interface PointerTouch {
  84710. /**
  84711. * X coordinate of touch.
  84712. */
  84713. x: number;
  84714. /**
  84715. * Y coordinate of touch.
  84716. */
  84717. y: number;
  84718. /**
  84719. * Id of touch. Unique for each finger.
  84720. */
  84721. pointerId: number;
  84722. /**
  84723. * Event type passed from DOM.
  84724. */
  84725. type: any;
  84726. }
  84727. }
  84728. declare module BABYLON {
  84729. /**
  84730. * Manage the mouse inputs to control the movement of a free camera.
  84731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84732. */
  84733. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  84734. /**
  84735. * Define if touch is enabled in the mouse input
  84736. */
  84737. touchEnabled: boolean;
  84738. /**
  84739. * Defines the camera the input is attached to.
  84740. */
  84741. camera: FreeCamera;
  84742. /**
  84743. * Defines the buttons associated with the input to handle camera move.
  84744. */
  84745. buttons: number[];
  84746. /**
  84747. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  84748. */
  84749. angularSensibility: number;
  84750. private _pointerInput;
  84751. private _onMouseMove;
  84752. private _observer;
  84753. private previousPosition;
  84754. /**
  84755. * Observable for when a pointer move event occurs containing the move offset
  84756. */
  84757. onPointerMovedObservable: Observable<{
  84758. offsetX: number;
  84759. offsetY: number;
  84760. }>;
  84761. /**
  84762. * @hidden
  84763. * If the camera should be rotated automatically based on pointer movement
  84764. */
  84765. _allowCameraRotation: boolean;
  84766. /**
  84767. * Manage the mouse inputs to control the movement of a free camera.
  84768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84769. * @param touchEnabled Defines if touch is enabled or not
  84770. */
  84771. constructor(
  84772. /**
  84773. * Define if touch is enabled in the mouse input
  84774. */
  84775. touchEnabled?: boolean);
  84776. /**
  84777. * Attach the input controls to a specific dom element to get the input from.
  84778. * @param element Defines the element the controls should be listened from
  84779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84780. */
  84781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84782. /**
  84783. * Called on JS contextmenu event.
  84784. * Override this method to provide functionality.
  84785. */
  84786. protected onContextMenu(evt: PointerEvent): void;
  84787. /**
  84788. * Detach the current controls from the specified dom element.
  84789. * @param element Defines the element to stop listening the inputs from
  84790. */
  84791. detachControl(element: Nullable<HTMLElement>): void;
  84792. /**
  84793. * Gets the class name of the current intput.
  84794. * @returns the class name
  84795. */
  84796. getClassName(): string;
  84797. /**
  84798. * Get the friendly name associated with the input class.
  84799. * @returns the input friendly name
  84800. */
  84801. getSimpleName(): string;
  84802. }
  84803. }
  84804. declare module BABYLON {
  84805. /**
  84806. * Manage the touch inputs to control the movement of a free camera.
  84807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84808. */
  84809. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  84810. /**
  84811. * Defines the camera the input is attached to.
  84812. */
  84813. camera: FreeCamera;
  84814. /**
  84815. * Defines the touch sensibility for rotation.
  84816. * The higher the faster.
  84817. */
  84818. touchAngularSensibility: number;
  84819. /**
  84820. * Defines the touch sensibility for move.
  84821. * The higher the faster.
  84822. */
  84823. touchMoveSensibility: number;
  84824. private _offsetX;
  84825. private _offsetY;
  84826. private _pointerPressed;
  84827. private _pointerInput;
  84828. private _observer;
  84829. private _onLostFocus;
  84830. /**
  84831. * Attach the input controls to a specific dom element to get the input from.
  84832. * @param element Defines the element the controls should be listened from
  84833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84834. */
  84835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84836. /**
  84837. * Detach the current controls from the specified dom element.
  84838. * @param element Defines the element to stop listening the inputs from
  84839. */
  84840. detachControl(element: Nullable<HTMLElement>): void;
  84841. /**
  84842. * Update the current camera state depending on the inputs that have been used this frame.
  84843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84844. */
  84845. checkInputs(): void;
  84846. /**
  84847. * Gets the class name of the current intput.
  84848. * @returns the class name
  84849. */
  84850. getClassName(): string;
  84851. /**
  84852. * Get the friendly name associated with the input class.
  84853. * @returns the input friendly name
  84854. */
  84855. getSimpleName(): string;
  84856. }
  84857. }
  84858. declare module BABYLON {
  84859. /**
  84860. * Default Inputs manager for the FreeCamera.
  84861. * It groups all the default supported inputs for ease of use.
  84862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84863. */
  84864. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  84865. /**
  84866. * @hidden
  84867. */
  84868. _mouseInput: Nullable<FreeCameraMouseInput>;
  84869. /**
  84870. * Instantiates a new FreeCameraInputsManager.
  84871. * @param camera Defines the camera the inputs belong to
  84872. */
  84873. constructor(camera: FreeCamera);
  84874. /**
  84875. * Add keyboard input support to the input manager.
  84876. * @returns the current input manager
  84877. */
  84878. addKeyboard(): FreeCameraInputsManager;
  84879. /**
  84880. * Add mouse input support to the input manager.
  84881. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  84882. * @returns the current input manager
  84883. */
  84884. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  84885. /**
  84886. * Removes the mouse input support from the manager
  84887. * @returns the current input manager
  84888. */
  84889. removeMouse(): FreeCameraInputsManager;
  84890. /**
  84891. * Add touch input support to the input manager.
  84892. * @returns the current input manager
  84893. */
  84894. addTouch(): FreeCameraInputsManager;
  84895. /**
  84896. * Remove all attached input methods from a camera
  84897. */
  84898. clear(): void;
  84899. }
  84900. }
  84901. declare module BABYLON {
  84902. /**
  84903. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84904. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  84905. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84906. */
  84907. export class FreeCamera extends TargetCamera {
  84908. /**
  84909. * Define the collision ellipsoid of the camera.
  84910. * This is helpful to simulate a camera body like the player body around the camera
  84911. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  84912. */
  84913. ellipsoid: Vector3;
  84914. /**
  84915. * Define an offset for the position of the ellipsoid around the camera.
  84916. * This can be helpful to determine the center of the body near the gravity center of the body
  84917. * instead of its head.
  84918. */
  84919. ellipsoidOffset: Vector3;
  84920. /**
  84921. * Enable or disable collisions of the camera with the rest of the scene objects.
  84922. */
  84923. checkCollisions: boolean;
  84924. /**
  84925. * Enable or disable gravity on the camera.
  84926. */
  84927. applyGravity: boolean;
  84928. /**
  84929. * Define the input manager associated to the camera.
  84930. */
  84931. inputs: FreeCameraInputsManager;
  84932. /**
  84933. * Gets the input sensibility for a mouse input. (default is 2000.0)
  84934. * Higher values reduce sensitivity.
  84935. */
  84936. get angularSensibility(): number;
  84937. /**
  84938. * Sets the input sensibility for a mouse input. (default is 2000.0)
  84939. * Higher values reduce sensitivity.
  84940. */
  84941. set angularSensibility(value: number);
  84942. /**
  84943. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84944. */
  84945. get keysUp(): number[];
  84946. set keysUp(value: number[]);
  84947. /**
  84948. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84949. */
  84950. get keysDown(): number[];
  84951. set keysDown(value: number[]);
  84952. /**
  84953. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84954. */
  84955. get keysLeft(): number[];
  84956. set keysLeft(value: number[]);
  84957. /**
  84958. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84959. */
  84960. get keysRight(): number[];
  84961. set keysRight(value: number[]);
  84962. /**
  84963. * Event raised when the camera collide with a mesh in the scene.
  84964. */
  84965. onCollide: (collidedMesh: AbstractMesh) => void;
  84966. private _collider;
  84967. private _needMoveForGravity;
  84968. private _oldPosition;
  84969. private _diffPosition;
  84970. private _newPosition;
  84971. /** @hidden */
  84972. _localDirection: Vector3;
  84973. /** @hidden */
  84974. _transformedDirection: Vector3;
  84975. /**
  84976. * Instantiates a Free Camera.
  84977. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84978. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  84979. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84980. * @param name Define the name of the camera in the scene
  84981. * @param position Define the start position of the camera in the scene
  84982. * @param scene Define the scene the camera belongs to
  84983. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84984. */
  84985. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84986. /**
  84987. * Attached controls to the current camera.
  84988. * @param element Defines the element the controls should be listened from
  84989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84990. */
  84991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84992. /**
  84993. * Detach the current controls from the camera.
  84994. * The camera will stop reacting to inputs.
  84995. * @param element Defines the element to stop listening the inputs from
  84996. */
  84997. detachControl(element: HTMLElement): void;
  84998. private _collisionMask;
  84999. /**
  85000. * Define a collision mask to limit the list of object the camera can collide with
  85001. */
  85002. get collisionMask(): number;
  85003. set collisionMask(mask: number);
  85004. /** @hidden */
  85005. _collideWithWorld(displacement: Vector3): void;
  85006. private _onCollisionPositionChange;
  85007. /** @hidden */
  85008. _checkInputs(): void;
  85009. /** @hidden */
  85010. _decideIfNeedsToMove(): boolean;
  85011. /** @hidden */
  85012. _updatePosition(): void;
  85013. /**
  85014. * Destroy the camera and release the current resources hold by it.
  85015. */
  85016. dispose(): void;
  85017. /**
  85018. * Gets the current object class name.
  85019. * @return the class name
  85020. */
  85021. getClassName(): string;
  85022. }
  85023. }
  85024. declare module BABYLON {
  85025. /**
  85026. * Represents a gamepad control stick position
  85027. */
  85028. export class StickValues {
  85029. /**
  85030. * The x component of the control stick
  85031. */
  85032. x: number;
  85033. /**
  85034. * The y component of the control stick
  85035. */
  85036. y: number;
  85037. /**
  85038. * Initializes the gamepad x and y control stick values
  85039. * @param x The x component of the gamepad control stick value
  85040. * @param y The y component of the gamepad control stick value
  85041. */
  85042. constructor(
  85043. /**
  85044. * The x component of the control stick
  85045. */
  85046. x: number,
  85047. /**
  85048. * The y component of the control stick
  85049. */
  85050. y: number);
  85051. }
  85052. /**
  85053. * An interface which manages callbacks for gamepad button changes
  85054. */
  85055. export interface GamepadButtonChanges {
  85056. /**
  85057. * Called when a gamepad has been changed
  85058. */
  85059. changed: boolean;
  85060. /**
  85061. * Called when a gamepad press event has been triggered
  85062. */
  85063. pressChanged: boolean;
  85064. /**
  85065. * Called when a touch event has been triggered
  85066. */
  85067. touchChanged: boolean;
  85068. /**
  85069. * Called when a value has changed
  85070. */
  85071. valueChanged: boolean;
  85072. }
  85073. /**
  85074. * Represents a gamepad
  85075. */
  85076. export class Gamepad {
  85077. /**
  85078. * The id of the gamepad
  85079. */
  85080. id: string;
  85081. /**
  85082. * The index of the gamepad
  85083. */
  85084. index: number;
  85085. /**
  85086. * The browser gamepad
  85087. */
  85088. browserGamepad: any;
  85089. /**
  85090. * Specifies what type of gamepad this represents
  85091. */
  85092. type: number;
  85093. private _leftStick;
  85094. private _rightStick;
  85095. /** @hidden */
  85096. _isConnected: boolean;
  85097. private _leftStickAxisX;
  85098. private _leftStickAxisY;
  85099. private _rightStickAxisX;
  85100. private _rightStickAxisY;
  85101. /**
  85102. * Triggered when the left control stick has been changed
  85103. */
  85104. private _onleftstickchanged;
  85105. /**
  85106. * Triggered when the right control stick has been changed
  85107. */
  85108. private _onrightstickchanged;
  85109. /**
  85110. * Represents a gamepad controller
  85111. */
  85112. static GAMEPAD: number;
  85113. /**
  85114. * Represents a generic controller
  85115. */
  85116. static GENERIC: number;
  85117. /**
  85118. * Represents an XBox controller
  85119. */
  85120. static XBOX: number;
  85121. /**
  85122. * Represents a pose-enabled controller
  85123. */
  85124. static POSE_ENABLED: number;
  85125. /**
  85126. * Represents an Dual Shock controller
  85127. */
  85128. static DUALSHOCK: number;
  85129. /**
  85130. * Specifies whether the left control stick should be Y-inverted
  85131. */
  85132. protected _invertLeftStickY: boolean;
  85133. /**
  85134. * Specifies if the gamepad has been connected
  85135. */
  85136. get isConnected(): boolean;
  85137. /**
  85138. * Initializes the gamepad
  85139. * @param id The id of the gamepad
  85140. * @param index The index of the gamepad
  85141. * @param browserGamepad The browser gamepad
  85142. * @param leftStickX The x component of the left joystick
  85143. * @param leftStickY The y component of the left joystick
  85144. * @param rightStickX The x component of the right joystick
  85145. * @param rightStickY The y component of the right joystick
  85146. */
  85147. constructor(
  85148. /**
  85149. * The id of the gamepad
  85150. */
  85151. id: string,
  85152. /**
  85153. * The index of the gamepad
  85154. */
  85155. index: number,
  85156. /**
  85157. * The browser gamepad
  85158. */
  85159. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  85160. /**
  85161. * Callback triggered when the left joystick has changed
  85162. * @param callback
  85163. */
  85164. onleftstickchanged(callback: (values: StickValues) => void): void;
  85165. /**
  85166. * Callback triggered when the right joystick has changed
  85167. * @param callback
  85168. */
  85169. onrightstickchanged(callback: (values: StickValues) => void): void;
  85170. /**
  85171. * Gets the left joystick
  85172. */
  85173. get leftStick(): StickValues;
  85174. /**
  85175. * Sets the left joystick values
  85176. */
  85177. set leftStick(newValues: StickValues);
  85178. /**
  85179. * Gets the right joystick
  85180. */
  85181. get rightStick(): StickValues;
  85182. /**
  85183. * Sets the right joystick value
  85184. */
  85185. set rightStick(newValues: StickValues);
  85186. /**
  85187. * Updates the gamepad joystick positions
  85188. */
  85189. update(): void;
  85190. /**
  85191. * Disposes the gamepad
  85192. */
  85193. dispose(): void;
  85194. }
  85195. /**
  85196. * Represents a generic gamepad
  85197. */
  85198. export class GenericPad extends Gamepad {
  85199. private _buttons;
  85200. private _onbuttondown;
  85201. private _onbuttonup;
  85202. /**
  85203. * Observable triggered when a button has been pressed
  85204. */
  85205. onButtonDownObservable: Observable<number>;
  85206. /**
  85207. * Observable triggered when a button has been released
  85208. */
  85209. onButtonUpObservable: Observable<number>;
  85210. /**
  85211. * Callback triggered when a button has been pressed
  85212. * @param callback Called when a button has been pressed
  85213. */
  85214. onbuttondown(callback: (buttonPressed: number) => void): void;
  85215. /**
  85216. * Callback triggered when a button has been released
  85217. * @param callback Called when a button has been released
  85218. */
  85219. onbuttonup(callback: (buttonReleased: number) => void): void;
  85220. /**
  85221. * Initializes the generic gamepad
  85222. * @param id The id of the generic gamepad
  85223. * @param index The index of the generic gamepad
  85224. * @param browserGamepad The browser gamepad
  85225. */
  85226. constructor(id: string, index: number, browserGamepad: any);
  85227. private _setButtonValue;
  85228. /**
  85229. * Updates the generic gamepad
  85230. */
  85231. update(): void;
  85232. /**
  85233. * Disposes the generic gamepad
  85234. */
  85235. dispose(): void;
  85236. }
  85237. }
  85238. declare module BABYLON {
  85239. interface Engine {
  85240. /**
  85241. * Creates a raw texture
  85242. * @param data defines the data to store in the texture
  85243. * @param width defines the width of the texture
  85244. * @param height defines the height of the texture
  85245. * @param format defines the format of the data
  85246. * @param generateMipMaps defines if the engine should generate the mip levels
  85247. * @param invertY defines if data must be stored with Y axis inverted
  85248. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85249. * @param compression defines the compression used (null by default)
  85250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85251. * @returns the raw texture inside an InternalTexture
  85252. */
  85253. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85254. /**
  85255. * Update a raw texture
  85256. * @param texture defines the texture to update
  85257. * @param data defines the data to store in the texture
  85258. * @param format defines the format of the data
  85259. * @param invertY defines if data must be stored with Y axis inverted
  85260. */
  85261. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85262. /**
  85263. * Update a raw texture
  85264. * @param texture defines the texture to update
  85265. * @param data defines the data to store in the texture
  85266. * @param format defines the format of the data
  85267. * @param invertY defines if data must be stored with Y axis inverted
  85268. * @param compression defines the compression used (null by default)
  85269. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85270. */
  85271. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85272. /**
  85273. * Creates a new raw cube texture
  85274. * @param data defines the array of data to use to create each face
  85275. * @param size defines the size of the textures
  85276. * @param format defines the format of the data
  85277. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85278. * @param generateMipMaps defines if the engine should generate the mip levels
  85279. * @param invertY defines if data must be stored with Y axis inverted
  85280. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85281. * @param compression defines the compression used (null by default)
  85282. * @returns the cube texture as an InternalTexture
  85283. */
  85284. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85285. /**
  85286. * Update a raw cube texture
  85287. * @param texture defines the texture to udpdate
  85288. * @param data defines the data to store
  85289. * @param format defines the data format
  85290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85291. * @param invertY defines if data must be stored with Y axis inverted
  85292. */
  85293. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85294. /**
  85295. * Update a raw cube texture
  85296. * @param texture defines the texture to udpdate
  85297. * @param data defines the data to store
  85298. * @param format defines the data format
  85299. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85300. * @param invertY defines if data must be stored with Y axis inverted
  85301. * @param compression defines the compression used (null by default)
  85302. */
  85303. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85304. /**
  85305. * Update a raw cube texture
  85306. * @param texture defines the texture to udpdate
  85307. * @param data defines the data to store
  85308. * @param format defines the data format
  85309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85310. * @param invertY defines if data must be stored with Y axis inverted
  85311. * @param compression defines the compression used (null by default)
  85312. * @param level defines which level of the texture to update
  85313. */
  85314. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85315. /**
  85316. * Creates a new raw cube texture from a specified url
  85317. * @param url defines the url where the data is located
  85318. * @param scene defines the current scene
  85319. * @param size defines the size of the textures
  85320. * @param format defines the format of the data
  85321. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85322. * @param noMipmap defines if the engine should avoid generating the mip levels
  85323. * @param callback defines a callback used to extract texture data from loaded data
  85324. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85325. * @param onLoad defines a callback called when texture is loaded
  85326. * @param onError defines a callback called if there is an error
  85327. * @returns the cube texture as an InternalTexture
  85328. */
  85329. 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;
  85330. /**
  85331. * Creates a new raw cube texture from a specified url
  85332. * @param url defines the url where the data is located
  85333. * @param scene defines the current scene
  85334. * @param size defines the size of the textures
  85335. * @param format defines the format of the data
  85336. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85337. * @param noMipmap defines if the engine should avoid generating the mip levels
  85338. * @param callback defines a callback used to extract texture data from loaded data
  85339. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85340. * @param onLoad defines a callback called when texture is loaded
  85341. * @param onError defines a callback called if there is an error
  85342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85343. * @param invertY defines if data must be stored with Y axis inverted
  85344. * @returns the cube texture as an InternalTexture
  85345. */
  85346. 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;
  85347. /**
  85348. * Creates a new raw 3D texture
  85349. * @param data defines the data used to create the texture
  85350. * @param width defines the width of the texture
  85351. * @param height defines the height of the texture
  85352. * @param depth defines the depth of the texture
  85353. * @param format defines the format of the texture
  85354. * @param generateMipMaps defines if the engine must generate mip levels
  85355. * @param invertY defines if data must be stored with Y axis inverted
  85356. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85357. * @param compression defines the compressed used (can be null)
  85358. * @param textureType defines the compressed used (can be null)
  85359. * @returns a new raw 3D texture (stored in an InternalTexture)
  85360. */
  85361. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85362. /**
  85363. * Update a raw 3D texture
  85364. * @param texture defines the texture to update
  85365. * @param data defines the data to store
  85366. * @param format defines the data format
  85367. * @param invertY defines if data must be stored with Y axis inverted
  85368. */
  85369. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85370. /**
  85371. * Update a raw 3D texture
  85372. * @param texture defines the texture to update
  85373. * @param data defines the data to store
  85374. * @param format defines the data format
  85375. * @param invertY defines if data must be stored with Y axis inverted
  85376. * @param compression defines the used compression (can be null)
  85377. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85378. */
  85379. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85380. /**
  85381. * Creates a new raw 2D array texture
  85382. * @param data defines the data used to create the texture
  85383. * @param width defines the width of the texture
  85384. * @param height defines the height of the texture
  85385. * @param depth defines the number of layers of the texture
  85386. * @param format defines the format of the texture
  85387. * @param generateMipMaps defines if the engine must generate mip levels
  85388. * @param invertY defines if data must be stored with Y axis inverted
  85389. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85390. * @param compression defines the compressed used (can be null)
  85391. * @param textureType defines the compressed used (can be null)
  85392. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85393. */
  85394. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85395. /**
  85396. * Update a raw 2D array texture
  85397. * @param texture defines the texture to update
  85398. * @param data defines the data to store
  85399. * @param format defines the data format
  85400. * @param invertY defines if data must be stored with Y axis inverted
  85401. */
  85402. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85403. /**
  85404. * Update a raw 2D array texture
  85405. * @param texture defines the texture to update
  85406. * @param data defines the data to store
  85407. * @param format defines the data format
  85408. * @param invertY defines if data must be stored with Y axis inverted
  85409. * @param compression defines the used compression (can be null)
  85410. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85411. */
  85412. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85413. }
  85414. }
  85415. declare module BABYLON {
  85416. /**
  85417. * Raw texture can help creating a texture directly from an array of data.
  85418. * This can be super useful if you either get the data from an uncompressed source or
  85419. * if you wish to create your texture pixel by pixel.
  85420. */
  85421. export class RawTexture extends Texture {
  85422. /**
  85423. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85424. */
  85425. format: number;
  85426. private _engine;
  85427. /**
  85428. * Instantiates a new RawTexture.
  85429. * Raw texture can help creating a texture directly from an array of data.
  85430. * This can be super useful if you either get the data from an uncompressed source or
  85431. * if you wish to create your texture pixel by pixel.
  85432. * @param data define the array of data to use to create the texture
  85433. * @param width define the width of the texture
  85434. * @param height define the height of the texture
  85435. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85436. * @param scene define the scene the texture belongs to
  85437. * @param generateMipMaps define whether mip maps should be generated or not
  85438. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85439. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85440. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85441. */
  85442. constructor(data: ArrayBufferView, width: number, height: number,
  85443. /**
  85444. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85445. */
  85446. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  85447. /**
  85448. * Updates the texture underlying data.
  85449. * @param data Define the new data of the texture
  85450. */
  85451. update(data: ArrayBufferView): void;
  85452. /**
  85453. * Creates a luminance texture from some data.
  85454. * @param data Define the texture data
  85455. * @param width Define the width of the texture
  85456. * @param height Define the height of the texture
  85457. * @param scene Define the scene the texture belongs to
  85458. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85459. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85460. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85461. * @returns the luminance texture
  85462. */
  85463. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85464. /**
  85465. * Creates a luminance alpha texture from some data.
  85466. * @param data Define the texture data
  85467. * @param width Define the width of the texture
  85468. * @param height Define the height of the texture
  85469. * @param scene Define the scene the texture belongs to
  85470. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85471. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85472. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85473. * @returns the luminance alpha texture
  85474. */
  85475. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85476. /**
  85477. * Creates an alpha texture from some data.
  85478. * @param data Define the texture data
  85479. * @param width Define the width of the texture
  85480. * @param height Define the height of the texture
  85481. * @param scene Define the scene the texture belongs to
  85482. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85483. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85484. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85485. * @returns the alpha texture
  85486. */
  85487. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85488. /**
  85489. * Creates a RGB texture from some data.
  85490. * @param data Define the texture data
  85491. * @param width Define the width of the texture
  85492. * @param height Define the height of the texture
  85493. * @param scene Define the scene the texture belongs to
  85494. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85495. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85496. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85497. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85498. * @returns the RGB alpha texture
  85499. */
  85500. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85501. /**
  85502. * Creates a RGBA texture from some data.
  85503. * @param data Define the texture data
  85504. * @param width Define the width of the texture
  85505. * @param height Define the height of the texture
  85506. * @param scene Define the scene the texture belongs to
  85507. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85510. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85511. * @returns the RGBA texture
  85512. */
  85513. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85514. /**
  85515. * Creates a R texture from some data.
  85516. * @param data Define the texture data
  85517. * @param width Define the width of the texture
  85518. * @param height Define the height of the texture
  85519. * @param scene Define the scene the texture belongs to
  85520. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85523. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85524. * @returns the R texture
  85525. */
  85526. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85527. }
  85528. }
  85529. declare module BABYLON {
  85530. /**
  85531. * Interface for the size containing width and height
  85532. */
  85533. export interface ISize {
  85534. /**
  85535. * Width
  85536. */
  85537. width: number;
  85538. /**
  85539. * Heighht
  85540. */
  85541. height: number;
  85542. }
  85543. /**
  85544. * Size containing widht and height
  85545. */
  85546. export class Size implements ISize {
  85547. /**
  85548. * Width
  85549. */
  85550. width: number;
  85551. /**
  85552. * Height
  85553. */
  85554. height: number;
  85555. /**
  85556. * Creates a Size object from the given width and height (floats).
  85557. * @param width width of the new size
  85558. * @param height height of the new size
  85559. */
  85560. constructor(width: number, height: number);
  85561. /**
  85562. * Returns a string with the Size width and height
  85563. * @returns a string with the Size width and height
  85564. */
  85565. toString(): string;
  85566. /**
  85567. * "Size"
  85568. * @returns the string "Size"
  85569. */
  85570. getClassName(): string;
  85571. /**
  85572. * Returns the Size hash code.
  85573. * @returns a hash code for a unique width and height
  85574. */
  85575. getHashCode(): number;
  85576. /**
  85577. * Updates the current size from the given one.
  85578. * @param src the given size
  85579. */
  85580. copyFrom(src: Size): void;
  85581. /**
  85582. * Updates in place the current Size from the given floats.
  85583. * @param width width of the new size
  85584. * @param height height of the new size
  85585. * @returns the updated Size.
  85586. */
  85587. copyFromFloats(width: number, height: number): Size;
  85588. /**
  85589. * Updates in place the current Size from the given floats.
  85590. * @param width width to set
  85591. * @param height height to set
  85592. * @returns the updated Size.
  85593. */
  85594. set(width: number, height: number): Size;
  85595. /**
  85596. * Multiplies the width and height by numbers
  85597. * @param w factor to multiple the width by
  85598. * @param h factor to multiple the height by
  85599. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85600. */
  85601. multiplyByFloats(w: number, h: number): Size;
  85602. /**
  85603. * Clones the size
  85604. * @returns a new Size copied from the given one.
  85605. */
  85606. clone(): Size;
  85607. /**
  85608. * True if the current Size and the given one width and height are strictly equal.
  85609. * @param other the other size to compare against
  85610. * @returns True if the current Size and the given one width and height are strictly equal.
  85611. */
  85612. equals(other: Size): boolean;
  85613. /**
  85614. * The surface of the Size : width * height (float).
  85615. */
  85616. get surface(): number;
  85617. /**
  85618. * Create a new size of zero
  85619. * @returns a new Size set to (0.0, 0.0)
  85620. */
  85621. static Zero(): Size;
  85622. /**
  85623. * Sums the width and height of two sizes
  85624. * @param otherSize size to add to this size
  85625. * @returns a new Size set as the addition result of the current Size and the given one.
  85626. */
  85627. add(otherSize: Size): Size;
  85628. /**
  85629. * Subtracts the width and height of two
  85630. * @param otherSize size to subtract to this size
  85631. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85632. */
  85633. subtract(otherSize: Size): Size;
  85634. /**
  85635. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85636. * @param start starting size to lerp between
  85637. * @param end end size to lerp between
  85638. * @param amount amount to lerp between the start and end values
  85639. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85640. */
  85641. static Lerp(start: Size, end: Size, amount: number): Size;
  85642. }
  85643. }
  85644. declare module BABYLON {
  85645. /**
  85646. * Defines a runtime animation
  85647. */
  85648. export class RuntimeAnimation {
  85649. private _events;
  85650. /**
  85651. * The current frame of the runtime animation
  85652. */
  85653. private _currentFrame;
  85654. /**
  85655. * The animation used by the runtime animation
  85656. */
  85657. private _animation;
  85658. /**
  85659. * The target of the runtime animation
  85660. */
  85661. private _target;
  85662. /**
  85663. * The initiating animatable
  85664. */
  85665. private _host;
  85666. /**
  85667. * The original value of the runtime animation
  85668. */
  85669. private _originalValue;
  85670. /**
  85671. * The original blend value of the runtime animation
  85672. */
  85673. private _originalBlendValue;
  85674. /**
  85675. * The offsets cache of the runtime animation
  85676. */
  85677. private _offsetsCache;
  85678. /**
  85679. * The high limits cache of the runtime animation
  85680. */
  85681. private _highLimitsCache;
  85682. /**
  85683. * Specifies if the runtime animation has been stopped
  85684. */
  85685. private _stopped;
  85686. /**
  85687. * The blending factor of the runtime animation
  85688. */
  85689. private _blendingFactor;
  85690. /**
  85691. * The BabylonJS scene
  85692. */
  85693. private _scene;
  85694. /**
  85695. * The current value of the runtime animation
  85696. */
  85697. private _currentValue;
  85698. /** @hidden */
  85699. _animationState: _IAnimationState;
  85700. /**
  85701. * The active target of the runtime animation
  85702. */
  85703. private _activeTargets;
  85704. private _currentActiveTarget;
  85705. private _directTarget;
  85706. /**
  85707. * The target path of the runtime animation
  85708. */
  85709. private _targetPath;
  85710. /**
  85711. * The weight of the runtime animation
  85712. */
  85713. private _weight;
  85714. /**
  85715. * The ratio offset of the runtime animation
  85716. */
  85717. private _ratioOffset;
  85718. /**
  85719. * The previous delay of the runtime animation
  85720. */
  85721. private _previousDelay;
  85722. /**
  85723. * The previous ratio of the runtime animation
  85724. */
  85725. private _previousRatio;
  85726. private _enableBlending;
  85727. private _keys;
  85728. private _minFrame;
  85729. private _maxFrame;
  85730. private _minValue;
  85731. private _maxValue;
  85732. private _targetIsArray;
  85733. /**
  85734. * Gets the current frame of the runtime animation
  85735. */
  85736. get currentFrame(): number;
  85737. /**
  85738. * Gets the weight of the runtime animation
  85739. */
  85740. get weight(): number;
  85741. /**
  85742. * Gets the current value of the runtime animation
  85743. */
  85744. get currentValue(): any;
  85745. /**
  85746. * Gets the target path of the runtime animation
  85747. */
  85748. get targetPath(): string;
  85749. /**
  85750. * Gets the actual target of the runtime animation
  85751. */
  85752. get target(): any;
  85753. /** @hidden */
  85754. _onLoop: () => void;
  85755. /**
  85756. * Create a new RuntimeAnimation object
  85757. * @param target defines the target of the animation
  85758. * @param animation defines the source animation object
  85759. * @param scene defines the hosting scene
  85760. * @param host defines the initiating Animatable
  85761. */
  85762. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  85763. private _preparePath;
  85764. /**
  85765. * Gets the animation from the runtime animation
  85766. */
  85767. get animation(): Animation;
  85768. /**
  85769. * Resets the runtime animation to the beginning
  85770. * @param restoreOriginal defines whether to restore the target property to the original value
  85771. */
  85772. reset(restoreOriginal?: boolean): void;
  85773. /**
  85774. * Specifies if the runtime animation is stopped
  85775. * @returns Boolean specifying if the runtime animation is stopped
  85776. */
  85777. isStopped(): boolean;
  85778. /**
  85779. * Disposes of the runtime animation
  85780. */
  85781. dispose(): void;
  85782. /**
  85783. * Apply the interpolated value to the target
  85784. * @param currentValue defines the value computed by the animation
  85785. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  85786. */
  85787. setValue(currentValue: any, weight: number): void;
  85788. private _getOriginalValues;
  85789. private _setValue;
  85790. /**
  85791. * Gets the loop pmode of the runtime animation
  85792. * @returns Loop Mode
  85793. */
  85794. private _getCorrectLoopMode;
  85795. /**
  85796. * Move the current animation to a given frame
  85797. * @param frame defines the frame to move to
  85798. */
  85799. goToFrame(frame: number): void;
  85800. /**
  85801. * @hidden Internal use only
  85802. */
  85803. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  85804. /**
  85805. * Execute the current animation
  85806. * @param delay defines the delay to add to the current frame
  85807. * @param from defines the lower bound of the animation range
  85808. * @param to defines the upper bound of the animation range
  85809. * @param loop defines if the current animation must loop
  85810. * @param speedRatio defines the current speed ratio
  85811. * @param weight defines the weight of the animation (default is -1 so no weight)
  85812. * @param onLoop optional callback called when animation loops
  85813. * @returns a boolean indicating if the animation is running
  85814. */
  85815. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  85816. }
  85817. }
  85818. declare module BABYLON {
  85819. /**
  85820. * Class used to store an actual running animation
  85821. */
  85822. export class Animatable {
  85823. /** defines the target object */
  85824. target: any;
  85825. /** defines the starting frame number (default is 0) */
  85826. fromFrame: number;
  85827. /** defines the ending frame number (default is 100) */
  85828. toFrame: number;
  85829. /** defines if the animation must loop (default is false) */
  85830. loopAnimation: boolean;
  85831. /** defines a callback to call when animation ends if it is not looping */
  85832. onAnimationEnd?: (() => void) | null | undefined;
  85833. /** defines a callback to call when animation loops */
  85834. onAnimationLoop?: (() => void) | null | undefined;
  85835. private _localDelayOffset;
  85836. private _pausedDelay;
  85837. private _runtimeAnimations;
  85838. private _paused;
  85839. private _scene;
  85840. private _speedRatio;
  85841. private _weight;
  85842. private _syncRoot;
  85843. /**
  85844. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  85845. * This will only apply for non looping animation (default is true)
  85846. */
  85847. disposeOnEnd: boolean;
  85848. /**
  85849. * Gets a boolean indicating if the animation has started
  85850. */
  85851. animationStarted: boolean;
  85852. /**
  85853. * Observer raised when the animation ends
  85854. */
  85855. onAnimationEndObservable: Observable<Animatable>;
  85856. /**
  85857. * Observer raised when the animation loops
  85858. */
  85859. onAnimationLoopObservable: Observable<Animatable>;
  85860. /**
  85861. * Gets the root Animatable used to synchronize and normalize animations
  85862. */
  85863. get syncRoot(): Nullable<Animatable>;
  85864. /**
  85865. * Gets the current frame of the first RuntimeAnimation
  85866. * Used to synchronize Animatables
  85867. */
  85868. get masterFrame(): number;
  85869. /**
  85870. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  85871. */
  85872. get weight(): number;
  85873. set weight(value: number);
  85874. /**
  85875. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  85876. */
  85877. get speedRatio(): number;
  85878. set speedRatio(value: number);
  85879. /**
  85880. * Creates a new Animatable
  85881. * @param scene defines the hosting scene
  85882. * @param target defines the target object
  85883. * @param fromFrame defines the starting frame number (default is 0)
  85884. * @param toFrame defines the ending frame number (default is 100)
  85885. * @param loopAnimation defines if the animation must loop (default is false)
  85886. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  85887. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  85888. * @param animations defines a group of animation to add to the new Animatable
  85889. * @param onAnimationLoop defines a callback to call when animation loops
  85890. */
  85891. constructor(scene: Scene,
  85892. /** defines the target object */
  85893. target: any,
  85894. /** defines the starting frame number (default is 0) */
  85895. fromFrame?: number,
  85896. /** defines the ending frame number (default is 100) */
  85897. toFrame?: number,
  85898. /** defines if the animation must loop (default is false) */
  85899. loopAnimation?: boolean, speedRatio?: number,
  85900. /** defines a callback to call when animation ends if it is not looping */
  85901. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  85902. /** defines a callback to call when animation loops */
  85903. onAnimationLoop?: (() => void) | null | undefined);
  85904. /**
  85905. * Synchronize and normalize current Animatable with a source Animatable
  85906. * This is useful when using animation weights and when animations are not of the same length
  85907. * @param root defines the root Animatable to synchronize with
  85908. * @returns the current Animatable
  85909. */
  85910. syncWith(root: Animatable): Animatable;
  85911. /**
  85912. * Gets the list of runtime animations
  85913. * @returns an array of RuntimeAnimation
  85914. */
  85915. getAnimations(): RuntimeAnimation[];
  85916. /**
  85917. * Adds more animations to the current animatable
  85918. * @param target defines the target of the animations
  85919. * @param animations defines the new animations to add
  85920. */
  85921. appendAnimations(target: any, animations: Animation[]): void;
  85922. /**
  85923. * Gets the source animation for a specific property
  85924. * @param property defines the propertyu to look for
  85925. * @returns null or the source animation for the given property
  85926. */
  85927. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  85928. /**
  85929. * Gets the runtime animation for a specific property
  85930. * @param property defines the propertyu to look for
  85931. * @returns null or the runtime animation for the given property
  85932. */
  85933. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  85934. /**
  85935. * Resets the animatable to its original state
  85936. */
  85937. reset(): void;
  85938. /**
  85939. * Allows the animatable to blend with current running animations
  85940. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85941. * @param blendingSpeed defines the blending speed to use
  85942. */
  85943. enableBlending(blendingSpeed: number): void;
  85944. /**
  85945. * Disable animation blending
  85946. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85947. */
  85948. disableBlending(): void;
  85949. /**
  85950. * Jump directly to a given frame
  85951. * @param frame defines the frame to jump to
  85952. */
  85953. goToFrame(frame: number): void;
  85954. /**
  85955. * Pause the animation
  85956. */
  85957. pause(): void;
  85958. /**
  85959. * Restart the animation
  85960. */
  85961. restart(): void;
  85962. private _raiseOnAnimationEnd;
  85963. /**
  85964. * Stop and delete the current animation
  85965. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  85966. * @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)
  85967. */
  85968. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  85969. /**
  85970. * Wait asynchronously for the animation to end
  85971. * @returns a promise which will be fullfilled when the animation ends
  85972. */
  85973. waitAsync(): Promise<Animatable>;
  85974. /** @hidden */
  85975. _animate(delay: number): boolean;
  85976. }
  85977. interface Scene {
  85978. /** @hidden */
  85979. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  85980. /** @hidden */
  85981. _processLateAnimationBindingsForMatrices(holder: {
  85982. totalWeight: number;
  85983. animations: RuntimeAnimation[];
  85984. originalValue: Matrix;
  85985. }): any;
  85986. /** @hidden */
  85987. _processLateAnimationBindingsForQuaternions(holder: {
  85988. totalWeight: number;
  85989. animations: RuntimeAnimation[];
  85990. originalValue: Quaternion;
  85991. }, refQuaternion: Quaternion): Quaternion;
  85992. /** @hidden */
  85993. _processLateAnimationBindings(): void;
  85994. /**
  85995. * Will start the animation sequence of a given target
  85996. * @param target defines the target
  85997. * @param from defines from which frame should animation start
  85998. * @param to defines until which frame should animation run.
  85999. * @param weight defines the weight to apply to the animation (1.0 by default)
  86000. * @param loop defines if the animation loops
  86001. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86002. * @param onAnimationEnd defines the function to be executed when the animation ends
  86003. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86004. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86005. * @param onAnimationLoop defines the callback to call when an animation loops
  86006. * @returns the animatable object created for this animation
  86007. */
  86008. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86009. /**
  86010. * Will start the animation sequence of a given target
  86011. * @param target defines the target
  86012. * @param from defines from which frame should animation start
  86013. * @param to defines until which frame should animation run.
  86014. * @param loop defines if the animation loops
  86015. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86016. * @param onAnimationEnd defines the function to be executed when the animation ends
  86017. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86018. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86019. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  86020. * @param onAnimationLoop defines the callback to call when an animation loops
  86021. * @returns the animatable object created for this animation
  86022. */
  86023. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86024. /**
  86025. * Will start the animation sequence of a given target and its hierarchy
  86026. * @param target defines the target
  86027. * @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.
  86028. * @param from defines from which frame should animation start
  86029. * @param to defines until which frame should animation run.
  86030. * @param loop defines if the animation loops
  86031. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86032. * @param onAnimationEnd defines the function to be executed when the animation ends
  86033. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86034. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86035. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86036. * @param onAnimationLoop defines the callback to call when an animation loops
  86037. * @returns the list of created animatables
  86038. */
  86039. 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[];
  86040. /**
  86041. * Begin a new animation on a given node
  86042. * @param target defines the target where the animation will take place
  86043. * @param animations defines the list of animations to start
  86044. * @param from defines the initial value
  86045. * @param to defines the final value
  86046. * @param loop defines if you want animation to loop (off by default)
  86047. * @param speedRatio defines the speed ratio to apply to all animations
  86048. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86049. * @param onAnimationLoop defines the callback to call when an animation loops
  86050. * @returns the list of created animatables
  86051. */
  86052. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  86053. /**
  86054. * Begin a new animation on a given node and its hierarchy
  86055. * @param target defines the root node where the animation will take place
  86056. * @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.
  86057. * @param animations defines the list of animations to start
  86058. * @param from defines the initial value
  86059. * @param to defines the final value
  86060. * @param loop defines if you want animation to loop (off by default)
  86061. * @param speedRatio defines the speed ratio to apply to all animations
  86062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86063. * @param onAnimationLoop defines the callback to call when an animation loops
  86064. * @returns the list of animatables created for all nodes
  86065. */
  86066. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  86067. /**
  86068. * Gets the animatable associated with a specific target
  86069. * @param target defines the target of the animatable
  86070. * @returns the required animatable if found
  86071. */
  86072. getAnimatableByTarget(target: any): Nullable<Animatable>;
  86073. /**
  86074. * Gets all animatables associated with a given target
  86075. * @param target defines the target to look animatables for
  86076. * @returns an array of Animatables
  86077. */
  86078. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  86079. /**
  86080. * Stops and removes all animations that have been applied to the scene
  86081. */
  86082. stopAllAnimations(): void;
  86083. /**
  86084. * Gets the current delta time used by animation engine
  86085. */
  86086. deltaTime: number;
  86087. }
  86088. interface Bone {
  86089. /**
  86090. * Copy an animation range from another bone
  86091. * @param source defines the source bone
  86092. * @param rangeName defines the range name to copy
  86093. * @param frameOffset defines the frame offset
  86094. * @param rescaleAsRequired defines if rescaling must be applied if required
  86095. * @param skelDimensionsRatio defines the scaling ratio
  86096. * @returns true if operation was successful
  86097. */
  86098. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  86099. }
  86100. }
  86101. declare module BABYLON {
  86102. /**
  86103. * Class used to override all child animations of a given target
  86104. */
  86105. export class AnimationPropertiesOverride {
  86106. /**
  86107. * Gets or sets a value indicating if animation blending must be used
  86108. */
  86109. enableBlending: boolean;
  86110. /**
  86111. * Gets or sets the blending speed to use when enableBlending is true
  86112. */
  86113. blendingSpeed: number;
  86114. /**
  86115. * Gets or sets the default loop mode to use
  86116. */
  86117. loopMode: number;
  86118. }
  86119. }
  86120. declare module BABYLON {
  86121. /**
  86122. * Class used to handle skinning animations
  86123. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86124. */
  86125. export class Skeleton implements IAnimatable {
  86126. /** defines the skeleton name */
  86127. name: string;
  86128. /** defines the skeleton Id */
  86129. id: string;
  86130. /**
  86131. * Defines the list of child bones
  86132. */
  86133. bones: Bone[];
  86134. /**
  86135. * Defines an estimate of the dimension of the skeleton at rest
  86136. */
  86137. dimensionsAtRest: Vector3;
  86138. /**
  86139. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  86140. */
  86141. needInitialSkinMatrix: boolean;
  86142. /**
  86143. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  86144. */
  86145. overrideMesh: Nullable<AbstractMesh>;
  86146. /**
  86147. * Gets the list of animations attached to this skeleton
  86148. */
  86149. animations: Array<Animation>;
  86150. private _scene;
  86151. private _isDirty;
  86152. private _transformMatrices;
  86153. private _transformMatrixTexture;
  86154. private _meshesWithPoseMatrix;
  86155. private _animatables;
  86156. private _identity;
  86157. private _synchronizedWithMesh;
  86158. private _ranges;
  86159. private _lastAbsoluteTransformsUpdateId;
  86160. private _canUseTextureForBones;
  86161. private _uniqueId;
  86162. /** @hidden */
  86163. _numBonesWithLinkedTransformNode: number;
  86164. /** @hidden */
  86165. _hasWaitingData: Nullable<boolean>;
  86166. /**
  86167. * Specifies if the skeleton should be serialized
  86168. */
  86169. doNotSerialize: boolean;
  86170. private _useTextureToStoreBoneMatrices;
  86171. /**
  86172. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  86173. * Please note that this option is not available if the hardware does not support it
  86174. */
  86175. get useTextureToStoreBoneMatrices(): boolean;
  86176. set useTextureToStoreBoneMatrices(value: boolean);
  86177. private _animationPropertiesOverride;
  86178. /**
  86179. * Gets or sets the animation properties override
  86180. */
  86181. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86182. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  86183. /**
  86184. * List of inspectable custom properties (used by the Inspector)
  86185. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86186. */
  86187. inspectableCustomProperties: IInspectable[];
  86188. /**
  86189. * An observable triggered before computing the skeleton's matrices
  86190. */
  86191. onBeforeComputeObservable: Observable<Skeleton>;
  86192. /**
  86193. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  86194. */
  86195. get isUsingTextureForMatrices(): boolean;
  86196. /**
  86197. * Gets the unique ID of this skeleton
  86198. */
  86199. get uniqueId(): number;
  86200. /**
  86201. * Creates a new skeleton
  86202. * @param name defines the skeleton name
  86203. * @param id defines the skeleton Id
  86204. * @param scene defines the hosting scene
  86205. */
  86206. constructor(
  86207. /** defines the skeleton name */
  86208. name: string,
  86209. /** defines the skeleton Id */
  86210. id: string, scene: Scene);
  86211. /**
  86212. * Gets the current object class name.
  86213. * @return the class name
  86214. */
  86215. getClassName(): string;
  86216. /**
  86217. * Returns an array containing the root bones
  86218. * @returns an array containing the root bones
  86219. */
  86220. getChildren(): Array<Bone>;
  86221. /**
  86222. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  86223. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86224. * @returns a Float32Array containing matrices data
  86225. */
  86226. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  86227. /**
  86228. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  86229. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86230. * @returns a raw texture containing the data
  86231. */
  86232. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  86233. /**
  86234. * Gets the current hosting scene
  86235. * @returns a scene object
  86236. */
  86237. getScene(): Scene;
  86238. /**
  86239. * Gets a string representing the current skeleton data
  86240. * @param fullDetails defines a boolean indicating if we want a verbose version
  86241. * @returns a string representing the current skeleton data
  86242. */
  86243. toString(fullDetails?: boolean): string;
  86244. /**
  86245. * Get bone's index searching by name
  86246. * @param name defines bone's name to search for
  86247. * @return the indice of the bone. Returns -1 if not found
  86248. */
  86249. getBoneIndexByName(name: string): number;
  86250. /**
  86251. * Creater a new animation range
  86252. * @param name defines the name of the range
  86253. * @param from defines the start key
  86254. * @param to defines the end key
  86255. */
  86256. createAnimationRange(name: string, from: number, to: number): void;
  86257. /**
  86258. * Delete a specific animation range
  86259. * @param name defines the name of the range
  86260. * @param deleteFrames defines if frames must be removed as well
  86261. */
  86262. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  86263. /**
  86264. * Gets a specific animation range
  86265. * @param name defines the name of the range to look for
  86266. * @returns the requested animation range or null if not found
  86267. */
  86268. getAnimationRange(name: string): Nullable<AnimationRange>;
  86269. /**
  86270. * Gets the list of all animation ranges defined on this skeleton
  86271. * @returns an array
  86272. */
  86273. getAnimationRanges(): Nullable<AnimationRange>[];
  86274. /**
  86275. * Copy animation range from a source skeleton.
  86276. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  86277. * @param source defines the source skeleton
  86278. * @param name defines the name of the range to copy
  86279. * @param rescaleAsRequired defines if rescaling must be applied if required
  86280. * @returns true if operation was successful
  86281. */
  86282. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  86283. /**
  86284. * Forces the skeleton to go to rest pose
  86285. */
  86286. returnToRest(): void;
  86287. private _getHighestAnimationFrame;
  86288. /**
  86289. * Begin a specific animation range
  86290. * @param name defines the name of the range to start
  86291. * @param loop defines if looping must be turned on (false by default)
  86292. * @param speedRatio defines the speed ratio to apply (1 by default)
  86293. * @param onAnimationEnd defines a callback which will be called when animation will end
  86294. * @returns a new animatable
  86295. */
  86296. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  86297. /** @hidden */
  86298. _markAsDirty(): void;
  86299. /** @hidden */
  86300. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86301. /** @hidden */
  86302. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86303. private _computeTransformMatrices;
  86304. /**
  86305. * Build all resources required to render a skeleton
  86306. */
  86307. prepare(): void;
  86308. /**
  86309. * Gets the list of animatables currently running for this skeleton
  86310. * @returns an array of animatables
  86311. */
  86312. getAnimatables(): IAnimatable[];
  86313. /**
  86314. * Clone the current skeleton
  86315. * @param name defines the name of the new skeleton
  86316. * @param id defines the id of the new skeleton
  86317. * @returns the new skeleton
  86318. */
  86319. clone(name: string, id?: string): Skeleton;
  86320. /**
  86321. * Enable animation blending for this skeleton
  86322. * @param blendingSpeed defines the blending speed to apply
  86323. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86324. */
  86325. enableBlending(blendingSpeed?: number): void;
  86326. /**
  86327. * Releases all resources associated with the current skeleton
  86328. */
  86329. dispose(): void;
  86330. /**
  86331. * Serialize the skeleton in a JSON object
  86332. * @returns a JSON object
  86333. */
  86334. serialize(): any;
  86335. /**
  86336. * Creates a new skeleton from serialized data
  86337. * @param parsedSkeleton defines the serialized data
  86338. * @param scene defines the hosting scene
  86339. * @returns a new skeleton
  86340. */
  86341. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  86342. /**
  86343. * Compute all node absolute transforms
  86344. * @param forceUpdate defines if computation must be done even if cache is up to date
  86345. */
  86346. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  86347. /**
  86348. * Gets the root pose matrix
  86349. * @returns a matrix
  86350. */
  86351. getPoseMatrix(): Nullable<Matrix>;
  86352. /**
  86353. * Sorts bones per internal index
  86354. */
  86355. sortBones(): void;
  86356. private _sortBones;
  86357. }
  86358. }
  86359. declare module BABYLON {
  86360. /**
  86361. * Class used to store bone information
  86362. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86363. */
  86364. export class Bone extends Node {
  86365. /**
  86366. * defines the bone name
  86367. */
  86368. name: string;
  86369. private static _tmpVecs;
  86370. private static _tmpQuat;
  86371. private static _tmpMats;
  86372. /**
  86373. * Gets the list of child bones
  86374. */
  86375. children: Bone[];
  86376. /** Gets the animations associated with this bone */
  86377. animations: Animation[];
  86378. /**
  86379. * Gets or sets bone length
  86380. */
  86381. length: number;
  86382. /**
  86383. * @hidden Internal only
  86384. * Set this value to map this bone to a different index in the transform matrices
  86385. * Set this value to -1 to exclude the bone from the transform matrices
  86386. */
  86387. _index: Nullable<number>;
  86388. private _skeleton;
  86389. private _localMatrix;
  86390. private _restPose;
  86391. private _baseMatrix;
  86392. private _absoluteTransform;
  86393. private _invertedAbsoluteTransform;
  86394. private _parent;
  86395. private _scalingDeterminant;
  86396. private _worldTransform;
  86397. private _localScaling;
  86398. private _localRotation;
  86399. private _localPosition;
  86400. private _needToDecompose;
  86401. private _needToCompose;
  86402. /** @hidden */
  86403. _linkedTransformNode: Nullable<TransformNode>;
  86404. /** @hidden */
  86405. _waitingTransformNodeId: Nullable<string>;
  86406. /** @hidden */
  86407. get _matrix(): Matrix;
  86408. /** @hidden */
  86409. set _matrix(value: Matrix);
  86410. /**
  86411. * Create a new bone
  86412. * @param name defines the bone name
  86413. * @param skeleton defines the parent skeleton
  86414. * @param parentBone defines the parent (can be null if the bone is the root)
  86415. * @param localMatrix defines the local matrix
  86416. * @param restPose defines the rest pose matrix
  86417. * @param baseMatrix defines the base matrix
  86418. * @param index defines index of the bone in the hiearchy
  86419. */
  86420. constructor(
  86421. /**
  86422. * defines the bone name
  86423. */
  86424. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  86425. /**
  86426. * Gets the current object class name.
  86427. * @return the class name
  86428. */
  86429. getClassName(): string;
  86430. /**
  86431. * Gets the parent skeleton
  86432. * @returns a skeleton
  86433. */
  86434. getSkeleton(): Skeleton;
  86435. /**
  86436. * Gets parent bone
  86437. * @returns a bone or null if the bone is the root of the bone hierarchy
  86438. */
  86439. getParent(): Nullable<Bone>;
  86440. /**
  86441. * Returns an array containing the root bones
  86442. * @returns an array containing the root bones
  86443. */
  86444. getChildren(): Array<Bone>;
  86445. /**
  86446. * Gets the node index in matrix array generated for rendering
  86447. * @returns the node index
  86448. */
  86449. getIndex(): number;
  86450. /**
  86451. * Sets the parent bone
  86452. * @param parent defines the parent (can be null if the bone is the root)
  86453. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86454. */
  86455. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  86456. /**
  86457. * Gets the local matrix
  86458. * @returns a matrix
  86459. */
  86460. getLocalMatrix(): Matrix;
  86461. /**
  86462. * Gets the base matrix (initial matrix which remains unchanged)
  86463. * @returns a matrix
  86464. */
  86465. getBaseMatrix(): Matrix;
  86466. /**
  86467. * Gets the rest pose matrix
  86468. * @returns a matrix
  86469. */
  86470. getRestPose(): Matrix;
  86471. /**
  86472. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  86473. */
  86474. getWorldMatrix(): Matrix;
  86475. /**
  86476. * Sets the local matrix to rest pose matrix
  86477. */
  86478. returnToRest(): void;
  86479. /**
  86480. * Gets the inverse of the absolute transform matrix.
  86481. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  86482. * @returns a matrix
  86483. */
  86484. getInvertedAbsoluteTransform(): Matrix;
  86485. /**
  86486. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  86487. * @returns a matrix
  86488. */
  86489. getAbsoluteTransform(): Matrix;
  86490. /**
  86491. * Links with the given transform node.
  86492. * The local matrix of this bone is copied from the transform node every frame.
  86493. * @param transformNode defines the transform node to link to
  86494. */
  86495. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  86496. /**
  86497. * Gets the node used to drive the bone's transformation
  86498. * @returns a transform node or null
  86499. */
  86500. getTransformNode(): Nullable<TransformNode>;
  86501. /** Gets or sets current position (in local space) */
  86502. get position(): Vector3;
  86503. set position(newPosition: Vector3);
  86504. /** Gets or sets current rotation (in local space) */
  86505. get rotation(): Vector3;
  86506. set rotation(newRotation: Vector3);
  86507. /** Gets or sets current rotation quaternion (in local space) */
  86508. get rotationQuaternion(): Quaternion;
  86509. set rotationQuaternion(newRotation: Quaternion);
  86510. /** Gets or sets current scaling (in local space) */
  86511. get scaling(): Vector3;
  86512. set scaling(newScaling: Vector3);
  86513. /**
  86514. * Gets the animation properties override
  86515. */
  86516. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86517. private _decompose;
  86518. private _compose;
  86519. /**
  86520. * Update the base and local matrices
  86521. * @param matrix defines the new base or local matrix
  86522. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86523. * @param updateLocalMatrix defines if the local matrix should be updated
  86524. */
  86525. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  86526. /** @hidden */
  86527. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  86528. /**
  86529. * Flag the bone as dirty (Forcing it to update everything)
  86530. */
  86531. markAsDirty(): void;
  86532. /** @hidden */
  86533. _markAsDirtyAndCompose(): void;
  86534. private _markAsDirtyAndDecompose;
  86535. /**
  86536. * Translate the bone in local or world space
  86537. * @param vec The amount to translate the bone
  86538. * @param space The space that the translation is in
  86539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86540. */
  86541. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86542. /**
  86543. * Set the postion of the bone in local or world space
  86544. * @param position The position to set the bone
  86545. * @param space The space that the position is in
  86546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86547. */
  86548. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86549. /**
  86550. * Set the absolute position of the bone (world space)
  86551. * @param position The position to set the bone
  86552. * @param mesh The mesh that this bone is attached to
  86553. */
  86554. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  86555. /**
  86556. * Scale the bone on the x, y and z axes (in local space)
  86557. * @param x The amount to scale the bone on the x axis
  86558. * @param y The amount to scale the bone on the y axis
  86559. * @param z The amount to scale the bone on the z axis
  86560. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  86561. */
  86562. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  86563. /**
  86564. * Set the bone scaling in local space
  86565. * @param scale defines the scaling vector
  86566. */
  86567. setScale(scale: Vector3): void;
  86568. /**
  86569. * Gets the current scaling in local space
  86570. * @returns the current scaling vector
  86571. */
  86572. getScale(): Vector3;
  86573. /**
  86574. * Gets the current scaling in local space and stores it in a target vector
  86575. * @param result defines the target vector
  86576. */
  86577. getScaleToRef(result: Vector3): void;
  86578. /**
  86579. * Set the yaw, pitch, and roll of the bone in local or world space
  86580. * @param yaw The rotation of the bone on the y axis
  86581. * @param pitch The rotation of the bone on the x axis
  86582. * @param roll The rotation of the bone on the z axis
  86583. * @param space The space that the axes of rotation are in
  86584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86585. */
  86586. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  86587. /**
  86588. * Add a rotation to the bone on an axis in local or world space
  86589. * @param axis The axis to rotate the bone on
  86590. * @param amount The amount to rotate the bone
  86591. * @param space The space that the axis is in
  86592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86593. */
  86594. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  86595. /**
  86596. * Set the rotation of the bone to a particular axis angle in local or world space
  86597. * @param axis The axis to rotate the bone on
  86598. * @param angle The angle that the bone should be rotated to
  86599. * @param space The space that the axis is in
  86600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86601. */
  86602. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  86603. /**
  86604. * Set the euler rotation of the bone in local of world space
  86605. * @param rotation The euler rotation that the bone should be set to
  86606. * @param space The space that the rotation is in
  86607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86608. */
  86609. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86610. /**
  86611. * Set the quaternion rotation of the bone in local of world space
  86612. * @param quat The quaternion rotation that the bone should be set to
  86613. * @param space The space that the rotation is in
  86614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86615. */
  86616. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  86617. /**
  86618. * Set the rotation matrix of the bone in local of world space
  86619. * @param rotMat The rotation matrix that the bone should be set to
  86620. * @param space The space that the rotation is in
  86621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86622. */
  86623. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  86624. private _rotateWithMatrix;
  86625. private _getNegativeRotationToRef;
  86626. /**
  86627. * Get the position of the bone in local or world space
  86628. * @param space The space that the returned position is in
  86629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86630. * @returns The position of the bone
  86631. */
  86632. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86633. /**
  86634. * Copy the position of the bone to a vector3 in local or world space
  86635. * @param space The space that the returned position is in
  86636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86637. * @param result The vector3 to copy the position to
  86638. */
  86639. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  86640. /**
  86641. * Get the absolute position of the bone (world space)
  86642. * @param mesh The mesh that this bone is attached to
  86643. * @returns The absolute position of the bone
  86644. */
  86645. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  86646. /**
  86647. * Copy the absolute position of the bone (world space) to the result param
  86648. * @param mesh The mesh that this bone is attached to
  86649. * @param result The vector3 to copy the absolute position to
  86650. */
  86651. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  86652. /**
  86653. * Compute the absolute transforms of this bone and its children
  86654. */
  86655. computeAbsoluteTransforms(): void;
  86656. /**
  86657. * Get the world direction from an axis that is in the local space of the bone
  86658. * @param localAxis The local direction that is used to compute the world direction
  86659. * @param mesh The mesh that this bone is attached to
  86660. * @returns The world direction
  86661. */
  86662. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86663. /**
  86664. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  86665. * @param localAxis The local direction that is used to compute the world direction
  86666. * @param mesh The mesh that this bone is attached to
  86667. * @param result The vector3 that the world direction will be copied to
  86668. */
  86669. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86670. /**
  86671. * Get the euler rotation of the bone in local or world space
  86672. * @param space The space that the rotation should be in
  86673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86674. * @returns The euler rotation
  86675. */
  86676. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86677. /**
  86678. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  86679. * @param space The space that the rotation should be in
  86680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86681. * @param result The vector3 that the rotation should be copied to
  86682. */
  86683. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86684. /**
  86685. * Get the quaternion rotation of the bone in either local or world space
  86686. * @param space The space that the rotation should be in
  86687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86688. * @returns The quaternion rotation
  86689. */
  86690. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  86691. /**
  86692. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  86693. * @param space The space that the rotation should be in
  86694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86695. * @param result The quaternion that the rotation should be copied to
  86696. */
  86697. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  86698. /**
  86699. * Get the rotation matrix of the bone in local or world space
  86700. * @param space The space that the rotation should be in
  86701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86702. * @returns The rotation matrix
  86703. */
  86704. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  86705. /**
  86706. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  86707. * @param space The space that the rotation should be in
  86708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86709. * @param result The quaternion that the rotation should be copied to
  86710. */
  86711. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  86712. /**
  86713. * Get the world position of a point that is in the local space of the bone
  86714. * @param position The local position
  86715. * @param mesh The mesh that this bone is attached to
  86716. * @returns The world position
  86717. */
  86718. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86719. /**
  86720. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  86721. * @param position The local position
  86722. * @param mesh The mesh that this bone is attached to
  86723. * @param result The vector3 that the world position should be copied to
  86724. */
  86725. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86726. /**
  86727. * Get the local position of a point that is in world space
  86728. * @param position The world position
  86729. * @param mesh The mesh that this bone is attached to
  86730. * @returns The local position
  86731. */
  86732. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86733. /**
  86734. * Get the local position of a point that is in world space and copy it to the result param
  86735. * @param position The world position
  86736. * @param mesh The mesh that this bone is attached to
  86737. * @param result The vector3 that the local position should be copied to
  86738. */
  86739. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86740. }
  86741. }
  86742. declare module BABYLON {
  86743. /**
  86744. * 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.
  86745. * @see https://doc.babylonjs.com/how_to/transformnode
  86746. */
  86747. export class TransformNode extends Node {
  86748. /**
  86749. * Object will not rotate to face the camera
  86750. */
  86751. static BILLBOARDMODE_NONE: number;
  86752. /**
  86753. * Object will rotate to face the camera but only on the x axis
  86754. */
  86755. static BILLBOARDMODE_X: number;
  86756. /**
  86757. * Object will rotate to face the camera but only on the y axis
  86758. */
  86759. static BILLBOARDMODE_Y: number;
  86760. /**
  86761. * Object will rotate to face the camera but only on the z axis
  86762. */
  86763. static BILLBOARDMODE_Z: number;
  86764. /**
  86765. * Object will rotate to face the camera
  86766. */
  86767. static BILLBOARDMODE_ALL: number;
  86768. /**
  86769. * Object will rotate to face the camera's position instead of orientation
  86770. */
  86771. static BILLBOARDMODE_USE_POSITION: number;
  86772. private _forward;
  86773. private _forwardInverted;
  86774. private _up;
  86775. private _right;
  86776. private _rightInverted;
  86777. private _position;
  86778. private _rotation;
  86779. private _rotationQuaternion;
  86780. protected _scaling: Vector3;
  86781. protected _isDirty: boolean;
  86782. private _transformToBoneReferal;
  86783. private _isAbsoluteSynced;
  86784. private _billboardMode;
  86785. /**
  86786. * Gets or sets the billboard mode. Default is 0.
  86787. *
  86788. * | Value | Type | Description |
  86789. * | --- | --- | --- |
  86790. * | 0 | BILLBOARDMODE_NONE | |
  86791. * | 1 | BILLBOARDMODE_X | |
  86792. * | 2 | BILLBOARDMODE_Y | |
  86793. * | 4 | BILLBOARDMODE_Z | |
  86794. * | 7 | BILLBOARDMODE_ALL | |
  86795. *
  86796. */
  86797. get billboardMode(): number;
  86798. set billboardMode(value: number);
  86799. private _preserveParentRotationForBillboard;
  86800. /**
  86801. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86802. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86803. */
  86804. get preserveParentRotationForBillboard(): boolean;
  86805. set preserveParentRotationForBillboard(value: boolean);
  86806. /**
  86807. * 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
  86808. */
  86809. scalingDeterminant: number;
  86810. private _infiniteDistance;
  86811. /**
  86812. * Gets or sets the distance of the object to max, often used by skybox
  86813. */
  86814. get infiniteDistance(): boolean;
  86815. set infiniteDistance(value: boolean);
  86816. /**
  86817. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86818. * By default the system will update normals to compensate
  86819. */
  86820. ignoreNonUniformScaling: boolean;
  86821. /**
  86822. * 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
  86823. */
  86824. reIntegrateRotationIntoRotationQuaternion: boolean;
  86825. /** @hidden */
  86826. _poseMatrix: Nullable<Matrix>;
  86827. /** @hidden */
  86828. _localMatrix: Matrix;
  86829. private _usePivotMatrix;
  86830. private _absolutePosition;
  86831. private _absoluteScaling;
  86832. private _absoluteRotationQuaternion;
  86833. private _pivotMatrix;
  86834. private _pivotMatrixInverse;
  86835. protected _postMultiplyPivotMatrix: boolean;
  86836. protected _isWorldMatrixFrozen: boolean;
  86837. /** @hidden */
  86838. _indexInSceneTransformNodesArray: number;
  86839. /**
  86840. * An event triggered after the world matrix is updated
  86841. */
  86842. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86843. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86844. /**
  86845. * Gets a string identifying the name of the class
  86846. * @returns "TransformNode" string
  86847. */
  86848. getClassName(): string;
  86849. /**
  86850. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86851. */
  86852. get position(): Vector3;
  86853. set position(newPosition: Vector3);
  86854. /**
  86855. * 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)).
  86856. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86857. */
  86858. get rotation(): Vector3;
  86859. set rotation(newRotation: Vector3);
  86860. /**
  86861. * 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)).
  86862. */
  86863. get scaling(): Vector3;
  86864. set scaling(newScaling: Vector3);
  86865. /**
  86866. * 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).
  86867. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86868. */
  86869. get rotationQuaternion(): Nullable<Quaternion>;
  86870. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86871. /**
  86872. * The forward direction of that transform in world space.
  86873. */
  86874. get forward(): Vector3;
  86875. /**
  86876. * The up direction of that transform in world space.
  86877. */
  86878. get up(): Vector3;
  86879. /**
  86880. * The right direction of that transform in world space.
  86881. */
  86882. get right(): Vector3;
  86883. /**
  86884. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86885. * @param matrix the matrix to copy the pose from
  86886. * @returns this TransformNode.
  86887. */
  86888. updatePoseMatrix(matrix: Matrix): TransformNode;
  86889. /**
  86890. * Returns the mesh Pose matrix.
  86891. * @returns the pose matrix
  86892. */
  86893. getPoseMatrix(): Matrix;
  86894. /** @hidden */
  86895. _isSynchronized(): boolean;
  86896. /** @hidden */
  86897. _initCache(): void;
  86898. /**
  86899. * Flag the transform node as dirty (Forcing it to update everything)
  86900. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86901. * @returns this transform node
  86902. */
  86903. markAsDirty(property: string): TransformNode;
  86904. /**
  86905. * Returns the current mesh absolute position.
  86906. * Returns a Vector3.
  86907. */
  86908. get absolutePosition(): Vector3;
  86909. /**
  86910. * Returns the current mesh absolute scaling.
  86911. * Returns a Vector3.
  86912. */
  86913. get absoluteScaling(): Vector3;
  86914. /**
  86915. * Returns the current mesh absolute rotation.
  86916. * Returns a Quaternion.
  86917. */
  86918. get absoluteRotationQuaternion(): Quaternion;
  86919. /**
  86920. * Sets a new matrix to apply before all other transformation
  86921. * @param matrix defines the transform matrix
  86922. * @returns the current TransformNode
  86923. */
  86924. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86925. /**
  86926. * Sets a new pivot matrix to the current node
  86927. * @param matrix defines the new pivot matrix to use
  86928. * @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
  86929. * @returns the current TransformNode
  86930. */
  86931. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86932. /**
  86933. * Returns the mesh pivot matrix.
  86934. * Default : Identity.
  86935. * @returns the matrix
  86936. */
  86937. getPivotMatrix(): Matrix;
  86938. /**
  86939. * Instantiate (when possible) or clone that node with its hierarchy
  86940. * @param newParent defines the new parent to use for the instance (or clone)
  86941. * @param options defines options to configure how copy is done
  86942. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86943. * @returns an instance (or a clone) of the current node with its hiearchy
  86944. */
  86945. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86946. doNotInstantiate: boolean;
  86947. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86948. /**
  86949. * Prevents the World matrix to be computed any longer
  86950. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86951. * @returns the TransformNode.
  86952. */
  86953. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86954. /**
  86955. * Allows back the World matrix computation.
  86956. * @returns the TransformNode.
  86957. */
  86958. unfreezeWorldMatrix(): this;
  86959. /**
  86960. * True if the World matrix has been frozen.
  86961. */
  86962. get isWorldMatrixFrozen(): boolean;
  86963. /**
  86964. * Retuns the mesh absolute position in the World.
  86965. * @returns a Vector3.
  86966. */
  86967. getAbsolutePosition(): Vector3;
  86968. /**
  86969. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86970. * @param absolutePosition the absolute position to set
  86971. * @returns the TransformNode.
  86972. */
  86973. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86974. /**
  86975. * Sets the mesh position in its local space.
  86976. * @param vector3 the position to set in localspace
  86977. * @returns the TransformNode.
  86978. */
  86979. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86980. /**
  86981. * Returns the mesh position in the local space from the current World matrix values.
  86982. * @returns a new Vector3.
  86983. */
  86984. getPositionExpressedInLocalSpace(): Vector3;
  86985. /**
  86986. * Translates the mesh along the passed Vector3 in its local space.
  86987. * @param vector3 the distance to translate in localspace
  86988. * @returns the TransformNode.
  86989. */
  86990. locallyTranslate(vector3: Vector3): TransformNode;
  86991. private static _lookAtVectorCache;
  86992. /**
  86993. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86994. * @param targetPoint the position (must be in same space as current mesh) to look at
  86995. * @param yawCor optional yaw (y-axis) correction in radians
  86996. * @param pitchCor optional pitch (x-axis) correction in radians
  86997. * @param rollCor optional roll (z-axis) correction in radians
  86998. * @param space the choosen space of the target
  86999. * @returns the TransformNode.
  87000. */
  87001. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87002. /**
  87003. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87004. * This Vector3 is expressed in the World space.
  87005. * @param localAxis axis to rotate
  87006. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87007. */
  87008. getDirection(localAxis: Vector3): Vector3;
  87009. /**
  87010. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87011. * localAxis is expressed in the mesh local space.
  87012. * result is computed in the Wordl space from the mesh World matrix.
  87013. * @param localAxis axis to rotate
  87014. * @param result the resulting transformnode
  87015. * @returns this TransformNode.
  87016. */
  87017. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87018. /**
  87019. * Sets this transform node rotation to the given local axis.
  87020. * @param localAxis the axis in local space
  87021. * @param yawCor optional yaw (y-axis) correction in radians
  87022. * @param pitchCor optional pitch (x-axis) correction in radians
  87023. * @param rollCor optional roll (z-axis) correction in radians
  87024. * @returns this TransformNode
  87025. */
  87026. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87027. /**
  87028. * Sets a new pivot point to the current node
  87029. * @param point defines the new pivot point to use
  87030. * @param space defines if the point is in world or local space (local by default)
  87031. * @returns the current TransformNode
  87032. */
  87033. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87034. /**
  87035. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87036. * @returns the pivot point
  87037. */
  87038. getPivotPoint(): Vector3;
  87039. /**
  87040. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87041. * @param result the vector3 to store the result
  87042. * @returns this TransformNode.
  87043. */
  87044. getPivotPointToRef(result: Vector3): TransformNode;
  87045. /**
  87046. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87047. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87048. */
  87049. getAbsolutePivotPoint(): Vector3;
  87050. /**
  87051. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87052. * @param result vector3 to store the result
  87053. * @returns this TransformNode.
  87054. */
  87055. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87056. /**
  87057. * Defines the passed node as the parent of the current node.
  87058. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87059. * @see https://doc.babylonjs.com/how_to/parenting
  87060. * @param node the node ot set as the parent
  87061. * @returns this TransformNode.
  87062. */
  87063. setParent(node: Nullable<Node>): TransformNode;
  87064. private _nonUniformScaling;
  87065. /**
  87066. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87067. */
  87068. get nonUniformScaling(): boolean;
  87069. /** @hidden */
  87070. _updateNonUniformScalingState(value: boolean): boolean;
  87071. /**
  87072. * Attach the current TransformNode to another TransformNode associated with a bone
  87073. * @param bone Bone affecting the TransformNode
  87074. * @param affectedTransformNode TransformNode associated with the bone
  87075. * @returns this object
  87076. */
  87077. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87078. /**
  87079. * Detach the transform node if its associated with a bone
  87080. * @returns this object
  87081. */
  87082. detachFromBone(): TransformNode;
  87083. private static _rotationAxisCache;
  87084. /**
  87085. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87086. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87087. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87088. * The passed axis is also normalized.
  87089. * @param axis the axis to rotate around
  87090. * @param amount the amount to rotate in radians
  87091. * @param space Space to rotate in (Default: local)
  87092. * @returns the TransformNode.
  87093. */
  87094. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87095. /**
  87096. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87097. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87098. * The passed axis is also normalized. .
  87099. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87100. * @param point the point to rotate around
  87101. * @param axis the axis to rotate around
  87102. * @param amount the amount to rotate in radians
  87103. * @returns the TransformNode
  87104. */
  87105. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87106. /**
  87107. * Translates the mesh along the axis vector for the passed distance in the given space.
  87108. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87109. * @param axis the axis to translate in
  87110. * @param distance the distance to translate
  87111. * @param space Space to rotate in (Default: local)
  87112. * @returns the TransformNode.
  87113. */
  87114. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87115. /**
  87116. * Adds a rotation step to the mesh current rotation.
  87117. * x, y, z are Euler angles expressed in radians.
  87118. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87119. * This means this rotation is made in the mesh local space only.
  87120. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87121. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87122. * ```javascript
  87123. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87124. * ```
  87125. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87126. * 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.
  87127. * @param x Rotation to add
  87128. * @param y Rotation to add
  87129. * @param z Rotation to add
  87130. * @returns the TransformNode.
  87131. */
  87132. addRotation(x: number, y: number, z: number): TransformNode;
  87133. /**
  87134. * @hidden
  87135. */
  87136. protected _getEffectiveParent(): Nullable<Node>;
  87137. /**
  87138. * Computes the world matrix of the node
  87139. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87140. * @returns the world matrix
  87141. */
  87142. computeWorldMatrix(force?: boolean): Matrix;
  87143. protected _afterComputeWorldMatrix(): void;
  87144. /**
  87145. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87146. * @param func callback function to add
  87147. *
  87148. * @returns the TransformNode.
  87149. */
  87150. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87151. /**
  87152. * Removes a registered callback function.
  87153. * @param func callback function to remove
  87154. * @returns the TransformNode.
  87155. */
  87156. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87157. /**
  87158. * Gets the position of the current mesh in camera space
  87159. * @param camera defines the camera to use
  87160. * @returns a position
  87161. */
  87162. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87163. /**
  87164. * Returns the distance from the mesh to the active camera
  87165. * @param camera defines the camera to use
  87166. * @returns the distance
  87167. */
  87168. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87169. /**
  87170. * Clone the current transform node
  87171. * @param name Name of the new clone
  87172. * @param newParent New parent for the clone
  87173. * @param doNotCloneChildren Do not clone children hierarchy
  87174. * @returns the new transform node
  87175. */
  87176. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87177. /**
  87178. * Serializes the objects information.
  87179. * @param currentSerializationObject defines the object to serialize in
  87180. * @returns the serialized object
  87181. */
  87182. serialize(currentSerializationObject?: any): any;
  87183. /**
  87184. * Returns a new TransformNode object parsed from the source provided.
  87185. * @param parsedTransformNode is the source.
  87186. * @param scene the scne the object belongs to
  87187. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87188. * @returns a new TransformNode object parsed from the source provided.
  87189. */
  87190. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87191. /**
  87192. * Get all child-transformNodes of this node
  87193. * @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
  87194. * @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
  87195. * @returns an array of TransformNode
  87196. */
  87197. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87198. /**
  87199. * Releases resources associated with this transform node.
  87200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87202. */
  87203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87204. /**
  87205. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87206. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87207. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87208. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87209. * @returns the current mesh
  87210. */
  87211. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87212. private _syncAbsoluteScalingAndRotation;
  87213. }
  87214. }
  87215. declare module BABYLON {
  87216. /**
  87217. * Defines the types of pose enabled controllers that are supported
  87218. */
  87219. export enum PoseEnabledControllerType {
  87220. /**
  87221. * HTC Vive
  87222. */
  87223. VIVE = 0,
  87224. /**
  87225. * Oculus Rift
  87226. */
  87227. OCULUS = 1,
  87228. /**
  87229. * Windows mixed reality
  87230. */
  87231. WINDOWS = 2,
  87232. /**
  87233. * Samsung gear VR
  87234. */
  87235. GEAR_VR = 3,
  87236. /**
  87237. * Google Daydream
  87238. */
  87239. DAYDREAM = 4,
  87240. /**
  87241. * Generic
  87242. */
  87243. GENERIC = 5
  87244. }
  87245. /**
  87246. * Defines the MutableGamepadButton interface for the state of a gamepad button
  87247. */
  87248. export interface MutableGamepadButton {
  87249. /**
  87250. * Value of the button/trigger
  87251. */
  87252. value: number;
  87253. /**
  87254. * If the button/trigger is currently touched
  87255. */
  87256. touched: boolean;
  87257. /**
  87258. * If the button/trigger is currently pressed
  87259. */
  87260. pressed: boolean;
  87261. }
  87262. /**
  87263. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  87264. * @hidden
  87265. */
  87266. export interface ExtendedGamepadButton extends GamepadButton {
  87267. /**
  87268. * If the button/trigger is currently pressed
  87269. */
  87270. readonly pressed: boolean;
  87271. /**
  87272. * If the button/trigger is currently touched
  87273. */
  87274. readonly touched: boolean;
  87275. /**
  87276. * Value of the button/trigger
  87277. */
  87278. readonly value: number;
  87279. }
  87280. /** @hidden */
  87281. export interface _GamePadFactory {
  87282. /**
  87283. * Returns wether or not the current gamepad can be created for this type of controller.
  87284. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87285. * @returns true if it can be created, otherwise false
  87286. */
  87287. canCreate(gamepadInfo: any): boolean;
  87288. /**
  87289. * Creates a new instance of the Gamepad.
  87290. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87291. * @returns the new gamepad instance
  87292. */
  87293. create(gamepadInfo: any): Gamepad;
  87294. }
  87295. /**
  87296. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87297. */
  87298. export class PoseEnabledControllerHelper {
  87299. /** @hidden */
  87300. static _ControllerFactories: _GamePadFactory[];
  87301. /** @hidden */
  87302. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  87303. /**
  87304. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87305. * @param vrGamepad the gamepad to initialized
  87306. * @returns a vr controller of the type the gamepad identified as
  87307. */
  87308. static InitiateController(vrGamepad: any): Gamepad;
  87309. }
  87310. /**
  87311. * Defines the PoseEnabledController object that contains state of a vr capable controller
  87312. */
  87313. export class PoseEnabledController extends Gamepad implements PoseControlled {
  87314. /**
  87315. * If the controller is used in a webXR session
  87316. */
  87317. isXR: boolean;
  87318. private _deviceRoomPosition;
  87319. private _deviceRoomRotationQuaternion;
  87320. /**
  87321. * The device position in babylon space
  87322. */
  87323. devicePosition: Vector3;
  87324. /**
  87325. * The device rotation in babylon space
  87326. */
  87327. deviceRotationQuaternion: Quaternion;
  87328. /**
  87329. * The scale factor of the device in babylon space
  87330. */
  87331. deviceScaleFactor: number;
  87332. /**
  87333. * (Likely devicePosition should be used instead) The device position in its room space
  87334. */
  87335. position: Vector3;
  87336. /**
  87337. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  87338. */
  87339. rotationQuaternion: Quaternion;
  87340. /**
  87341. * The type of controller (Eg. Windows mixed reality)
  87342. */
  87343. controllerType: PoseEnabledControllerType;
  87344. protected _calculatedPosition: Vector3;
  87345. private _calculatedRotation;
  87346. /**
  87347. * The raw pose from the device
  87348. */
  87349. rawPose: DevicePose;
  87350. private _trackPosition;
  87351. private _maxRotationDistFromHeadset;
  87352. private _draggedRoomRotation;
  87353. /**
  87354. * @hidden
  87355. */
  87356. _disableTrackPosition(fixedPosition: Vector3): void;
  87357. /**
  87358. * Internal, the mesh attached to the controller
  87359. * @hidden
  87360. */
  87361. _mesh: Nullable<AbstractMesh>;
  87362. private _poseControlledCamera;
  87363. private _leftHandSystemQuaternion;
  87364. /**
  87365. * Internal, matrix used to convert room space to babylon space
  87366. * @hidden
  87367. */
  87368. _deviceToWorld: Matrix;
  87369. /**
  87370. * Node to be used when casting a ray from the controller
  87371. * @hidden
  87372. */
  87373. _pointingPoseNode: Nullable<TransformNode>;
  87374. /**
  87375. * Name of the child mesh that can be used to cast a ray from the controller
  87376. */
  87377. static readonly POINTING_POSE: string;
  87378. /**
  87379. * Creates a new PoseEnabledController from a gamepad
  87380. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  87381. */
  87382. constructor(browserGamepad: any);
  87383. private _workingMatrix;
  87384. /**
  87385. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  87386. */
  87387. update(): void;
  87388. /**
  87389. * Updates only the pose device and mesh without doing any button event checking
  87390. */
  87391. protected _updatePoseAndMesh(): void;
  87392. /**
  87393. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  87394. * @param poseData raw pose fromthe device
  87395. */
  87396. updateFromDevice(poseData: DevicePose): void;
  87397. /**
  87398. * @hidden
  87399. */
  87400. _meshAttachedObservable: Observable<AbstractMesh>;
  87401. /**
  87402. * Attaches a mesh to the controller
  87403. * @param mesh the mesh to be attached
  87404. */
  87405. attachToMesh(mesh: AbstractMesh): void;
  87406. /**
  87407. * Attaches the controllers mesh to a camera
  87408. * @param camera the camera the mesh should be attached to
  87409. */
  87410. attachToPoseControlledCamera(camera: TargetCamera): void;
  87411. /**
  87412. * Disposes of the controller
  87413. */
  87414. dispose(): void;
  87415. /**
  87416. * The mesh that is attached to the controller
  87417. */
  87418. get mesh(): Nullable<AbstractMesh>;
  87419. /**
  87420. * Gets the ray of the controller in the direction the controller is pointing
  87421. * @param length the length the resulting ray should be
  87422. * @returns a ray in the direction the controller is pointing
  87423. */
  87424. getForwardRay(length?: number): Ray;
  87425. }
  87426. }
  87427. declare module BABYLON {
  87428. /**
  87429. * Defines the WebVRController object that represents controllers tracked in 3D space
  87430. */
  87431. export abstract class WebVRController extends PoseEnabledController {
  87432. /**
  87433. * Internal, the default controller model for the controller
  87434. */
  87435. protected _defaultModel: Nullable<AbstractMesh>;
  87436. /**
  87437. * Fired when the trigger state has changed
  87438. */
  87439. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  87440. /**
  87441. * Fired when the main button state has changed
  87442. */
  87443. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87444. /**
  87445. * Fired when the secondary button state has changed
  87446. */
  87447. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87448. /**
  87449. * Fired when the pad state has changed
  87450. */
  87451. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  87452. /**
  87453. * Fired when controllers stick values have changed
  87454. */
  87455. onPadValuesChangedObservable: Observable<StickValues>;
  87456. /**
  87457. * Array of button availible on the controller
  87458. */
  87459. protected _buttons: Array<MutableGamepadButton>;
  87460. private _onButtonStateChange;
  87461. /**
  87462. * Fired when a controller button's state has changed
  87463. * @param callback the callback containing the button that was modified
  87464. */
  87465. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  87466. /**
  87467. * X and Y axis corresponding to the controllers joystick
  87468. */
  87469. pad: StickValues;
  87470. /**
  87471. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  87472. */
  87473. hand: string;
  87474. /**
  87475. * The default controller model for the controller
  87476. */
  87477. get defaultModel(): Nullable<AbstractMesh>;
  87478. /**
  87479. * Creates a new WebVRController from a gamepad
  87480. * @param vrGamepad the gamepad that the WebVRController should be created from
  87481. */
  87482. constructor(vrGamepad: any);
  87483. /**
  87484. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  87485. */
  87486. update(): void;
  87487. /**
  87488. * Function to be called when a button is modified
  87489. */
  87490. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  87491. /**
  87492. * Loads a mesh and attaches it to the controller
  87493. * @param scene the scene the mesh should be added to
  87494. * @param meshLoaded callback for when the mesh has been loaded
  87495. */
  87496. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  87497. private _setButtonValue;
  87498. private _changes;
  87499. private _checkChanges;
  87500. /**
  87501. * Disposes of th webVRCOntroller
  87502. */
  87503. dispose(): void;
  87504. }
  87505. }
  87506. declare module BABYLON {
  87507. /**
  87508. * The HemisphericLight simulates the ambient environment light,
  87509. * so the passed direction is the light reflection direction, not the incoming direction.
  87510. */
  87511. export class HemisphericLight extends Light {
  87512. /**
  87513. * The groundColor is the light in the opposite direction to the one specified during creation.
  87514. * 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.
  87515. */
  87516. groundColor: Color3;
  87517. /**
  87518. * The light reflection direction, not the incoming direction.
  87519. */
  87520. direction: Vector3;
  87521. /**
  87522. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  87523. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  87524. * The HemisphericLight can't cast shadows.
  87525. * Documentation : https://doc.babylonjs.com/babylon101/lights
  87526. * @param name The friendly name of the light
  87527. * @param direction The direction of the light reflection
  87528. * @param scene The scene the light belongs to
  87529. */
  87530. constructor(name: string, direction: Vector3, scene: Scene);
  87531. protected _buildUniformLayout(): void;
  87532. /**
  87533. * Returns the string "HemisphericLight".
  87534. * @return The class name
  87535. */
  87536. getClassName(): string;
  87537. /**
  87538. * Sets the HemisphericLight direction towards the passed target (Vector3).
  87539. * Returns the updated direction.
  87540. * @param target The target the direction should point to
  87541. * @return The computed direction
  87542. */
  87543. setDirectionToTarget(target: Vector3): Vector3;
  87544. /**
  87545. * Returns the shadow generator associated to the light.
  87546. * @returns Always null for hemispheric lights because it does not support shadows.
  87547. */
  87548. getShadowGenerator(): Nullable<IShadowGenerator>;
  87549. /**
  87550. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  87551. * @param effect The effect to update
  87552. * @param lightIndex The index of the light in the effect to update
  87553. * @returns The hemispheric light
  87554. */
  87555. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  87556. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  87557. /**
  87558. * Computes the world matrix of the node
  87559. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87560. * @param useWasUpdatedFlag defines a reserved property
  87561. * @returns the world matrix
  87562. */
  87563. computeWorldMatrix(): Matrix;
  87564. /**
  87565. * Returns the integer 3.
  87566. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  87567. */
  87568. getTypeID(): number;
  87569. /**
  87570. * Prepares the list of defines specific to the light type.
  87571. * @param defines the list of defines
  87572. * @param lightIndex defines the index of the light for the effect
  87573. */
  87574. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  87575. }
  87576. }
  87577. declare module BABYLON {
  87578. /** @hidden */
  87579. export var vrMultiviewToSingleviewPixelShader: {
  87580. name: string;
  87581. shader: string;
  87582. };
  87583. }
  87584. declare module BABYLON {
  87585. /**
  87586. * Renders to multiple views with a single draw call
  87587. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  87588. */
  87589. export class MultiviewRenderTarget extends RenderTargetTexture {
  87590. /**
  87591. * Creates a multiview render target
  87592. * @param scene scene used with the render target
  87593. * @param size the size of the render target (used for each view)
  87594. */
  87595. constructor(scene: Scene, size?: number | {
  87596. width: number;
  87597. height: number;
  87598. } | {
  87599. ratio: number;
  87600. });
  87601. /**
  87602. * @hidden
  87603. * @param faceIndex the face index, if its a cube texture
  87604. */
  87605. _bindFrameBuffer(faceIndex?: number): void;
  87606. /**
  87607. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87608. * @returns the view count
  87609. */
  87610. getViewCount(): number;
  87611. }
  87612. }
  87613. declare module BABYLON {
  87614. /**
  87615. * Represents a camera frustum
  87616. */
  87617. export class Frustum {
  87618. /**
  87619. * Gets the planes representing the frustum
  87620. * @param transform matrix to be applied to the returned planes
  87621. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87622. */
  87623. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87624. /**
  87625. * Gets the near frustum plane transformed by the transform matrix
  87626. * @param transform transformation matrix to be applied to the resulting frustum plane
  87627. * @param frustumPlane the resuling frustum plane
  87628. */
  87629. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87630. /**
  87631. * Gets the far frustum plane transformed by the transform matrix
  87632. * @param transform transformation matrix to be applied to the resulting frustum plane
  87633. * @param frustumPlane the resuling frustum plane
  87634. */
  87635. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87636. /**
  87637. * Gets the left frustum plane transformed by the transform matrix
  87638. * @param transform transformation matrix to be applied to the resulting frustum plane
  87639. * @param frustumPlane the resuling frustum plane
  87640. */
  87641. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87642. /**
  87643. * Gets the right frustum plane transformed by the transform matrix
  87644. * @param transform transformation matrix to be applied to the resulting frustum plane
  87645. * @param frustumPlane the resuling frustum plane
  87646. */
  87647. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87648. /**
  87649. * Gets the top frustum plane transformed by the transform matrix
  87650. * @param transform transformation matrix to be applied to the resulting frustum plane
  87651. * @param frustumPlane the resuling frustum plane
  87652. */
  87653. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87654. /**
  87655. * Gets the bottom frustum plane transformed by the transform matrix
  87656. * @param transform transformation matrix to be applied to the resulting frustum plane
  87657. * @param frustumPlane the resuling frustum plane
  87658. */
  87659. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87660. /**
  87661. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87662. * @param transform transformation matrix to be applied to the resulting frustum planes
  87663. * @param frustumPlanes the resuling frustum planes
  87664. */
  87665. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87666. }
  87667. }
  87668. declare module BABYLON {
  87669. interface Engine {
  87670. /**
  87671. * Creates a new multiview render target
  87672. * @param width defines the width of the texture
  87673. * @param height defines the height of the texture
  87674. * @returns the created multiview texture
  87675. */
  87676. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87677. /**
  87678. * Binds a multiview framebuffer to be drawn to
  87679. * @param multiviewTexture texture to bind
  87680. */
  87681. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87682. }
  87683. interface Camera {
  87684. /**
  87685. * @hidden
  87686. * 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)
  87687. */
  87688. _useMultiviewToSingleView: boolean;
  87689. /**
  87690. * @hidden
  87691. * 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)
  87692. */
  87693. _multiviewTexture: Nullable<RenderTargetTexture>;
  87694. /**
  87695. * @hidden
  87696. * ensures the multiview texture of the camera exists and has the specified width/height
  87697. * @param width height to set on the multiview texture
  87698. * @param height width to set on the multiview texture
  87699. */
  87700. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  87701. }
  87702. interface Scene {
  87703. /** @hidden */
  87704. _transformMatrixR: Matrix;
  87705. /** @hidden */
  87706. _multiviewSceneUbo: Nullable<UniformBuffer>;
  87707. /** @hidden */
  87708. _createMultiviewUbo(): void;
  87709. /** @hidden */
  87710. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  87711. /** @hidden */
  87712. _renderMultiviewToSingleView(camera: Camera): void;
  87713. }
  87714. }
  87715. declare module BABYLON {
  87716. /**
  87717. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  87718. * This will not be used for webXR as it supports displaying texture arrays directly
  87719. */
  87720. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  87721. /**
  87722. * Initializes a VRMultiviewToSingleview
  87723. * @param name name of the post process
  87724. * @param camera camera to be applied to
  87725. * @param scaleFactor scaling factor to the size of the output texture
  87726. */
  87727. constructor(name: string, camera: Camera, scaleFactor: number);
  87728. }
  87729. }
  87730. declare module BABYLON {
  87731. /**
  87732. * Interface used to define additional presentation attributes
  87733. */
  87734. export interface IVRPresentationAttributes {
  87735. /**
  87736. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  87737. */
  87738. highRefreshRate: boolean;
  87739. /**
  87740. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  87741. */
  87742. foveationLevel: number;
  87743. }
  87744. interface Engine {
  87745. /** @hidden */
  87746. _vrDisplay: any;
  87747. /** @hidden */
  87748. _vrSupported: boolean;
  87749. /** @hidden */
  87750. _oldSize: Size;
  87751. /** @hidden */
  87752. _oldHardwareScaleFactor: number;
  87753. /** @hidden */
  87754. _vrExclusivePointerMode: boolean;
  87755. /** @hidden */
  87756. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  87757. /** @hidden */
  87758. _onVRDisplayPointerRestricted: () => void;
  87759. /** @hidden */
  87760. _onVRDisplayPointerUnrestricted: () => void;
  87761. /** @hidden */
  87762. _onVrDisplayConnect: Nullable<(display: any) => void>;
  87763. /** @hidden */
  87764. _onVrDisplayDisconnect: Nullable<() => void>;
  87765. /** @hidden */
  87766. _onVrDisplayPresentChange: Nullable<() => void>;
  87767. /**
  87768. * Observable signaled when VR display mode changes
  87769. */
  87770. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  87771. /**
  87772. * Observable signaled when VR request present is complete
  87773. */
  87774. onVRRequestPresentComplete: Observable<boolean>;
  87775. /**
  87776. * Observable signaled when VR request present starts
  87777. */
  87778. onVRRequestPresentStart: Observable<Engine>;
  87779. /**
  87780. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  87781. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  87782. */
  87783. isInVRExclusivePointerMode: boolean;
  87784. /**
  87785. * Gets a boolean indicating if a webVR device was detected
  87786. * @returns true if a webVR device was detected
  87787. */
  87788. isVRDevicePresent(): boolean;
  87789. /**
  87790. * Gets the current webVR device
  87791. * @returns the current webVR device (or null)
  87792. */
  87793. getVRDevice(): any;
  87794. /**
  87795. * Initializes a webVR display and starts listening to display change events
  87796. * The onVRDisplayChangedObservable will be notified upon these changes
  87797. * @returns A promise containing a VRDisplay and if vr is supported
  87798. */
  87799. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87800. /** @hidden */
  87801. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  87802. /**
  87803. * Gets or sets the presentation attributes used to configure VR rendering
  87804. */
  87805. vrPresentationAttributes?: IVRPresentationAttributes;
  87806. /**
  87807. * Call this function to switch to webVR mode
  87808. * Will do nothing if webVR is not supported or if there is no webVR device
  87809. * @param options the webvr options provided to the camera. mainly used for multiview
  87810. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87811. */
  87812. enableVR(options: WebVROptions): void;
  87813. /** @hidden */
  87814. _onVRFullScreenTriggered(): void;
  87815. }
  87816. }
  87817. declare module BABYLON {
  87818. /**
  87819. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  87820. * IMPORTANT!! The data is right-hand data.
  87821. * @export
  87822. * @interface DevicePose
  87823. */
  87824. export interface DevicePose {
  87825. /**
  87826. * The position of the device, values in array are [x,y,z].
  87827. */
  87828. readonly position: Nullable<Float32Array>;
  87829. /**
  87830. * The linearVelocity of the device, values in array are [x,y,z].
  87831. */
  87832. readonly linearVelocity: Nullable<Float32Array>;
  87833. /**
  87834. * The linearAcceleration of the device, values in array are [x,y,z].
  87835. */
  87836. readonly linearAcceleration: Nullable<Float32Array>;
  87837. /**
  87838. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  87839. */
  87840. readonly orientation: Nullable<Float32Array>;
  87841. /**
  87842. * The angularVelocity of the device, values in array are [x,y,z].
  87843. */
  87844. readonly angularVelocity: Nullable<Float32Array>;
  87845. /**
  87846. * The angularAcceleration of the device, values in array are [x,y,z].
  87847. */
  87848. readonly angularAcceleration: Nullable<Float32Array>;
  87849. }
  87850. /**
  87851. * Interface representing a pose controlled object in Babylon.
  87852. * A pose controlled object has both regular pose values as well as pose values
  87853. * from an external device such as a VR head mounted display
  87854. */
  87855. export interface PoseControlled {
  87856. /**
  87857. * The position of the object in babylon space.
  87858. */
  87859. position: Vector3;
  87860. /**
  87861. * The rotation quaternion of the object in babylon space.
  87862. */
  87863. rotationQuaternion: Quaternion;
  87864. /**
  87865. * The position of the device in babylon space.
  87866. */
  87867. devicePosition?: Vector3;
  87868. /**
  87869. * The rotation quaternion of the device in babylon space.
  87870. */
  87871. deviceRotationQuaternion: Quaternion;
  87872. /**
  87873. * The raw pose coming from the device.
  87874. */
  87875. rawPose: Nullable<DevicePose>;
  87876. /**
  87877. * The scale of the device to be used when translating from device space to babylon space.
  87878. */
  87879. deviceScaleFactor: number;
  87880. /**
  87881. * Updates the poseControlled values based on the input device pose.
  87882. * @param poseData the pose data to update the object with
  87883. */
  87884. updateFromDevice(poseData: DevicePose): void;
  87885. }
  87886. /**
  87887. * Set of options to customize the webVRCamera
  87888. */
  87889. export interface WebVROptions {
  87890. /**
  87891. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  87892. */
  87893. trackPosition?: boolean;
  87894. /**
  87895. * Sets the scale of the vrDevice in babylon space. (default: 1)
  87896. */
  87897. positionScale?: number;
  87898. /**
  87899. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  87900. */
  87901. displayName?: string;
  87902. /**
  87903. * Should the native controller meshes be initialized. (default: true)
  87904. */
  87905. controllerMeshes?: boolean;
  87906. /**
  87907. * Creating a default HemiLight only on controllers. (default: true)
  87908. */
  87909. defaultLightingOnControllers?: boolean;
  87910. /**
  87911. * If you don't want to use the default VR button of the helper. (default: false)
  87912. */
  87913. useCustomVRButton?: boolean;
  87914. /**
  87915. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  87916. */
  87917. customVRButton?: HTMLButtonElement;
  87918. /**
  87919. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  87920. */
  87921. rayLength?: number;
  87922. /**
  87923. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  87924. */
  87925. defaultHeight?: number;
  87926. /**
  87927. * If multiview should be used if availible (default: false)
  87928. */
  87929. useMultiview?: boolean;
  87930. }
  87931. /**
  87932. * This represents a WebVR camera.
  87933. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  87934. * @example http://doc.babylonjs.com/how_to/webvr_camera
  87935. */
  87936. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  87937. private webVROptions;
  87938. /**
  87939. * @hidden
  87940. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  87941. */
  87942. _vrDevice: any;
  87943. /**
  87944. * The rawPose of the vrDevice.
  87945. */
  87946. rawPose: Nullable<DevicePose>;
  87947. private _onVREnabled;
  87948. private _specsVersion;
  87949. private _attached;
  87950. private _frameData;
  87951. protected _descendants: Array<Node>;
  87952. private _deviceRoomPosition;
  87953. /** @hidden */
  87954. _deviceRoomRotationQuaternion: Quaternion;
  87955. private _standingMatrix;
  87956. /**
  87957. * Represents device position in babylon space.
  87958. */
  87959. devicePosition: Vector3;
  87960. /**
  87961. * Represents device rotation in babylon space.
  87962. */
  87963. deviceRotationQuaternion: Quaternion;
  87964. /**
  87965. * The scale of the device to be used when translating from device space to babylon space.
  87966. */
  87967. deviceScaleFactor: number;
  87968. private _deviceToWorld;
  87969. private _worldToDevice;
  87970. /**
  87971. * References to the webVR controllers for the vrDevice.
  87972. */
  87973. controllers: Array<WebVRController>;
  87974. /**
  87975. * Emits an event when a controller is attached.
  87976. */
  87977. onControllersAttachedObservable: Observable<WebVRController[]>;
  87978. /**
  87979. * Emits an event when a controller's mesh has been loaded;
  87980. */
  87981. onControllerMeshLoadedObservable: Observable<WebVRController>;
  87982. /**
  87983. * Emits an event when the HMD's pose has been updated.
  87984. */
  87985. onPoseUpdatedFromDeviceObservable: Observable<any>;
  87986. private _poseSet;
  87987. /**
  87988. * If the rig cameras be used as parent instead of this camera.
  87989. */
  87990. rigParenting: boolean;
  87991. private _lightOnControllers;
  87992. private _defaultHeight?;
  87993. /**
  87994. * Instantiates a WebVRFreeCamera.
  87995. * @param name The name of the WebVRFreeCamera
  87996. * @param position The starting anchor position for the camera
  87997. * @param scene The scene the camera belongs to
  87998. * @param webVROptions a set of customizable options for the webVRCamera
  87999. */
  88000. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  88001. /**
  88002. * Gets the device distance from the ground in meters.
  88003. * @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.
  88004. */
  88005. deviceDistanceToRoomGround(): number;
  88006. /**
  88007. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88008. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  88009. */
  88010. useStandingMatrix(callback?: (bool: boolean) => void): void;
  88011. /**
  88012. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88013. * @returns A promise with a boolean set to if the standing matrix is supported.
  88014. */
  88015. useStandingMatrixAsync(): Promise<boolean>;
  88016. /**
  88017. * Disposes the camera
  88018. */
  88019. dispose(): void;
  88020. /**
  88021. * Gets a vrController by name.
  88022. * @param name The name of the controller to retreive
  88023. * @returns the controller matching the name specified or null if not found
  88024. */
  88025. getControllerByName(name: string): Nullable<WebVRController>;
  88026. private _leftController;
  88027. /**
  88028. * The controller corresponding to the users left hand.
  88029. */
  88030. get leftController(): Nullable<WebVRController>;
  88031. private _rightController;
  88032. /**
  88033. * The controller corresponding to the users right hand.
  88034. */
  88035. get rightController(): Nullable<WebVRController>;
  88036. /**
  88037. * Casts a ray forward from the vrCamera's gaze.
  88038. * @param length Length of the ray (default: 100)
  88039. * @returns the ray corresponding to the gaze
  88040. */
  88041. getForwardRay(length?: number): Ray;
  88042. /**
  88043. * @hidden
  88044. * Updates the camera based on device's frame data
  88045. */
  88046. _checkInputs(): void;
  88047. /**
  88048. * Updates the poseControlled values based on the input device pose.
  88049. * @param poseData Pose coming from the device
  88050. */
  88051. updateFromDevice(poseData: DevicePose): void;
  88052. private _htmlElementAttached;
  88053. private _detachIfAttached;
  88054. /**
  88055. * WebVR's attach control will start broadcasting frames to the device.
  88056. * Note that in certain browsers (chrome for example) this function must be called
  88057. * within a user-interaction callback. Example:
  88058. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  88059. *
  88060. * @param element html element to attach the vrDevice to
  88061. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  88062. */
  88063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88064. /**
  88065. * Detaches the camera from the html element and disables VR
  88066. *
  88067. * @param element html element to detach from
  88068. */
  88069. detachControl(element: HTMLElement): void;
  88070. /**
  88071. * @returns the name of this class
  88072. */
  88073. getClassName(): string;
  88074. /**
  88075. * Calls resetPose on the vrDisplay
  88076. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  88077. */
  88078. resetToCurrentRotation(): void;
  88079. /**
  88080. * @hidden
  88081. * Updates the rig cameras (left and right eye)
  88082. */
  88083. _updateRigCameras(): void;
  88084. private _workingVector;
  88085. private _oneVector;
  88086. private _workingMatrix;
  88087. private updateCacheCalled;
  88088. private _correctPositionIfNotTrackPosition;
  88089. /**
  88090. * @hidden
  88091. * Updates the cached values of the camera
  88092. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  88093. */
  88094. _updateCache(ignoreParentClass?: boolean): void;
  88095. /**
  88096. * @hidden
  88097. * Get current device position in babylon world
  88098. */
  88099. _computeDevicePosition(): void;
  88100. /**
  88101. * Updates the current device position and rotation in the babylon world
  88102. */
  88103. update(): void;
  88104. /**
  88105. * @hidden
  88106. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  88107. * @returns an identity matrix
  88108. */
  88109. _getViewMatrix(): Matrix;
  88110. private _tmpMatrix;
  88111. /**
  88112. * This function is called by the two RIG cameras.
  88113. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  88114. * @hidden
  88115. */
  88116. _getWebVRViewMatrix(): Matrix;
  88117. /** @hidden */
  88118. _getWebVRProjectionMatrix(): Matrix;
  88119. private _onGamepadConnectedObserver;
  88120. private _onGamepadDisconnectedObserver;
  88121. private _updateCacheWhenTrackingDisabledObserver;
  88122. /**
  88123. * Initializes the controllers and their meshes
  88124. */
  88125. initControllers(): void;
  88126. }
  88127. }
  88128. declare module BABYLON {
  88129. /**
  88130. * Size options for a post process
  88131. */
  88132. export type PostProcessOptions = {
  88133. width: number;
  88134. height: number;
  88135. };
  88136. /**
  88137. * PostProcess can be used to apply a shader to a texture after it has been rendered
  88138. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88139. */
  88140. export class PostProcess {
  88141. /** Name of the PostProcess. */
  88142. name: string;
  88143. /**
  88144. * Gets or sets the unique id of the post process
  88145. */
  88146. uniqueId: number;
  88147. /**
  88148. * Width of the texture to apply the post process on
  88149. */
  88150. width: number;
  88151. /**
  88152. * Height of the texture to apply the post process on
  88153. */
  88154. height: number;
  88155. /**
  88156. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  88157. * @hidden
  88158. */
  88159. _outputTexture: Nullable<InternalTexture>;
  88160. /**
  88161. * Sampling mode used by the shader
  88162. * See https://doc.babylonjs.com/classes/3.1/texture
  88163. */
  88164. renderTargetSamplingMode: number;
  88165. /**
  88166. * Clear color to use when screen clearing
  88167. */
  88168. clearColor: Color4;
  88169. /**
  88170. * If the buffer needs to be cleared before applying the post process. (default: true)
  88171. * Should be set to false if shader will overwrite all previous pixels.
  88172. */
  88173. autoClear: boolean;
  88174. /**
  88175. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  88176. */
  88177. alphaMode: number;
  88178. /**
  88179. * Sets the setAlphaBlendConstants of the babylon engine
  88180. */
  88181. alphaConstants: Color4;
  88182. /**
  88183. * Animations to be used for the post processing
  88184. */
  88185. animations: Animation[];
  88186. /**
  88187. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  88188. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  88189. */
  88190. enablePixelPerfectMode: boolean;
  88191. /**
  88192. * Force the postprocess to be applied without taking in account viewport
  88193. */
  88194. forceFullscreenViewport: boolean;
  88195. /**
  88196. * List of inspectable custom properties (used by the Inspector)
  88197. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88198. */
  88199. inspectableCustomProperties: IInspectable[];
  88200. /**
  88201. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  88202. *
  88203. * | Value | Type | Description |
  88204. * | ----- | ----------------------------------- | ----------- |
  88205. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  88206. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  88207. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  88208. *
  88209. */
  88210. scaleMode: number;
  88211. /**
  88212. * Force textures to be a power of two (default: false)
  88213. */
  88214. alwaysForcePOT: boolean;
  88215. private _samples;
  88216. /**
  88217. * Number of sample textures (default: 1)
  88218. */
  88219. get samples(): number;
  88220. set samples(n: number);
  88221. /**
  88222. * Modify the scale of the post process to be the same as the viewport (default: false)
  88223. */
  88224. adaptScaleToCurrentViewport: boolean;
  88225. private _camera;
  88226. private _scene;
  88227. private _engine;
  88228. private _options;
  88229. private _reusable;
  88230. private _textureType;
  88231. private _textureFormat;
  88232. /**
  88233. * Smart array of input and output textures for the post process.
  88234. * @hidden
  88235. */
  88236. _textures: SmartArray<InternalTexture>;
  88237. /**
  88238. * The index in _textures that corresponds to the output texture.
  88239. * @hidden
  88240. */
  88241. _currentRenderTextureInd: number;
  88242. private _effect;
  88243. private _samplers;
  88244. private _fragmentUrl;
  88245. private _vertexUrl;
  88246. private _parameters;
  88247. private _scaleRatio;
  88248. protected _indexParameters: any;
  88249. private _shareOutputWithPostProcess;
  88250. private _texelSize;
  88251. private _forcedOutputTexture;
  88252. /**
  88253. * Returns the fragment url or shader name used in the post process.
  88254. * @returns the fragment url or name in the shader store.
  88255. */
  88256. getEffectName(): string;
  88257. /**
  88258. * An event triggered when the postprocess is activated.
  88259. */
  88260. onActivateObservable: Observable<Camera>;
  88261. private _onActivateObserver;
  88262. /**
  88263. * A function that is added to the onActivateObservable
  88264. */
  88265. set onActivate(callback: Nullable<(camera: Camera) => void>);
  88266. /**
  88267. * An event triggered when the postprocess changes its size.
  88268. */
  88269. onSizeChangedObservable: Observable<PostProcess>;
  88270. private _onSizeChangedObserver;
  88271. /**
  88272. * A function that is added to the onSizeChangedObservable
  88273. */
  88274. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  88275. /**
  88276. * An event triggered when the postprocess applies its effect.
  88277. */
  88278. onApplyObservable: Observable<Effect>;
  88279. private _onApplyObserver;
  88280. /**
  88281. * A function that is added to the onApplyObservable
  88282. */
  88283. set onApply(callback: (effect: Effect) => void);
  88284. /**
  88285. * An event triggered before rendering the postprocess
  88286. */
  88287. onBeforeRenderObservable: Observable<Effect>;
  88288. private _onBeforeRenderObserver;
  88289. /**
  88290. * A function that is added to the onBeforeRenderObservable
  88291. */
  88292. set onBeforeRender(callback: (effect: Effect) => void);
  88293. /**
  88294. * An event triggered after rendering the postprocess
  88295. */
  88296. onAfterRenderObservable: Observable<Effect>;
  88297. private _onAfterRenderObserver;
  88298. /**
  88299. * A function that is added to the onAfterRenderObservable
  88300. */
  88301. set onAfterRender(callback: (efect: Effect) => void);
  88302. /**
  88303. * 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
  88304. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  88305. */
  88306. get inputTexture(): InternalTexture;
  88307. set inputTexture(value: InternalTexture);
  88308. /**
  88309. * Gets the camera which post process is applied to.
  88310. * @returns The camera the post process is applied to.
  88311. */
  88312. getCamera(): Camera;
  88313. /**
  88314. * Gets the texel size of the postprocess.
  88315. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  88316. */
  88317. get texelSize(): Vector2;
  88318. /**
  88319. * Creates a new instance PostProcess
  88320. * @param name The name of the PostProcess.
  88321. * @param fragmentUrl The url of the fragment shader to be used.
  88322. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  88323. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  88324. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88325. * @param camera The camera to apply the render pass to.
  88326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88327. * @param engine The engine which the post process will be applied. (default: current engine)
  88328. * @param reusable If the post process can be reused on the same frame. (default: false)
  88329. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  88330. * @param textureType Type of textures used when performing the post process. (default: 0)
  88331. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  88332. * @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
  88333. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  88334. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  88335. */
  88336. constructor(
  88337. /** Name of the PostProcess. */
  88338. 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);
  88339. /**
  88340. * Gets a string idenfifying the name of the class
  88341. * @returns "PostProcess" string
  88342. */
  88343. getClassName(): string;
  88344. /**
  88345. * Gets the engine which this post process belongs to.
  88346. * @returns The engine the post process was enabled with.
  88347. */
  88348. getEngine(): Engine;
  88349. /**
  88350. * The effect that is created when initializing the post process.
  88351. * @returns The created effect corresponding the the postprocess.
  88352. */
  88353. getEffect(): Effect;
  88354. /**
  88355. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  88356. * @param postProcess The post process to share the output with.
  88357. * @returns This post process.
  88358. */
  88359. shareOutputWith(postProcess: PostProcess): PostProcess;
  88360. /**
  88361. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  88362. * This should be called if the post process that shares output with this post process is disabled/disposed.
  88363. */
  88364. useOwnOutput(): void;
  88365. /**
  88366. * Updates the effect with the current post process compile time values and recompiles the shader.
  88367. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88368. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88369. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88370. * @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
  88371. * @param onCompiled Called when the shader has been compiled.
  88372. * @param onError Called if there is an error when compiling a shader.
  88373. */
  88374. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88375. /**
  88376. * The post process is reusable if it can be used multiple times within one frame.
  88377. * @returns If the post process is reusable
  88378. */
  88379. isReusable(): boolean;
  88380. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  88381. markTextureDirty(): void;
  88382. /**
  88383. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  88384. * 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.
  88385. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  88386. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  88387. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  88388. * @returns The target texture that was bound to be written to.
  88389. */
  88390. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  88391. /**
  88392. * If the post process is supported.
  88393. */
  88394. get isSupported(): boolean;
  88395. /**
  88396. * The aspect ratio of the output texture.
  88397. */
  88398. get aspectRatio(): number;
  88399. /**
  88400. * Get a value indicating if the post-process is ready to be used
  88401. * @returns true if the post-process is ready (shader is compiled)
  88402. */
  88403. isReady(): boolean;
  88404. /**
  88405. * Binds all textures and uniforms to the shader, this will be run on every pass.
  88406. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  88407. */
  88408. apply(): Nullable<Effect>;
  88409. private _disposeTextures;
  88410. /**
  88411. * Disposes the post process.
  88412. * @param camera The camera to dispose the post process on.
  88413. */
  88414. dispose(camera?: Camera): void;
  88415. }
  88416. }
  88417. declare module BABYLON {
  88418. /** @hidden */
  88419. export var kernelBlurVaryingDeclaration: {
  88420. name: string;
  88421. shader: string;
  88422. };
  88423. }
  88424. declare module BABYLON {
  88425. /** @hidden */
  88426. export var kernelBlurFragment: {
  88427. name: string;
  88428. shader: string;
  88429. };
  88430. }
  88431. declare module BABYLON {
  88432. /** @hidden */
  88433. export var kernelBlurFragment2: {
  88434. name: string;
  88435. shader: string;
  88436. };
  88437. }
  88438. declare module BABYLON {
  88439. /** @hidden */
  88440. export var kernelBlurPixelShader: {
  88441. name: string;
  88442. shader: string;
  88443. };
  88444. }
  88445. declare module BABYLON {
  88446. /** @hidden */
  88447. export var kernelBlurVertex: {
  88448. name: string;
  88449. shader: string;
  88450. };
  88451. }
  88452. declare module BABYLON {
  88453. /** @hidden */
  88454. export var kernelBlurVertexShader: {
  88455. name: string;
  88456. shader: string;
  88457. };
  88458. }
  88459. declare module BABYLON {
  88460. /**
  88461. * The Blur Post Process which blurs an image based on a kernel and direction.
  88462. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  88463. */
  88464. export class BlurPostProcess extends PostProcess {
  88465. /** The direction in which to blur the image. */
  88466. direction: Vector2;
  88467. private blockCompilation;
  88468. protected _kernel: number;
  88469. protected _idealKernel: number;
  88470. protected _packedFloat: boolean;
  88471. private _staticDefines;
  88472. /**
  88473. * Sets the length in pixels of the blur sample region
  88474. */
  88475. set kernel(v: number);
  88476. /**
  88477. * Gets the length in pixels of the blur sample region
  88478. */
  88479. get kernel(): number;
  88480. /**
  88481. * Sets wether or not the blur needs to unpack/repack floats
  88482. */
  88483. set packedFloat(v: boolean);
  88484. /**
  88485. * Gets wether or not the blur is unpacking/repacking floats
  88486. */
  88487. get packedFloat(): boolean;
  88488. /**
  88489. * Creates a new instance BlurPostProcess
  88490. * @param name The name of the effect.
  88491. * @param direction The direction in which to blur the image.
  88492. * @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.
  88493. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88494. * @param camera The camera to apply the render pass to.
  88495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88496. * @param engine The engine which the post process will be applied. (default: current engine)
  88497. * @param reusable If the post process can be reused on the same frame. (default: false)
  88498. * @param textureType Type of textures used when performing the post process. (default: 0)
  88499. * @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)
  88500. */
  88501. constructor(name: string,
  88502. /** The direction in which to blur the image. */
  88503. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  88504. /**
  88505. * Updates the effect with the current post process compile time values and recompiles the shader.
  88506. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88507. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88508. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88509. * @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
  88510. * @param onCompiled Called when the shader has been compiled.
  88511. * @param onError Called if there is an error when compiling a shader.
  88512. */
  88513. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88514. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88515. /**
  88516. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  88517. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  88518. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  88519. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  88520. * The gaps between physical kernels are compensated for in the weighting of the samples
  88521. * @param idealKernel Ideal blur kernel.
  88522. * @return Nearest best kernel.
  88523. */
  88524. protected _nearestBestKernel(idealKernel: number): number;
  88525. /**
  88526. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  88527. * @param x The point on the Gaussian distribution to sample.
  88528. * @return the value of the Gaussian function at x.
  88529. */
  88530. protected _gaussianWeight(x: number): number;
  88531. /**
  88532. * Generates a string that can be used as a floating point number in GLSL.
  88533. * @param x Value to print.
  88534. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  88535. * @return GLSL float string.
  88536. */
  88537. protected _glslFloat(x: number, decimalFigures?: number): string;
  88538. }
  88539. }
  88540. declare module BABYLON {
  88541. /**
  88542. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88543. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88544. * You can then easily use it as a reflectionTexture on a flat surface.
  88545. * In case the surface is not a plane, please consider relying on reflection probes.
  88546. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88547. */
  88548. export class MirrorTexture extends RenderTargetTexture {
  88549. private scene;
  88550. /**
  88551. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  88552. * 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.
  88553. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88554. */
  88555. mirrorPlane: Plane;
  88556. /**
  88557. * Define the blur ratio used to blur the reflection if needed.
  88558. */
  88559. set blurRatio(value: number);
  88560. get blurRatio(): number;
  88561. /**
  88562. * Define the adaptive blur kernel used to blur the reflection if needed.
  88563. * This will autocompute the closest best match for the `blurKernel`
  88564. */
  88565. set adaptiveBlurKernel(value: number);
  88566. /**
  88567. * Define the blur kernel used to blur the reflection if needed.
  88568. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88569. */
  88570. set blurKernel(value: number);
  88571. /**
  88572. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  88573. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88574. */
  88575. set blurKernelX(value: number);
  88576. get blurKernelX(): number;
  88577. /**
  88578. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  88579. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88580. */
  88581. set blurKernelY(value: number);
  88582. get blurKernelY(): number;
  88583. private _autoComputeBlurKernel;
  88584. protected _onRatioRescale(): void;
  88585. private _updateGammaSpace;
  88586. private _imageProcessingConfigChangeObserver;
  88587. private _transformMatrix;
  88588. private _mirrorMatrix;
  88589. private _savedViewMatrix;
  88590. private _blurX;
  88591. private _blurY;
  88592. private _adaptiveBlurKernel;
  88593. private _blurKernelX;
  88594. private _blurKernelY;
  88595. private _blurRatio;
  88596. /**
  88597. * Instantiates a Mirror Texture.
  88598. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88599. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88600. * You can then easily use it as a reflectionTexture on a flat surface.
  88601. * In case the surface is not a plane, please consider relying on reflection probes.
  88602. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88603. * @param name
  88604. * @param size
  88605. * @param scene
  88606. * @param generateMipMaps
  88607. * @param type
  88608. * @param samplingMode
  88609. * @param generateDepthBuffer
  88610. */
  88611. constructor(name: string, size: number | {
  88612. width: number;
  88613. height: number;
  88614. } | {
  88615. ratio: number;
  88616. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  88617. private _preparePostProcesses;
  88618. /**
  88619. * Clone the mirror texture.
  88620. * @returns the cloned texture
  88621. */
  88622. clone(): MirrorTexture;
  88623. /**
  88624. * Serialize the texture to a JSON representation you could use in Parse later on
  88625. * @returns the serialized JSON representation
  88626. */
  88627. serialize(): any;
  88628. /**
  88629. * Dispose the texture and release its associated resources.
  88630. */
  88631. dispose(): void;
  88632. }
  88633. }
  88634. declare module BABYLON {
  88635. /**
  88636. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88637. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88638. */
  88639. export class Texture extends BaseTexture {
  88640. /**
  88641. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  88642. */
  88643. static SerializeBuffers: boolean;
  88644. /** @hidden */
  88645. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  88646. /** @hidden */
  88647. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  88648. /** @hidden */
  88649. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  88650. /** nearest is mag = nearest and min = nearest and mip = linear */
  88651. static readonly NEAREST_SAMPLINGMODE: number;
  88652. /** nearest is mag = nearest and min = nearest and mip = linear */
  88653. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  88654. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88655. static readonly BILINEAR_SAMPLINGMODE: number;
  88656. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88657. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  88658. /** Trilinear is mag = linear and min = linear and mip = linear */
  88659. static readonly TRILINEAR_SAMPLINGMODE: number;
  88660. /** Trilinear is mag = linear and min = linear and mip = linear */
  88661. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  88662. /** mag = nearest and min = nearest and mip = nearest */
  88663. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  88664. /** mag = nearest and min = linear and mip = nearest */
  88665. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  88666. /** mag = nearest and min = linear and mip = linear */
  88667. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  88668. /** mag = nearest and min = linear and mip = none */
  88669. static readonly NEAREST_LINEAR: number;
  88670. /** mag = nearest and min = nearest and mip = none */
  88671. static readonly NEAREST_NEAREST: number;
  88672. /** mag = linear and min = nearest and mip = nearest */
  88673. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  88674. /** mag = linear and min = nearest and mip = linear */
  88675. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  88676. /** mag = linear and min = linear and mip = none */
  88677. static readonly LINEAR_LINEAR: number;
  88678. /** mag = linear and min = nearest and mip = none */
  88679. static readonly LINEAR_NEAREST: number;
  88680. /** Explicit coordinates mode */
  88681. static readonly EXPLICIT_MODE: number;
  88682. /** Spherical coordinates mode */
  88683. static readonly SPHERICAL_MODE: number;
  88684. /** Planar coordinates mode */
  88685. static readonly PLANAR_MODE: number;
  88686. /** Cubic coordinates mode */
  88687. static readonly CUBIC_MODE: number;
  88688. /** Projection coordinates mode */
  88689. static readonly PROJECTION_MODE: number;
  88690. /** Inverse Cubic coordinates mode */
  88691. static readonly SKYBOX_MODE: number;
  88692. /** Inverse Cubic coordinates mode */
  88693. static readonly INVCUBIC_MODE: number;
  88694. /** Equirectangular coordinates mode */
  88695. static readonly EQUIRECTANGULAR_MODE: number;
  88696. /** Equirectangular Fixed coordinates mode */
  88697. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  88698. /** Equirectangular Fixed Mirrored coordinates mode */
  88699. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  88700. /** Texture is not repeating outside of 0..1 UVs */
  88701. static readonly CLAMP_ADDRESSMODE: number;
  88702. /** Texture is repeating outside of 0..1 UVs */
  88703. static readonly WRAP_ADDRESSMODE: number;
  88704. /** Texture is repeating and mirrored */
  88705. static readonly MIRROR_ADDRESSMODE: number;
  88706. /**
  88707. * 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
  88708. */
  88709. static UseSerializedUrlIfAny: boolean;
  88710. /**
  88711. * Define the url of the texture.
  88712. */
  88713. url: Nullable<string>;
  88714. /**
  88715. * Define an offset on the texture to offset the u coordinates of the UVs
  88716. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88717. */
  88718. uOffset: number;
  88719. /**
  88720. * Define an offset on the texture to offset the v coordinates of the UVs
  88721. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88722. */
  88723. vOffset: number;
  88724. /**
  88725. * Define an offset on the texture to scale the u coordinates of the UVs
  88726. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88727. */
  88728. uScale: number;
  88729. /**
  88730. * Define an offset on the texture to scale the v coordinates of the UVs
  88731. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88732. */
  88733. vScale: number;
  88734. /**
  88735. * Define an offset on the texture to rotate around the u coordinates of the UVs
  88736. * @see http://doc.babylonjs.com/how_to/more_materials
  88737. */
  88738. uAng: number;
  88739. /**
  88740. * Define an offset on the texture to rotate around the v coordinates of the UVs
  88741. * @see http://doc.babylonjs.com/how_to/more_materials
  88742. */
  88743. vAng: number;
  88744. /**
  88745. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  88746. * @see http://doc.babylonjs.com/how_to/more_materials
  88747. */
  88748. wAng: number;
  88749. /**
  88750. * Defines the center of rotation (U)
  88751. */
  88752. uRotationCenter: number;
  88753. /**
  88754. * Defines the center of rotation (V)
  88755. */
  88756. vRotationCenter: number;
  88757. /**
  88758. * Defines the center of rotation (W)
  88759. */
  88760. wRotationCenter: number;
  88761. /**
  88762. * Are mip maps generated for this texture or not.
  88763. */
  88764. get noMipmap(): boolean;
  88765. /**
  88766. * List of inspectable custom properties (used by the Inspector)
  88767. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88768. */
  88769. inspectableCustomProperties: Nullable<IInspectable[]>;
  88770. private _noMipmap;
  88771. /** @hidden */
  88772. _invertY: boolean;
  88773. private _rowGenerationMatrix;
  88774. private _cachedTextureMatrix;
  88775. private _projectionModeMatrix;
  88776. private _t0;
  88777. private _t1;
  88778. private _t2;
  88779. private _cachedUOffset;
  88780. private _cachedVOffset;
  88781. private _cachedUScale;
  88782. private _cachedVScale;
  88783. private _cachedUAng;
  88784. private _cachedVAng;
  88785. private _cachedWAng;
  88786. private _cachedProjectionMatrixId;
  88787. private _cachedCoordinatesMode;
  88788. /** @hidden */
  88789. protected _initialSamplingMode: number;
  88790. /** @hidden */
  88791. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  88792. private _deleteBuffer;
  88793. protected _format: Nullable<number>;
  88794. private _delayedOnLoad;
  88795. private _delayedOnError;
  88796. private _mimeType?;
  88797. /**
  88798. * Observable triggered once the texture has been loaded.
  88799. */
  88800. onLoadObservable: Observable<Texture>;
  88801. protected _isBlocking: boolean;
  88802. /**
  88803. * Is the texture preventing material to render while loading.
  88804. * If false, a default texture will be used instead of the loading one during the preparation step.
  88805. */
  88806. set isBlocking(value: boolean);
  88807. get isBlocking(): boolean;
  88808. /**
  88809. * Get the current sampling mode associated with the texture.
  88810. */
  88811. get samplingMode(): number;
  88812. /**
  88813. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  88814. */
  88815. get invertY(): boolean;
  88816. /**
  88817. * Instantiates a new texture.
  88818. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88819. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88820. * @param url defines the url of the picture to load as a texture
  88821. * @param scene defines the scene or engine the texture will belong to
  88822. * @param noMipmap defines if the texture will require mip maps or not
  88823. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  88824. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88825. * @param onLoad defines a callback triggered when the texture has been loaded
  88826. * @param onError defines a callback triggered when an error occurred during the loading session
  88827. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  88828. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  88829. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88830. * @param mimeType defines an optional mime type information
  88831. */
  88832. 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);
  88833. /**
  88834. * Update the url (and optional buffer) of this texture if url was null during construction.
  88835. * @param url the url of the texture
  88836. * @param buffer the buffer of the texture (defaults to null)
  88837. * @param onLoad callback called when the texture is loaded (defaults to null)
  88838. */
  88839. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  88840. /**
  88841. * Finish the loading sequence of a texture flagged as delayed load.
  88842. * @hidden
  88843. */
  88844. delayLoad(): void;
  88845. private _prepareRowForTextureGeneration;
  88846. /**
  88847. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  88848. * @returns the transform matrix of the texture.
  88849. */
  88850. getTextureMatrix(uBase?: number): Matrix;
  88851. /**
  88852. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  88853. * @returns The reflection texture transform
  88854. */
  88855. getReflectionTextureMatrix(): Matrix;
  88856. /**
  88857. * Clones the texture.
  88858. * @returns the cloned texture
  88859. */
  88860. clone(): Texture;
  88861. /**
  88862. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88863. * @returns The JSON representation of the texture
  88864. */
  88865. serialize(): any;
  88866. /**
  88867. * Get the current class name of the texture useful for serialization or dynamic coding.
  88868. * @returns "Texture"
  88869. */
  88870. getClassName(): string;
  88871. /**
  88872. * Dispose the texture and release its associated resources.
  88873. */
  88874. dispose(): void;
  88875. /**
  88876. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  88877. * @param parsedTexture Define the JSON representation of the texture
  88878. * @param scene Define the scene the parsed texture should be instantiated in
  88879. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  88880. * @returns The parsed texture if successful
  88881. */
  88882. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  88883. /**
  88884. * Creates a texture from its base 64 representation.
  88885. * @param data Define the base64 payload without the data: prefix
  88886. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88887. * @param scene Define the scene the texture should belong to
  88888. * @param noMipmap Forces the texture to not create mip map information if true
  88889. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88890. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88891. * @param onLoad define a callback triggered when the texture has been loaded
  88892. * @param onError define a callback triggered when an error occurred during the loading session
  88893. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88894. * @returns the created texture
  88895. */
  88896. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  88897. /**
  88898. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  88899. * @param data Define the base64 payload without the data: prefix
  88900. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88901. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  88902. * @param scene Define the scene the texture should belong to
  88903. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  88904. * @param noMipmap Forces the texture to not create mip map information if true
  88905. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88906. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88907. * @param onLoad define a callback triggered when the texture has been loaded
  88908. * @param onError define a callback triggered when an error occurred during the loading session
  88909. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88910. * @returns the created texture
  88911. */
  88912. 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;
  88913. }
  88914. }
  88915. declare module BABYLON {
  88916. /**
  88917. * PostProcessManager is used to manage one or more post processes or post process pipelines
  88918. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88919. */
  88920. export class PostProcessManager {
  88921. private _scene;
  88922. private _indexBuffer;
  88923. private _vertexBuffers;
  88924. /**
  88925. * Creates a new instance PostProcess
  88926. * @param scene The scene that the post process is associated with.
  88927. */
  88928. constructor(scene: Scene);
  88929. private _prepareBuffers;
  88930. private _buildIndexBuffer;
  88931. /**
  88932. * Rebuilds the vertex buffers of the manager.
  88933. * @hidden
  88934. */
  88935. _rebuild(): void;
  88936. /**
  88937. * Prepares a frame to be run through a post process.
  88938. * @param sourceTexture The input texture to the post procesess. (default: null)
  88939. * @param postProcesses An array of post processes to be run. (default: null)
  88940. * @returns True if the post processes were able to be run.
  88941. * @hidden
  88942. */
  88943. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  88944. /**
  88945. * Manually render a set of post processes to a texture.
  88946. * @param postProcesses An array of post processes to be run.
  88947. * @param targetTexture The target texture to render to.
  88948. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  88949. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  88950. * @param lodLevel defines which lod of the texture to render to
  88951. */
  88952. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  88953. /**
  88954. * Finalize the result of the output of the postprocesses.
  88955. * @param doNotPresent If true the result will not be displayed to the screen.
  88956. * @param targetTexture The target texture to render to.
  88957. * @param faceIndex The index of the face to bind the target texture to.
  88958. * @param postProcesses The array of post processes to render.
  88959. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  88960. * @hidden
  88961. */
  88962. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  88963. /**
  88964. * Disposes of the post process manager.
  88965. */
  88966. dispose(): void;
  88967. }
  88968. }
  88969. declare module BABYLON {
  88970. /** Interface used by value gradients (color, factor, ...) */
  88971. export interface IValueGradient {
  88972. /**
  88973. * Gets or sets the gradient value (between 0 and 1)
  88974. */
  88975. gradient: number;
  88976. }
  88977. /** Class used to store color4 gradient */
  88978. export class ColorGradient implements IValueGradient {
  88979. /**
  88980. * Gets or sets the gradient value (between 0 and 1)
  88981. */
  88982. gradient: number;
  88983. /**
  88984. * Gets or sets first associated color
  88985. */
  88986. color1: Color4;
  88987. /**
  88988. * Gets or sets second associated color
  88989. */
  88990. color2?: Color4;
  88991. /**
  88992. * Will get a color picked randomly between color1 and color2.
  88993. * If color2 is undefined then color1 will be used
  88994. * @param result defines the target Color4 to store the result in
  88995. */
  88996. getColorToRef(result: Color4): void;
  88997. }
  88998. /** Class used to store color 3 gradient */
  88999. export class Color3Gradient implements IValueGradient {
  89000. /**
  89001. * Gets or sets the gradient value (between 0 and 1)
  89002. */
  89003. gradient: number;
  89004. /**
  89005. * Gets or sets the associated color
  89006. */
  89007. color: Color3;
  89008. }
  89009. /** Class used to store factor gradient */
  89010. export class FactorGradient implements IValueGradient {
  89011. /**
  89012. * Gets or sets the gradient value (between 0 and 1)
  89013. */
  89014. gradient: number;
  89015. /**
  89016. * Gets or sets first associated factor
  89017. */
  89018. factor1: number;
  89019. /**
  89020. * Gets or sets second associated factor
  89021. */
  89022. factor2?: number;
  89023. /**
  89024. * Will get a number picked randomly between factor1 and factor2.
  89025. * If factor2 is undefined then factor1 will be used
  89026. * @returns the picked number
  89027. */
  89028. getFactor(): number;
  89029. }
  89030. /**
  89031. * Helper used to simplify some generic gradient tasks
  89032. */
  89033. export class GradientHelper {
  89034. /**
  89035. * Gets the current gradient from an array of IValueGradient
  89036. * @param ratio defines the current ratio to get
  89037. * @param gradients defines the array of IValueGradient
  89038. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89039. */
  89040. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89041. }
  89042. }
  89043. declare module BABYLON {
  89044. interface ThinEngine {
  89045. /**
  89046. * Creates a dynamic texture
  89047. * @param width defines the width of the texture
  89048. * @param height defines the height of the texture
  89049. * @param generateMipMaps defines if the engine should generate the mip levels
  89050. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89051. * @returns the dynamic texture inside an InternalTexture
  89052. */
  89053. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  89054. /**
  89055. * Update the content of a dynamic texture
  89056. * @param texture defines the texture to update
  89057. * @param canvas defines the canvas containing the source
  89058. * @param invertY defines if data must be stored with Y axis inverted
  89059. * @param premulAlpha defines if alpha is stored as premultiplied
  89060. * @param format defines the format of the data
  89061. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  89062. */
  89063. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  89064. }
  89065. }
  89066. declare module BABYLON {
  89067. /**
  89068. * Helper class used to generate a canvas to manipulate images
  89069. */
  89070. export class CanvasGenerator {
  89071. /**
  89072. * Create a new canvas (or offscreen canvas depending on the context)
  89073. * @param width defines the expected width
  89074. * @param height defines the expected height
  89075. * @return a new canvas or offscreen canvas
  89076. */
  89077. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  89078. }
  89079. }
  89080. declare module BABYLON {
  89081. /**
  89082. * A class extending Texture allowing drawing on a texture
  89083. * @see http://doc.babylonjs.com/how_to/dynamictexture
  89084. */
  89085. export class DynamicTexture extends Texture {
  89086. private _generateMipMaps;
  89087. private _canvas;
  89088. private _context;
  89089. private _engine;
  89090. /**
  89091. * Creates a DynamicTexture
  89092. * @param name defines the name of the texture
  89093. * @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
  89094. * @param scene defines the scene where you want the texture
  89095. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  89096. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  89097. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  89098. */
  89099. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  89100. /**
  89101. * Get the current class name of the texture useful for serialization or dynamic coding.
  89102. * @returns "DynamicTexture"
  89103. */
  89104. getClassName(): string;
  89105. /**
  89106. * Gets the current state of canRescale
  89107. */
  89108. get canRescale(): boolean;
  89109. private _recreate;
  89110. /**
  89111. * Scales the texture
  89112. * @param ratio the scale factor to apply to both width and height
  89113. */
  89114. scale(ratio: number): void;
  89115. /**
  89116. * Resizes the texture
  89117. * @param width the new width
  89118. * @param height the new height
  89119. */
  89120. scaleTo(width: number, height: number): void;
  89121. /**
  89122. * Gets the context of the canvas used by the texture
  89123. * @returns the canvas context of the dynamic texture
  89124. */
  89125. getContext(): CanvasRenderingContext2D;
  89126. /**
  89127. * Clears the texture
  89128. */
  89129. clear(): void;
  89130. /**
  89131. * Updates the texture
  89132. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89133. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  89134. */
  89135. update(invertY?: boolean, premulAlpha?: boolean): void;
  89136. /**
  89137. * Draws text onto the texture
  89138. * @param text defines the text to be drawn
  89139. * @param x defines the placement of the text from the left
  89140. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  89141. * @param font defines the font to be used with font-style, font-size, font-name
  89142. * @param color defines the color used for the text
  89143. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  89144. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89145. * @param update defines whether texture is immediately update (default is true)
  89146. */
  89147. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  89148. /**
  89149. * Clones the texture
  89150. * @returns the clone of the texture.
  89151. */
  89152. clone(): DynamicTexture;
  89153. /**
  89154. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  89155. * @returns a serialized dynamic texture object
  89156. */
  89157. serialize(): any;
  89158. /** @hidden */
  89159. _rebuild(): void;
  89160. }
  89161. }
  89162. declare module BABYLON {
  89163. interface AbstractScene {
  89164. /**
  89165. * The list of procedural textures added to the scene
  89166. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89167. */
  89168. proceduralTextures: Array<ProceduralTexture>;
  89169. }
  89170. /**
  89171. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89172. * in a given scene.
  89173. */
  89174. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89175. /**
  89176. * The component name helpfull to identify the component in the list of scene components.
  89177. */
  89178. readonly name: string;
  89179. /**
  89180. * The scene the component belongs to.
  89181. */
  89182. scene: Scene;
  89183. /**
  89184. * Creates a new instance of the component for the given scene
  89185. * @param scene Defines the scene to register the component in
  89186. */
  89187. constructor(scene: Scene);
  89188. /**
  89189. * Registers the component in a given scene
  89190. */
  89191. register(): void;
  89192. /**
  89193. * Rebuilds the elements related to this component in case of
  89194. * context lost for instance.
  89195. */
  89196. rebuild(): void;
  89197. /**
  89198. * Disposes the component and the associated ressources.
  89199. */
  89200. dispose(): void;
  89201. private _beforeClear;
  89202. }
  89203. }
  89204. declare module BABYLON {
  89205. interface ThinEngine {
  89206. /**
  89207. * Creates a new render target cube texture
  89208. * @param size defines the size of the texture
  89209. * @param options defines the options used to create the texture
  89210. * @returns a new render target cube texture stored in an InternalTexture
  89211. */
  89212. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89213. }
  89214. }
  89215. declare module BABYLON {
  89216. /** @hidden */
  89217. export var proceduralVertexShader: {
  89218. name: string;
  89219. shader: string;
  89220. };
  89221. }
  89222. declare module BABYLON {
  89223. /**
  89224. * 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.
  89225. * This is the base class of any Procedural texture and contains most of the shareable code.
  89226. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89227. */
  89228. export class ProceduralTexture extends Texture {
  89229. isCube: boolean;
  89230. /**
  89231. * Define if the texture is enabled or not (disabled texture will not render)
  89232. */
  89233. isEnabled: boolean;
  89234. /**
  89235. * Define if the texture must be cleared before rendering (default is true)
  89236. */
  89237. autoClear: boolean;
  89238. /**
  89239. * Callback called when the texture is generated
  89240. */
  89241. onGenerated: () => void;
  89242. /**
  89243. * Event raised when the texture is generated
  89244. */
  89245. onGeneratedObservable: Observable<ProceduralTexture>;
  89246. /** @hidden */
  89247. _generateMipMaps: boolean;
  89248. /** @hidden **/
  89249. _effect: Effect;
  89250. /** @hidden */
  89251. _textures: {
  89252. [key: string]: Texture;
  89253. };
  89254. private _size;
  89255. private _currentRefreshId;
  89256. private _frameId;
  89257. private _refreshRate;
  89258. private _vertexBuffers;
  89259. private _indexBuffer;
  89260. private _uniforms;
  89261. private _samplers;
  89262. private _fragment;
  89263. private _floats;
  89264. private _ints;
  89265. private _floatsArrays;
  89266. private _colors3;
  89267. private _colors4;
  89268. private _vectors2;
  89269. private _vectors3;
  89270. private _matrices;
  89271. private _fallbackTexture;
  89272. private _fallbackTextureUsed;
  89273. private _engine;
  89274. private _cachedDefines;
  89275. private _contentUpdateId;
  89276. private _contentData;
  89277. /**
  89278. * Instantiates a new procedural texture.
  89279. * 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.
  89280. * This is the base class of any Procedural texture and contains most of the shareable code.
  89281. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89282. * @param name Define the name of the texture
  89283. * @param size Define the size of the texture to create
  89284. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89285. * @param scene Define the scene the texture belongs to
  89286. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89287. * @param generateMipMaps Define if the texture should creates mip maps or not
  89288. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89289. */
  89290. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89291. /**
  89292. * The effect that is created when initializing the post process.
  89293. * @returns The created effect corresponding the the postprocess.
  89294. */
  89295. getEffect(): Effect;
  89296. /**
  89297. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89298. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89299. */
  89300. getContent(): Nullable<ArrayBufferView>;
  89301. private _createIndexBuffer;
  89302. /** @hidden */
  89303. _rebuild(): void;
  89304. /**
  89305. * Resets the texture in order to recreate its associated resources.
  89306. * This can be called in case of context loss
  89307. */
  89308. reset(): void;
  89309. protected _getDefines(): string;
  89310. /**
  89311. * Is the texture ready to be used ? (rendered at least once)
  89312. * @returns true if ready, otherwise, false.
  89313. */
  89314. isReady(): boolean;
  89315. /**
  89316. * Resets the refresh counter of the texture and start bak from scratch.
  89317. * Could be useful to regenerate the texture if it is setup to render only once.
  89318. */
  89319. resetRefreshCounter(): void;
  89320. /**
  89321. * Set the fragment shader to use in order to render the texture.
  89322. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89323. */
  89324. setFragment(fragment: any): void;
  89325. /**
  89326. * Define the refresh rate of the texture or the rendering frequency.
  89327. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89328. */
  89329. get refreshRate(): number;
  89330. set refreshRate(value: number);
  89331. /** @hidden */
  89332. _shouldRender(): boolean;
  89333. /**
  89334. * Get the size the texture is rendering at.
  89335. * @returns the size (texture is always squared)
  89336. */
  89337. getRenderSize(): number;
  89338. /**
  89339. * Resize the texture to new value.
  89340. * @param size Define the new size the texture should have
  89341. * @param generateMipMaps Define whether the new texture should create mip maps
  89342. */
  89343. resize(size: number, generateMipMaps: boolean): void;
  89344. private _checkUniform;
  89345. /**
  89346. * Set a texture in the shader program used to render.
  89347. * @param name Define the name of the uniform samplers as defined in the shader
  89348. * @param texture Define the texture to bind to this sampler
  89349. * @return the texture itself allowing "fluent" like uniform updates
  89350. */
  89351. setTexture(name: string, texture: Texture): ProceduralTexture;
  89352. /**
  89353. * Set a float in the shader.
  89354. * @param name Define the name of the uniform as defined in the shader
  89355. * @param value Define the value to give to the uniform
  89356. * @return the texture itself allowing "fluent" like uniform updates
  89357. */
  89358. setFloat(name: string, value: number): ProceduralTexture;
  89359. /**
  89360. * Set a int in the shader.
  89361. * @param name Define the name of the uniform as defined in the shader
  89362. * @param value Define the value to give to the uniform
  89363. * @return the texture itself allowing "fluent" like uniform updates
  89364. */
  89365. setInt(name: string, value: number): ProceduralTexture;
  89366. /**
  89367. * Set an array of floats in the shader.
  89368. * @param name Define the name of the uniform as defined in the shader
  89369. * @param value Define the value to give to the uniform
  89370. * @return the texture itself allowing "fluent" like uniform updates
  89371. */
  89372. setFloats(name: string, value: number[]): ProceduralTexture;
  89373. /**
  89374. * Set a vec3 in the shader from a Color3.
  89375. * @param name Define the name of the uniform as defined in the shader
  89376. * @param value Define the value to give to the uniform
  89377. * @return the texture itself allowing "fluent" like uniform updates
  89378. */
  89379. setColor3(name: string, value: Color3): ProceduralTexture;
  89380. /**
  89381. * Set a vec4 in the shader from a Color4.
  89382. * @param name Define the name of the uniform as defined in the shader
  89383. * @param value Define the value to give to the uniform
  89384. * @return the texture itself allowing "fluent" like uniform updates
  89385. */
  89386. setColor4(name: string, value: Color4): ProceduralTexture;
  89387. /**
  89388. * Set a vec2 in the shader from a Vector2.
  89389. * @param name Define the name of the uniform as defined in the shader
  89390. * @param value Define the value to give to the uniform
  89391. * @return the texture itself allowing "fluent" like uniform updates
  89392. */
  89393. setVector2(name: string, value: Vector2): ProceduralTexture;
  89394. /**
  89395. * Set a vec3 in the shader from a Vector3.
  89396. * @param name Define the name of the uniform as defined in the shader
  89397. * @param value Define the value to give to the uniform
  89398. * @return the texture itself allowing "fluent" like uniform updates
  89399. */
  89400. setVector3(name: string, value: Vector3): ProceduralTexture;
  89401. /**
  89402. * Set a mat4 in the shader from a MAtrix.
  89403. * @param name Define the name of the uniform as defined in the shader
  89404. * @param value Define the value to give to the uniform
  89405. * @return the texture itself allowing "fluent" like uniform updates
  89406. */
  89407. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89408. /**
  89409. * Render the texture to its associated render target.
  89410. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89411. */
  89412. render(useCameraPostProcess?: boolean): void;
  89413. /**
  89414. * Clone the texture.
  89415. * @returns the cloned texture
  89416. */
  89417. clone(): ProceduralTexture;
  89418. /**
  89419. * Dispose the texture and release its asoociated resources.
  89420. */
  89421. dispose(): void;
  89422. }
  89423. }
  89424. declare module BABYLON {
  89425. /**
  89426. * This represents the base class for particle system in Babylon.
  89427. * 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.
  89428. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89429. * @example https://doc.babylonjs.com/babylon101/particles
  89430. */
  89431. export class BaseParticleSystem {
  89432. /**
  89433. * Source color is added to the destination color without alpha affecting the result
  89434. */
  89435. static BLENDMODE_ONEONE: number;
  89436. /**
  89437. * Blend current color and particle color using particle’s alpha
  89438. */
  89439. static BLENDMODE_STANDARD: number;
  89440. /**
  89441. * Add current color and particle color multiplied by particle’s alpha
  89442. */
  89443. static BLENDMODE_ADD: number;
  89444. /**
  89445. * Multiply current color with particle color
  89446. */
  89447. static BLENDMODE_MULTIPLY: number;
  89448. /**
  89449. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89450. */
  89451. static BLENDMODE_MULTIPLYADD: number;
  89452. /**
  89453. * List of animations used by the particle system.
  89454. */
  89455. animations: Animation[];
  89456. /**
  89457. * The id of the Particle system.
  89458. */
  89459. id: string;
  89460. /**
  89461. * The friendly name of the Particle system.
  89462. */
  89463. name: string;
  89464. /**
  89465. * The rendering group used by the Particle system to chose when to render.
  89466. */
  89467. renderingGroupId: number;
  89468. /**
  89469. * The emitter represents the Mesh or position we are attaching the particle system to.
  89470. */
  89471. emitter: Nullable<AbstractMesh | Vector3>;
  89472. /**
  89473. * The maximum number of particles to emit per frame
  89474. */
  89475. emitRate: number;
  89476. /**
  89477. * If you want to launch only a few particles at once, that can be done, as well.
  89478. */
  89479. manualEmitCount: number;
  89480. /**
  89481. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89482. */
  89483. updateSpeed: number;
  89484. /**
  89485. * The amount of time the particle system is running (depends of the overall update speed).
  89486. */
  89487. targetStopDuration: number;
  89488. /**
  89489. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89490. */
  89491. disposeOnStop: boolean;
  89492. /**
  89493. * Minimum power of emitting particles.
  89494. */
  89495. minEmitPower: number;
  89496. /**
  89497. * Maximum power of emitting particles.
  89498. */
  89499. maxEmitPower: number;
  89500. /**
  89501. * Minimum life time of emitting particles.
  89502. */
  89503. minLifeTime: number;
  89504. /**
  89505. * Maximum life time of emitting particles.
  89506. */
  89507. maxLifeTime: number;
  89508. /**
  89509. * Minimum Size of emitting particles.
  89510. */
  89511. minSize: number;
  89512. /**
  89513. * Maximum Size of emitting particles.
  89514. */
  89515. maxSize: number;
  89516. /**
  89517. * Minimum scale of emitting particles on X axis.
  89518. */
  89519. minScaleX: number;
  89520. /**
  89521. * Maximum scale of emitting particles on X axis.
  89522. */
  89523. maxScaleX: number;
  89524. /**
  89525. * Minimum scale of emitting particles on Y axis.
  89526. */
  89527. minScaleY: number;
  89528. /**
  89529. * Maximum scale of emitting particles on Y axis.
  89530. */
  89531. maxScaleY: number;
  89532. /**
  89533. * Gets or sets the minimal initial rotation in radians.
  89534. */
  89535. minInitialRotation: number;
  89536. /**
  89537. * Gets or sets the maximal initial rotation in radians.
  89538. */
  89539. maxInitialRotation: number;
  89540. /**
  89541. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89542. */
  89543. minAngularSpeed: number;
  89544. /**
  89545. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89546. */
  89547. maxAngularSpeed: number;
  89548. /**
  89549. * The texture used to render each particle. (this can be a spritesheet)
  89550. */
  89551. particleTexture: Nullable<Texture>;
  89552. /**
  89553. * The layer mask we are rendering the particles through.
  89554. */
  89555. layerMask: number;
  89556. /**
  89557. * This can help using your own shader to render the particle system.
  89558. * The according effect will be created
  89559. */
  89560. customShader: any;
  89561. /**
  89562. * By default particle system starts as soon as they are created. This prevents the
  89563. * automatic start to happen and let you decide when to start emitting particles.
  89564. */
  89565. preventAutoStart: boolean;
  89566. private _noiseTexture;
  89567. /**
  89568. * Gets or sets a texture used to add random noise to particle positions
  89569. */
  89570. get noiseTexture(): Nullable<ProceduralTexture>;
  89571. set noiseTexture(value: Nullable<ProceduralTexture>);
  89572. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89573. noiseStrength: Vector3;
  89574. /**
  89575. * Callback triggered when the particle animation is ending.
  89576. */
  89577. onAnimationEnd: Nullable<() => void>;
  89578. /**
  89579. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89580. */
  89581. blendMode: number;
  89582. /**
  89583. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89584. * to override the particles.
  89585. */
  89586. forceDepthWrite: boolean;
  89587. /** 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 */
  89588. preWarmCycles: number;
  89589. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89590. preWarmStepOffset: number;
  89591. /**
  89592. * 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)
  89593. */
  89594. spriteCellChangeSpeed: number;
  89595. /**
  89596. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89597. */
  89598. startSpriteCellID: number;
  89599. /**
  89600. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89601. */
  89602. endSpriteCellID: number;
  89603. /**
  89604. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89605. */
  89606. spriteCellWidth: number;
  89607. /**
  89608. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89609. */
  89610. spriteCellHeight: number;
  89611. /**
  89612. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89613. */
  89614. spriteRandomStartCell: boolean;
  89615. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89616. translationPivot: Vector2;
  89617. /** @hidden */
  89618. protected _isAnimationSheetEnabled: boolean;
  89619. /**
  89620. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89621. */
  89622. beginAnimationOnStart: boolean;
  89623. /**
  89624. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89625. */
  89626. beginAnimationFrom: number;
  89627. /**
  89628. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89629. */
  89630. beginAnimationTo: number;
  89631. /**
  89632. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89633. */
  89634. beginAnimationLoop: boolean;
  89635. /**
  89636. * Gets or sets a world offset applied to all particles
  89637. */
  89638. worldOffset: Vector3;
  89639. /**
  89640. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89641. */
  89642. get isAnimationSheetEnabled(): boolean;
  89643. set isAnimationSheetEnabled(value: boolean);
  89644. /**
  89645. * Get hosting scene
  89646. * @returns the scene
  89647. */
  89648. getScene(): Scene;
  89649. /**
  89650. * You can use gravity if you want to give an orientation to your particles.
  89651. */
  89652. gravity: Vector3;
  89653. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89654. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89655. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89656. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89657. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89658. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89659. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89660. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89661. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89662. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89663. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89664. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89665. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89666. /**
  89667. * Defines the delay in milliseconds before starting the system (0 by default)
  89668. */
  89669. startDelay: number;
  89670. /**
  89671. * Gets the current list of drag gradients.
  89672. * You must use addDragGradient and removeDragGradient to udpate this list
  89673. * @returns the list of drag gradients
  89674. */
  89675. getDragGradients(): Nullable<Array<FactorGradient>>;
  89676. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89677. limitVelocityDamping: number;
  89678. /**
  89679. * Gets the current list of limit velocity gradients.
  89680. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89681. * @returns the list of limit velocity gradients
  89682. */
  89683. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89684. /**
  89685. * Gets the current list of color gradients.
  89686. * You must use addColorGradient and removeColorGradient to udpate this list
  89687. * @returns the list of color gradients
  89688. */
  89689. getColorGradients(): Nullable<Array<ColorGradient>>;
  89690. /**
  89691. * Gets the current list of size gradients.
  89692. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89693. * @returns the list of size gradients
  89694. */
  89695. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89696. /**
  89697. * Gets the current list of color remap gradients.
  89698. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89699. * @returns the list of color remap gradients
  89700. */
  89701. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89702. /**
  89703. * Gets the current list of alpha remap gradients.
  89704. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89705. * @returns the list of alpha remap gradients
  89706. */
  89707. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89708. /**
  89709. * Gets the current list of life time gradients.
  89710. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89711. * @returns the list of life time gradients
  89712. */
  89713. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89714. /**
  89715. * Gets the current list of angular speed gradients.
  89716. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89717. * @returns the list of angular speed gradients
  89718. */
  89719. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89720. /**
  89721. * Gets the current list of velocity gradients.
  89722. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89723. * @returns the list of velocity gradients
  89724. */
  89725. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89726. /**
  89727. * Gets the current list of start size gradients.
  89728. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89729. * @returns the list of start size gradients
  89730. */
  89731. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89732. /**
  89733. * Gets the current list of emit rate gradients.
  89734. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89735. * @returns the list of emit rate gradients
  89736. */
  89737. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89738. /**
  89739. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89740. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89741. */
  89742. get direction1(): Vector3;
  89743. set direction1(value: Vector3);
  89744. /**
  89745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89746. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89747. */
  89748. get direction2(): Vector3;
  89749. set direction2(value: Vector3);
  89750. /**
  89751. * 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.
  89752. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89753. */
  89754. get minEmitBox(): Vector3;
  89755. set minEmitBox(value: Vector3);
  89756. /**
  89757. * 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.
  89758. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89759. */
  89760. get maxEmitBox(): Vector3;
  89761. set maxEmitBox(value: Vector3);
  89762. /**
  89763. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89764. */
  89765. color1: Color4;
  89766. /**
  89767. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89768. */
  89769. color2: Color4;
  89770. /**
  89771. * Color the particle will have at the end of its lifetime
  89772. */
  89773. colorDead: Color4;
  89774. /**
  89775. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89776. */
  89777. textureMask: Color4;
  89778. /**
  89779. * The particle emitter type defines the emitter used by the particle system.
  89780. * It can be for example box, sphere, or cone...
  89781. */
  89782. particleEmitterType: IParticleEmitterType;
  89783. /** @hidden */
  89784. _isSubEmitter: boolean;
  89785. /**
  89786. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89787. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89788. */
  89789. billboardMode: number;
  89790. protected _isBillboardBased: boolean;
  89791. /**
  89792. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89793. */
  89794. get isBillboardBased(): boolean;
  89795. set isBillboardBased(value: boolean);
  89796. /**
  89797. * The scene the particle system belongs to.
  89798. */
  89799. protected _scene: Scene;
  89800. /**
  89801. * Local cache of defines for image processing.
  89802. */
  89803. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89804. /**
  89805. * Default configuration related to image processing available in the standard Material.
  89806. */
  89807. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89808. /**
  89809. * Gets the image processing configuration used either in this material.
  89810. */
  89811. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89812. /**
  89813. * Sets the Default image processing configuration used either in the this material.
  89814. *
  89815. * If sets to null, the scene one is in use.
  89816. */
  89817. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89818. /**
  89819. * Attaches a new image processing configuration to the Standard Material.
  89820. * @param configuration
  89821. */
  89822. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89823. /** @hidden */
  89824. protected _reset(): void;
  89825. /** @hidden */
  89826. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89827. /**
  89828. * Instantiates a particle system.
  89829. * 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.
  89830. * @param name The name of the particle system
  89831. */
  89832. constructor(name: string);
  89833. /**
  89834. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89837. * @returns the emitter
  89838. */
  89839. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89840. /**
  89841. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89842. * @param radius The radius of the hemisphere to emit from
  89843. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89844. * @returns the emitter
  89845. */
  89846. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89847. /**
  89848. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89849. * @param radius The radius of the sphere to emit from
  89850. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89851. * @returns the emitter
  89852. */
  89853. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89854. /**
  89855. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89856. * @param radius The radius of the sphere to emit from
  89857. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89858. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89859. * @returns the emitter
  89860. */
  89861. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89862. /**
  89863. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89864. * @param radius The radius of the emission cylinder
  89865. * @param height The height of the emission cylinder
  89866. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89867. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89868. * @returns the emitter
  89869. */
  89870. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89871. /**
  89872. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89873. * @param radius The radius of the cylinder to emit from
  89874. * @param height The height of the emission cylinder
  89875. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89876. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89877. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89878. * @returns the emitter
  89879. */
  89880. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89881. /**
  89882. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89883. * @param radius The radius of the cone to emit from
  89884. * @param angle The base angle of the cone
  89885. * @returns the emitter
  89886. */
  89887. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89888. /**
  89889. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89890. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89891. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89892. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89893. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89894. * @returns the emitter
  89895. */
  89896. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89897. }
  89898. }
  89899. declare module BABYLON {
  89900. /**
  89901. * Type of sub emitter
  89902. */
  89903. export enum SubEmitterType {
  89904. /**
  89905. * Attached to the particle over it's lifetime
  89906. */
  89907. ATTACHED = 0,
  89908. /**
  89909. * Created when the particle dies
  89910. */
  89911. END = 1
  89912. }
  89913. /**
  89914. * Sub emitter class used to emit particles from an existing particle
  89915. */
  89916. export class SubEmitter {
  89917. /**
  89918. * the particle system to be used by the sub emitter
  89919. */
  89920. particleSystem: ParticleSystem;
  89921. /**
  89922. * Type of the submitter (Default: END)
  89923. */
  89924. type: SubEmitterType;
  89925. /**
  89926. * 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)
  89927. * Note: This only is supported when using an emitter of type Mesh
  89928. */
  89929. inheritDirection: boolean;
  89930. /**
  89931. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89932. */
  89933. inheritedVelocityAmount: number;
  89934. /**
  89935. * Creates a sub emitter
  89936. * @param particleSystem the particle system to be used by the sub emitter
  89937. */
  89938. constructor(
  89939. /**
  89940. * the particle system to be used by the sub emitter
  89941. */
  89942. particleSystem: ParticleSystem);
  89943. /**
  89944. * Clones the sub emitter
  89945. * @returns the cloned sub emitter
  89946. */
  89947. clone(): SubEmitter;
  89948. /**
  89949. * Serialize current object to a JSON object
  89950. * @returns the serialized object
  89951. */
  89952. serialize(): any;
  89953. /** @hidden */
  89954. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89955. /**
  89956. * Creates a new SubEmitter from a serialized JSON version
  89957. * @param serializationObject defines the JSON object to read from
  89958. * @param scene defines the hosting scene
  89959. * @param rootUrl defines the rootUrl for data loading
  89960. * @returns a new SubEmitter
  89961. */
  89962. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89963. /** Release associated resources */
  89964. dispose(): void;
  89965. }
  89966. }
  89967. declare module BABYLON {
  89968. /** @hidden */
  89969. export var clipPlaneFragmentDeclaration: {
  89970. name: string;
  89971. shader: string;
  89972. };
  89973. }
  89974. declare module BABYLON {
  89975. /** @hidden */
  89976. export var imageProcessingDeclaration: {
  89977. name: string;
  89978. shader: string;
  89979. };
  89980. }
  89981. declare module BABYLON {
  89982. /** @hidden */
  89983. export var imageProcessingFunctions: {
  89984. name: string;
  89985. shader: string;
  89986. };
  89987. }
  89988. declare module BABYLON {
  89989. /** @hidden */
  89990. export var clipPlaneFragment: {
  89991. name: string;
  89992. shader: string;
  89993. };
  89994. }
  89995. declare module BABYLON {
  89996. /** @hidden */
  89997. export var particlesPixelShader: {
  89998. name: string;
  89999. shader: string;
  90000. };
  90001. }
  90002. declare module BABYLON {
  90003. /** @hidden */
  90004. export var clipPlaneVertexDeclaration: {
  90005. name: string;
  90006. shader: string;
  90007. };
  90008. }
  90009. declare module BABYLON {
  90010. /** @hidden */
  90011. export var clipPlaneVertex: {
  90012. name: string;
  90013. shader: string;
  90014. };
  90015. }
  90016. declare module BABYLON {
  90017. /** @hidden */
  90018. export var particlesVertexShader: {
  90019. name: string;
  90020. shader: string;
  90021. };
  90022. }
  90023. declare module BABYLON {
  90024. /**
  90025. * This represents a particle system in Babylon.
  90026. * 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.
  90027. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90028. * @example https://doc.babylonjs.com/babylon101/particles
  90029. */
  90030. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90031. /**
  90032. * Billboard mode will only apply to Y axis
  90033. */
  90034. static readonly BILLBOARDMODE_Y: number;
  90035. /**
  90036. * Billboard mode will apply to all axes
  90037. */
  90038. static readonly BILLBOARDMODE_ALL: number;
  90039. /**
  90040. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90041. */
  90042. static readonly BILLBOARDMODE_STRETCHED: number;
  90043. /**
  90044. * This function can be defined to provide custom update for active particles.
  90045. * This function will be called instead of regular update (age, position, color, etc.).
  90046. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90047. */
  90048. updateFunction: (particles: Particle[]) => void;
  90049. private _emitterWorldMatrix;
  90050. /**
  90051. * This function can be defined to specify initial direction for every new particle.
  90052. * It by default use the emitterType defined function
  90053. */
  90054. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  90055. /**
  90056. * This function can be defined to specify initial position for every new particle.
  90057. * It by default use the emitterType defined function
  90058. */
  90059. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  90060. /**
  90061. * @hidden
  90062. */
  90063. _inheritedVelocityOffset: Vector3;
  90064. /**
  90065. * An event triggered when the system is disposed
  90066. */
  90067. onDisposeObservable: Observable<ParticleSystem>;
  90068. private _onDisposeObserver;
  90069. /**
  90070. * Sets a callback that will be triggered when the system is disposed
  90071. */
  90072. set onDispose(callback: () => void);
  90073. private _particles;
  90074. private _epsilon;
  90075. private _capacity;
  90076. private _stockParticles;
  90077. private _newPartsExcess;
  90078. private _vertexData;
  90079. private _vertexBuffer;
  90080. private _vertexBuffers;
  90081. private _spriteBuffer;
  90082. private _indexBuffer;
  90083. private _effect;
  90084. private _customEffect;
  90085. private _cachedDefines;
  90086. private _scaledColorStep;
  90087. private _colorDiff;
  90088. private _scaledDirection;
  90089. private _scaledGravity;
  90090. private _currentRenderId;
  90091. private _alive;
  90092. private _useInstancing;
  90093. private _started;
  90094. private _stopped;
  90095. private _actualFrame;
  90096. private _scaledUpdateSpeed;
  90097. private _vertexBufferSize;
  90098. /** @hidden */
  90099. _currentEmitRateGradient: Nullable<FactorGradient>;
  90100. /** @hidden */
  90101. _currentEmitRate1: number;
  90102. /** @hidden */
  90103. _currentEmitRate2: number;
  90104. /** @hidden */
  90105. _currentStartSizeGradient: Nullable<FactorGradient>;
  90106. /** @hidden */
  90107. _currentStartSize1: number;
  90108. /** @hidden */
  90109. _currentStartSize2: number;
  90110. private readonly _rawTextureWidth;
  90111. private _rampGradientsTexture;
  90112. private _useRampGradients;
  90113. /** Gets or sets a boolean indicating that ramp gradients must be used
  90114. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90115. */
  90116. get useRampGradients(): boolean;
  90117. set useRampGradients(value: boolean);
  90118. /**
  90119. * 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.
  90120. * 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: [])
  90121. */
  90122. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90123. private _subEmitters;
  90124. /**
  90125. * @hidden
  90126. * If the particle systems emitter should be disposed when the particle system is disposed
  90127. */
  90128. _disposeEmitterOnDispose: boolean;
  90129. /**
  90130. * The current active Sub-systems, this property is used by the root particle system only.
  90131. */
  90132. activeSubSystems: Array<ParticleSystem>;
  90133. private _rootParticleSystem;
  90134. /**
  90135. * Gets the current list of active particles
  90136. */
  90137. get particles(): Particle[];
  90138. /**
  90139. * Returns the string "ParticleSystem"
  90140. * @returns a string containing the class name
  90141. */
  90142. getClassName(): string;
  90143. /**
  90144. * Instantiates a particle system.
  90145. * 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.
  90146. * @param name The name of the particle system
  90147. * @param capacity The max number of particles alive at the same time
  90148. * @param scene The scene the particle system belongs to
  90149. * @param customEffect a custom effect used to change the way particles are rendered by default
  90150. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90151. * @param epsilon Offset used to render the particles
  90152. */
  90153. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90154. private _addFactorGradient;
  90155. private _removeFactorGradient;
  90156. /**
  90157. * Adds a new life time gradient
  90158. * @param gradient defines the gradient to use (between 0 and 1)
  90159. * @param factor defines the life time factor to affect to the specified gradient
  90160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90161. * @returns the current particle system
  90162. */
  90163. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90164. /**
  90165. * Remove a specific life time gradient
  90166. * @param gradient defines the gradient to remove
  90167. * @returns the current particle system
  90168. */
  90169. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90170. /**
  90171. * Adds a new size gradient
  90172. * @param gradient defines the gradient to use (between 0 and 1)
  90173. * @param factor defines the size factor to affect to the specified gradient
  90174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90175. * @returns the current particle system
  90176. */
  90177. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90178. /**
  90179. * Remove a specific size gradient
  90180. * @param gradient defines the gradient to remove
  90181. * @returns the current particle system
  90182. */
  90183. removeSizeGradient(gradient: number): IParticleSystem;
  90184. /**
  90185. * Adds a new color remap gradient
  90186. * @param gradient defines the gradient to use (between 0 and 1)
  90187. * @param min defines the color remap minimal range
  90188. * @param max defines the color remap maximal range
  90189. * @returns the current particle system
  90190. */
  90191. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90192. /**
  90193. * Remove a specific color remap gradient
  90194. * @param gradient defines the gradient to remove
  90195. * @returns the current particle system
  90196. */
  90197. removeColorRemapGradient(gradient: number): IParticleSystem;
  90198. /**
  90199. * Adds a new alpha remap gradient
  90200. * @param gradient defines the gradient to use (between 0 and 1)
  90201. * @param min defines the alpha remap minimal range
  90202. * @param max defines the alpha remap maximal range
  90203. * @returns the current particle system
  90204. */
  90205. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90206. /**
  90207. * Remove a specific alpha remap gradient
  90208. * @param gradient defines the gradient to remove
  90209. * @returns the current particle system
  90210. */
  90211. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90212. /**
  90213. * Adds a new angular speed gradient
  90214. * @param gradient defines the gradient to use (between 0 and 1)
  90215. * @param factor defines the angular speed to affect to the specified gradient
  90216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90217. * @returns the current particle system
  90218. */
  90219. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90220. /**
  90221. * Remove a specific angular speed gradient
  90222. * @param gradient defines the gradient to remove
  90223. * @returns the current particle system
  90224. */
  90225. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90226. /**
  90227. * Adds a new velocity gradient
  90228. * @param gradient defines the gradient to use (between 0 and 1)
  90229. * @param factor defines the velocity to affect to the specified gradient
  90230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90231. * @returns the current particle system
  90232. */
  90233. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90234. /**
  90235. * Remove a specific velocity gradient
  90236. * @param gradient defines the gradient to remove
  90237. * @returns the current particle system
  90238. */
  90239. removeVelocityGradient(gradient: number): IParticleSystem;
  90240. /**
  90241. * Adds a new limit velocity gradient
  90242. * @param gradient defines the gradient to use (between 0 and 1)
  90243. * @param factor defines the limit velocity value to affect to the specified gradient
  90244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90245. * @returns the current particle system
  90246. */
  90247. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90248. /**
  90249. * Remove a specific limit velocity gradient
  90250. * @param gradient defines the gradient to remove
  90251. * @returns the current particle system
  90252. */
  90253. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90254. /**
  90255. * Adds a new drag gradient
  90256. * @param gradient defines the gradient to use (between 0 and 1)
  90257. * @param factor defines the drag value to affect to the specified gradient
  90258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90259. * @returns the current particle system
  90260. */
  90261. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90262. /**
  90263. * Remove a specific drag gradient
  90264. * @param gradient defines the gradient to remove
  90265. * @returns the current particle system
  90266. */
  90267. removeDragGradient(gradient: number): IParticleSystem;
  90268. /**
  90269. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90270. * @param gradient defines the gradient to use (between 0 and 1)
  90271. * @param factor defines the emit rate value to affect to the specified gradient
  90272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90273. * @returns the current particle system
  90274. */
  90275. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90276. /**
  90277. * Remove a specific emit rate gradient
  90278. * @param gradient defines the gradient to remove
  90279. * @returns the current particle system
  90280. */
  90281. removeEmitRateGradient(gradient: number): IParticleSystem;
  90282. /**
  90283. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90284. * @param gradient defines the gradient to use (between 0 and 1)
  90285. * @param factor defines the start size value to affect to the specified gradient
  90286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90287. * @returns the current particle system
  90288. */
  90289. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90290. /**
  90291. * Remove a specific start size gradient
  90292. * @param gradient defines the gradient to remove
  90293. * @returns the current particle system
  90294. */
  90295. removeStartSizeGradient(gradient: number): IParticleSystem;
  90296. private _createRampGradientTexture;
  90297. /**
  90298. * Gets the current list of ramp gradients.
  90299. * You must use addRampGradient and removeRampGradient to udpate this list
  90300. * @returns the list of ramp gradients
  90301. */
  90302. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90303. /**
  90304. * Adds a new ramp gradient used to remap particle colors
  90305. * @param gradient defines the gradient to use (between 0 and 1)
  90306. * @param color defines the color to affect to the specified gradient
  90307. * @returns the current particle system
  90308. */
  90309. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90310. /**
  90311. * Remove a specific ramp gradient
  90312. * @param gradient defines the gradient to remove
  90313. * @returns the current particle system
  90314. */
  90315. removeRampGradient(gradient: number): ParticleSystem;
  90316. /**
  90317. * Adds a new color gradient
  90318. * @param gradient defines the gradient to use (between 0 and 1)
  90319. * @param color1 defines the color to affect to the specified gradient
  90320. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90321. * @returns this particle system
  90322. */
  90323. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90324. /**
  90325. * Remove a specific color gradient
  90326. * @param gradient defines the gradient to remove
  90327. * @returns this particle system
  90328. */
  90329. removeColorGradient(gradient: number): IParticleSystem;
  90330. private _fetchR;
  90331. protected _reset(): void;
  90332. private _resetEffect;
  90333. private _createVertexBuffers;
  90334. private _createIndexBuffer;
  90335. /**
  90336. * Gets the maximum number of particles active at the same time.
  90337. * @returns The max number of active particles.
  90338. */
  90339. getCapacity(): number;
  90340. /**
  90341. * Gets whether there are still active particles in the system.
  90342. * @returns True if it is alive, otherwise false.
  90343. */
  90344. isAlive(): boolean;
  90345. /**
  90346. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90347. * @returns True if it has been started, otherwise false.
  90348. */
  90349. isStarted(): boolean;
  90350. private _prepareSubEmitterInternalArray;
  90351. /**
  90352. * Starts the particle system and begins to emit
  90353. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90354. */
  90355. start(delay?: number): void;
  90356. /**
  90357. * Stops the particle system.
  90358. * @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.
  90359. */
  90360. stop(stopSubEmitters?: boolean): void;
  90361. /**
  90362. * Remove all active particles
  90363. */
  90364. reset(): void;
  90365. /**
  90366. * @hidden (for internal use only)
  90367. */
  90368. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90369. /**
  90370. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90371. * Its lifetime will start back at 0.
  90372. */
  90373. recycleParticle: (particle: Particle) => void;
  90374. private _stopSubEmitters;
  90375. private _createParticle;
  90376. private _removeFromRoot;
  90377. private _emitFromParticle;
  90378. private _update;
  90379. /** @hidden */
  90380. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90381. /** @hidden */
  90382. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90383. /** @hidden */
  90384. private _getEffect;
  90385. /**
  90386. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90387. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90388. */
  90389. animate(preWarmOnly?: boolean): void;
  90390. private _appendParticleVertices;
  90391. /**
  90392. * Rebuilds the particle system.
  90393. */
  90394. rebuild(): void;
  90395. /**
  90396. * Is this system ready to be used/rendered
  90397. * @return true if the system is ready
  90398. */
  90399. isReady(): boolean;
  90400. private _render;
  90401. /**
  90402. * Renders the particle system in its current state.
  90403. * @returns the current number of particles
  90404. */
  90405. render(): number;
  90406. /**
  90407. * Disposes the particle system and free the associated resources
  90408. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90409. */
  90410. dispose(disposeTexture?: boolean): void;
  90411. /**
  90412. * Clones the particle system.
  90413. * @param name The name of the cloned object
  90414. * @param newEmitter The new emitter to use
  90415. * @returns the cloned particle system
  90416. */
  90417. clone(name: string, newEmitter: any): ParticleSystem;
  90418. /**
  90419. * Serializes the particle system to a JSON object.
  90420. * @returns the JSON object
  90421. */
  90422. serialize(): any;
  90423. /** @hidden */
  90424. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  90425. /** @hidden */
  90426. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90427. /**
  90428. * Parses a JSON object to create a particle system.
  90429. * @param parsedParticleSystem The JSON object to parse
  90430. * @param scene The scene to create the particle system in
  90431. * @param rootUrl The root url to use to load external dependencies like texture
  90432. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90433. * @returns the Parsed particle system
  90434. */
  90435. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90436. }
  90437. }
  90438. declare module BABYLON {
  90439. /**
  90440. * A particle represents one of the element emitted by a particle system.
  90441. * This is mainly define by its coordinates, direction, velocity and age.
  90442. */
  90443. export class Particle {
  90444. /**
  90445. * The particle system the particle belongs to.
  90446. */
  90447. particleSystem: ParticleSystem;
  90448. private static _Count;
  90449. /**
  90450. * Unique ID of the particle
  90451. */
  90452. id: number;
  90453. /**
  90454. * The world position of the particle in the scene.
  90455. */
  90456. position: Vector3;
  90457. /**
  90458. * The world direction of the particle in the scene.
  90459. */
  90460. direction: Vector3;
  90461. /**
  90462. * The color of the particle.
  90463. */
  90464. color: Color4;
  90465. /**
  90466. * The color change of the particle per step.
  90467. */
  90468. colorStep: Color4;
  90469. /**
  90470. * Defines how long will the life of the particle be.
  90471. */
  90472. lifeTime: number;
  90473. /**
  90474. * The current age of the particle.
  90475. */
  90476. age: number;
  90477. /**
  90478. * The current size of the particle.
  90479. */
  90480. size: number;
  90481. /**
  90482. * The current scale of the particle.
  90483. */
  90484. scale: Vector2;
  90485. /**
  90486. * The current angle of the particle.
  90487. */
  90488. angle: number;
  90489. /**
  90490. * Defines how fast is the angle changing.
  90491. */
  90492. angularSpeed: number;
  90493. /**
  90494. * Defines the cell index used by the particle to be rendered from a sprite.
  90495. */
  90496. cellIndex: number;
  90497. /**
  90498. * The information required to support color remapping
  90499. */
  90500. remapData: Vector4;
  90501. /** @hidden */
  90502. _randomCellOffset?: number;
  90503. /** @hidden */
  90504. _initialDirection: Nullable<Vector3>;
  90505. /** @hidden */
  90506. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90507. /** @hidden */
  90508. _initialStartSpriteCellID: number;
  90509. /** @hidden */
  90510. _initialEndSpriteCellID: number;
  90511. /** @hidden */
  90512. _currentColorGradient: Nullable<ColorGradient>;
  90513. /** @hidden */
  90514. _currentColor1: Color4;
  90515. /** @hidden */
  90516. _currentColor2: Color4;
  90517. /** @hidden */
  90518. _currentSizeGradient: Nullable<FactorGradient>;
  90519. /** @hidden */
  90520. _currentSize1: number;
  90521. /** @hidden */
  90522. _currentSize2: number;
  90523. /** @hidden */
  90524. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90525. /** @hidden */
  90526. _currentAngularSpeed1: number;
  90527. /** @hidden */
  90528. _currentAngularSpeed2: number;
  90529. /** @hidden */
  90530. _currentVelocityGradient: Nullable<FactorGradient>;
  90531. /** @hidden */
  90532. _currentVelocity1: number;
  90533. /** @hidden */
  90534. _currentVelocity2: number;
  90535. /** @hidden */
  90536. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90537. /** @hidden */
  90538. _currentLimitVelocity1: number;
  90539. /** @hidden */
  90540. _currentLimitVelocity2: number;
  90541. /** @hidden */
  90542. _currentDragGradient: Nullable<FactorGradient>;
  90543. /** @hidden */
  90544. _currentDrag1: number;
  90545. /** @hidden */
  90546. _currentDrag2: number;
  90547. /** @hidden */
  90548. _randomNoiseCoordinates1: Vector3;
  90549. /** @hidden */
  90550. _randomNoiseCoordinates2: Vector3;
  90551. /**
  90552. * Creates a new instance Particle
  90553. * @param particleSystem the particle system the particle belongs to
  90554. */
  90555. constructor(
  90556. /**
  90557. * The particle system the particle belongs to.
  90558. */
  90559. particleSystem: ParticleSystem);
  90560. private updateCellInfoFromSystem;
  90561. /**
  90562. * Defines how the sprite cell index is updated for the particle
  90563. */
  90564. updateCellIndex(): void;
  90565. /** @hidden */
  90566. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90567. /** @hidden */
  90568. _inheritParticleInfoToSubEmitters(): void;
  90569. /** @hidden */
  90570. _reset(): void;
  90571. /**
  90572. * Copy the properties of particle to another one.
  90573. * @param other the particle to copy the information to.
  90574. */
  90575. copyTo(other: Particle): void;
  90576. }
  90577. }
  90578. declare module BABYLON {
  90579. /**
  90580. * Particle emitter represents a volume emitting particles.
  90581. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90582. */
  90583. export interface IParticleEmitterType {
  90584. /**
  90585. * Called by the particle System when the direction is computed for the created particle.
  90586. * @param worldMatrix is the world matrix of the particle system
  90587. * @param directionToUpdate is the direction vector to update with the result
  90588. * @param particle is the particle we are computed the direction for
  90589. */
  90590. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90591. /**
  90592. * Called by the particle System when the position is computed for the created particle.
  90593. * @param worldMatrix is the world matrix of the particle system
  90594. * @param positionToUpdate is the position vector to update with the result
  90595. * @param particle is the particle we are computed the position for
  90596. */
  90597. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90598. /**
  90599. * Clones the current emitter and returns a copy of it
  90600. * @returns the new emitter
  90601. */
  90602. clone(): IParticleEmitterType;
  90603. /**
  90604. * Called by the GPUParticleSystem to setup the update shader
  90605. * @param effect defines the update shader
  90606. */
  90607. applyToShader(effect: Effect): void;
  90608. /**
  90609. * Returns a string to use to update the GPU particles update shader
  90610. * @returns the effect defines string
  90611. */
  90612. getEffectDefines(): string;
  90613. /**
  90614. * Returns a string representing the class name
  90615. * @returns a string containing the class name
  90616. */
  90617. getClassName(): string;
  90618. /**
  90619. * Serializes the particle system to a JSON object.
  90620. * @returns the JSON object
  90621. */
  90622. serialize(): any;
  90623. /**
  90624. * Parse properties from a JSON object
  90625. * @param serializationObject defines the JSON object
  90626. */
  90627. parse(serializationObject: any): void;
  90628. }
  90629. }
  90630. declare module BABYLON {
  90631. /**
  90632. * Particle emitter emitting particles from the inside of a box.
  90633. * It emits the particles randomly between 2 given directions.
  90634. */
  90635. export class BoxParticleEmitter implements IParticleEmitterType {
  90636. /**
  90637. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90638. */
  90639. direction1: Vector3;
  90640. /**
  90641. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90642. */
  90643. direction2: Vector3;
  90644. /**
  90645. * 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.
  90646. */
  90647. minEmitBox: Vector3;
  90648. /**
  90649. * 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.
  90650. */
  90651. maxEmitBox: Vector3;
  90652. /**
  90653. * Creates a new instance BoxParticleEmitter
  90654. */
  90655. constructor();
  90656. /**
  90657. * Called by the particle System when the direction is computed for the created particle.
  90658. * @param worldMatrix is the world matrix of the particle system
  90659. * @param directionToUpdate is the direction vector to update with the result
  90660. * @param particle is the particle we are computed the direction for
  90661. */
  90662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90663. /**
  90664. * Called by the particle System when the position is computed for the created particle.
  90665. * @param worldMatrix is the world matrix of the particle system
  90666. * @param positionToUpdate is the position vector to update with the result
  90667. * @param particle is the particle we are computed the position for
  90668. */
  90669. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90670. /**
  90671. * Clones the current emitter and returns a copy of it
  90672. * @returns the new emitter
  90673. */
  90674. clone(): BoxParticleEmitter;
  90675. /**
  90676. * Called by the GPUParticleSystem to setup the update shader
  90677. * @param effect defines the update shader
  90678. */
  90679. applyToShader(effect: Effect): void;
  90680. /**
  90681. * Returns a string to use to update the GPU particles update shader
  90682. * @returns a string containng the defines string
  90683. */
  90684. getEffectDefines(): string;
  90685. /**
  90686. * Returns the string "BoxParticleEmitter"
  90687. * @returns a string containing the class name
  90688. */
  90689. getClassName(): string;
  90690. /**
  90691. * Serializes the particle system to a JSON object.
  90692. * @returns the JSON object
  90693. */
  90694. serialize(): any;
  90695. /**
  90696. * Parse properties from a JSON object
  90697. * @param serializationObject defines the JSON object
  90698. */
  90699. parse(serializationObject: any): void;
  90700. }
  90701. }
  90702. declare module BABYLON {
  90703. /**
  90704. * Particle emitter emitting particles from the inside of a cone.
  90705. * It emits the particles alongside the cone volume from the base to the particle.
  90706. * The emission direction might be randomized.
  90707. */
  90708. export class ConeParticleEmitter implements IParticleEmitterType {
  90709. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90710. directionRandomizer: number;
  90711. private _radius;
  90712. private _angle;
  90713. private _height;
  90714. /**
  90715. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90716. */
  90717. radiusRange: number;
  90718. /**
  90719. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90720. */
  90721. heightRange: number;
  90722. /**
  90723. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90724. */
  90725. emitFromSpawnPointOnly: boolean;
  90726. /**
  90727. * Gets or sets the radius of the emission cone
  90728. */
  90729. get radius(): number;
  90730. set radius(value: number);
  90731. /**
  90732. * Gets or sets the angle of the emission cone
  90733. */
  90734. get angle(): number;
  90735. set angle(value: number);
  90736. private _buildHeight;
  90737. /**
  90738. * Creates a new instance ConeParticleEmitter
  90739. * @param radius the radius of the emission cone (1 by default)
  90740. * @param angle the cone base angle (PI by default)
  90741. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90742. */
  90743. constructor(radius?: number, angle?: number,
  90744. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90745. directionRandomizer?: number);
  90746. /**
  90747. * Called by the particle System when the direction is computed for the created particle.
  90748. * @param worldMatrix is the world matrix of the particle system
  90749. * @param directionToUpdate is the direction vector to update with the result
  90750. * @param particle is the particle we are computed the direction for
  90751. */
  90752. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90753. /**
  90754. * Called by the particle System when the position is computed for the created particle.
  90755. * @param worldMatrix is the world matrix of the particle system
  90756. * @param positionToUpdate is the position vector to update with the result
  90757. * @param particle is the particle we are computed the position for
  90758. */
  90759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90760. /**
  90761. * Clones the current emitter and returns a copy of it
  90762. * @returns the new emitter
  90763. */
  90764. clone(): ConeParticleEmitter;
  90765. /**
  90766. * Called by the GPUParticleSystem to setup the update shader
  90767. * @param effect defines the update shader
  90768. */
  90769. applyToShader(effect: Effect): void;
  90770. /**
  90771. * Returns a string to use to update the GPU particles update shader
  90772. * @returns a string containng the defines string
  90773. */
  90774. getEffectDefines(): string;
  90775. /**
  90776. * Returns the string "ConeParticleEmitter"
  90777. * @returns a string containing the class name
  90778. */
  90779. getClassName(): string;
  90780. /**
  90781. * Serializes the particle system to a JSON object.
  90782. * @returns the JSON object
  90783. */
  90784. serialize(): any;
  90785. /**
  90786. * Parse properties from a JSON object
  90787. * @param serializationObject defines the JSON object
  90788. */
  90789. parse(serializationObject: any): void;
  90790. }
  90791. }
  90792. declare module BABYLON {
  90793. /**
  90794. * Particle emitter emitting particles from the inside of a cylinder.
  90795. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90796. */
  90797. export class CylinderParticleEmitter implements IParticleEmitterType {
  90798. /**
  90799. * The radius of the emission cylinder.
  90800. */
  90801. radius: number;
  90802. /**
  90803. * The height of the emission cylinder.
  90804. */
  90805. height: number;
  90806. /**
  90807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90808. */
  90809. radiusRange: number;
  90810. /**
  90811. * How much to randomize the particle direction [0-1].
  90812. */
  90813. directionRandomizer: number;
  90814. /**
  90815. * Creates a new instance CylinderParticleEmitter
  90816. * @param radius the radius of the emission cylinder (1 by default)
  90817. * @param height the height of the emission cylinder (1 by default)
  90818. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90819. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90820. */
  90821. constructor(
  90822. /**
  90823. * The radius of the emission cylinder.
  90824. */
  90825. radius?: number,
  90826. /**
  90827. * The height of the emission cylinder.
  90828. */
  90829. height?: number,
  90830. /**
  90831. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90832. */
  90833. radiusRange?: number,
  90834. /**
  90835. * How much to randomize the particle direction [0-1].
  90836. */
  90837. directionRandomizer?: number);
  90838. /**
  90839. * Called by the particle System when the direction is computed for the created particle.
  90840. * @param worldMatrix is the world matrix of the particle system
  90841. * @param directionToUpdate is the direction vector to update with the result
  90842. * @param particle is the particle we are computed the direction for
  90843. */
  90844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90845. /**
  90846. * Called by the particle System when the position is computed for the created particle.
  90847. * @param worldMatrix is the world matrix of the particle system
  90848. * @param positionToUpdate is the position vector to update with the result
  90849. * @param particle is the particle we are computed the position for
  90850. */
  90851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90852. /**
  90853. * Clones the current emitter and returns a copy of it
  90854. * @returns the new emitter
  90855. */
  90856. clone(): CylinderParticleEmitter;
  90857. /**
  90858. * Called by the GPUParticleSystem to setup the update shader
  90859. * @param effect defines the update shader
  90860. */
  90861. applyToShader(effect: Effect): void;
  90862. /**
  90863. * Returns a string to use to update the GPU particles update shader
  90864. * @returns a string containng the defines string
  90865. */
  90866. getEffectDefines(): string;
  90867. /**
  90868. * Returns the string "CylinderParticleEmitter"
  90869. * @returns a string containing the class name
  90870. */
  90871. getClassName(): string;
  90872. /**
  90873. * Serializes the particle system to a JSON object.
  90874. * @returns the JSON object
  90875. */
  90876. serialize(): any;
  90877. /**
  90878. * Parse properties from a JSON object
  90879. * @param serializationObject defines the JSON object
  90880. */
  90881. parse(serializationObject: any): void;
  90882. }
  90883. /**
  90884. * Particle emitter emitting particles from the inside of a cylinder.
  90885. * It emits the particles randomly between two vectors.
  90886. */
  90887. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90888. /**
  90889. * The min limit of the emission direction.
  90890. */
  90891. direction1: Vector3;
  90892. /**
  90893. * The max limit of the emission direction.
  90894. */
  90895. direction2: Vector3;
  90896. /**
  90897. * Creates a new instance CylinderDirectedParticleEmitter
  90898. * @param radius the radius of the emission cylinder (1 by default)
  90899. * @param height the height of the emission cylinder (1 by default)
  90900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90901. * @param direction1 the min limit of the emission direction (up vector by default)
  90902. * @param direction2 the max limit of the emission direction (up vector by default)
  90903. */
  90904. constructor(radius?: number, height?: number, radiusRange?: number,
  90905. /**
  90906. * The min limit of the emission direction.
  90907. */
  90908. direction1?: Vector3,
  90909. /**
  90910. * The max limit of the emission direction.
  90911. */
  90912. direction2?: Vector3);
  90913. /**
  90914. * Called by the particle System when the direction is computed for the created particle.
  90915. * @param worldMatrix is the world matrix of the particle system
  90916. * @param directionToUpdate is the direction vector to update with the result
  90917. * @param particle is the particle we are computed the direction for
  90918. */
  90919. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90920. /**
  90921. * Clones the current emitter and returns a copy of it
  90922. * @returns the new emitter
  90923. */
  90924. clone(): CylinderDirectedParticleEmitter;
  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 "CylinderDirectedParticleEmitter"
  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. declare module BABYLON {
  90953. /**
  90954. * Particle emitter emitting particles from the inside of a hemisphere.
  90955. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90956. */
  90957. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90958. /**
  90959. * The radius of the emission hemisphere.
  90960. */
  90961. radius: number;
  90962. /**
  90963. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90964. */
  90965. radiusRange: number;
  90966. /**
  90967. * How much to randomize the particle direction [0-1].
  90968. */
  90969. directionRandomizer: number;
  90970. /**
  90971. * Creates a new instance HemisphericParticleEmitter
  90972. * @param radius the radius of the emission hemisphere (1 by default)
  90973. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90974. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90975. */
  90976. constructor(
  90977. /**
  90978. * The radius of the emission hemisphere.
  90979. */
  90980. radius?: number,
  90981. /**
  90982. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90983. */
  90984. radiusRange?: number,
  90985. /**
  90986. * How much to randomize the particle direction [0-1].
  90987. */
  90988. directionRandomizer?: number);
  90989. /**
  90990. * Called by the particle System when the direction is computed for the created particle.
  90991. * @param worldMatrix is the world matrix of the particle system
  90992. * @param directionToUpdate is the direction vector to update with the result
  90993. * @param particle is the particle we are computed the direction for
  90994. */
  90995. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90996. /**
  90997. * Called by the particle System when the position is computed for the created particle.
  90998. * @param worldMatrix is the world matrix of the particle system
  90999. * @param positionToUpdate is the position vector to update with the result
  91000. * @param particle is the particle we are computed the position for
  91001. */
  91002. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91003. /**
  91004. * Clones the current emitter and returns a copy of it
  91005. * @returns the new emitter
  91006. */
  91007. clone(): HemisphericParticleEmitter;
  91008. /**
  91009. * Called by the GPUParticleSystem to setup the update shader
  91010. * @param effect defines the update shader
  91011. */
  91012. applyToShader(effect: Effect): void;
  91013. /**
  91014. * Returns a string to use to update the GPU particles update shader
  91015. * @returns a string containng the defines string
  91016. */
  91017. getEffectDefines(): string;
  91018. /**
  91019. * Returns the string "HemisphericParticleEmitter"
  91020. * @returns a string containing the class name
  91021. */
  91022. getClassName(): string;
  91023. /**
  91024. * Serializes the particle system to a JSON object.
  91025. * @returns the JSON object
  91026. */
  91027. serialize(): any;
  91028. /**
  91029. * Parse properties from a JSON object
  91030. * @param serializationObject defines the JSON object
  91031. */
  91032. parse(serializationObject: any): void;
  91033. }
  91034. }
  91035. declare module BABYLON {
  91036. /**
  91037. * Particle emitter emitting particles from a point.
  91038. * It emits the particles randomly between 2 given directions.
  91039. */
  91040. export class PointParticleEmitter implements IParticleEmitterType {
  91041. /**
  91042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91043. */
  91044. direction1: Vector3;
  91045. /**
  91046. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91047. */
  91048. direction2: Vector3;
  91049. /**
  91050. * Creates a new instance PointParticleEmitter
  91051. */
  91052. constructor();
  91053. /**
  91054. * Called by the particle System when the direction is computed for the created particle.
  91055. * @param worldMatrix is the world matrix of the particle system
  91056. * @param directionToUpdate is the direction vector to update with the result
  91057. * @param particle is the particle we are computed the direction for
  91058. */
  91059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91060. /**
  91061. * Called by the particle System when the position is computed for the created particle.
  91062. * @param worldMatrix is the world matrix of the particle system
  91063. * @param positionToUpdate is the position vector to update with the result
  91064. * @param particle is the particle we are computed the position for
  91065. */
  91066. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91067. /**
  91068. * Clones the current emitter and returns a copy of it
  91069. * @returns the new emitter
  91070. */
  91071. clone(): PointParticleEmitter;
  91072. /**
  91073. * Called by the GPUParticleSystem to setup the update shader
  91074. * @param effect defines the update shader
  91075. */
  91076. applyToShader(effect: Effect): void;
  91077. /**
  91078. * Returns a string to use to update the GPU particles update shader
  91079. * @returns a string containng the defines string
  91080. */
  91081. getEffectDefines(): string;
  91082. /**
  91083. * Returns the string "PointParticleEmitter"
  91084. * @returns a string containing the class name
  91085. */
  91086. getClassName(): string;
  91087. /**
  91088. * Serializes the particle system to a JSON object.
  91089. * @returns the JSON object
  91090. */
  91091. serialize(): any;
  91092. /**
  91093. * Parse properties from a JSON object
  91094. * @param serializationObject defines the JSON object
  91095. */
  91096. parse(serializationObject: any): void;
  91097. }
  91098. }
  91099. declare module BABYLON {
  91100. /**
  91101. * Particle emitter emitting particles from the inside of a sphere.
  91102. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91103. */
  91104. export class SphereParticleEmitter implements IParticleEmitterType {
  91105. /**
  91106. * The radius of the emission sphere.
  91107. */
  91108. radius: number;
  91109. /**
  91110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91111. */
  91112. radiusRange: number;
  91113. /**
  91114. * How much to randomize the particle direction [0-1].
  91115. */
  91116. directionRandomizer: number;
  91117. /**
  91118. * Creates a new instance SphereParticleEmitter
  91119. * @param radius the radius of the emission sphere (1 by default)
  91120. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91121. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91122. */
  91123. constructor(
  91124. /**
  91125. * The radius of the emission sphere.
  91126. */
  91127. radius?: number,
  91128. /**
  91129. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91130. */
  91131. radiusRange?: number,
  91132. /**
  91133. * How much to randomize the particle direction [0-1].
  91134. */
  91135. directionRandomizer?: number);
  91136. /**
  91137. * Called by the particle System when the direction is computed for the created particle.
  91138. * @param worldMatrix is the world matrix of the particle system
  91139. * @param directionToUpdate is the direction vector to update with the result
  91140. * @param particle is the particle we are computed the direction for
  91141. */
  91142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91143. /**
  91144. * Called by the particle System when the position is computed for the created particle.
  91145. * @param worldMatrix is the world matrix of the particle system
  91146. * @param positionToUpdate is the position vector to update with the result
  91147. * @param particle is the particle we are computed the position for
  91148. */
  91149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91150. /**
  91151. * Clones the current emitter and returns a copy of it
  91152. * @returns the new emitter
  91153. */
  91154. clone(): SphereParticleEmitter;
  91155. /**
  91156. * Called by the GPUParticleSystem to setup the update shader
  91157. * @param effect defines the update shader
  91158. */
  91159. applyToShader(effect: Effect): void;
  91160. /**
  91161. * Returns a string to use to update the GPU particles update shader
  91162. * @returns a string containng the defines string
  91163. */
  91164. getEffectDefines(): string;
  91165. /**
  91166. * Returns the string "SphereParticleEmitter"
  91167. * @returns a string containing the class name
  91168. */
  91169. getClassName(): string;
  91170. /**
  91171. * Serializes the particle system to a JSON object.
  91172. * @returns the JSON object
  91173. */
  91174. serialize(): any;
  91175. /**
  91176. * Parse properties from a JSON object
  91177. * @param serializationObject defines the JSON object
  91178. */
  91179. parse(serializationObject: any): void;
  91180. }
  91181. /**
  91182. * Particle emitter emitting particles from the inside of a sphere.
  91183. * It emits the particles randomly between two vectors.
  91184. */
  91185. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91186. /**
  91187. * The min limit of the emission direction.
  91188. */
  91189. direction1: Vector3;
  91190. /**
  91191. * The max limit of the emission direction.
  91192. */
  91193. direction2: Vector3;
  91194. /**
  91195. * Creates a new instance SphereDirectedParticleEmitter
  91196. * @param radius the radius of the emission sphere (1 by default)
  91197. * @param direction1 the min limit of the emission direction (up vector by default)
  91198. * @param direction2 the max limit of the emission direction (up vector by default)
  91199. */
  91200. constructor(radius?: number,
  91201. /**
  91202. * The min limit of the emission direction.
  91203. */
  91204. direction1?: Vector3,
  91205. /**
  91206. * The max limit of the emission direction.
  91207. */
  91208. direction2?: Vector3);
  91209. /**
  91210. * Called by the particle System when the direction is computed for the created particle.
  91211. * @param worldMatrix is the world matrix of the particle system
  91212. * @param directionToUpdate is the direction vector to update with the result
  91213. * @param particle is the particle we are computed the direction for
  91214. */
  91215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91216. /**
  91217. * Clones the current emitter and returns a copy of it
  91218. * @returns the new emitter
  91219. */
  91220. clone(): SphereDirectedParticleEmitter;
  91221. /**
  91222. * Called by the GPUParticleSystem to setup the update shader
  91223. * @param effect defines the update shader
  91224. */
  91225. applyToShader(effect: Effect): void;
  91226. /**
  91227. * Returns a string to use to update the GPU particles update shader
  91228. * @returns a string containng the defines string
  91229. */
  91230. getEffectDefines(): string;
  91231. /**
  91232. * Returns the string "SphereDirectedParticleEmitter"
  91233. * @returns a string containing the class name
  91234. */
  91235. getClassName(): string;
  91236. /**
  91237. * Serializes the particle system to a JSON object.
  91238. * @returns the JSON object
  91239. */
  91240. serialize(): any;
  91241. /**
  91242. * Parse properties from a JSON object
  91243. * @param serializationObject defines the JSON object
  91244. */
  91245. parse(serializationObject: any): void;
  91246. }
  91247. }
  91248. declare module BABYLON {
  91249. /**
  91250. * Particle emitter emitting particles from a custom list of positions.
  91251. */
  91252. export class CustomParticleEmitter implements IParticleEmitterType {
  91253. /**
  91254. * Gets or sets the position generator that will create the inital position of each particle.
  91255. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91256. */
  91257. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91258. /**
  91259. * Gets or sets the destination generator that will create the final destination of each particle.
  91260. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91261. */
  91262. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91263. /**
  91264. * Creates a new instance CustomParticleEmitter
  91265. */
  91266. constructor();
  91267. /**
  91268. * Called by the particle System when the direction is computed for the created particle.
  91269. * @param worldMatrix is the world matrix of the particle system
  91270. * @param directionToUpdate is the direction vector to update with the result
  91271. * @param particle is the particle we are computed the direction for
  91272. */
  91273. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91274. /**
  91275. * Called by the particle System when the position is computed for the created particle.
  91276. * @param worldMatrix is the world matrix of the particle system
  91277. * @param positionToUpdate is the position vector to update with the result
  91278. * @param particle is the particle we are computed the position for
  91279. */
  91280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91281. /**
  91282. * Clones the current emitter and returns a copy of it
  91283. * @returns the new emitter
  91284. */
  91285. clone(): CustomParticleEmitter;
  91286. /**
  91287. * Called by the GPUParticleSystem to setup the update shader
  91288. * @param effect defines the update shader
  91289. */
  91290. applyToShader(effect: Effect): void;
  91291. /**
  91292. * Returns a string to use to update the GPU particles update shader
  91293. * @returns a string containng the defines string
  91294. */
  91295. getEffectDefines(): string;
  91296. /**
  91297. * Returns the string "PointParticleEmitter"
  91298. * @returns a string containing the class name
  91299. */
  91300. getClassName(): string;
  91301. /**
  91302. * Serializes the particle system to a JSON object.
  91303. * @returns the JSON object
  91304. */
  91305. serialize(): any;
  91306. /**
  91307. * Parse properties from a JSON object
  91308. * @param serializationObject defines the JSON object
  91309. */
  91310. parse(serializationObject: any): void;
  91311. }
  91312. }
  91313. declare module BABYLON {
  91314. /**
  91315. * Interface representing a particle system in Babylon.js.
  91316. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91317. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91318. */
  91319. export interface IParticleSystem {
  91320. /**
  91321. * List of animations used by the particle system.
  91322. */
  91323. animations: Animation[];
  91324. /**
  91325. * The id of the Particle system.
  91326. */
  91327. id: string;
  91328. /**
  91329. * The name of the Particle system.
  91330. */
  91331. name: string;
  91332. /**
  91333. * The emitter represents the Mesh or position we are attaching the particle system to.
  91334. */
  91335. emitter: Nullable<AbstractMesh | Vector3>;
  91336. /**
  91337. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91338. */
  91339. isBillboardBased: boolean;
  91340. /**
  91341. * The rendering group used by the Particle system to chose when to render.
  91342. */
  91343. renderingGroupId: number;
  91344. /**
  91345. * The layer mask we are rendering the particles through.
  91346. */
  91347. layerMask: number;
  91348. /**
  91349. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91350. */
  91351. updateSpeed: number;
  91352. /**
  91353. * The amount of time the particle system is running (depends of the overall update speed).
  91354. */
  91355. targetStopDuration: number;
  91356. /**
  91357. * The texture used to render each particle. (this can be a spritesheet)
  91358. */
  91359. particleTexture: Nullable<Texture>;
  91360. /**
  91361. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91362. */
  91363. blendMode: number;
  91364. /**
  91365. * Minimum life time of emitting particles.
  91366. */
  91367. minLifeTime: number;
  91368. /**
  91369. * Maximum life time of emitting particles.
  91370. */
  91371. maxLifeTime: number;
  91372. /**
  91373. * Minimum Size of emitting particles.
  91374. */
  91375. minSize: number;
  91376. /**
  91377. * Maximum Size of emitting particles.
  91378. */
  91379. maxSize: number;
  91380. /**
  91381. * Minimum scale of emitting particles on X axis.
  91382. */
  91383. minScaleX: number;
  91384. /**
  91385. * Maximum scale of emitting particles on X axis.
  91386. */
  91387. maxScaleX: number;
  91388. /**
  91389. * Minimum scale of emitting particles on Y axis.
  91390. */
  91391. minScaleY: number;
  91392. /**
  91393. * Maximum scale of emitting particles on Y axis.
  91394. */
  91395. maxScaleY: number;
  91396. /**
  91397. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91398. */
  91399. color1: Color4;
  91400. /**
  91401. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91402. */
  91403. color2: Color4;
  91404. /**
  91405. * Color the particle will have at the end of its lifetime.
  91406. */
  91407. colorDead: Color4;
  91408. /**
  91409. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91410. */
  91411. emitRate: number;
  91412. /**
  91413. * You can use gravity if you want to give an orientation to your particles.
  91414. */
  91415. gravity: Vector3;
  91416. /**
  91417. * Minimum power of emitting particles.
  91418. */
  91419. minEmitPower: number;
  91420. /**
  91421. * Maximum power of emitting particles.
  91422. */
  91423. maxEmitPower: number;
  91424. /**
  91425. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91426. */
  91427. minAngularSpeed: number;
  91428. /**
  91429. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91430. */
  91431. maxAngularSpeed: number;
  91432. /**
  91433. * Gets or sets the minimal initial rotation in radians.
  91434. */
  91435. minInitialRotation: number;
  91436. /**
  91437. * Gets or sets the maximal initial rotation in radians.
  91438. */
  91439. maxInitialRotation: number;
  91440. /**
  91441. * The particle emitter type defines the emitter used by the particle system.
  91442. * It can be for example box, sphere, or cone...
  91443. */
  91444. particleEmitterType: Nullable<IParticleEmitterType>;
  91445. /**
  91446. * Defines the delay in milliseconds before starting the system (0 by default)
  91447. */
  91448. startDelay: number;
  91449. /**
  91450. * 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
  91451. */
  91452. preWarmCycles: number;
  91453. /**
  91454. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91455. */
  91456. preWarmStepOffset: number;
  91457. /**
  91458. * 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)
  91459. */
  91460. spriteCellChangeSpeed: number;
  91461. /**
  91462. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91463. */
  91464. startSpriteCellID: number;
  91465. /**
  91466. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91467. */
  91468. endSpriteCellID: number;
  91469. /**
  91470. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91471. */
  91472. spriteCellWidth: number;
  91473. /**
  91474. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91475. */
  91476. spriteCellHeight: number;
  91477. /**
  91478. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91479. */
  91480. spriteRandomStartCell: boolean;
  91481. /**
  91482. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91483. */
  91484. isAnimationSheetEnabled: boolean;
  91485. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91486. translationPivot: Vector2;
  91487. /**
  91488. * Gets or sets a texture used to add random noise to particle positions
  91489. */
  91490. noiseTexture: Nullable<BaseTexture>;
  91491. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91492. noiseStrength: Vector3;
  91493. /**
  91494. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91495. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91496. */
  91497. billboardMode: number;
  91498. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91499. limitVelocityDamping: number;
  91500. /**
  91501. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91502. */
  91503. beginAnimationOnStart: boolean;
  91504. /**
  91505. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91506. */
  91507. beginAnimationFrom: number;
  91508. /**
  91509. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91510. */
  91511. beginAnimationTo: number;
  91512. /**
  91513. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91514. */
  91515. beginAnimationLoop: boolean;
  91516. /**
  91517. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91518. */
  91519. disposeOnStop: boolean;
  91520. /**
  91521. * Gets the maximum number of particles active at the same time.
  91522. * @returns The max number of active particles.
  91523. */
  91524. getCapacity(): number;
  91525. /**
  91526. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91527. * @returns True if it has been started, otherwise false.
  91528. */
  91529. isStarted(): boolean;
  91530. /**
  91531. * Animates the particle system for this frame.
  91532. */
  91533. animate(): void;
  91534. /**
  91535. * Renders the particle system in its current state.
  91536. * @returns the current number of particles
  91537. */
  91538. render(): number;
  91539. /**
  91540. * Dispose the particle system and frees its associated resources.
  91541. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91542. */
  91543. dispose(disposeTexture?: boolean): void;
  91544. /**
  91545. * Clones the particle system.
  91546. * @param name The name of the cloned object
  91547. * @param newEmitter The new emitter to use
  91548. * @returns the cloned particle system
  91549. */
  91550. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91551. /**
  91552. * Serializes the particle system to a JSON object.
  91553. * @returns the JSON object
  91554. */
  91555. serialize(): any;
  91556. /**
  91557. * Rebuild the particle system
  91558. */
  91559. rebuild(): void;
  91560. /**
  91561. * Starts the particle system and begins to emit
  91562. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91563. */
  91564. start(delay?: number): void;
  91565. /**
  91566. * Stops the particle system.
  91567. */
  91568. stop(): void;
  91569. /**
  91570. * Remove all active particles
  91571. */
  91572. reset(): void;
  91573. /**
  91574. * Is this system ready to be used/rendered
  91575. * @return true if the system is ready
  91576. */
  91577. isReady(): boolean;
  91578. /**
  91579. * Adds a new color gradient
  91580. * @param gradient defines the gradient to use (between 0 and 1)
  91581. * @param color1 defines the color to affect to the specified gradient
  91582. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91583. * @returns the current particle system
  91584. */
  91585. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91586. /**
  91587. * Remove a specific color gradient
  91588. * @param gradient defines the gradient to remove
  91589. * @returns the current particle system
  91590. */
  91591. removeColorGradient(gradient: number): IParticleSystem;
  91592. /**
  91593. * Adds a new size gradient
  91594. * @param gradient defines the gradient to use (between 0 and 1)
  91595. * @param factor defines the size factor to affect to the specified gradient
  91596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91597. * @returns the current particle system
  91598. */
  91599. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91600. /**
  91601. * Remove a specific size gradient
  91602. * @param gradient defines the gradient to remove
  91603. * @returns the current particle system
  91604. */
  91605. removeSizeGradient(gradient: number): IParticleSystem;
  91606. /**
  91607. * Gets the current list of color gradients.
  91608. * You must use addColorGradient and removeColorGradient to udpate this list
  91609. * @returns the list of color gradients
  91610. */
  91611. getColorGradients(): Nullable<Array<ColorGradient>>;
  91612. /**
  91613. * Gets the current list of size gradients.
  91614. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91615. * @returns the list of size gradients
  91616. */
  91617. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91618. /**
  91619. * Gets the current list of angular speed gradients.
  91620. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91621. * @returns the list of angular speed gradients
  91622. */
  91623. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91624. /**
  91625. * Adds a new angular speed gradient
  91626. * @param gradient defines the gradient to use (between 0 and 1)
  91627. * @param factor defines the angular speed to affect to the specified gradient
  91628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91629. * @returns the current particle system
  91630. */
  91631. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91632. /**
  91633. * Remove a specific angular speed gradient
  91634. * @param gradient defines the gradient to remove
  91635. * @returns the current particle system
  91636. */
  91637. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91638. /**
  91639. * Gets the current list of velocity gradients.
  91640. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91641. * @returns the list of velocity gradients
  91642. */
  91643. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91644. /**
  91645. * Adds a new velocity gradient
  91646. * @param gradient defines the gradient to use (between 0 and 1)
  91647. * @param factor defines the velocity to affect to the specified gradient
  91648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91649. * @returns the current particle system
  91650. */
  91651. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91652. /**
  91653. * Remove a specific velocity gradient
  91654. * @param gradient defines the gradient to remove
  91655. * @returns the current particle system
  91656. */
  91657. removeVelocityGradient(gradient: number): IParticleSystem;
  91658. /**
  91659. * Gets the current list of limit velocity gradients.
  91660. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91661. * @returns the list of limit velocity gradients
  91662. */
  91663. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91664. /**
  91665. * Adds a new limit velocity gradient
  91666. * @param gradient defines the gradient to use (between 0 and 1)
  91667. * @param factor defines the limit velocity to affect to the specified gradient
  91668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91669. * @returns the current particle system
  91670. */
  91671. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91672. /**
  91673. * Remove a specific limit velocity gradient
  91674. * @param gradient defines the gradient to remove
  91675. * @returns the current particle system
  91676. */
  91677. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91678. /**
  91679. * Adds a new drag gradient
  91680. * @param gradient defines the gradient to use (between 0 and 1)
  91681. * @param factor defines the drag to affect to the specified gradient
  91682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91683. * @returns the current particle system
  91684. */
  91685. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91686. /**
  91687. * Remove a specific drag gradient
  91688. * @param gradient defines the gradient to remove
  91689. * @returns the current particle system
  91690. */
  91691. removeDragGradient(gradient: number): IParticleSystem;
  91692. /**
  91693. * Gets the current list of drag gradients.
  91694. * You must use addDragGradient and removeDragGradient to udpate this list
  91695. * @returns the list of drag gradients
  91696. */
  91697. getDragGradients(): Nullable<Array<FactorGradient>>;
  91698. /**
  91699. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91700. * @param gradient defines the gradient to use (between 0 and 1)
  91701. * @param factor defines the emit rate to affect to the specified gradient
  91702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91703. * @returns the current particle system
  91704. */
  91705. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91706. /**
  91707. * Remove a specific emit rate gradient
  91708. * @param gradient defines the gradient to remove
  91709. * @returns the current particle system
  91710. */
  91711. removeEmitRateGradient(gradient: number): IParticleSystem;
  91712. /**
  91713. * Gets the current list of emit rate gradients.
  91714. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91715. * @returns the list of emit rate gradients
  91716. */
  91717. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91718. /**
  91719. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91720. * @param gradient defines the gradient to use (between 0 and 1)
  91721. * @param factor defines the start size to affect to the specified gradient
  91722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91723. * @returns the current particle system
  91724. */
  91725. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91726. /**
  91727. * Remove a specific start size gradient
  91728. * @param gradient defines the gradient to remove
  91729. * @returns the current particle system
  91730. */
  91731. removeStartSizeGradient(gradient: number): IParticleSystem;
  91732. /**
  91733. * Gets the current list of start size gradients.
  91734. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91735. * @returns the list of start size gradients
  91736. */
  91737. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91738. /**
  91739. * Adds a new life time gradient
  91740. * @param gradient defines the gradient to use (between 0 and 1)
  91741. * @param factor defines the life time factor to affect to the specified gradient
  91742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91743. * @returns the current particle system
  91744. */
  91745. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91746. /**
  91747. * Remove a specific life time gradient
  91748. * @param gradient defines the gradient to remove
  91749. * @returns the current particle system
  91750. */
  91751. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91752. /**
  91753. * Gets the current list of life time gradients.
  91754. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91755. * @returns the list of life time gradients
  91756. */
  91757. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91758. /**
  91759. * Gets the current list of color gradients.
  91760. * You must use addColorGradient and removeColorGradient to udpate this list
  91761. * @returns the list of color gradients
  91762. */
  91763. getColorGradients(): Nullable<Array<ColorGradient>>;
  91764. /**
  91765. * Adds a new ramp gradient used to remap particle colors
  91766. * @param gradient defines the gradient to use (between 0 and 1)
  91767. * @param color defines the color to affect to the specified gradient
  91768. * @returns the current particle system
  91769. */
  91770. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91771. /**
  91772. * Gets the current list of ramp gradients.
  91773. * You must use addRampGradient and removeRampGradient to udpate this list
  91774. * @returns the list of ramp gradients
  91775. */
  91776. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91777. /** Gets or sets a boolean indicating that ramp gradients must be used
  91778. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91779. */
  91780. useRampGradients: boolean;
  91781. /**
  91782. * Adds a new color remap gradient
  91783. * @param gradient defines the gradient to use (between 0 and 1)
  91784. * @param min defines the color remap minimal range
  91785. * @param max defines the color remap maximal range
  91786. * @returns the current particle system
  91787. */
  91788. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91789. /**
  91790. * Gets the current list of color remap gradients.
  91791. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91792. * @returns the list of color remap gradients
  91793. */
  91794. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91795. /**
  91796. * Adds a new alpha remap gradient
  91797. * @param gradient defines the gradient to use (between 0 and 1)
  91798. * @param min defines the alpha remap minimal range
  91799. * @param max defines the alpha remap maximal range
  91800. * @returns the current particle system
  91801. */
  91802. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91803. /**
  91804. * Gets the current list of alpha remap gradients.
  91805. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91806. * @returns the list of alpha remap gradients
  91807. */
  91808. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91809. /**
  91810. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91811. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91812. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91813. * @returns the emitter
  91814. */
  91815. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91816. /**
  91817. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91818. * @param radius The radius of the hemisphere to emit from
  91819. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91820. * @returns the emitter
  91821. */
  91822. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91823. /**
  91824. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91825. * @param radius The radius of the sphere to emit from
  91826. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91827. * @returns the emitter
  91828. */
  91829. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91830. /**
  91831. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91832. * @param radius The radius of the sphere to emit from
  91833. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91834. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91835. * @returns the emitter
  91836. */
  91837. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91838. /**
  91839. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91840. * @param radius The radius of the emission cylinder
  91841. * @param height The height of the emission cylinder
  91842. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91843. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91844. * @returns the emitter
  91845. */
  91846. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91847. /**
  91848. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91849. * @param radius The radius of the cylinder to emit from
  91850. * @param height The height of the emission cylinder
  91851. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91852. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91853. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91854. * @returns the emitter
  91855. */
  91856. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91857. /**
  91858. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91859. * @param radius The radius of the cone to emit from
  91860. * @param angle The base angle of the cone
  91861. * @returns the emitter
  91862. */
  91863. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91864. /**
  91865. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91866. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91867. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91868. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91869. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91870. * @returns the emitter
  91871. */
  91872. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91873. /**
  91874. * Get hosting scene
  91875. * @returns the scene
  91876. */
  91877. getScene(): Scene;
  91878. }
  91879. }
  91880. declare module BABYLON {
  91881. /**
  91882. * Creates an instance based on a source mesh.
  91883. */
  91884. export class InstancedMesh extends AbstractMesh {
  91885. private _sourceMesh;
  91886. private _currentLOD;
  91887. /** @hidden */
  91888. _indexInSourceMeshInstanceArray: number;
  91889. constructor(name: string, source: Mesh);
  91890. /**
  91891. * Returns the string "InstancedMesh".
  91892. */
  91893. getClassName(): string;
  91894. /** Gets the list of lights affecting that mesh */
  91895. get lightSources(): Light[];
  91896. _resyncLightSources(): void;
  91897. _resyncLightSource(light: Light): void;
  91898. _removeLightSource(light: Light, dispose: boolean): void;
  91899. /**
  91900. * If the source mesh receives shadows
  91901. */
  91902. get receiveShadows(): boolean;
  91903. /**
  91904. * The material of the source mesh
  91905. */
  91906. get material(): Nullable<Material>;
  91907. /**
  91908. * Visibility of the source mesh
  91909. */
  91910. get visibility(): number;
  91911. /**
  91912. * Skeleton of the source mesh
  91913. */
  91914. get skeleton(): Nullable<Skeleton>;
  91915. /**
  91916. * Rendering ground id of the source mesh
  91917. */
  91918. get renderingGroupId(): number;
  91919. set renderingGroupId(value: number);
  91920. /**
  91921. * Returns the total number of vertices (integer).
  91922. */
  91923. getTotalVertices(): number;
  91924. /**
  91925. * Returns a positive integer : the total number of indices in this mesh geometry.
  91926. * @returns the numner of indices or zero if the mesh has no geometry.
  91927. */
  91928. getTotalIndices(): number;
  91929. /**
  91930. * The source mesh of the instance
  91931. */
  91932. get sourceMesh(): Mesh;
  91933. /**
  91934. * Is this node ready to be used/rendered
  91935. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91936. * @return {boolean} is it ready
  91937. */
  91938. isReady(completeCheck?: boolean): boolean;
  91939. /**
  91940. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91941. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91942. * @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.
  91943. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91944. */
  91945. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91946. /**
  91947. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91948. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91949. * The `data` are either a numeric array either a Float32Array.
  91950. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91951. * 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).
  91952. * Note that a new underlying VertexBuffer object is created each call.
  91953. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91954. *
  91955. * Possible `kind` values :
  91956. * - VertexBuffer.PositionKind
  91957. * - VertexBuffer.UVKind
  91958. * - VertexBuffer.UV2Kind
  91959. * - VertexBuffer.UV3Kind
  91960. * - VertexBuffer.UV4Kind
  91961. * - VertexBuffer.UV5Kind
  91962. * - VertexBuffer.UV6Kind
  91963. * - VertexBuffer.ColorKind
  91964. * - VertexBuffer.MatricesIndicesKind
  91965. * - VertexBuffer.MatricesIndicesExtraKind
  91966. * - VertexBuffer.MatricesWeightsKind
  91967. * - VertexBuffer.MatricesWeightsExtraKind
  91968. *
  91969. * Returns the Mesh.
  91970. */
  91971. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91972. /**
  91973. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91974. * If the mesh has no geometry, it is simply returned as it is.
  91975. * The `data` are either a numeric array either a Float32Array.
  91976. * No new underlying VertexBuffer object is created.
  91977. * 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.
  91978. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91979. *
  91980. * Possible `kind` values :
  91981. * - VertexBuffer.PositionKind
  91982. * - VertexBuffer.UVKind
  91983. * - VertexBuffer.UV2Kind
  91984. * - VertexBuffer.UV3Kind
  91985. * - VertexBuffer.UV4Kind
  91986. * - VertexBuffer.UV5Kind
  91987. * - VertexBuffer.UV6Kind
  91988. * - VertexBuffer.ColorKind
  91989. * - VertexBuffer.MatricesIndicesKind
  91990. * - VertexBuffer.MatricesIndicesExtraKind
  91991. * - VertexBuffer.MatricesWeightsKind
  91992. * - VertexBuffer.MatricesWeightsExtraKind
  91993. *
  91994. * Returns the Mesh.
  91995. */
  91996. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91997. /**
  91998. * Sets the mesh indices.
  91999. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  92000. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92001. * This method creates a new index buffer each call.
  92002. * Returns the Mesh.
  92003. */
  92004. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  92005. /**
  92006. * Boolean : True if the mesh owns the requested kind of data.
  92007. */
  92008. isVerticesDataPresent(kind: string): boolean;
  92009. /**
  92010. * Returns an array of indices (IndicesArray).
  92011. */
  92012. getIndices(): Nullable<IndicesArray>;
  92013. get _positions(): Nullable<Vector3[]>;
  92014. /**
  92015. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92016. * This means the mesh underlying bounding box and sphere are recomputed.
  92017. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92018. * @returns the current mesh
  92019. */
  92020. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  92021. /** @hidden */
  92022. _preActivate(): InstancedMesh;
  92023. /** @hidden */
  92024. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92025. /** @hidden */
  92026. _postActivate(): void;
  92027. getWorldMatrix(): Matrix;
  92028. get isAnInstance(): boolean;
  92029. /**
  92030. * Returns the current associated LOD AbstractMesh.
  92031. */
  92032. getLOD(camera: Camera): AbstractMesh;
  92033. /** @hidden */
  92034. _syncSubMeshes(): InstancedMesh;
  92035. /** @hidden */
  92036. _generatePointsArray(): boolean;
  92037. /**
  92038. * Creates a new InstancedMesh from the current mesh.
  92039. * - name (string) : the cloned mesh name
  92040. * - newParent (optional Node) : the optional Node to parent the clone to.
  92041. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  92042. *
  92043. * Returns the clone.
  92044. */
  92045. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  92046. /**
  92047. * Disposes the InstancedMesh.
  92048. * Returns nothing.
  92049. */
  92050. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92051. }
  92052. interface Mesh {
  92053. /**
  92054. * Register a custom buffer that will be instanced
  92055. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92056. * @param kind defines the buffer kind
  92057. * @param stride defines the stride in floats
  92058. */
  92059. registerInstancedBuffer(kind: string, stride: number): void;
  92060. /** @hidden */
  92061. _userInstancedBuffersStorage: {
  92062. data: {
  92063. [key: string]: Float32Array;
  92064. };
  92065. sizes: {
  92066. [key: string]: number;
  92067. };
  92068. vertexBuffers: {
  92069. [key: string]: Nullable<VertexBuffer>;
  92070. };
  92071. strides: {
  92072. [key: string]: number;
  92073. };
  92074. };
  92075. }
  92076. interface AbstractMesh {
  92077. /**
  92078. * Object used to store instanced buffers defined by user
  92079. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92080. */
  92081. instancedBuffers: {
  92082. [key: string]: any;
  92083. };
  92084. }
  92085. }
  92086. declare module BABYLON {
  92087. /**
  92088. * Defines the options associated with the creation of a shader material.
  92089. */
  92090. export interface IShaderMaterialOptions {
  92091. /**
  92092. * Does the material work in alpha blend mode
  92093. */
  92094. needAlphaBlending: boolean;
  92095. /**
  92096. * Does the material work in alpha test mode
  92097. */
  92098. needAlphaTesting: boolean;
  92099. /**
  92100. * The list of attribute names used in the shader
  92101. */
  92102. attributes: string[];
  92103. /**
  92104. * The list of unifrom names used in the shader
  92105. */
  92106. uniforms: string[];
  92107. /**
  92108. * The list of UBO names used in the shader
  92109. */
  92110. uniformBuffers: string[];
  92111. /**
  92112. * The list of sampler names used in the shader
  92113. */
  92114. samplers: string[];
  92115. /**
  92116. * The list of defines used in the shader
  92117. */
  92118. defines: string[];
  92119. }
  92120. /**
  92121. * 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.
  92122. *
  92123. * This returned material effects how the mesh will look based on the code in the shaders.
  92124. *
  92125. * @see http://doc.babylonjs.com/how_to/shader_material
  92126. */
  92127. export class ShaderMaterial extends Material {
  92128. private _shaderPath;
  92129. private _options;
  92130. private _textures;
  92131. private _textureArrays;
  92132. private _floats;
  92133. private _ints;
  92134. private _floatsArrays;
  92135. private _colors3;
  92136. private _colors3Arrays;
  92137. private _colors4;
  92138. private _colors4Arrays;
  92139. private _vectors2;
  92140. private _vectors3;
  92141. private _vectors4;
  92142. private _matrices;
  92143. private _matrixArrays;
  92144. private _matrices3x3;
  92145. private _matrices2x2;
  92146. private _vectors2Arrays;
  92147. private _vectors3Arrays;
  92148. private _vectors4Arrays;
  92149. private _cachedWorldViewMatrix;
  92150. private _cachedWorldViewProjectionMatrix;
  92151. private _renderId;
  92152. private _multiview;
  92153. /**
  92154. * Instantiate a new shader material.
  92155. * 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.
  92156. * This returned material effects how the mesh will look based on the code in the shaders.
  92157. * @see http://doc.babylonjs.com/how_to/shader_material
  92158. * @param name Define the name of the material in the scene
  92159. * @param scene Define the scene the material belongs to
  92160. * @param shaderPath Defines the route to the shader code in one of three ways:
  92161. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  92162. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  92163. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  92164. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  92165. * @param options Define the options used to create the shader
  92166. */
  92167. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  92168. /**
  92169. * Gets the shader path used to define the shader code
  92170. * It can be modified to trigger a new compilation
  92171. */
  92172. get shaderPath(): any;
  92173. /**
  92174. * Sets the shader path used to define the shader code
  92175. * It can be modified to trigger a new compilation
  92176. */
  92177. set shaderPath(shaderPath: any);
  92178. /**
  92179. * Gets the options used to compile the shader.
  92180. * They can be modified to trigger a new compilation
  92181. */
  92182. get options(): IShaderMaterialOptions;
  92183. /**
  92184. * Gets the current class name of the material e.g. "ShaderMaterial"
  92185. * Mainly use in serialization.
  92186. * @returns the class name
  92187. */
  92188. getClassName(): string;
  92189. /**
  92190. * Specifies if the material will require alpha blending
  92191. * @returns a boolean specifying if alpha blending is needed
  92192. */
  92193. needAlphaBlending(): boolean;
  92194. /**
  92195. * Specifies if this material should be rendered in alpha test mode
  92196. * @returns a boolean specifying if an alpha test is needed.
  92197. */
  92198. needAlphaTesting(): boolean;
  92199. private _checkUniform;
  92200. /**
  92201. * Set a texture in the shader.
  92202. * @param name Define the name of the uniform samplers as defined in the shader
  92203. * @param texture Define the texture to bind to this sampler
  92204. * @return the material itself allowing "fluent" like uniform updates
  92205. */
  92206. setTexture(name: string, texture: Texture): ShaderMaterial;
  92207. /**
  92208. * Set a texture array in the shader.
  92209. * @param name Define the name of the uniform sampler array as defined in the shader
  92210. * @param textures Define the list of textures to bind to this sampler
  92211. * @return the material itself allowing "fluent" like uniform updates
  92212. */
  92213. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  92214. /**
  92215. * Set a float in the shader.
  92216. * @param name Define the name of the uniform as defined in the shader
  92217. * @param value Define the value to give to the uniform
  92218. * @return the material itself allowing "fluent" like uniform updates
  92219. */
  92220. setFloat(name: string, value: number): ShaderMaterial;
  92221. /**
  92222. * Set a int in the shader.
  92223. * @param name Define the name of the uniform as defined in the shader
  92224. * @param value Define the value to give to the uniform
  92225. * @return the material itself allowing "fluent" like uniform updates
  92226. */
  92227. setInt(name: string, value: number): ShaderMaterial;
  92228. /**
  92229. * Set an array of floats in the shader.
  92230. * @param name Define the name of the uniform as defined in the shader
  92231. * @param value Define the value to give to the uniform
  92232. * @return the material itself allowing "fluent" like uniform updates
  92233. */
  92234. setFloats(name: string, value: number[]): ShaderMaterial;
  92235. /**
  92236. * Set a vec3 in the shader from a Color3.
  92237. * @param name Define the name of the uniform as defined in the shader
  92238. * @param value Define the value to give to the uniform
  92239. * @return the material itself allowing "fluent" like uniform updates
  92240. */
  92241. setColor3(name: string, value: Color3): ShaderMaterial;
  92242. /**
  92243. * Set a vec3 array in the shader from a Color3 array.
  92244. * @param name Define the name of the uniform as defined in the shader
  92245. * @param value Define the value to give to the uniform
  92246. * @return the material itself allowing "fluent" like uniform updates
  92247. */
  92248. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  92249. /**
  92250. * Set a vec4 in the shader from a Color4.
  92251. * @param name Define the name of the uniform as defined in the shader
  92252. * @param value Define the value to give to the uniform
  92253. * @return the material itself allowing "fluent" like uniform updates
  92254. */
  92255. setColor4(name: string, value: Color4): ShaderMaterial;
  92256. /**
  92257. * Set a vec4 array in the shader from a Color4 array.
  92258. * @param name Define the name of the uniform as defined in the shader
  92259. * @param value Define the value to give to the uniform
  92260. * @return the material itself allowing "fluent" like uniform updates
  92261. */
  92262. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  92263. /**
  92264. * Set a vec2 in the shader from a Vector2.
  92265. * @param name Define the name of the uniform as defined in the shader
  92266. * @param value Define the value to give to the uniform
  92267. * @return the material itself allowing "fluent" like uniform updates
  92268. */
  92269. setVector2(name: string, value: Vector2): ShaderMaterial;
  92270. /**
  92271. * Set a vec3 in the shader from a Vector3.
  92272. * @param name Define the name of the uniform as defined in the shader
  92273. * @param value Define the value to give to the uniform
  92274. * @return the material itself allowing "fluent" like uniform updates
  92275. */
  92276. setVector3(name: string, value: Vector3): ShaderMaterial;
  92277. /**
  92278. * Set a vec4 in the shader from a Vector4.
  92279. * @param name Define the name of the uniform as defined in the shader
  92280. * @param value Define the value to give to the uniform
  92281. * @return the material itself allowing "fluent" like uniform updates
  92282. */
  92283. setVector4(name: string, value: Vector4): ShaderMaterial;
  92284. /**
  92285. * Set a mat4 in the shader from a Matrix.
  92286. * @param name Define the name of the uniform as defined in the shader
  92287. * @param value Define the value to give to the uniform
  92288. * @return the material itself allowing "fluent" like uniform updates
  92289. */
  92290. setMatrix(name: string, value: Matrix): ShaderMaterial;
  92291. /**
  92292. * Set a float32Array in the shader from a matrix array.
  92293. * @param name Define the name of the uniform as defined in the shader
  92294. * @param value Define the value to give to the uniform
  92295. * @return the material itself allowing "fluent" like uniform updates
  92296. */
  92297. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  92298. /**
  92299. * Set a mat3 in the shader from a Float32Array.
  92300. * @param name Define the name of the uniform as defined in the shader
  92301. * @param value Define the value to give to the uniform
  92302. * @return the material itself allowing "fluent" like uniform updates
  92303. */
  92304. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  92305. /**
  92306. * Set a mat2 in the shader from a Float32Array.
  92307. * @param name Define the name of the uniform as defined in the shader
  92308. * @param value Define the value to give to the uniform
  92309. * @return the material itself allowing "fluent" like uniform updates
  92310. */
  92311. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  92312. /**
  92313. * Set a vec2 array in the shader from a number array.
  92314. * @param name Define the name of the uniform as defined in the shader
  92315. * @param value Define the value to give to the uniform
  92316. * @return the material itself allowing "fluent" like uniform updates
  92317. */
  92318. setArray2(name: string, value: number[]): ShaderMaterial;
  92319. /**
  92320. * Set a vec3 array in the shader from a number array.
  92321. * @param name Define the name of the uniform as defined in the shader
  92322. * @param value Define the value to give to the uniform
  92323. * @return the material itself allowing "fluent" like uniform updates
  92324. */
  92325. setArray3(name: string, value: number[]): ShaderMaterial;
  92326. /**
  92327. * Set a vec4 array in the shader from a number array.
  92328. * @param name Define the name of the uniform as defined in the shader
  92329. * @param value Define the value to give to the uniform
  92330. * @return the material itself allowing "fluent" like uniform updates
  92331. */
  92332. setArray4(name: string, value: number[]): ShaderMaterial;
  92333. private _checkCache;
  92334. /**
  92335. * Specifies that the submesh is ready to be used
  92336. * @param mesh defines the mesh to check
  92337. * @param subMesh defines which submesh to check
  92338. * @param useInstances specifies that instances should be used
  92339. * @returns a boolean indicating that the submesh is ready or not
  92340. */
  92341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92342. /**
  92343. * Checks if the material is ready to render the requested mesh
  92344. * @param mesh Define the mesh to render
  92345. * @param useInstances Define whether or not the material is used with instances
  92346. * @returns true if ready, otherwise false
  92347. */
  92348. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92349. /**
  92350. * Binds the world matrix to the material
  92351. * @param world defines the world transformation matrix
  92352. */
  92353. bindOnlyWorldMatrix(world: Matrix): void;
  92354. /**
  92355. * Binds the material to the mesh
  92356. * @param world defines the world transformation matrix
  92357. * @param mesh defines the mesh to bind the material to
  92358. */
  92359. bind(world: Matrix, mesh?: Mesh): void;
  92360. /**
  92361. * Gets the active textures from the material
  92362. * @returns an array of textures
  92363. */
  92364. getActiveTextures(): BaseTexture[];
  92365. /**
  92366. * Specifies if the material uses a texture
  92367. * @param texture defines the texture to check against the material
  92368. * @returns a boolean specifying if the material uses the texture
  92369. */
  92370. hasTexture(texture: BaseTexture): boolean;
  92371. /**
  92372. * Makes a duplicate of the material, and gives it a new name
  92373. * @param name defines the new name for the duplicated material
  92374. * @returns the cloned material
  92375. */
  92376. clone(name: string): ShaderMaterial;
  92377. /**
  92378. * Disposes the material
  92379. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92380. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92381. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92382. */
  92383. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92384. /**
  92385. * Serializes this material in a JSON representation
  92386. * @returns the serialized material object
  92387. */
  92388. serialize(): any;
  92389. /**
  92390. * Creates a shader material from parsed shader material data
  92391. * @param source defines the JSON represnetation of the material
  92392. * @param scene defines the hosting scene
  92393. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92394. * @returns a new material
  92395. */
  92396. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  92397. }
  92398. }
  92399. declare module BABYLON {
  92400. /** @hidden */
  92401. export var colorPixelShader: {
  92402. name: string;
  92403. shader: string;
  92404. };
  92405. }
  92406. declare module BABYLON {
  92407. /** @hidden */
  92408. export var colorVertexShader: {
  92409. name: string;
  92410. shader: string;
  92411. };
  92412. }
  92413. declare module BABYLON {
  92414. /**
  92415. * Line mesh
  92416. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  92417. */
  92418. export class LinesMesh extends Mesh {
  92419. /**
  92420. * If vertex color should be applied to the mesh
  92421. */
  92422. readonly useVertexColor?: boolean | undefined;
  92423. /**
  92424. * If vertex alpha should be applied to the mesh
  92425. */
  92426. readonly useVertexAlpha?: boolean | undefined;
  92427. /**
  92428. * Color of the line (Default: White)
  92429. */
  92430. color: Color3;
  92431. /**
  92432. * Alpha of the line (Default: 1)
  92433. */
  92434. alpha: number;
  92435. /**
  92436. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92437. * This margin is expressed in world space coordinates, so its value may vary.
  92438. * Default value is 0.1
  92439. */
  92440. intersectionThreshold: number;
  92441. private _colorShader;
  92442. private color4;
  92443. /**
  92444. * Creates a new LinesMesh
  92445. * @param name defines the name
  92446. * @param scene defines the hosting scene
  92447. * @param parent defines the parent mesh if any
  92448. * @param source defines the optional source LinesMesh used to clone data from
  92449. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92450. * When false, achieved by calling a clone(), also passing False.
  92451. * This will make creation of children, recursive.
  92452. * @param useVertexColor defines if this LinesMesh supports vertex color
  92453. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  92454. */
  92455. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  92456. /**
  92457. * If vertex color should be applied to the mesh
  92458. */
  92459. useVertexColor?: boolean | undefined,
  92460. /**
  92461. * If vertex alpha should be applied to the mesh
  92462. */
  92463. useVertexAlpha?: boolean | undefined);
  92464. private _addClipPlaneDefine;
  92465. private _removeClipPlaneDefine;
  92466. isReady(): boolean;
  92467. /**
  92468. * Returns the string "LineMesh"
  92469. */
  92470. getClassName(): string;
  92471. /**
  92472. * @hidden
  92473. */
  92474. get material(): Material;
  92475. /**
  92476. * @hidden
  92477. */
  92478. set material(value: Material);
  92479. /**
  92480. * @hidden
  92481. */
  92482. get checkCollisions(): boolean;
  92483. /** @hidden */
  92484. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92485. /** @hidden */
  92486. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92487. /**
  92488. * Disposes of the line mesh
  92489. * @param doNotRecurse If children should be disposed
  92490. */
  92491. dispose(doNotRecurse?: boolean): void;
  92492. /**
  92493. * Returns a new LineMesh object cloned from the current one.
  92494. */
  92495. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  92496. /**
  92497. * Creates a new InstancedLinesMesh object from the mesh model.
  92498. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92499. * @param name defines the name of the new instance
  92500. * @returns a new InstancedLinesMesh
  92501. */
  92502. createInstance(name: string): InstancedLinesMesh;
  92503. }
  92504. /**
  92505. * Creates an instance based on a source LinesMesh
  92506. */
  92507. export class InstancedLinesMesh extends InstancedMesh {
  92508. /**
  92509. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92510. * This margin is expressed in world space coordinates, so its value may vary.
  92511. * Initilized with the intersectionThreshold value of the source LinesMesh
  92512. */
  92513. intersectionThreshold: number;
  92514. constructor(name: string, source: LinesMesh);
  92515. /**
  92516. * Returns the string "InstancedLinesMesh".
  92517. */
  92518. getClassName(): string;
  92519. }
  92520. }
  92521. declare module BABYLON {
  92522. /** @hidden */
  92523. export var linePixelShader: {
  92524. name: string;
  92525. shader: string;
  92526. };
  92527. }
  92528. declare module BABYLON {
  92529. /** @hidden */
  92530. export var lineVertexShader: {
  92531. name: string;
  92532. shader: string;
  92533. };
  92534. }
  92535. declare module BABYLON {
  92536. interface AbstractMesh {
  92537. /**
  92538. * Gets the edgesRenderer associated with the mesh
  92539. */
  92540. edgesRenderer: Nullable<EdgesRenderer>;
  92541. }
  92542. interface LinesMesh {
  92543. /**
  92544. * Enables the edge rendering mode on the mesh.
  92545. * This mode makes the mesh edges visible
  92546. * @param epsilon defines the maximal distance between two angles to detect a face
  92547. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92548. * @returns the currentAbstractMesh
  92549. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92550. */
  92551. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92552. }
  92553. interface InstancedLinesMesh {
  92554. /**
  92555. * Enables the edge rendering mode on the mesh.
  92556. * This mode makes the mesh edges visible
  92557. * @param epsilon defines the maximal distance between two angles to detect a face
  92558. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92559. * @returns the current InstancedLinesMesh
  92560. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92561. */
  92562. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  92563. }
  92564. /**
  92565. * Defines the minimum contract an Edges renderer should follow.
  92566. */
  92567. export interface IEdgesRenderer extends IDisposable {
  92568. /**
  92569. * Gets or sets a boolean indicating if the edgesRenderer is active
  92570. */
  92571. isEnabled: boolean;
  92572. /**
  92573. * Renders the edges of the attached mesh,
  92574. */
  92575. render(): void;
  92576. /**
  92577. * Checks wether or not the edges renderer is ready to render.
  92578. * @return true if ready, otherwise false.
  92579. */
  92580. isReady(): boolean;
  92581. }
  92582. /**
  92583. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92584. */
  92585. export class EdgesRenderer implements IEdgesRenderer {
  92586. /**
  92587. * Define the size of the edges with an orthographic camera
  92588. */
  92589. edgesWidthScalerForOrthographic: number;
  92590. /**
  92591. * Define the size of the edges with a perspective camera
  92592. */
  92593. edgesWidthScalerForPerspective: number;
  92594. protected _source: AbstractMesh;
  92595. protected _linesPositions: number[];
  92596. protected _linesNormals: number[];
  92597. protected _linesIndices: number[];
  92598. protected _epsilon: number;
  92599. protected _indicesCount: number;
  92600. protected _lineShader: ShaderMaterial;
  92601. protected _ib: DataBuffer;
  92602. protected _buffers: {
  92603. [key: string]: Nullable<VertexBuffer>;
  92604. };
  92605. protected _checkVerticesInsteadOfIndices: boolean;
  92606. private _meshRebuildObserver;
  92607. private _meshDisposeObserver;
  92608. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92609. isEnabled: boolean;
  92610. /**
  92611. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92612. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92613. * @param source Mesh used to create edges
  92614. * @param epsilon sum of angles in adjacency to check for edge
  92615. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92616. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92617. */
  92618. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92619. protected _prepareRessources(): void;
  92620. /** @hidden */
  92621. _rebuild(): void;
  92622. /**
  92623. * Releases the required resources for the edges renderer
  92624. */
  92625. dispose(): void;
  92626. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92627. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92628. /**
  92629. * Checks if the pair of p0 and p1 is en edge
  92630. * @param faceIndex
  92631. * @param edge
  92632. * @param faceNormals
  92633. * @param p0
  92634. * @param p1
  92635. * @private
  92636. */
  92637. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92638. /**
  92639. * push line into the position, normal and index buffer
  92640. * @protected
  92641. */
  92642. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92643. /**
  92644. * Generates lines edges from adjacencjes
  92645. * @private
  92646. */
  92647. _generateEdgesLines(): void;
  92648. /**
  92649. * Checks wether or not the edges renderer is ready to render.
  92650. * @return true if ready, otherwise false.
  92651. */
  92652. isReady(): boolean;
  92653. /**
  92654. * Renders the edges of the attached mesh,
  92655. */
  92656. render(): void;
  92657. }
  92658. /**
  92659. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92660. */
  92661. export class LineEdgesRenderer extends EdgesRenderer {
  92662. /**
  92663. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92664. * @param source LineMesh used to generate edges
  92665. * @param epsilon not important (specified angle for edge detection)
  92666. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92667. */
  92668. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92669. /**
  92670. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92671. */
  92672. _generateEdgesLines(): void;
  92673. }
  92674. }
  92675. declare module BABYLON {
  92676. /**
  92677. * This represents the object necessary to create a rendering group.
  92678. * This is exclusively used and created by the rendering manager.
  92679. * To modify the behavior, you use the available helpers in your scene or meshes.
  92680. * @hidden
  92681. */
  92682. export class RenderingGroup {
  92683. index: number;
  92684. private static _zeroVector;
  92685. private _scene;
  92686. private _opaqueSubMeshes;
  92687. private _transparentSubMeshes;
  92688. private _alphaTestSubMeshes;
  92689. private _depthOnlySubMeshes;
  92690. private _particleSystems;
  92691. private _spriteManagers;
  92692. private _opaqueSortCompareFn;
  92693. private _alphaTestSortCompareFn;
  92694. private _transparentSortCompareFn;
  92695. private _renderOpaque;
  92696. private _renderAlphaTest;
  92697. private _renderTransparent;
  92698. /** @hidden */
  92699. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92700. onBeforeTransparentRendering: () => void;
  92701. /**
  92702. * Set the opaque sort comparison function.
  92703. * If null the sub meshes will be render in the order they were created
  92704. */
  92705. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92706. /**
  92707. * Set the alpha test sort comparison function.
  92708. * If null the sub meshes will be render in the order they were created
  92709. */
  92710. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92711. /**
  92712. * Set the transparent sort comparison function.
  92713. * If null the sub meshes will be render in the order they were created
  92714. */
  92715. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92716. /**
  92717. * Creates a new rendering group.
  92718. * @param index The rendering group index
  92719. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92720. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92721. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92722. */
  92723. 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>);
  92724. /**
  92725. * Render all the sub meshes contained in the group.
  92726. * @param customRenderFunction Used to override the default render behaviour of the group.
  92727. * @returns true if rendered some submeshes.
  92728. */
  92729. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92730. /**
  92731. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92732. * @param subMeshes The submeshes to render
  92733. */
  92734. private renderOpaqueSorted;
  92735. /**
  92736. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92737. * @param subMeshes The submeshes to render
  92738. */
  92739. private renderAlphaTestSorted;
  92740. /**
  92741. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92742. * @param subMeshes The submeshes to render
  92743. */
  92744. private renderTransparentSorted;
  92745. /**
  92746. * Renders the submeshes in a specified order.
  92747. * @param subMeshes The submeshes to sort before render
  92748. * @param sortCompareFn The comparison function use to sort
  92749. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92750. * @param transparent Specifies to activate blending if true
  92751. */
  92752. private static renderSorted;
  92753. /**
  92754. * Renders the submeshes in the order they were dispatched (no sort applied).
  92755. * @param subMeshes The submeshes to render
  92756. */
  92757. private static renderUnsorted;
  92758. /**
  92759. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92760. * are rendered back to front if in the same alpha index.
  92761. *
  92762. * @param a The first submesh
  92763. * @param b The second submesh
  92764. * @returns The result of the comparison
  92765. */
  92766. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92767. /**
  92768. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92769. * are rendered back to front.
  92770. *
  92771. * @param a The first submesh
  92772. * @param b The second submesh
  92773. * @returns The result of the comparison
  92774. */
  92775. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92776. /**
  92777. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92778. * are rendered front to back (prevent overdraw).
  92779. *
  92780. * @param a The first submesh
  92781. * @param b The second submesh
  92782. * @returns The result of the comparison
  92783. */
  92784. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92785. /**
  92786. * Resets the different lists of submeshes to prepare a new frame.
  92787. */
  92788. prepare(): void;
  92789. dispose(): void;
  92790. /**
  92791. * Inserts the submesh in its correct queue depending on its material.
  92792. * @param subMesh The submesh to dispatch
  92793. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92794. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92795. */
  92796. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92797. dispatchSprites(spriteManager: ISpriteManager): void;
  92798. dispatchParticles(particleSystem: IParticleSystem): void;
  92799. private _renderParticles;
  92800. private _renderSprites;
  92801. }
  92802. }
  92803. declare module BABYLON {
  92804. /**
  92805. * Interface describing the different options available in the rendering manager
  92806. * regarding Auto Clear between groups.
  92807. */
  92808. export interface IRenderingManagerAutoClearSetup {
  92809. /**
  92810. * Defines whether or not autoclear is enable.
  92811. */
  92812. autoClear: boolean;
  92813. /**
  92814. * Defines whether or not to autoclear the depth buffer.
  92815. */
  92816. depth: boolean;
  92817. /**
  92818. * Defines whether or not to autoclear the stencil buffer.
  92819. */
  92820. stencil: boolean;
  92821. }
  92822. /**
  92823. * This class is used by the onRenderingGroupObservable
  92824. */
  92825. export class RenderingGroupInfo {
  92826. /**
  92827. * The Scene that being rendered
  92828. */
  92829. scene: Scene;
  92830. /**
  92831. * The camera currently used for the rendering pass
  92832. */
  92833. camera: Nullable<Camera>;
  92834. /**
  92835. * The ID of the renderingGroup being processed
  92836. */
  92837. renderingGroupId: number;
  92838. }
  92839. /**
  92840. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92841. * It is enable to manage the different groups as well as the different necessary sort functions.
  92842. * This should not be used directly aside of the few static configurations
  92843. */
  92844. export class RenderingManager {
  92845. /**
  92846. * The max id used for rendering groups (not included)
  92847. */
  92848. static MAX_RENDERINGGROUPS: number;
  92849. /**
  92850. * The min id used for rendering groups (included)
  92851. */
  92852. static MIN_RENDERINGGROUPS: number;
  92853. /**
  92854. * Used to globally prevent autoclearing scenes.
  92855. */
  92856. static AUTOCLEAR: boolean;
  92857. /**
  92858. * @hidden
  92859. */
  92860. _useSceneAutoClearSetup: boolean;
  92861. private _scene;
  92862. private _renderingGroups;
  92863. private _depthStencilBufferAlreadyCleaned;
  92864. private _autoClearDepthStencil;
  92865. private _customOpaqueSortCompareFn;
  92866. private _customAlphaTestSortCompareFn;
  92867. private _customTransparentSortCompareFn;
  92868. private _renderingGroupInfo;
  92869. /**
  92870. * Instantiates a new rendering group for a particular scene
  92871. * @param scene Defines the scene the groups belongs to
  92872. */
  92873. constructor(scene: Scene);
  92874. private _clearDepthStencilBuffer;
  92875. /**
  92876. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92877. * @hidden
  92878. */
  92879. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92880. /**
  92881. * Resets the different information of the group to prepare a new frame
  92882. * @hidden
  92883. */
  92884. reset(): void;
  92885. /**
  92886. * Dispose and release the group and its associated resources.
  92887. * @hidden
  92888. */
  92889. dispose(): void;
  92890. /**
  92891. * Clear the info related to rendering groups preventing retention points during dispose.
  92892. */
  92893. freeRenderingGroups(): void;
  92894. private _prepareRenderingGroup;
  92895. /**
  92896. * Add a sprite manager to the rendering manager in order to render it this frame.
  92897. * @param spriteManager Define the sprite manager to render
  92898. */
  92899. dispatchSprites(spriteManager: ISpriteManager): void;
  92900. /**
  92901. * Add a particle system to the rendering manager in order to render it this frame.
  92902. * @param particleSystem Define the particle system to render
  92903. */
  92904. dispatchParticles(particleSystem: IParticleSystem): void;
  92905. /**
  92906. * Add a submesh to the manager in order to render it this frame
  92907. * @param subMesh The submesh to dispatch
  92908. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92909. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92910. */
  92911. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92912. /**
  92913. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92914. * This allowed control for front to back rendering or reversly depending of the special needs.
  92915. *
  92916. * @param renderingGroupId The rendering group id corresponding to its index
  92917. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92918. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92919. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92920. */
  92921. 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;
  92922. /**
  92923. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92924. *
  92925. * @param renderingGroupId The rendering group id corresponding to its index
  92926. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92927. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92928. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92929. */
  92930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92931. /**
  92932. * Gets the current auto clear configuration for one rendering group of the rendering
  92933. * manager.
  92934. * @param index the rendering group index to get the information for
  92935. * @returns The auto clear setup for the requested rendering group
  92936. */
  92937. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92938. }
  92939. }
  92940. declare module BABYLON {
  92941. /**
  92942. * This Helps creating a texture that will be created from a camera in your scene.
  92943. * It is basically a dynamic texture that could be used to create special effects for instance.
  92944. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  92945. */
  92946. export class RenderTargetTexture extends Texture {
  92947. isCube: boolean;
  92948. /**
  92949. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  92950. */
  92951. static readonly REFRESHRATE_RENDER_ONCE: number;
  92952. /**
  92953. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  92954. */
  92955. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  92956. /**
  92957. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  92958. * the central point of your effect and can save a lot of performances.
  92959. */
  92960. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  92961. /**
  92962. * Use this predicate to dynamically define the list of mesh you want to render.
  92963. * If set, the renderList property will be overwritten.
  92964. */
  92965. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  92966. private _renderList;
  92967. /**
  92968. * Use this list to define the list of mesh you want to render.
  92969. */
  92970. get renderList(): Nullable<Array<AbstractMesh>>;
  92971. set renderList(value: Nullable<Array<AbstractMesh>>);
  92972. /**
  92973. * Use this function to overload the renderList array at rendering time.
  92974. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  92975. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  92976. * the cube (if the RTT is a cube, else layerOrFace=0).
  92977. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  92978. */
  92979. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  92980. private _hookArray;
  92981. /**
  92982. * Define if particles should be rendered in your texture.
  92983. */
  92984. renderParticles: boolean;
  92985. /**
  92986. * Define if sprites should be rendered in your texture.
  92987. */
  92988. renderSprites: boolean;
  92989. /**
  92990. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  92991. */
  92992. coordinatesMode: number;
  92993. /**
  92994. * Define the camera used to render the texture.
  92995. */
  92996. activeCamera: Nullable<Camera>;
  92997. /**
  92998. * Override the render function of the texture with your own one.
  92999. */
  93000. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93001. /**
  93002. * Define if camera post processes should be use while rendering the texture.
  93003. */
  93004. useCameraPostProcesses: boolean;
  93005. /**
  93006. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93007. */
  93008. ignoreCameraViewport: boolean;
  93009. private _postProcessManager;
  93010. private _postProcesses;
  93011. private _resizeObserver;
  93012. /**
  93013. * An event triggered when the texture is unbind.
  93014. */
  93015. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93016. /**
  93017. * An event triggered when the texture is unbind.
  93018. */
  93019. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93020. private _onAfterUnbindObserver;
  93021. /**
  93022. * Set a after unbind callback in the texture.
  93023. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93024. */
  93025. set onAfterUnbind(callback: () => void);
  93026. /**
  93027. * An event triggered before rendering the texture
  93028. */
  93029. onBeforeRenderObservable: Observable<number>;
  93030. private _onBeforeRenderObserver;
  93031. /**
  93032. * Set a before render callback in the texture.
  93033. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93034. */
  93035. set onBeforeRender(callback: (faceIndex: number) => void);
  93036. /**
  93037. * An event triggered after rendering the texture
  93038. */
  93039. onAfterRenderObservable: Observable<number>;
  93040. private _onAfterRenderObserver;
  93041. /**
  93042. * Set a after render callback in the texture.
  93043. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93044. */
  93045. set onAfterRender(callback: (faceIndex: number) => void);
  93046. /**
  93047. * An event triggered after the texture clear
  93048. */
  93049. onClearObservable: Observable<Engine>;
  93050. private _onClearObserver;
  93051. /**
  93052. * Set a clear callback in the texture.
  93053. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93054. */
  93055. set onClear(callback: (Engine: Engine) => void);
  93056. /**
  93057. * An event triggered when the texture is resized.
  93058. */
  93059. onResizeObservable: Observable<RenderTargetTexture>;
  93060. /**
  93061. * Define the clear color of the Render Target if it should be different from the scene.
  93062. */
  93063. clearColor: Color4;
  93064. protected _size: number | {
  93065. width: number;
  93066. height: number;
  93067. layers?: number;
  93068. };
  93069. protected _initialSizeParameter: number | {
  93070. width: number;
  93071. height: number;
  93072. } | {
  93073. ratio: number;
  93074. };
  93075. protected _sizeRatio: Nullable<number>;
  93076. /** @hidden */
  93077. _generateMipMaps: boolean;
  93078. protected _renderingManager: RenderingManager;
  93079. /** @hidden */
  93080. _waitingRenderList: string[];
  93081. protected _doNotChangeAspectRatio: boolean;
  93082. protected _currentRefreshId: number;
  93083. protected _refreshRate: number;
  93084. protected _textureMatrix: Matrix;
  93085. protected _samples: number;
  93086. protected _renderTargetOptions: RenderTargetCreationOptions;
  93087. /**
  93088. * Gets render target creation options that were used.
  93089. */
  93090. get renderTargetOptions(): RenderTargetCreationOptions;
  93091. protected _engine: Engine;
  93092. protected _onRatioRescale(): void;
  93093. /**
  93094. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93095. * It must define where the camera used to render the texture is set
  93096. */
  93097. boundingBoxPosition: Vector3;
  93098. private _boundingBoxSize;
  93099. /**
  93100. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93101. * When defined, the cubemap will switch to local mode
  93102. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93103. * @example https://www.babylonjs-playground.com/#RNASML
  93104. */
  93105. set boundingBoxSize(value: Vector3);
  93106. get boundingBoxSize(): Vector3;
  93107. /**
  93108. * In case the RTT has been created with a depth texture, get the associated
  93109. * depth texture.
  93110. * Otherwise, return null.
  93111. */
  93112. get depthStencilTexture(): Nullable<InternalTexture>;
  93113. /**
  93114. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93115. * or used a shadow, depth texture...
  93116. * @param name The friendly name of the texture
  93117. * @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)
  93118. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93119. * @param generateMipMaps True if mip maps need to be generated after render.
  93120. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93121. * @param type The type of the buffer in the RTT (int, half float, float...)
  93122. * @param isCube True if a cube texture needs to be created
  93123. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93124. * @param generateDepthBuffer True to generate a depth buffer
  93125. * @param generateStencilBuffer True to generate a stencil buffer
  93126. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93127. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93128. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93129. */
  93130. constructor(name: string, size: number | {
  93131. width: number;
  93132. height: number;
  93133. layers?: number;
  93134. } | {
  93135. ratio: number;
  93136. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93137. /**
  93138. * Creates a depth stencil texture.
  93139. * This is only available in WebGL 2 or with the depth texture extension available.
  93140. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93141. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93142. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93143. */
  93144. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93145. private _processSizeParameter;
  93146. /**
  93147. * Define the number of samples to use in case of MSAA.
  93148. * It defaults to one meaning no MSAA has been enabled.
  93149. */
  93150. get samples(): number;
  93151. set samples(value: number);
  93152. /**
  93153. * Resets the refresh counter of the texture and start bak from scratch.
  93154. * Could be useful to regenerate the texture if it is setup to render only once.
  93155. */
  93156. resetRefreshCounter(): void;
  93157. /**
  93158. * Define the refresh rate of the texture or the rendering frequency.
  93159. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93160. */
  93161. get refreshRate(): number;
  93162. set refreshRate(value: number);
  93163. /**
  93164. * Adds a post process to the render target rendering passes.
  93165. * @param postProcess define the post process to add
  93166. */
  93167. addPostProcess(postProcess: PostProcess): void;
  93168. /**
  93169. * Clear all the post processes attached to the render target
  93170. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93171. */
  93172. clearPostProcesses(dispose?: boolean): void;
  93173. /**
  93174. * Remove one of the post process from the list of attached post processes to the texture
  93175. * @param postProcess define the post process to remove from the list
  93176. */
  93177. removePostProcess(postProcess: PostProcess): void;
  93178. /** @hidden */
  93179. _shouldRender(): boolean;
  93180. /**
  93181. * Gets the actual render size of the texture.
  93182. * @returns the width of the render size
  93183. */
  93184. getRenderSize(): number;
  93185. /**
  93186. * Gets the actual render width of the texture.
  93187. * @returns the width of the render size
  93188. */
  93189. getRenderWidth(): number;
  93190. /**
  93191. * Gets the actual render height of the texture.
  93192. * @returns the height of the render size
  93193. */
  93194. getRenderHeight(): number;
  93195. /**
  93196. * Gets the actual number of layers of the texture.
  93197. * @returns the number of layers
  93198. */
  93199. getRenderLayers(): number;
  93200. /**
  93201. * Get if the texture can be rescaled or not.
  93202. */
  93203. get canRescale(): boolean;
  93204. /**
  93205. * Resize the texture using a ratio.
  93206. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93207. */
  93208. scale(ratio: number): void;
  93209. /**
  93210. * Get the texture reflection matrix used to rotate/transform the reflection.
  93211. * @returns the reflection matrix
  93212. */
  93213. getReflectionTextureMatrix(): Matrix;
  93214. /**
  93215. * Resize the texture to a new desired size.
  93216. * Be carrefull as it will recreate all the data in the new texture.
  93217. * @param size Define the new size. It can be:
  93218. * - a number for squared texture,
  93219. * - an object containing { width: number, height: number }
  93220. * - or an object containing a ratio { ratio: number }
  93221. */
  93222. resize(size: number | {
  93223. width: number;
  93224. height: number;
  93225. } | {
  93226. ratio: number;
  93227. }): void;
  93228. private _defaultRenderListPrepared;
  93229. /**
  93230. * Renders all the objects from the render list into the texture.
  93231. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93232. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93233. */
  93234. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93235. private _bestReflectionRenderTargetDimension;
  93236. private _prepareRenderingManager;
  93237. /**
  93238. * @hidden
  93239. * @param faceIndex face index to bind to if this is a cubetexture
  93240. * @param layer defines the index of the texture to bind in the array
  93241. */
  93242. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93243. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93244. private renderToTarget;
  93245. /**
  93246. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93247. * This allowed control for front to back rendering or reversly depending of the special needs.
  93248. *
  93249. * @param renderingGroupId The rendering group id corresponding to its index
  93250. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93251. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93252. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93253. */
  93254. 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;
  93255. /**
  93256. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93257. *
  93258. * @param renderingGroupId The rendering group id corresponding to its index
  93259. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93260. */
  93261. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93262. /**
  93263. * Clones the texture.
  93264. * @returns the cloned texture
  93265. */
  93266. clone(): RenderTargetTexture;
  93267. /**
  93268. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93269. * @returns The JSON representation of the texture
  93270. */
  93271. serialize(): any;
  93272. /**
  93273. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93274. */
  93275. disposeFramebufferObjects(): void;
  93276. /**
  93277. * Dispose the texture and release its associated resources.
  93278. */
  93279. dispose(): void;
  93280. /** @hidden */
  93281. _rebuild(): void;
  93282. /**
  93283. * Clear the info related to rendering groups preventing retention point in material dispose.
  93284. */
  93285. freeRenderingGroups(): void;
  93286. /**
  93287. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93288. * @returns the view count
  93289. */
  93290. getViewCount(): number;
  93291. }
  93292. }
  93293. declare module BABYLON {
  93294. /**
  93295. * Options for compiling materials.
  93296. */
  93297. export interface IMaterialCompilationOptions {
  93298. /**
  93299. * Defines whether clip planes are enabled.
  93300. */
  93301. clipPlane: boolean;
  93302. /**
  93303. * Defines whether instances are enabled.
  93304. */
  93305. useInstances: boolean;
  93306. }
  93307. /**
  93308. * Base class for the main features of a material in Babylon.js
  93309. */
  93310. export class Material implements IAnimatable {
  93311. /**
  93312. * Returns the triangle fill mode
  93313. */
  93314. static readonly TriangleFillMode: number;
  93315. /**
  93316. * Returns the wireframe mode
  93317. */
  93318. static readonly WireFrameFillMode: number;
  93319. /**
  93320. * Returns the point fill mode
  93321. */
  93322. static readonly PointFillMode: number;
  93323. /**
  93324. * Returns the point list draw mode
  93325. */
  93326. static readonly PointListDrawMode: number;
  93327. /**
  93328. * Returns the line list draw mode
  93329. */
  93330. static readonly LineListDrawMode: number;
  93331. /**
  93332. * Returns the line loop draw mode
  93333. */
  93334. static readonly LineLoopDrawMode: number;
  93335. /**
  93336. * Returns the line strip draw mode
  93337. */
  93338. static readonly LineStripDrawMode: number;
  93339. /**
  93340. * Returns the triangle strip draw mode
  93341. */
  93342. static readonly TriangleStripDrawMode: number;
  93343. /**
  93344. * Returns the triangle fan draw mode
  93345. */
  93346. static readonly TriangleFanDrawMode: number;
  93347. /**
  93348. * Stores the clock-wise side orientation
  93349. */
  93350. static readonly ClockWiseSideOrientation: number;
  93351. /**
  93352. * Stores the counter clock-wise side orientation
  93353. */
  93354. static readonly CounterClockWiseSideOrientation: number;
  93355. /**
  93356. * The dirty texture flag value
  93357. */
  93358. static readonly TextureDirtyFlag: number;
  93359. /**
  93360. * The dirty light flag value
  93361. */
  93362. static readonly LightDirtyFlag: number;
  93363. /**
  93364. * The dirty fresnel flag value
  93365. */
  93366. static readonly FresnelDirtyFlag: number;
  93367. /**
  93368. * The dirty attribute flag value
  93369. */
  93370. static readonly AttributesDirtyFlag: number;
  93371. /**
  93372. * The dirty misc flag value
  93373. */
  93374. static readonly MiscDirtyFlag: number;
  93375. /**
  93376. * The all dirty flag value
  93377. */
  93378. static readonly AllDirtyFlag: number;
  93379. /**
  93380. * The ID of the material
  93381. */
  93382. id: string;
  93383. /**
  93384. * Gets or sets the unique id of the material
  93385. */
  93386. uniqueId: number;
  93387. /**
  93388. * The name of the material
  93389. */
  93390. name: string;
  93391. /**
  93392. * Gets or sets user defined metadata
  93393. */
  93394. metadata: any;
  93395. /**
  93396. * For internal use only. Please do not use.
  93397. */
  93398. reservedDataStore: any;
  93399. /**
  93400. * Specifies if the ready state should be checked on each call
  93401. */
  93402. checkReadyOnEveryCall: boolean;
  93403. /**
  93404. * Specifies if the ready state should be checked once
  93405. */
  93406. checkReadyOnlyOnce: boolean;
  93407. /**
  93408. * The state of the material
  93409. */
  93410. state: string;
  93411. /**
  93412. * The alpha value of the material
  93413. */
  93414. protected _alpha: number;
  93415. /**
  93416. * List of inspectable custom properties (used by the Inspector)
  93417. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93418. */
  93419. inspectableCustomProperties: IInspectable[];
  93420. /**
  93421. * Sets the alpha value of the material
  93422. */
  93423. set alpha(value: number);
  93424. /**
  93425. * Gets the alpha value of the material
  93426. */
  93427. get alpha(): number;
  93428. /**
  93429. * Specifies if back face culling is enabled
  93430. */
  93431. protected _backFaceCulling: boolean;
  93432. /**
  93433. * Sets the back-face culling state
  93434. */
  93435. set backFaceCulling(value: boolean);
  93436. /**
  93437. * Gets the back-face culling state
  93438. */
  93439. get backFaceCulling(): boolean;
  93440. /**
  93441. * Stores the value for side orientation
  93442. */
  93443. sideOrientation: number;
  93444. /**
  93445. * Callback triggered when the material is compiled
  93446. */
  93447. onCompiled: Nullable<(effect: Effect) => void>;
  93448. /**
  93449. * Callback triggered when an error occurs
  93450. */
  93451. onError: Nullable<(effect: Effect, errors: string) => void>;
  93452. /**
  93453. * Callback triggered to get the render target textures
  93454. */
  93455. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  93456. /**
  93457. * Gets a boolean indicating that current material needs to register RTT
  93458. */
  93459. get hasRenderTargetTextures(): boolean;
  93460. /**
  93461. * Specifies if the material should be serialized
  93462. */
  93463. doNotSerialize: boolean;
  93464. /**
  93465. * @hidden
  93466. */
  93467. _storeEffectOnSubMeshes: boolean;
  93468. /**
  93469. * Stores the animations for the material
  93470. */
  93471. animations: Nullable<Array<Animation>>;
  93472. /**
  93473. * An event triggered when the material is disposed
  93474. */
  93475. onDisposeObservable: Observable<Material>;
  93476. /**
  93477. * An observer which watches for dispose events
  93478. */
  93479. private _onDisposeObserver;
  93480. private _onUnBindObservable;
  93481. /**
  93482. * Called during a dispose event
  93483. */
  93484. set onDispose(callback: () => void);
  93485. private _onBindObservable;
  93486. /**
  93487. * An event triggered when the material is bound
  93488. */
  93489. get onBindObservable(): Observable<AbstractMesh>;
  93490. /**
  93491. * An observer which watches for bind events
  93492. */
  93493. private _onBindObserver;
  93494. /**
  93495. * Called during a bind event
  93496. */
  93497. set onBind(callback: (Mesh: AbstractMesh) => void);
  93498. /**
  93499. * An event triggered when the material is unbound
  93500. */
  93501. get onUnBindObservable(): Observable<Material>;
  93502. /**
  93503. * Stores the value of the alpha mode
  93504. */
  93505. private _alphaMode;
  93506. /**
  93507. * Sets the value of the alpha mode.
  93508. *
  93509. * | Value | Type | Description |
  93510. * | --- | --- | --- |
  93511. * | 0 | ALPHA_DISABLE | |
  93512. * | 1 | ALPHA_ADD | |
  93513. * | 2 | ALPHA_COMBINE | |
  93514. * | 3 | ALPHA_SUBTRACT | |
  93515. * | 4 | ALPHA_MULTIPLY | |
  93516. * | 5 | ALPHA_MAXIMIZED | |
  93517. * | 6 | ALPHA_ONEONE | |
  93518. * | 7 | ALPHA_PREMULTIPLIED | |
  93519. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  93520. * | 9 | ALPHA_INTERPOLATE | |
  93521. * | 10 | ALPHA_SCREENMODE | |
  93522. *
  93523. */
  93524. set alphaMode(value: number);
  93525. /**
  93526. * Gets the value of the alpha mode
  93527. */
  93528. get alphaMode(): number;
  93529. /**
  93530. * Stores the state of the need depth pre-pass value
  93531. */
  93532. private _needDepthPrePass;
  93533. /**
  93534. * Sets the need depth pre-pass value
  93535. */
  93536. set needDepthPrePass(value: boolean);
  93537. /**
  93538. * Gets the depth pre-pass value
  93539. */
  93540. get needDepthPrePass(): boolean;
  93541. /**
  93542. * Specifies if depth writing should be disabled
  93543. */
  93544. disableDepthWrite: boolean;
  93545. /**
  93546. * Specifies if depth writing should be forced
  93547. */
  93548. forceDepthWrite: boolean;
  93549. /**
  93550. * Specifies the depth function that should be used. 0 means the default engine function
  93551. */
  93552. depthFunction: number;
  93553. /**
  93554. * Specifies if there should be a separate pass for culling
  93555. */
  93556. separateCullingPass: boolean;
  93557. /**
  93558. * Stores the state specifing if fog should be enabled
  93559. */
  93560. private _fogEnabled;
  93561. /**
  93562. * Sets the state for enabling fog
  93563. */
  93564. set fogEnabled(value: boolean);
  93565. /**
  93566. * Gets the value of the fog enabled state
  93567. */
  93568. get fogEnabled(): boolean;
  93569. /**
  93570. * Stores the size of points
  93571. */
  93572. pointSize: number;
  93573. /**
  93574. * Stores the z offset value
  93575. */
  93576. zOffset: number;
  93577. /**
  93578. * Gets a value specifying if wireframe mode is enabled
  93579. */
  93580. get wireframe(): boolean;
  93581. /**
  93582. * Sets the state of wireframe mode
  93583. */
  93584. set wireframe(value: boolean);
  93585. /**
  93586. * Gets the value specifying if point clouds are enabled
  93587. */
  93588. get pointsCloud(): boolean;
  93589. /**
  93590. * Sets the state of point cloud mode
  93591. */
  93592. set pointsCloud(value: boolean);
  93593. /**
  93594. * Gets the material fill mode
  93595. */
  93596. get fillMode(): number;
  93597. /**
  93598. * Sets the material fill mode
  93599. */
  93600. set fillMode(value: number);
  93601. /**
  93602. * @hidden
  93603. * Stores the effects for the material
  93604. */
  93605. _effect: Nullable<Effect>;
  93606. /**
  93607. * Specifies if uniform buffers should be used
  93608. */
  93609. private _useUBO;
  93610. /**
  93611. * Stores a reference to the scene
  93612. */
  93613. private _scene;
  93614. /**
  93615. * Stores the fill mode state
  93616. */
  93617. private _fillMode;
  93618. /**
  93619. * Specifies if the depth write state should be cached
  93620. */
  93621. private _cachedDepthWriteState;
  93622. /**
  93623. * Specifies if the depth function state should be cached
  93624. */
  93625. private _cachedDepthFunctionState;
  93626. /**
  93627. * Stores the uniform buffer
  93628. */
  93629. protected _uniformBuffer: UniformBuffer;
  93630. /** @hidden */
  93631. _indexInSceneMaterialArray: number;
  93632. /** @hidden */
  93633. meshMap: Nullable<{
  93634. [id: string]: AbstractMesh | undefined;
  93635. }>;
  93636. /**
  93637. * Creates a material instance
  93638. * @param name defines the name of the material
  93639. * @param scene defines the scene to reference
  93640. * @param doNotAdd specifies if the material should be added to the scene
  93641. */
  93642. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  93643. /**
  93644. * Returns a string representation of the current material
  93645. * @param fullDetails defines a boolean indicating which levels of logging is desired
  93646. * @returns a string with material information
  93647. */
  93648. toString(fullDetails?: boolean): string;
  93649. /**
  93650. * Gets the class name of the material
  93651. * @returns a string with the class name of the material
  93652. */
  93653. getClassName(): string;
  93654. /**
  93655. * Specifies if updates for the material been locked
  93656. */
  93657. get isFrozen(): boolean;
  93658. /**
  93659. * Locks updates for the material
  93660. */
  93661. freeze(): void;
  93662. /**
  93663. * Unlocks updates for the material
  93664. */
  93665. unfreeze(): void;
  93666. /**
  93667. * Specifies if the material is ready to be used
  93668. * @param mesh defines the mesh to check
  93669. * @param useInstances specifies if instances should be used
  93670. * @returns a boolean indicating if the material is ready to be used
  93671. */
  93672. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93673. /**
  93674. * Specifies that the submesh is ready to be used
  93675. * @param mesh defines the mesh to check
  93676. * @param subMesh defines which submesh to check
  93677. * @param useInstances specifies that instances should be used
  93678. * @returns a boolean indicating that the submesh is ready or not
  93679. */
  93680. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93681. /**
  93682. * Returns the material effect
  93683. * @returns the effect associated with the material
  93684. */
  93685. getEffect(): Nullable<Effect>;
  93686. /**
  93687. * Returns the current scene
  93688. * @returns a Scene
  93689. */
  93690. getScene(): Scene;
  93691. /**
  93692. * Specifies if the material will require alpha blending
  93693. * @returns a boolean specifying if alpha blending is needed
  93694. */
  93695. needAlphaBlending(): boolean;
  93696. /**
  93697. * Specifies if the mesh will require alpha blending
  93698. * @param mesh defines the mesh to check
  93699. * @returns a boolean specifying if alpha blending is needed for the mesh
  93700. */
  93701. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  93702. /**
  93703. * Specifies if this material should be rendered in alpha test mode
  93704. * @returns a boolean specifying if an alpha test is needed.
  93705. */
  93706. needAlphaTesting(): boolean;
  93707. /**
  93708. * Gets the texture used for the alpha test
  93709. * @returns the texture to use for alpha testing
  93710. */
  93711. getAlphaTestTexture(): Nullable<BaseTexture>;
  93712. /**
  93713. * Marks the material to indicate that it needs to be re-calculated
  93714. */
  93715. markDirty(): void;
  93716. /** @hidden */
  93717. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  93718. /**
  93719. * Binds the material to the mesh
  93720. * @param world defines the world transformation matrix
  93721. * @param mesh defines the mesh to bind the material to
  93722. */
  93723. bind(world: Matrix, mesh?: Mesh): void;
  93724. /**
  93725. * Binds the submesh to the material
  93726. * @param world defines the world transformation matrix
  93727. * @param mesh defines the mesh containing the submesh
  93728. * @param subMesh defines the submesh to bind the material to
  93729. */
  93730. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93731. /**
  93732. * Binds the world matrix to the material
  93733. * @param world defines the world transformation matrix
  93734. */
  93735. bindOnlyWorldMatrix(world: Matrix): void;
  93736. /**
  93737. * Binds the scene's uniform buffer to the effect.
  93738. * @param effect defines the effect to bind to the scene uniform buffer
  93739. * @param sceneUbo defines the uniform buffer storing scene data
  93740. */
  93741. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  93742. /**
  93743. * Binds the view matrix to the effect
  93744. * @param effect defines the effect to bind the view matrix to
  93745. */
  93746. bindView(effect: Effect): void;
  93747. /**
  93748. * Binds the view projection matrix to the effect
  93749. * @param effect defines the effect to bind the view projection matrix to
  93750. */
  93751. bindViewProjection(effect: Effect): void;
  93752. /**
  93753. * Specifies if material alpha testing should be turned on for the mesh
  93754. * @param mesh defines the mesh to check
  93755. */
  93756. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  93757. /**
  93758. * Processes to execute after binding the material to a mesh
  93759. * @param mesh defines the rendered mesh
  93760. */
  93761. protected _afterBind(mesh?: Mesh): void;
  93762. /**
  93763. * Unbinds the material from the mesh
  93764. */
  93765. unbind(): void;
  93766. /**
  93767. * Gets the active textures from the material
  93768. * @returns an array of textures
  93769. */
  93770. getActiveTextures(): BaseTexture[];
  93771. /**
  93772. * Specifies if the material uses a texture
  93773. * @param texture defines the texture to check against the material
  93774. * @returns a boolean specifying if the material uses the texture
  93775. */
  93776. hasTexture(texture: BaseTexture): boolean;
  93777. /**
  93778. * Makes a duplicate of the material, and gives it a new name
  93779. * @param name defines the new name for the duplicated material
  93780. * @returns the cloned material
  93781. */
  93782. clone(name: string): Nullable<Material>;
  93783. /**
  93784. * Gets the meshes bound to the material
  93785. * @returns an array of meshes bound to the material
  93786. */
  93787. getBindedMeshes(): AbstractMesh[];
  93788. /**
  93789. * Force shader compilation
  93790. * @param mesh defines the mesh associated with this material
  93791. * @param onCompiled defines a function to execute once the material is compiled
  93792. * @param options defines the options to configure the compilation
  93793. * @param onError defines a function to execute if the material fails compiling
  93794. */
  93795. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  93796. /**
  93797. * Force shader compilation
  93798. * @param mesh defines the mesh that will use this material
  93799. * @param options defines additional options for compiling the shaders
  93800. * @returns a promise that resolves when the compilation completes
  93801. */
  93802. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  93803. private static readonly _AllDirtyCallBack;
  93804. private static readonly _ImageProcessingDirtyCallBack;
  93805. private static readonly _TextureDirtyCallBack;
  93806. private static readonly _FresnelDirtyCallBack;
  93807. private static readonly _MiscDirtyCallBack;
  93808. private static readonly _LightsDirtyCallBack;
  93809. private static readonly _AttributeDirtyCallBack;
  93810. private static _FresnelAndMiscDirtyCallBack;
  93811. private static _TextureAndMiscDirtyCallBack;
  93812. private static readonly _DirtyCallbackArray;
  93813. private static readonly _RunDirtyCallBacks;
  93814. /**
  93815. * Marks a define in the material to indicate that it needs to be re-computed
  93816. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  93817. */
  93818. markAsDirty(flag: number): void;
  93819. /**
  93820. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  93821. * @param func defines a function which checks material defines against the submeshes
  93822. */
  93823. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  93824. /**
  93825. * Indicates that we need to re-calculated for all submeshes
  93826. */
  93827. protected _markAllSubMeshesAsAllDirty(): void;
  93828. /**
  93829. * Indicates that image processing needs to be re-calculated for all submeshes
  93830. */
  93831. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  93832. /**
  93833. * Indicates that textures need to be re-calculated for all submeshes
  93834. */
  93835. protected _markAllSubMeshesAsTexturesDirty(): void;
  93836. /**
  93837. * Indicates that fresnel needs to be re-calculated for all submeshes
  93838. */
  93839. protected _markAllSubMeshesAsFresnelDirty(): void;
  93840. /**
  93841. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  93842. */
  93843. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  93844. /**
  93845. * Indicates that lights need to be re-calculated for all submeshes
  93846. */
  93847. protected _markAllSubMeshesAsLightsDirty(): void;
  93848. /**
  93849. * Indicates that attributes need to be re-calculated for all submeshes
  93850. */
  93851. protected _markAllSubMeshesAsAttributesDirty(): void;
  93852. /**
  93853. * Indicates that misc needs to be re-calculated for all submeshes
  93854. */
  93855. protected _markAllSubMeshesAsMiscDirty(): void;
  93856. /**
  93857. * Indicates that textures and misc need to be re-calculated for all submeshes
  93858. */
  93859. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  93860. /**
  93861. * Disposes the material
  93862. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93863. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93864. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93865. */
  93866. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93867. /** @hidden */
  93868. private releaseVertexArrayObject;
  93869. /**
  93870. * Serializes this material
  93871. * @returns the serialized material object
  93872. */
  93873. serialize(): any;
  93874. /**
  93875. * Creates a material from parsed material data
  93876. * @param parsedMaterial defines parsed material data
  93877. * @param scene defines the hosting scene
  93878. * @param rootUrl defines the root URL to use to load textures
  93879. * @returns a new material
  93880. */
  93881. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  93882. }
  93883. }
  93884. declare module BABYLON {
  93885. /**
  93886. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93887. * separate meshes. This can be use to improve performances.
  93888. * @see http://doc.babylonjs.com/how_to/multi_materials
  93889. */
  93890. export class MultiMaterial extends Material {
  93891. private _subMaterials;
  93892. /**
  93893. * Gets or Sets the list of Materials used within the multi material.
  93894. * They need to be ordered according to the submeshes order in the associated mesh
  93895. */
  93896. get subMaterials(): Nullable<Material>[];
  93897. set subMaterials(value: Nullable<Material>[]);
  93898. /**
  93899. * Function used to align with Node.getChildren()
  93900. * @returns the list of Materials used within the multi material
  93901. */
  93902. getChildren(): Nullable<Material>[];
  93903. /**
  93904. * Instantiates a new Multi Material
  93905. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93906. * separate meshes. This can be use to improve performances.
  93907. * @see http://doc.babylonjs.com/how_to/multi_materials
  93908. * @param name Define the name in the scene
  93909. * @param scene Define the scene the material belongs to
  93910. */
  93911. constructor(name: string, scene: Scene);
  93912. private _hookArray;
  93913. /**
  93914. * Get one of the submaterial by its index in the submaterials array
  93915. * @param index The index to look the sub material at
  93916. * @returns The Material if the index has been defined
  93917. */
  93918. getSubMaterial(index: number): Nullable<Material>;
  93919. /**
  93920. * Get the list of active textures for the whole sub materials list.
  93921. * @returns All the textures that will be used during the rendering
  93922. */
  93923. getActiveTextures(): BaseTexture[];
  93924. /**
  93925. * Gets the current class name of the material e.g. "MultiMaterial"
  93926. * Mainly use in serialization.
  93927. * @returns the class name
  93928. */
  93929. getClassName(): string;
  93930. /**
  93931. * Checks if the material is ready to render the requested sub mesh
  93932. * @param mesh Define the mesh the submesh belongs to
  93933. * @param subMesh Define the sub mesh to look readyness for
  93934. * @param useInstances Define whether or not the material is used with instances
  93935. * @returns true if ready, otherwise false
  93936. */
  93937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93938. /**
  93939. * Clones the current material and its related sub materials
  93940. * @param name Define the name of the newly cloned material
  93941. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  93942. * @returns the cloned material
  93943. */
  93944. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  93945. /**
  93946. * Serializes the materials into a JSON representation.
  93947. * @returns the JSON representation
  93948. */
  93949. serialize(): any;
  93950. /**
  93951. * Dispose the material and release its associated resources
  93952. * @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)
  93953. * @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)
  93954. * @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)
  93955. */
  93956. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  93957. /**
  93958. * Creates a MultiMaterial from parsed MultiMaterial data.
  93959. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  93960. * @param scene defines the hosting scene
  93961. * @returns a new MultiMaterial
  93962. */
  93963. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  93964. }
  93965. }
  93966. declare module BABYLON {
  93967. /**
  93968. * Base class for submeshes
  93969. */
  93970. export class BaseSubMesh {
  93971. /** @hidden */
  93972. _materialDefines: Nullable<MaterialDefines>;
  93973. /** @hidden */
  93974. _materialEffect: Nullable<Effect>;
  93975. /**
  93976. * Gets material defines used by the effect associated to the sub mesh
  93977. */
  93978. get materialDefines(): Nullable<MaterialDefines>;
  93979. /**
  93980. * Sets material defines used by the effect associated to the sub mesh
  93981. */
  93982. set materialDefines(defines: Nullable<MaterialDefines>);
  93983. /**
  93984. * Gets associated effect
  93985. */
  93986. get effect(): Nullable<Effect>;
  93987. /**
  93988. * Sets associated effect (effect used to render this submesh)
  93989. * @param effect defines the effect to associate with
  93990. * @param defines defines the set of defines used to compile this effect
  93991. */
  93992. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  93993. }
  93994. /**
  93995. * Defines a subdivision inside a mesh
  93996. */
  93997. export class SubMesh extends BaseSubMesh implements ICullable {
  93998. /** the material index to use */
  93999. materialIndex: number;
  94000. /** vertex index start */
  94001. verticesStart: number;
  94002. /** vertices count */
  94003. verticesCount: number;
  94004. /** index start */
  94005. indexStart: number;
  94006. /** indices count */
  94007. indexCount: number;
  94008. /** @hidden */
  94009. _linesIndexCount: number;
  94010. private _mesh;
  94011. private _renderingMesh;
  94012. private _boundingInfo;
  94013. private _linesIndexBuffer;
  94014. /** @hidden */
  94015. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94016. /** @hidden */
  94017. _trianglePlanes: Plane[];
  94018. /** @hidden */
  94019. _lastColliderTransformMatrix: Nullable<Matrix>;
  94020. /** @hidden */
  94021. _renderId: number;
  94022. /** @hidden */
  94023. _alphaIndex: number;
  94024. /** @hidden */
  94025. _distanceToCamera: number;
  94026. /** @hidden */
  94027. _id: number;
  94028. private _currentMaterial;
  94029. /**
  94030. * Add a new submesh to a mesh
  94031. * @param materialIndex defines the material index to use
  94032. * @param verticesStart defines vertex index start
  94033. * @param verticesCount defines vertices count
  94034. * @param indexStart defines index start
  94035. * @param indexCount defines indices count
  94036. * @param mesh defines the parent mesh
  94037. * @param renderingMesh defines an optional rendering mesh
  94038. * @param createBoundingBox defines if bounding box should be created for this submesh
  94039. * @returns the new submesh
  94040. */
  94041. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94042. /**
  94043. * Creates a new submesh
  94044. * @param materialIndex defines the material index to use
  94045. * @param verticesStart defines vertex index start
  94046. * @param verticesCount defines vertices count
  94047. * @param indexStart defines index start
  94048. * @param indexCount defines indices count
  94049. * @param mesh defines the parent mesh
  94050. * @param renderingMesh defines an optional rendering mesh
  94051. * @param createBoundingBox defines if bounding box should be created for this submesh
  94052. */
  94053. constructor(
  94054. /** the material index to use */
  94055. materialIndex: number,
  94056. /** vertex index start */
  94057. verticesStart: number,
  94058. /** vertices count */
  94059. verticesCount: number,
  94060. /** index start */
  94061. indexStart: number,
  94062. /** indices count */
  94063. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94064. /**
  94065. * Returns true if this submesh covers the entire parent mesh
  94066. * @ignorenaming
  94067. */
  94068. get IsGlobal(): boolean;
  94069. /**
  94070. * Returns the submesh BoudingInfo object
  94071. * @returns current bounding info (or mesh's one if the submesh is global)
  94072. */
  94073. getBoundingInfo(): BoundingInfo;
  94074. /**
  94075. * Sets the submesh BoundingInfo
  94076. * @param boundingInfo defines the new bounding info to use
  94077. * @returns the SubMesh
  94078. */
  94079. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94080. /**
  94081. * Returns the mesh of the current submesh
  94082. * @return the parent mesh
  94083. */
  94084. getMesh(): AbstractMesh;
  94085. /**
  94086. * Returns the rendering mesh of the submesh
  94087. * @returns the rendering mesh (could be different from parent mesh)
  94088. */
  94089. getRenderingMesh(): Mesh;
  94090. /**
  94091. * Returns the submesh material
  94092. * @returns null or the current material
  94093. */
  94094. getMaterial(): Nullable<Material>;
  94095. /**
  94096. * Sets a new updated BoundingInfo object to the submesh
  94097. * @param data defines an optional position array to use to determine the bounding info
  94098. * @returns the SubMesh
  94099. */
  94100. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94101. /** @hidden */
  94102. _checkCollision(collider: Collider): boolean;
  94103. /**
  94104. * Updates the submesh BoundingInfo
  94105. * @param world defines the world matrix to use to update the bounding info
  94106. * @returns the submesh
  94107. */
  94108. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94109. /**
  94110. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94111. * @param frustumPlanes defines the frustum planes
  94112. * @returns true if the submesh is intersecting with the frustum
  94113. */
  94114. isInFrustum(frustumPlanes: Plane[]): boolean;
  94115. /**
  94116. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94117. * @param frustumPlanes defines the frustum planes
  94118. * @returns true if the submesh is inside the frustum
  94119. */
  94120. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94121. /**
  94122. * Renders the submesh
  94123. * @param enableAlphaMode defines if alpha needs to be used
  94124. * @returns the submesh
  94125. */
  94126. render(enableAlphaMode: boolean): SubMesh;
  94127. /**
  94128. * @hidden
  94129. */
  94130. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94131. /**
  94132. * Checks if the submesh intersects with a ray
  94133. * @param ray defines the ray to test
  94134. * @returns true is the passed ray intersects the submesh bounding box
  94135. */
  94136. canIntersects(ray: Ray): boolean;
  94137. /**
  94138. * Intersects current submesh with a ray
  94139. * @param ray defines the ray to test
  94140. * @param positions defines mesh's positions array
  94141. * @param indices defines mesh's indices array
  94142. * @param fastCheck defines if only bounding info should be used
  94143. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94144. * @returns intersection info or null if no intersection
  94145. */
  94146. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94147. /** @hidden */
  94148. private _intersectLines;
  94149. /** @hidden */
  94150. private _intersectUnIndexedLines;
  94151. /** @hidden */
  94152. private _intersectTriangles;
  94153. /** @hidden */
  94154. private _intersectUnIndexedTriangles;
  94155. /** @hidden */
  94156. _rebuild(): void;
  94157. /**
  94158. * Creates a new submesh from the passed mesh
  94159. * @param newMesh defines the new hosting mesh
  94160. * @param newRenderingMesh defines an optional rendering mesh
  94161. * @returns the new submesh
  94162. */
  94163. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94164. /**
  94165. * Release associated resources
  94166. */
  94167. dispose(): void;
  94168. /**
  94169. * Gets the class name
  94170. * @returns the string "SubMesh".
  94171. */
  94172. getClassName(): string;
  94173. /**
  94174. * Creates a new submesh from indices data
  94175. * @param materialIndex the index of the main mesh material
  94176. * @param startIndex the index where to start the copy in the mesh indices array
  94177. * @param indexCount the number of indices to copy then from the startIndex
  94178. * @param mesh the main mesh to create the submesh from
  94179. * @param renderingMesh the optional rendering mesh
  94180. * @returns a new submesh
  94181. */
  94182. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94183. }
  94184. }
  94185. declare module BABYLON {
  94186. /**
  94187. * Class used to represent data loading progression
  94188. */
  94189. export class SceneLoaderFlags {
  94190. private static _ForceFullSceneLoadingForIncremental;
  94191. private static _ShowLoadingScreen;
  94192. private static _CleanBoneMatrixWeights;
  94193. private static _loggingLevel;
  94194. /**
  94195. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94196. */
  94197. static get ForceFullSceneLoadingForIncremental(): boolean;
  94198. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94199. /**
  94200. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94201. */
  94202. static get ShowLoadingScreen(): boolean;
  94203. static set ShowLoadingScreen(value: boolean);
  94204. /**
  94205. * Defines the current logging level (while loading the scene)
  94206. * @ignorenaming
  94207. */
  94208. static get loggingLevel(): number;
  94209. static set loggingLevel(value: number);
  94210. /**
  94211. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94212. */
  94213. static get CleanBoneMatrixWeights(): boolean;
  94214. static set CleanBoneMatrixWeights(value: boolean);
  94215. }
  94216. }
  94217. declare module BABYLON {
  94218. /**
  94219. * Class used to store geometry data (vertex buffers + index buffer)
  94220. */
  94221. export class Geometry implements IGetSetVerticesData {
  94222. /**
  94223. * Gets or sets the ID of the geometry
  94224. */
  94225. id: string;
  94226. /**
  94227. * Gets or sets the unique ID of the geometry
  94228. */
  94229. uniqueId: number;
  94230. /**
  94231. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94232. */
  94233. delayLoadState: number;
  94234. /**
  94235. * Gets the file containing the data to load when running in delay load state
  94236. */
  94237. delayLoadingFile: Nullable<string>;
  94238. /**
  94239. * Callback called when the geometry is updated
  94240. */
  94241. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94242. private _scene;
  94243. private _engine;
  94244. private _meshes;
  94245. private _totalVertices;
  94246. /** @hidden */
  94247. _indices: IndicesArray;
  94248. /** @hidden */
  94249. _vertexBuffers: {
  94250. [key: string]: VertexBuffer;
  94251. };
  94252. private _isDisposed;
  94253. private _extend;
  94254. private _boundingBias;
  94255. /** @hidden */
  94256. _delayInfo: Array<string>;
  94257. private _indexBuffer;
  94258. private _indexBufferIsUpdatable;
  94259. /** @hidden */
  94260. _boundingInfo: Nullable<BoundingInfo>;
  94261. /** @hidden */
  94262. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94263. /** @hidden */
  94264. _softwareSkinningFrameId: number;
  94265. private _vertexArrayObjects;
  94266. private _updatable;
  94267. /** @hidden */
  94268. _positions: Nullable<Vector3[]>;
  94269. /**
  94270. * 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
  94271. */
  94272. get boundingBias(): Vector2;
  94273. /**
  94274. * 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
  94275. */
  94276. set boundingBias(value: Vector2);
  94277. /**
  94278. * Static function used to attach a new empty geometry to a mesh
  94279. * @param mesh defines the mesh to attach the geometry to
  94280. * @returns the new Geometry
  94281. */
  94282. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94283. /**
  94284. * Creates a new geometry
  94285. * @param id defines the unique ID
  94286. * @param scene defines the hosting scene
  94287. * @param vertexData defines the VertexData used to get geometry data
  94288. * @param updatable defines if geometry must be updatable (false by default)
  94289. * @param mesh defines the mesh that will be associated with the geometry
  94290. */
  94291. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94292. /**
  94293. * Gets the current extend of the geometry
  94294. */
  94295. get extend(): {
  94296. minimum: Vector3;
  94297. maximum: Vector3;
  94298. };
  94299. /**
  94300. * Gets the hosting scene
  94301. * @returns the hosting Scene
  94302. */
  94303. getScene(): Scene;
  94304. /**
  94305. * Gets the hosting engine
  94306. * @returns the hosting Engine
  94307. */
  94308. getEngine(): Engine;
  94309. /**
  94310. * Defines if the geometry is ready to use
  94311. * @returns true if the geometry is ready to be used
  94312. */
  94313. isReady(): boolean;
  94314. /**
  94315. * Gets a value indicating that the geometry should not be serialized
  94316. */
  94317. get doNotSerialize(): boolean;
  94318. /** @hidden */
  94319. _rebuild(): void;
  94320. /**
  94321. * Affects all geometry data in one call
  94322. * @param vertexData defines the geometry data
  94323. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94324. */
  94325. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94326. /**
  94327. * Set specific vertex data
  94328. * @param kind defines the data kind (Position, normal, etc...)
  94329. * @param data defines the vertex data to use
  94330. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94331. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94332. */
  94333. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94334. /**
  94335. * Removes a specific vertex data
  94336. * @param kind defines the data kind (Position, normal, etc...)
  94337. */
  94338. removeVerticesData(kind: string): void;
  94339. /**
  94340. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  94341. * @param buffer defines the vertex buffer to use
  94342. * @param totalVertices defines the total number of vertices for position kind (could be null)
  94343. */
  94344. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  94345. /**
  94346. * Update a specific vertex buffer
  94347. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  94348. * It will do nothing if the buffer is not updatable
  94349. * @param kind defines the data kind (Position, normal, etc...)
  94350. * @param data defines the data to use
  94351. * @param offset defines the offset in the target buffer where to store the data
  94352. * @param useBytes set to true if the offset is in bytes
  94353. */
  94354. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  94355. /**
  94356. * Update a specific vertex buffer
  94357. * This function will create a new buffer if the current one is not updatable
  94358. * @param kind defines the data kind (Position, normal, etc...)
  94359. * @param data defines the data to use
  94360. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  94361. */
  94362. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  94363. private _updateBoundingInfo;
  94364. /** @hidden */
  94365. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  94366. /**
  94367. * Gets total number of vertices
  94368. * @returns the total number of vertices
  94369. */
  94370. getTotalVertices(): number;
  94371. /**
  94372. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94373. * @param kind defines the data kind (Position, normal, etc...)
  94374. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94375. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94376. * @returns a float array containing vertex data
  94377. */
  94378. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94379. /**
  94380. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  94381. * @param kind defines the data kind (Position, normal, etc...)
  94382. * @returns true if the vertex buffer with the specified kind is updatable
  94383. */
  94384. isVertexBufferUpdatable(kind: string): boolean;
  94385. /**
  94386. * Gets a specific vertex buffer
  94387. * @param kind defines the data kind (Position, normal, etc...)
  94388. * @returns a VertexBuffer
  94389. */
  94390. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94391. /**
  94392. * Returns all vertex buffers
  94393. * @return an object holding all vertex buffers indexed by kind
  94394. */
  94395. getVertexBuffers(): Nullable<{
  94396. [key: string]: VertexBuffer;
  94397. }>;
  94398. /**
  94399. * Gets a boolean indicating if specific vertex buffer is present
  94400. * @param kind defines the data kind (Position, normal, etc...)
  94401. * @returns true if data is present
  94402. */
  94403. isVerticesDataPresent(kind: string): boolean;
  94404. /**
  94405. * Gets a list of all attached data kinds (Position, normal, etc...)
  94406. * @returns a list of string containing all kinds
  94407. */
  94408. getVerticesDataKinds(): string[];
  94409. /**
  94410. * Update index buffer
  94411. * @param indices defines the indices to store in the index buffer
  94412. * @param offset defines the offset in the target buffer where to store the data
  94413. * @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)
  94414. */
  94415. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  94416. /**
  94417. * Creates a new index buffer
  94418. * @param indices defines the indices to store in the index buffer
  94419. * @param totalVertices defines the total number of vertices (could be null)
  94420. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94421. */
  94422. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  94423. /**
  94424. * Return the total number of indices
  94425. * @returns the total number of indices
  94426. */
  94427. getTotalIndices(): number;
  94428. /**
  94429. * Gets the index buffer array
  94430. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94431. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94432. * @returns the index buffer array
  94433. */
  94434. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94435. /**
  94436. * Gets the index buffer
  94437. * @return the index buffer
  94438. */
  94439. getIndexBuffer(): Nullable<DataBuffer>;
  94440. /** @hidden */
  94441. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  94442. /**
  94443. * Release the associated resources for a specific mesh
  94444. * @param mesh defines the source mesh
  94445. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  94446. */
  94447. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  94448. /**
  94449. * Apply current geometry to a given mesh
  94450. * @param mesh defines the mesh to apply geometry to
  94451. */
  94452. applyToMesh(mesh: Mesh): void;
  94453. private _updateExtend;
  94454. private _applyToMesh;
  94455. private notifyUpdate;
  94456. /**
  94457. * Load the geometry if it was flagged as delay loaded
  94458. * @param scene defines the hosting scene
  94459. * @param onLoaded defines a callback called when the geometry is loaded
  94460. */
  94461. load(scene: Scene, onLoaded?: () => void): void;
  94462. private _queueLoad;
  94463. /**
  94464. * Invert the geometry to move from a right handed system to a left handed one.
  94465. */
  94466. toLeftHanded(): void;
  94467. /** @hidden */
  94468. _resetPointsArrayCache(): void;
  94469. /** @hidden */
  94470. _generatePointsArray(): boolean;
  94471. /**
  94472. * Gets a value indicating if the geometry is disposed
  94473. * @returns true if the geometry was disposed
  94474. */
  94475. isDisposed(): boolean;
  94476. private _disposeVertexArrayObjects;
  94477. /**
  94478. * Free all associated resources
  94479. */
  94480. dispose(): void;
  94481. /**
  94482. * Clone the current geometry into a new geometry
  94483. * @param id defines the unique ID of the new geometry
  94484. * @returns a new geometry object
  94485. */
  94486. copy(id: string): Geometry;
  94487. /**
  94488. * Serialize the current geometry info (and not the vertices data) into a JSON object
  94489. * @return a JSON representation of the current geometry data (without the vertices data)
  94490. */
  94491. serialize(): any;
  94492. private toNumberArray;
  94493. /**
  94494. * Serialize all vertices data into a JSON oject
  94495. * @returns a JSON representation of the current geometry data
  94496. */
  94497. serializeVerticeData(): any;
  94498. /**
  94499. * Extracts a clone of a mesh geometry
  94500. * @param mesh defines the source mesh
  94501. * @param id defines the unique ID of the new geometry object
  94502. * @returns the new geometry object
  94503. */
  94504. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  94505. /**
  94506. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  94507. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94508. * Be aware Math.random() could cause collisions, but:
  94509. * "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"
  94510. * @returns a string containing a new GUID
  94511. */
  94512. static RandomId(): string;
  94513. /** @hidden */
  94514. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  94515. private static _CleanMatricesWeights;
  94516. /**
  94517. * Create a new geometry from persisted data (Using .babylon file format)
  94518. * @param parsedVertexData defines the persisted data
  94519. * @param scene defines the hosting scene
  94520. * @param rootUrl defines the root url to use to load assets (like delayed data)
  94521. * @returns the new geometry object
  94522. */
  94523. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  94524. }
  94525. }
  94526. declare module BABYLON {
  94527. /**
  94528. * Define an interface for all classes that will get and set the data on vertices
  94529. */
  94530. export interface IGetSetVerticesData {
  94531. /**
  94532. * Gets a boolean indicating if specific vertex data is present
  94533. * @param kind defines the vertex data kind to use
  94534. * @returns true is data kind is present
  94535. */
  94536. isVerticesDataPresent(kind: string): boolean;
  94537. /**
  94538. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94539. * @param kind defines the data kind (Position, normal, etc...)
  94540. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94542. * @returns a float array containing vertex data
  94543. */
  94544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94545. /**
  94546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94547. * @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.
  94548. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94549. * @returns the indices array or an empty array if the mesh has no geometry
  94550. */
  94551. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94552. /**
  94553. * Set specific vertex data
  94554. * @param kind defines the data kind (Position, normal, etc...)
  94555. * @param data defines the vertex data to use
  94556. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94557. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94558. */
  94559. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  94560. /**
  94561. * Update a specific associated vertex buffer
  94562. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94563. * - VertexBuffer.PositionKind
  94564. * - VertexBuffer.UVKind
  94565. * - VertexBuffer.UV2Kind
  94566. * - VertexBuffer.UV3Kind
  94567. * - VertexBuffer.UV4Kind
  94568. * - VertexBuffer.UV5Kind
  94569. * - VertexBuffer.UV6Kind
  94570. * - VertexBuffer.ColorKind
  94571. * - VertexBuffer.MatricesIndicesKind
  94572. * - VertexBuffer.MatricesIndicesExtraKind
  94573. * - VertexBuffer.MatricesWeightsKind
  94574. * - VertexBuffer.MatricesWeightsExtraKind
  94575. * @param data defines the data source
  94576. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  94577. * @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)
  94578. */
  94579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  94580. /**
  94581. * Creates a new index buffer
  94582. * @param indices defines the indices to store in the index buffer
  94583. * @param totalVertices defines the total number of vertices (could be null)
  94584. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94585. */
  94586. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  94587. }
  94588. /**
  94589. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  94590. */
  94591. export class VertexData {
  94592. /**
  94593. * Mesh side orientation : usually the external or front surface
  94594. */
  94595. static readonly FRONTSIDE: number;
  94596. /**
  94597. * Mesh side orientation : usually the internal or back surface
  94598. */
  94599. static readonly BACKSIDE: number;
  94600. /**
  94601. * Mesh side orientation : both internal and external or front and back surfaces
  94602. */
  94603. static readonly DOUBLESIDE: number;
  94604. /**
  94605. * Mesh side orientation : by default, `FRONTSIDE`
  94606. */
  94607. static readonly DEFAULTSIDE: number;
  94608. /**
  94609. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  94610. */
  94611. positions: Nullable<FloatArray>;
  94612. /**
  94613. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  94614. */
  94615. normals: Nullable<FloatArray>;
  94616. /**
  94617. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  94618. */
  94619. tangents: Nullable<FloatArray>;
  94620. /**
  94621. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94622. */
  94623. uvs: Nullable<FloatArray>;
  94624. /**
  94625. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94626. */
  94627. uvs2: Nullable<FloatArray>;
  94628. /**
  94629. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94630. */
  94631. uvs3: Nullable<FloatArray>;
  94632. /**
  94633. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94634. */
  94635. uvs4: Nullable<FloatArray>;
  94636. /**
  94637. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94638. */
  94639. uvs5: Nullable<FloatArray>;
  94640. /**
  94641. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94642. */
  94643. uvs6: Nullable<FloatArray>;
  94644. /**
  94645. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  94646. */
  94647. colors: Nullable<FloatArray>;
  94648. /**
  94649. * 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).
  94650. */
  94651. matricesIndices: Nullable<FloatArray>;
  94652. /**
  94653. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  94654. */
  94655. matricesWeights: Nullable<FloatArray>;
  94656. /**
  94657. * An array extending the number of possible indices
  94658. */
  94659. matricesIndicesExtra: Nullable<FloatArray>;
  94660. /**
  94661. * An array extending the number of possible weights when the number of indices is extended
  94662. */
  94663. matricesWeightsExtra: Nullable<FloatArray>;
  94664. /**
  94665. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  94666. */
  94667. indices: Nullable<IndicesArray>;
  94668. /**
  94669. * Uses the passed data array to set the set the values for the specified kind of data
  94670. * @param data a linear array of floating numbers
  94671. * @param kind the type of data that is being set, eg positions, colors etc
  94672. */
  94673. set(data: FloatArray, kind: string): void;
  94674. /**
  94675. * Associates the vertexData to the passed Mesh.
  94676. * Sets it as updatable or not (default `false`)
  94677. * @param mesh the mesh the vertexData is applied to
  94678. * @param updatable when used and having the value true allows new data to update the vertexData
  94679. * @returns the VertexData
  94680. */
  94681. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  94682. /**
  94683. * Associates the vertexData to the passed Geometry.
  94684. * Sets it as updatable or not (default `false`)
  94685. * @param geometry the geometry the vertexData is applied to
  94686. * @param updatable when used and having the value true allows new data to update the vertexData
  94687. * @returns VertexData
  94688. */
  94689. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  94690. /**
  94691. * Updates the associated mesh
  94692. * @param mesh the mesh to be updated
  94693. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94694. * @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
  94695. * @returns VertexData
  94696. */
  94697. updateMesh(mesh: Mesh): VertexData;
  94698. /**
  94699. * Updates the associated geometry
  94700. * @param geometry the geometry to be updated
  94701. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94702. * @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
  94703. * @returns VertexData.
  94704. */
  94705. updateGeometry(geometry: Geometry): VertexData;
  94706. private _applyTo;
  94707. private _update;
  94708. /**
  94709. * Transforms each position and each normal of the vertexData according to the passed Matrix
  94710. * @param matrix the transforming matrix
  94711. * @returns the VertexData
  94712. */
  94713. transform(matrix: Matrix): VertexData;
  94714. /**
  94715. * Merges the passed VertexData into the current one
  94716. * @param other the VertexData to be merged into the current one
  94717. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  94718. * @returns the modified VertexData
  94719. */
  94720. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  94721. private _mergeElement;
  94722. private _validate;
  94723. /**
  94724. * Serializes the VertexData
  94725. * @returns a serialized object
  94726. */
  94727. serialize(): any;
  94728. /**
  94729. * Extracts the vertexData from a mesh
  94730. * @param mesh the mesh from which to extract the VertexData
  94731. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  94732. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94733. * @returns the object VertexData associated to the passed mesh
  94734. */
  94735. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94736. /**
  94737. * Extracts the vertexData from the geometry
  94738. * @param geometry the geometry from which to extract the VertexData
  94739. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  94740. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94741. * @returns the object VertexData associated to the passed mesh
  94742. */
  94743. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94744. private static _ExtractFrom;
  94745. /**
  94746. * Creates the VertexData for a Ribbon
  94747. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  94748. * * pathArray array of paths, each of which an array of successive Vector3
  94749. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  94750. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  94751. * * 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
  94752. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94753. * * 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)
  94754. * * 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)
  94755. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  94756. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  94757. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  94758. * @returns the VertexData of the ribbon
  94759. */
  94760. static CreateRibbon(options: {
  94761. pathArray: Vector3[][];
  94762. closeArray?: boolean;
  94763. closePath?: boolean;
  94764. offset?: number;
  94765. sideOrientation?: number;
  94766. frontUVs?: Vector4;
  94767. backUVs?: Vector4;
  94768. invertUV?: boolean;
  94769. uvs?: Vector2[];
  94770. colors?: Color4[];
  94771. }): VertexData;
  94772. /**
  94773. * Creates the VertexData for a box
  94774. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94775. * * size sets the width, height and depth of the box to the value of size, optional default 1
  94776. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  94777. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  94778. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  94779. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94780. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94782. * * 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)
  94783. * * 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)
  94784. * @returns the VertexData of the box
  94785. */
  94786. static CreateBox(options: {
  94787. size?: number;
  94788. width?: number;
  94789. height?: number;
  94790. depth?: number;
  94791. faceUV?: Vector4[];
  94792. faceColors?: Color4[];
  94793. sideOrientation?: number;
  94794. frontUVs?: Vector4;
  94795. backUVs?: Vector4;
  94796. }): VertexData;
  94797. /**
  94798. * Creates the VertexData for a tiled box
  94799. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94800. * * faceTiles sets the pattern, tile size and number of tiles for a face
  94801. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94802. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94804. * @returns the VertexData of the box
  94805. */
  94806. static CreateTiledBox(options: {
  94807. pattern?: number;
  94808. width?: number;
  94809. height?: number;
  94810. depth?: number;
  94811. tileSize?: number;
  94812. tileWidth?: number;
  94813. tileHeight?: number;
  94814. alignHorizontal?: number;
  94815. alignVertical?: number;
  94816. faceUV?: Vector4[];
  94817. faceColors?: Color4[];
  94818. sideOrientation?: number;
  94819. }): VertexData;
  94820. /**
  94821. * Creates the VertexData for a tiled plane
  94822. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94823. * * pattern a limited pattern arrangement depending on the number
  94824. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  94825. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  94826. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  94827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94828. * * 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)
  94829. * * 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)
  94830. * @returns the VertexData of the tiled plane
  94831. */
  94832. static CreateTiledPlane(options: {
  94833. pattern?: number;
  94834. tileSize?: number;
  94835. tileWidth?: number;
  94836. tileHeight?: number;
  94837. size?: number;
  94838. width?: number;
  94839. height?: number;
  94840. alignHorizontal?: number;
  94841. alignVertical?: number;
  94842. sideOrientation?: number;
  94843. frontUVs?: Vector4;
  94844. backUVs?: Vector4;
  94845. }): VertexData;
  94846. /**
  94847. * Creates the VertexData for an ellipsoid, defaults to a sphere
  94848. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94849. * * segments sets the number of horizontal strips optional, default 32
  94850. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  94851. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  94852. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  94853. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  94854. * * 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
  94855. * * 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
  94856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94857. * * 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)
  94858. * * 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)
  94859. * @returns the VertexData of the ellipsoid
  94860. */
  94861. static CreateSphere(options: {
  94862. segments?: number;
  94863. diameter?: number;
  94864. diameterX?: number;
  94865. diameterY?: number;
  94866. diameterZ?: number;
  94867. arc?: number;
  94868. slice?: number;
  94869. sideOrientation?: number;
  94870. frontUVs?: Vector4;
  94871. backUVs?: Vector4;
  94872. }): VertexData;
  94873. /**
  94874. * Creates the VertexData for a cylinder, cone or prism
  94875. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94876. * * height sets the height (y direction) of the cylinder, optional, default 2
  94877. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  94878. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  94879. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  94880. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94881. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  94882. * * 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
  94883. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94884. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94885. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  94886. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  94887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94888. * * 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)
  94889. * * 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)
  94890. * @returns the VertexData of the cylinder, cone or prism
  94891. */
  94892. static CreateCylinder(options: {
  94893. height?: number;
  94894. diameterTop?: number;
  94895. diameterBottom?: number;
  94896. diameter?: number;
  94897. tessellation?: number;
  94898. subdivisions?: number;
  94899. arc?: number;
  94900. faceColors?: Color4[];
  94901. faceUV?: Vector4[];
  94902. hasRings?: boolean;
  94903. enclose?: boolean;
  94904. sideOrientation?: number;
  94905. frontUVs?: Vector4;
  94906. backUVs?: Vector4;
  94907. }): VertexData;
  94908. /**
  94909. * Creates the VertexData for a torus
  94910. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94911. * * diameter the diameter of the torus, optional default 1
  94912. * * thickness the diameter of the tube forming the torus, optional default 0.5
  94913. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94915. * * 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)
  94916. * * 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)
  94917. * @returns the VertexData of the torus
  94918. */
  94919. static CreateTorus(options: {
  94920. diameter?: number;
  94921. thickness?: number;
  94922. tessellation?: number;
  94923. sideOrientation?: number;
  94924. frontUVs?: Vector4;
  94925. backUVs?: Vector4;
  94926. }): VertexData;
  94927. /**
  94928. * Creates the VertexData of the LineSystem
  94929. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  94930. * - lines an array of lines, each line being an array of successive Vector3
  94931. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  94932. * @returns the VertexData of the LineSystem
  94933. */
  94934. static CreateLineSystem(options: {
  94935. lines: Vector3[][];
  94936. colors?: Nullable<Color4[][]>;
  94937. }): VertexData;
  94938. /**
  94939. * Create the VertexData for a DashedLines
  94940. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  94941. * - points an array successive Vector3
  94942. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  94943. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  94944. * - dashNb the intended total number of dashes, optional, default 200
  94945. * @returns the VertexData for the DashedLines
  94946. */
  94947. static CreateDashedLines(options: {
  94948. points: Vector3[];
  94949. dashSize?: number;
  94950. gapSize?: number;
  94951. dashNb?: number;
  94952. }): VertexData;
  94953. /**
  94954. * Creates the VertexData for a Ground
  94955. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94956. * - width the width (x direction) of the ground, optional, default 1
  94957. * - height the height (z direction) of the ground, optional, default 1
  94958. * - subdivisions the number of subdivisions per side, optional, default 1
  94959. * @returns the VertexData of the Ground
  94960. */
  94961. static CreateGround(options: {
  94962. width?: number;
  94963. height?: number;
  94964. subdivisions?: number;
  94965. subdivisionsX?: number;
  94966. subdivisionsY?: number;
  94967. }): VertexData;
  94968. /**
  94969. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  94970. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94971. * * xmin the ground minimum X coordinate, optional, default -1
  94972. * * zmin the ground minimum Z coordinate, optional, default -1
  94973. * * xmax the ground maximum X coordinate, optional, default 1
  94974. * * zmax the ground maximum Z coordinate, optional, default 1
  94975. * * 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}
  94976. * * 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}
  94977. * @returns the VertexData of the TiledGround
  94978. */
  94979. static CreateTiledGround(options: {
  94980. xmin: number;
  94981. zmin: number;
  94982. xmax: number;
  94983. zmax: number;
  94984. subdivisions?: {
  94985. w: number;
  94986. h: number;
  94987. };
  94988. precision?: {
  94989. w: number;
  94990. h: number;
  94991. };
  94992. }): VertexData;
  94993. /**
  94994. * Creates the VertexData of the Ground designed from a heightmap
  94995. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  94996. * * width the width (x direction) of the ground
  94997. * * height the height (z direction) of the ground
  94998. * * subdivisions the number of subdivisions per side
  94999. * * minHeight the minimum altitude on the ground, optional, default 0
  95000. * * maxHeight the maximum altitude on the ground, optional default 1
  95001. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95002. * * buffer the array holding the image color data
  95003. * * bufferWidth the width of image
  95004. * * bufferHeight the height of image
  95005. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95006. * @returns the VertexData of the Ground designed from a heightmap
  95007. */
  95008. static CreateGroundFromHeightMap(options: {
  95009. width: number;
  95010. height: number;
  95011. subdivisions: number;
  95012. minHeight: number;
  95013. maxHeight: number;
  95014. colorFilter: Color3;
  95015. buffer: Uint8Array;
  95016. bufferWidth: number;
  95017. bufferHeight: number;
  95018. alphaFilter: number;
  95019. }): VertexData;
  95020. /**
  95021. * Creates the VertexData for a Plane
  95022. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95023. * * size sets the width and height of the plane to the value of size, optional default 1
  95024. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95025. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95027. * * 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)
  95028. * * 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)
  95029. * @returns the VertexData of the box
  95030. */
  95031. static CreatePlane(options: {
  95032. size?: number;
  95033. width?: number;
  95034. height?: number;
  95035. sideOrientation?: number;
  95036. frontUVs?: Vector4;
  95037. backUVs?: Vector4;
  95038. }): VertexData;
  95039. /**
  95040. * Creates the VertexData of the Disc or regular Polygon
  95041. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95042. * * radius the radius of the disc, optional default 0.5
  95043. * * tessellation the number of polygon sides, optional, default 64
  95044. * * 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
  95045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95046. * * 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)
  95047. * * 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)
  95048. * @returns the VertexData of the box
  95049. */
  95050. static CreateDisc(options: {
  95051. radius?: number;
  95052. tessellation?: number;
  95053. arc?: number;
  95054. sideOrientation?: number;
  95055. frontUVs?: Vector4;
  95056. backUVs?: Vector4;
  95057. }): VertexData;
  95058. /**
  95059. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95060. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95061. * @param polygon a mesh built from polygonTriangulation.build()
  95062. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95063. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95064. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95065. * @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)
  95066. * @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)
  95067. * @returns the VertexData of the Polygon
  95068. */
  95069. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95070. /**
  95071. * Creates the VertexData of the IcoSphere
  95072. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95073. * * radius the radius of the IcoSphere, optional default 1
  95074. * * radiusX allows stretching in the x direction, optional, default radius
  95075. * * radiusY allows stretching in the y direction, optional, default radius
  95076. * * radiusZ allows stretching in the z direction, optional, default radius
  95077. * * flat when true creates a flat shaded mesh, optional, default true
  95078. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95080. * * 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)
  95081. * * 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)
  95082. * @returns the VertexData of the IcoSphere
  95083. */
  95084. static CreateIcoSphere(options: {
  95085. radius?: number;
  95086. radiusX?: number;
  95087. radiusY?: number;
  95088. radiusZ?: number;
  95089. flat?: boolean;
  95090. subdivisions?: number;
  95091. sideOrientation?: number;
  95092. frontUVs?: Vector4;
  95093. backUVs?: Vector4;
  95094. }): VertexData;
  95095. /**
  95096. * Creates the VertexData for a Polyhedron
  95097. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95098. * * type provided types are:
  95099. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95100. * * 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)
  95101. * * size the size of the IcoSphere, optional default 1
  95102. * * sizeX allows stretching in the x direction, optional, default size
  95103. * * sizeY allows stretching in the y direction, optional, default size
  95104. * * sizeZ allows stretching in the z direction, optional, default size
  95105. * * 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
  95106. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95107. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95108. * * flat when true creates a flat shaded mesh, optional, default true
  95109. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95111. * * 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)
  95112. * * 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)
  95113. * @returns the VertexData of the Polyhedron
  95114. */
  95115. static CreatePolyhedron(options: {
  95116. type?: number;
  95117. size?: number;
  95118. sizeX?: number;
  95119. sizeY?: number;
  95120. sizeZ?: number;
  95121. custom?: any;
  95122. faceUV?: Vector4[];
  95123. faceColors?: Color4[];
  95124. flat?: boolean;
  95125. sideOrientation?: number;
  95126. frontUVs?: Vector4;
  95127. backUVs?: Vector4;
  95128. }): VertexData;
  95129. /**
  95130. * Creates the VertexData for a TorusKnot
  95131. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95132. * * radius the radius of the torus knot, optional, default 2
  95133. * * tube the thickness of the tube, optional, default 0.5
  95134. * * radialSegments the number of sides on each tube segments, optional, default 32
  95135. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95136. * * p the number of windings around the z axis, optional, default 2
  95137. * * q the number of windings around the x axis, optional, default 3
  95138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95139. * * 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)
  95140. * * 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)
  95141. * @returns the VertexData of the Torus Knot
  95142. */
  95143. static CreateTorusKnot(options: {
  95144. radius?: number;
  95145. tube?: number;
  95146. radialSegments?: number;
  95147. tubularSegments?: number;
  95148. p?: number;
  95149. q?: number;
  95150. sideOrientation?: number;
  95151. frontUVs?: Vector4;
  95152. backUVs?: Vector4;
  95153. }): VertexData;
  95154. /**
  95155. * Compute normals for given positions and indices
  95156. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95157. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95158. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95159. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95160. * * facetNormals : optional array of facet normals (vector3)
  95161. * * facetPositions : optional array of facet positions (vector3)
  95162. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95163. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95164. * * bInfo : optional bounding info, required for facetPartitioning computation
  95165. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95166. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95167. * * useRightHandedSystem: optional boolean to for right handed system computation
  95168. * * depthSort : optional boolean to enable the facet depth sort computation
  95169. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95170. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95171. */
  95172. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95173. facetNormals?: any;
  95174. facetPositions?: any;
  95175. facetPartitioning?: any;
  95176. ratio?: number;
  95177. bInfo?: any;
  95178. bbSize?: Vector3;
  95179. subDiv?: any;
  95180. useRightHandedSystem?: boolean;
  95181. depthSort?: boolean;
  95182. distanceTo?: Vector3;
  95183. depthSortedFacets?: any;
  95184. }): void;
  95185. /** @hidden */
  95186. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95187. /**
  95188. * Applies VertexData created from the imported parameters to the geometry
  95189. * @param parsedVertexData the parsed data from an imported file
  95190. * @param geometry the geometry to apply the VertexData to
  95191. */
  95192. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95193. }
  95194. }
  95195. declare module BABYLON {
  95196. /**
  95197. * Defines a target to use with MorphTargetManager
  95198. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95199. */
  95200. export class MorphTarget implements IAnimatable {
  95201. /** defines the name of the target */
  95202. name: string;
  95203. /**
  95204. * Gets or sets the list of animations
  95205. */
  95206. animations: Animation[];
  95207. private _scene;
  95208. private _positions;
  95209. private _normals;
  95210. private _tangents;
  95211. private _uvs;
  95212. private _influence;
  95213. private _uniqueId;
  95214. /**
  95215. * Observable raised when the influence changes
  95216. */
  95217. onInfluenceChanged: Observable<boolean>;
  95218. /** @hidden */
  95219. _onDataLayoutChanged: Observable<void>;
  95220. /**
  95221. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95222. */
  95223. get influence(): number;
  95224. set influence(influence: number);
  95225. /**
  95226. * Gets or sets the id of the morph Target
  95227. */
  95228. id: string;
  95229. private _animationPropertiesOverride;
  95230. /**
  95231. * Gets or sets the animation properties override
  95232. */
  95233. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95234. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95235. /**
  95236. * Creates a new MorphTarget
  95237. * @param name defines the name of the target
  95238. * @param influence defines the influence to use
  95239. * @param scene defines the scene the morphtarget belongs to
  95240. */
  95241. constructor(
  95242. /** defines the name of the target */
  95243. name: string, influence?: number, scene?: Nullable<Scene>);
  95244. /**
  95245. * Gets the unique ID of this manager
  95246. */
  95247. get uniqueId(): number;
  95248. /**
  95249. * Gets a boolean defining if the target contains position data
  95250. */
  95251. get hasPositions(): boolean;
  95252. /**
  95253. * Gets a boolean defining if the target contains normal data
  95254. */
  95255. get hasNormals(): boolean;
  95256. /**
  95257. * Gets a boolean defining if the target contains tangent data
  95258. */
  95259. get hasTangents(): boolean;
  95260. /**
  95261. * Gets a boolean defining if the target contains texture coordinates data
  95262. */
  95263. get hasUVs(): boolean;
  95264. /**
  95265. * Affects position data to this target
  95266. * @param data defines the position data to use
  95267. */
  95268. setPositions(data: Nullable<FloatArray>): void;
  95269. /**
  95270. * Gets the position data stored in this target
  95271. * @returns a FloatArray containing the position data (or null if not present)
  95272. */
  95273. getPositions(): Nullable<FloatArray>;
  95274. /**
  95275. * Affects normal data to this target
  95276. * @param data defines the normal data to use
  95277. */
  95278. setNormals(data: Nullable<FloatArray>): void;
  95279. /**
  95280. * Gets the normal data stored in this target
  95281. * @returns a FloatArray containing the normal data (or null if not present)
  95282. */
  95283. getNormals(): Nullable<FloatArray>;
  95284. /**
  95285. * Affects tangent data to this target
  95286. * @param data defines the tangent data to use
  95287. */
  95288. setTangents(data: Nullable<FloatArray>): void;
  95289. /**
  95290. * Gets the tangent data stored in this target
  95291. * @returns a FloatArray containing the tangent data (or null if not present)
  95292. */
  95293. getTangents(): Nullable<FloatArray>;
  95294. /**
  95295. * Affects texture coordinates data to this target
  95296. * @param data defines the texture coordinates data to use
  95297. */
  95298. setUVs(data: Nullable<FloatArray>): void;
  95299. /**
  95300. * Gets the texture coordinates data stored in this target
  95301. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95302. */
  95303. getUVs(): Nullable<FloatArray>;
  95304. /**
  95305. * Clone the current target
  95306. * @returns a new MorphTarget
  95307. */
  95308. clone(): MorphTarget;
  95309. /**
  95310. * Serializes the current target into a Serialization object
  95311. * @returns the serialized object
  95312. */
  95313. serialize(): any;
  95314. /**
  95315. * Returns the string "MorphTarget"
  95316. * @returns "MorphTarget"
  95317. */
  95318. getClassName(): string;
  95319. /**
  95320. * Creates a new target from serialized data
  95321. * @param serializationObject defines the serialized data to use
  95322. * @returns a new MorphTarget
  95323. */
  95324. static Parse(serializationObject: any): MorphTarget;
  95325. /**
  95326. * Creates a MorphTarget from mesh data
  95327. * @param mesh defines the source mesh
  95328. * @param name defines the name to use for the new target
  95329. * @param influence defines the influence to attach to the target
  95330. * @returns a new MorphTarget
  95331. */
  95332. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95333. }
  95334. }
  95335. declare module BABYLON {
  95336. /**
  95337. * This class is used to deform meshes using morphing between different targets
  95338. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95339. */
  95340. export class MorphTargetManager {
  95341. private _targets;
  95342. private _targetInfluenceChangedObservers;
  95343. private _targetDataLayoutChangedObservers;
  95344. private _activeTargets;
  95345. private _scene;
  95346. private _influences;
  95347. private _supportsNormals;
  95348. private _supportsTangents;
  95349. private _supportsUVs;
  95350. private _vertexCount;
  95351. private _uniqueId;
  95352. private _tempInfluences;
  95353. /**
  95354. * Gets or sets a boolean indicating if normals must be morphed
  95355. */
  95356. enableNormalMorphing: boolean;
  95357. /**
  95358. * Gets or sets a boolean indicating if tangents must be morphed
  95359. */
  95360. enableTangentMorphing: boolean;
  95361. /**
  95362. * Gets or sets a boolean indicating if UV must be morphed
  95363. */
  95364. enableUVMorphing: boolean;
  95365. /**
  95366. * Creates a new MorphTargetManager
  95367. * @param scene defines the current scene
  95368. */
  95369. constructor(scene?: Nullable<Scene>);
  95370. /**
  95371. * Gets the unique ID of this manager
  95372. */
  95373. get uniqueId(): number;
  95374. /**
  95375. * Gets the number of vertices handled by this manager
  95376. */
  95377. get vertexCount(): number;
  95378. /**
  95379. * Gets a boolean indicating if this manager supports morphing of normals
  95380. */
  95381. get supportsNormals(): boolean;
  95382. /**
  95383. * Gets a boolean indicating if this manager supports morphing of tangents
  95384. */
  95385. get supportsTangents(): boolean;
  95386. /**
  95387. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  95388. */
  95389. get supportsUVs(): boolean;
  95390. /**
  95391. * Gets the number of targets stored in this manager
  95392. */
  95393. get numTargets(): number;
  95394. /**
  95395. * Gets the number of influencers (ie. the number of targets with influences > 0)
  95396. */
  95397. get numInfluencers(): number;
  95398. /**
  95399. * Gets the list of influences (one per target)
  95400. */
  95401. get influences(): Float32Array;
  95402. /**
  95403. * Gets the active target at specified index. An active target is a target with an influence > 0
  95404. * @param index defines the index to check
  95405. * @returns the requested target
  95406. */
  95407. getActiveTarget(index: number): MorphTarget;
  95408. /**
  95409. * Gets the target at specified index
  95410. * @param index defines the index to check
  95411. * @returns the requested target
  95412. */
  95413. getTarget(index: number): MorphTarget;
  95414. /**
  95415. * Add a new target to this manager
  95416. * @param target defines the target to add
  95417. */
  95418. addTarget(target: MorphTarget): void;
  95419. /**
  95420. * Removes a target from the manager
  95421. * @param target defines the target to remove
  95422. */
  95423. removeTarget(target: MorphTarget): void;
  95424. /**
  95425. * Clone the current manager
  95426. * @returns a new MorphTargetManager
  95427. */
  95428. clone(): MorphTargetManager;
  95429. /**
  95430. * Serializes the current manager into a Serialization object
  95431. * @returns the serialized object
  95432. */
  95433. serialize(): any;
  95434. private _syncActiveTargets;
  95435. /**
  95436. * Syncrhonize the targets with all the meshes using this morph target manager
  95437. */
  95438. synchronize(): void;
  95439. /**
  95440. * Creates a new MorphTargetManager from serialized data
  95441. * @param serializationObject defines the serialized data
  95442. * @param scene defines the hosting scene
  95443. * @returns the new MorphTargetManager
  95444. */
  95445. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  95446. }
  95447. }
  95448. declare module BABYLON {
  95449. /**
  95450. * Class used to represent a specific level of detail of a mesh
  95451. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95452. */
  95453. export class MeshLODLevel {
  95454. /** Defines the distance where this level should start being displayed */
  95455. distance: number;
  95456. /** Defines the mesh to use to render this level */
  95457. mesh: Nullable<Mesh>;
  95458. /**
  95459. * Creates a new LOD level
  95460. * @param distance defines the distance where this level should star being displayed
  95461. * @param mesh defines the mesh to use to render this level
  95462. */
  95463. constructor(
  95464. /** Defines the distance where this level should start being displayed */
  95465. distance: number,
  95466. /** Defines the mesh to use to render this level */
  95467. mesh: Nullable<Mesh>);
  95468. }
  95469. }
  95470. declare module BABYLON {
  95471. /**
  95472. * Mesh representing the gorund
  95473. */
  95474. export class GroundMesh extends Mesh {
  95475. /** If octree should be generated */
  95476. generateOctree: boolean;
  95477. private _heightQuads;
  95478. /** @hidden */
  95479. _subdivisionsX: number;
  95480. /** @hidden */
  95481. _subdivisionsY: number;
  95482. /** @hidden */
  95483. _width: number;
  95484. /** @hidden */
  95485. _height: number;
  95486. /** @hidden */
  95487. _minX: number;
  95488. /** @hidden */
  95489. _maxX: number;
  95490. /** @hidden */
  95491. _minZ: number;
  95492. /** @hidden */
  95493. _maxZ: number;
  95494. constructor(name: string, scene: Scene);
  95495. /**
  95496. * "GroundMesh"
  95497. * @returns "GroundMesh"
  95498. */
  95499. getClassName(): string;
  95500. /**
  95501. * The minimum of x and y subdivisions
  95502. */
  95503. get subdivisions(): number;
  95504. /**
  95505. * X subdivisions
  95506. */
  95507. get subdivisionsX(): number;
  95508. /**
  95509. * Y subdivisions
  95510. */
  95511. get subdivisionsY(): number;
  95512. /**
  95513. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  95514. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95515. * @param chunksCount the number of subdivisions for x and y
  95516. * @param octreeBlocksSize (Default: 32)
  95517. */
  95518. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  95519. /**
  95520. * Returns a height (y) value in the Worl system :
  95521. * the ground altitude at the coordinates (x, z) expressed in the World system.
  95522. * @param x x coordinate
  95523. * @param z z coordinate
  95524. * @returns the ground y position if (x, z) are outside the ground surface.
  95525. */
  95526. getHeightAtCoordinates(x: number, z: number): number;
  95527. /**
  95528. * Returns a normalized vector (Vector3) orthogonal to the ground
  95529. * at the ground coordinates (x, z) expressed in the World system.
  95530. * @param x x coordinate
  95531. * @param z z coordinate
  95532. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  95533. */
  95534. getNormalAtCoordinates(x: number, z: number): Vector3;
  95535. /**
  95536. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  95537. * at the ground coordinates (x, z) expressed in the World system.
  95538. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  95539. * @param x x coordinate
  95540. * @param z z coordinate
  95541. * @param ref vector to store the result
  95542. * @returns the GroundMesh.
  95543. */
  95544. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  95545. /**
  95546. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  95547. * if the ground has been updated.
  95548. * This can be used in the render loop.
  95549. * @returns the GroundMesh.
  95550. */
  95551. updateCoordinateHeights(): GroundMesh;
  95552. private _getFacetAt;
  95553. private _initHeightQuads;
  95554. private _computeHeightQuads;
  95555. /**
  95556. * Serializes this ground mesh
  95557. * @param serializationObject object to write serialization to
  95558. */
  95559. serialize(serializationObject: any): void;
  95560. /**
  95561. * Parses a serialized ground mesh
  95562. * @param parsedMesh the serialized mesh
  95563. * @param scene the scene to create the ground mesh in
  95564. * @returns the created ground mesh
  95565. */
  95566. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  95567. }
  95568. }
  95569. declare module BABYLON {
  95570. /**
  95571. * Interface for Physics-Joint data
  95572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95573. */
  95574. export interface PhysicsJointData {
  95575. /**
  95576. * The main pivot of the joint
  95577. */
  95578. mainPivot?: Vector3;
  95579. /**
  95580. * The connected pivot of the joint
  95581. */
  95582. connectedPivot?: Vector3;
  95583. /**
  95584. * The main axis of the joint
  95585. */
  95586. mainAxis?: Vector3;
  95587. /**
  95588. * The connected axis of the joint
  95589. */
  95590. connectedAxis?: Vector3;
  95591. /**
  95592. * The collision of the joint
  95593. */
  95594. collision?: boolean;
  95595. /**
  95596. * Native Oimo/Cannon/Energy data
  95597. */
  95598. nativeParams?: any;
  95599. }
  95600. /**
  95601. * This is a holder class for the physics joint created by the physics plugin
  95602. * It holds a set of functions to control the underlying joint
  95603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95604. */
  95605. export class PhysicsJoint {
  95606. /**
  95607. * The type of the physics joint
  95608. */
  95609. type: number;
  95610. /**
  95611. * The data for the physics joint
  95612. */
  95613. jointData: PhysicsJointData;
  95614. private _physicsJoint;
  95615. protected _physicsPlugin: IPhysicsEnginePlugin;
  95616. /**
  95617. * Initializes the physics joint
  95618. * @param type The type of the physics joint
  95619. * @param jointData The data for the physics joint
  95620. */
  95621. constructor(
  95622. /**
  95623. * The type of the physics joint
  95624. */
  95625. type: number,
  95626. /**
  95627. * The data for the physics joint
  95628. */
  95629. jointData: PhysicsJointData);
  95630. /**
  95631. * Gets the physics joint
  95632. */
  95633. get physicsJoint(): any;
  95634. /**
  95635. * Sets the physics joint
  95636. */
  95637. set physicsJoint(newJoint: any);
  95638. /**
  95639. * Sets the physics plugin
  95640. */
  95641. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  95642. /**
  95643. * Execute a function that is physics-plugin specific.
  95644. * @param {Function} func the function that will be executed.
  95645. * It accepts two parameters: the physics world and the physics joint
  95646. */
  95647. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  95648. /**
  95649. * Distance-Joint type
  95650. */
  95651. static DistanceJoint: number;
  95652. /**
  95653. * Hinge-Joint type
  95654. */
  95655. static HingeJoint: number;
  95656. /**
  95657. * Ball-and-Socket joint type
  95658. */
  95659. static BallAndSocketJoint: number;
  95660. /**
  95661. * Wheel-Joint type
  95662. */
  95663. static WheelJoint: number;
  95664. /**
  95665. * Slider-Joint type
  95666. */
  95667. static SliderJoint: number;
  95668. /**
  95669. * Prismatic-Joint type
  95670. */
  95671. static PrismaticJoint: number;
  95672. /**
  95673. * Universal-Joint type
  95674. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  95675. */
  95676. static UniversalJoint: number;
  95677. /**
  95678. * Hinge-Joint 2 type
  95679. */
  95680. static Hinge2Joint: number;
  95681. /**
  95682. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  95683. */
  95684. static PointToPointJoint: number;
  95685. /**
  95686. * Spring-Joint type
  95687. */
  95688. static SpringJoint: number;
  95689. /**
  95690. * Lock-Joint type
  95691. */
  95692. static LockJoint: number;
  95693. }
  95694. /**
  95695. * A class representing a physics distance joint
  95696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95697. */
  95698. export class DistanceJoint extends PhysicsJoint {
  95699. /**
  95700. *
  95701. * @param jointData The data for the Distance-Joint
  95702. */
  95703. constructor(jointData: DistanceJointData);
  95704. /**
  95705. * Update the predefined distance.
  95706. * @param maxDistance The maximum preferred distance
  95707. * @param minDistance The minimum preferred distance
  95708. */
  95709. updateDistance(maxDistance: number, minDistance?: number): void;
  95710. }
  95711. /**
  95712. * Represents a Motor-Enabled Joint
  95713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95714. */
  95715. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  95716. /**
  95717. * Initializes the Motor-Enabled Joint
  95718. * @param type The type of the joint
  95719. * @param jointData The physica joint data for the joint
  95720. */
  95721. constructor(type: number, jointData: PhysicsJointData);
  95722. /**
  95723. * Set the motor values.
  95724. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95725. * @param force the force to apply
  95726. * @param maxForce max force for this motor.
  95727. */
  95728. setMotor(force?: number, maxForce?: number): void;
  95729. /**
  95730. * Set the motor's limits.
  95731. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95732. * @param upperLimit The upper limit of the motor
  95733. * @param lowerLimit The lower limit of the motor
  95734. */
  95735. setLimit(upperLimit: number, lowerLimit?: number): void;
  95736. }
  95737. /**
  95738. * This class represents a single physics Hinge-Joint
  95739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95740. */
  95741. export class HingeJoint extends MotorEnabledJoint {
  95742. /**
  95743. * Initializes the Hinge-Joint
  95744. * @param jointData The joint data for the Hinge-Joint
  95745. */
  95746. constructor(jointData: PhysicsJointData);
  95747. /**
  95748. * Set the motor values.
  95749. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95750. * @param {number} force the force to apply
  95751. * @param {number} maxForce max force for this motor.
  95752. */
  95753. setMotor(force?: number, maxForce?: number): void;
  95754. /**
  95755. * Set the motor's limits.
  95756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95757. * @param upperLimit The upper limit of the motor
  95758. * @param lowerLimit The lower limit of the motor
  95759. */
  95760. setLimit(upperLimit: number, lowerLimit?: number): void;
  95761. }
  95762. /**
  95763. * This class represents a dual hinge physics joint (same as wheel joint)
  95764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95765. */
  95766. export class Hinge2Joint extends MotorEnabledJoint {
  95767. /**
  95768. * Initializes the Hinge2-Joint
  95769. * @param jointData The joint data for the Hinge2-Joint
  95770. */
  95771. constructor(jointData: PhysicsJointData);
  95772. /**
  95773. * Set the motor values.
  95774. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95775. * @param {number} targetSpeed the speed the motor is to reach
  95776. * @param {number} maxForce max force for this motor.
  95777. * @param {motorIndex} the motor's index, 0 or 1.
  95778. */
  95779. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  95780. /**
  95781. * Set the motor limits.
  95782. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95783. * @param {number} upperLimit the upper limit
  95784. * @param {number} lowerLimit lower limit
  95785. * @param {motorIndex} the motor's index, 0 or 1.
  95786. */
  95787. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95788. }
  95789. /**
  95790. * Interface for a motor enabled joint
  95791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95792. */
  95793. export interface IMotorEnabledJoint {
  95794. /**
  95795. * Physics joint
  95796. */
  95797. physicsJoint: any;
  95798. /**
  95799. * Sets the motor of the motor-enabled joint
  95800. * @param force The force of the motor
  95801. * @param maxForce The maximum force of the motor
  95802. * @param motorIndex The index of the motor
  95803. */
  95804. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  95805. /**
  95806. * Sets the limit of the motor
  95807. * @param upperLimit The upper limit of the motor
  95808. * @param lowerLimit The lower limit of the motor
  95809. * @param motorIndex The index of the motor
  95810. */
  95811. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95812. }
  95813. /**
  95814. * Joint data for a Distance-Joint
  95815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95816. */
  95817. export interface DistanceJointData extends PhysicsJointData {
  95818. /**
  95819. * Max distance the 2 joint objects can be apart
  95820. */
  95821. maxDistance: number;
  95822. }
  95823. /**
  95824. * Joint data from a spring joint
  95825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95826. */
  95827. export interface SpringJointData extends PhysicsJointData {
  95828. /**
  95829. * Length of the spring
  95830. */
  95831. length: number;
  95832. /**
  95833. * Stiffness of the spring
  95834. */
  95835. stiffness: number;
  95836. /**
  95837. * Damping of the spring
  95838. */
  95839. damping: number;
  95840. /** this callback will be called when applying the force to the impostors. */
  95841. forceApplicationCallback: () => void;
  95842. }
  95843. }
  95844. declare module BABYLON {
  95845. /**
  95846. * Holds the data for the raycast result
  95847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95848. */
  95849. export class PhysicsRaycastResult {
  95850. private _hasHit;
  95851. private _hitDistance;
  95852. private _hitNormalWorld;
  95853. private _hitPointWorld;
  95854. private _rayFromWorld;
  95855. private _rayToWorld;
  95856. /**
  95857. * Gets if there was a hit
  95858. */
  95859. get hasHit(): boolean;
  95860. /**
  95861. * Gets the distance from the hit
  95862. */
  95863. get hitDistance(): number;
  95864. /**
  95865. * Gets the hit normal/direction in the world
  95866. */
  95867. get hitNormalWorld(): Vector3;
  95868. /**
  95869. * Gets the hit point in the world
  95870. */
  95871. get hitPointWorld(): Vector3;
  95872. /**
  95873. * Gets the ray "start point" of the ray in the world
  95874. */
  95875. get rayFromWorld(): Vector3;
  95876. /**
  95877. * Gets the ray "end point" of the ray in the world
  95878. */
  95879. get rayToWorld(): Vector3;
  95880. /**
  95881. * Sets the hit data (normal & point in world space)
  95882. * @param hitNormalWorld defines the normal in world space
  95883. * @param hitPointWorld defines the point in world space
  95884. */
  95885. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  95886. /**
  95887. * Sets the distance from the start point to the hit point
  95888. * @param distance
  95889. */
  95890. setHitDistance(distance: number): void;
  95891. /**
  95892. * Calculates the distance manually
  95893. */
  95894. calculateHitDistance(): void;
  95895. /**
  95896. * Resets all the values to default
  95897. * @param from The from point on world space
  95898. * @param to The to point on world space
  95899. */
  95900. reset(from?: Vector3, to?: Vector3): void;
  95901. }
  95902. /**
  95903. * Interface for the size containing width and height
  95904. */
  95905. interface IXYZ {
  95906. /**
  95907. * X
  95908. */
  95909. x: number;
  95910. /**
  95911. * Y
  95912. */
  95913. y: number;
  95914. /**
  95915. * Z
  95916. */
  95917. z: number;
  95918. }
  95919. }
  95920. declare module BABYLON {
  95921. /**
  95922. * Interface used to describe a physics joint
  95923. */
  95924. export interface PhysicsImpostorJoint {
  95925. /** Defines the main impostor to which the joint is linked */
  95926. mainImpostor: PhysicsImpostor;
  95927. /** Defines the impostor that is connected to the main impostor using this joint */
  95928. connectedImpostor: PhysicsImpostor;
  95929. /** Defines the joint itself */
  95930. joint: PhysicsJoint;
  95931. }
  95932. /** @hidden */
  95933. export interface IPhysicsEnginePlugin {
  95934. world: any;
  95935. name: string;
  95936. setGravity(gravity: Vector3): void;
  95937. setTimeStep(timeStep: number): void;
  95938. getTimeStep(): number;
  95939. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  95940. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95941. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95942. generatePhysicsBody(impostor: PhysicsImpostor): void;
  95943. removePhysicsBody(impostor: PhysicsImpostor): void;
  95944. generateJoint(joint: PhysicsImpostorJoint): void;
  95945. removeJoint(joint: PhysicsImpostorJoint): void;
  95946. isSupported(): boolean;
  95947. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  95948. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  95949. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95950. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95951. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95952. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95953. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  95954. getBodyMass(impostor: PhysicsImpostor): number;
  95955. getBodyFriction(impostor: PhysicsImpostor): number;
  95956. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  95957. getBodyRestitution(impostor: PhysicsImpostor): number;
  95958. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  95959. getBodyPressure?(impostor: PhysicsImpostor): number;
  95960. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  95961. getBodyStiffness?(impostor: PhysicsImpostor): number;
  95962. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  95963. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  95964. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  95965. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  95966. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  95967. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95968. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95969. sleepBody(impostor: PhysicsImpostor): void;
  95970. wakeUpBody(impostor: PhysicsImpostor): void;
  95971. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  95972. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  95973. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  95974. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95975. getRadius(impostor: PhysicsImpostor): number;
  95976. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  95977. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  95978. dispose(): void;
  95979. }
  95980. /**
  95981. * Interface used to define a physics engine
  95982. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  95983. */
  95984. export interface IPhysicsEngine {
  95985. /**
  95986. * Gets the gravity vector used by the simulation
  95987. */
  95988. gravity: Vector3;
  95989. /**
  95990. * Sets the gravity vector used by the simulation
  95991. * @param gravity defines the gravity vector to use
  95992. */
  95993. setGravity(gravity: Vector3): void;
  95994. /**
  95995. * Set the time step of the physics engine.
  95996. * Default is 1/60.
  95997. * To slow it down, enter 1/600 for example.
  95998. * To speed it up, 1/30
  95999. * @param newTimeStep the new timestep to apply to this world.
  96000. */
  96001. setTimeStep(newTimeStep: number): void;
  96002. /**
  96003. * Get the time step of the physics engine.
  96004. * @returns the current time step
  96005. */
  96006. getTimeStep(): number;
  96007. /**
  96008. * Set the sub time step of the physics engine.
  96009. * Default is 0 meaning there is no sub steps
  96010. * To increase physics resolution precision, set a small value (like 1 ms)
  96011. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96012. */
  96013. setSubTimeStep(subTimeStep: number): void;
  96014. /**
  96015. * Get the sub time step of the physics engine.
  96016. * @returns the current sub time step
  96017. */
  96018. getSubTimeStep(): number;
  96019. /**
  96020. * Release all resources
  96021. */
  96022. dispose(): void;
  96023. /**
  96024. * Gets the name of the current physics plugin
  96025. * @returns the name of the plugin
  96026. */
  96027. getPhysicsPluginName(): string;
  96028. /**
  96029. * Adding a new impostor for the impostor tracking.
  96030. * This will be done by the impostor itself.
  96031. * @param impostor the impostor to add
  96032. */
  96033. addImpostor(impostor: PhysicsImpostor): void;
  96034. /**
  96035. * Remove an impostor from the engine.
  96036. * This impostor and its mesh will not longer be updated by the physics engine.
  96037. * @param impostor the impostor to remove
  96038. */
  96039. removeImpostor(impostor: PhysicsImpostor): void;
  96040. /**
  96041. * Add a joint to the physics engine
  96042. * @param mainImpostor defines the main impostor to which the joint is added.
  96043. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96044. * @param joint defines the joint that will connect both impostors.
  96045. */
  96046. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96047. /**
  96048. * Removes a joint from the simulation
  96049. * @param mainImpostor defines the impostor used with the joint
  96050. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96051. * @param joint defines the joint to remove
  96052. */
  96053. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96054. /**
  96055. * Gets the current plugin used to run the simulation
  96056. * @returns current plugin
  96057. */
  96058. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96059. /**
  96060. * Gets the list of physic impostors
  96061. * @returns an array of PhysicsImpostor
  96062. */
  96063. getImpostors(): Array<PhysicsImpostor>;
  96064. /**
  96065. * Gets the impostor for a physics enabled object
  96066. * @param object defines the object impersonated by the impostor
  96067. * @returns the PhysicsImpostor or null if not found
  96068. */
  96069. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96070. /**
  96071. * Gets the impostor for a physics body object
  96072. * @param body defines physics body used by the impostor
  96073. * @returns the PhysicsImpostor or null if not found
  96074. */
  96075. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96076. /**
  96077. * Does a raycast in the physics world
  96078. * @param from when should the ray start?
  96079. * @param to when should the ray end?
  96080. * @returns PhysicsRaycastResult
  96081. */
  96082. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96083. /**
  96084. * Called by the scene. No need to call it.
  96085. * @param delta defines the timespam between frames
  96086. */
  96087. _step(delta: number): void;
  96088. }
  96089. }
  96090. declare module BABYLON {
  96091. /**
  96092. * The interface for the physics imposter parameters
  96093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96094. */
  96095. export interface PhysicsImpostorParameters {
  96096. /**
  96097. * The mass of the physics imposter
  96098. */
  96099. mass: number;
  96100. /**
  96101. * The friction of the physics imposter
  96102. */
  96103. friction?: number;
  96104. /**
  96105. * The coefficient of restitution of the physics imposter
  96106. */
  96107. restitution?: number;
  96108. /**
  96109. * The native options of the physics imposter
  96110. */
  96111. nativeOptions?: any;
  96112. /**
  96113. * Specifies if the parent should be ignored
  96114. */
  96115. ignoreParent?: boolean;
  96116. /**
  96117. * Specifies if bi-directional transformations should be disabled
  96118. */
  96119. disableBidirectionalTransformation?: boolean;
  96120. /**
  96121. * The pressure inside the physics imposter, soft object only
  96122. */
  96123. pressure?: number;
  96124. /**
  96125. * The stiffness the physics imposter, soft object only
  96126. */
  96127. stiffness?: number;
  96128. /**
  96129. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96130. */
  96131. velocityIterations?: number;
  96132. /**
  96133. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96134. */
  96135. positionIterations?: number;
  96136. /**
  96137. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96138. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96139. * Add to fix multiple points
  96140. */
  96141. fixedPoints?: number;
  96142. /**
  96143. * The collision margin around a soft object
  96144. */
  96145. margin?: number;
  96146. /**
  96147. * The collision margin around a soft object
  96148. */
  96149. damping?: number;
  96150. /**
  96151. * The path for a rope based on an extrusion
  96152. */
  96153. path?: any;
  96154. /**
  96155. * The shape of an extrusion used for a rope based on an extrusion
  96156. */
  96157. shape?: any;
  96158. }
  96159. /**
  96160. * Interface for a physics-enabled object
  96161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96162. */
  96163. export interface IPhysicsEnabledObject {
  96164. /**
  96165. * The position of the physics-enabled object
  96166. */
  96167. position: Vector3;
  96168. /**
  96169. * The rotation of the physics-enabled object
  96170. */
  96171. rotationQuaternion: Nullable<Quaternion>;
  96172. /**
  96173. * The scale of the physics-enabled object
  96174. */
  96175. scaling: Vector3;
  96176. /**
  96177. * The rotation of the physics-enabled object
  96178. */
  96179. rotation?: Vector3;
  96180. /**
  96181. * The parent of the physics-enabled object
  96182. */
  96183. parent?: any;
  96184. /**
  96185. * The bounding info of the physics-enabled object
  96186. * @returns The bounding info of the physics-enabled object
  96187. */
  96188. getBoundingInfo(): BoundingInfo;
  96189. /**
  96190. * Computes the world matrix
  96191. * @param force Specifies if the world matrix should be computed by force
  96192. * @returns A world matrix
  96193. */
  96194. computeWorldMatrix(force: boolean): Matrix;
  96195. /**
  96196. * Gets the world matrix
  96197. * @returns A world matrix
  96198. */
  96199. getWorldMatrix?(): Matrix;
  96200. /**
  96201. * Gets the child meshes
  96202. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96203. * @returns An array of abstract meshes
  96204. */
  96205. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96206. /**
  96207. * Gets the vertex data
  96208. * @param kind The type of vertex data
  96209. * @returns A nullable array of numbers, or a float32 array
  96210. */
  96211. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96212. /**
  96213. * Gets the indices from the mesh
  96214. * @returns A nullable array of index arrays
  96215. */
  96216. getIndices?(): Nullable<IndicesArray>;
  96217. /**
  96218. * Gets the scene from the mesh
  96219. * @returns the indices array or null
  96220. */
  96221. getScene?(): Scene;
  96222. /**
  96223. * Gets the absolute position from the mesh
  96224. * @returns the absolute position
  96225. */
  96226. getAbsolutePosition(): Vector3;
  96227. /**
  96228. * Gets the absolute pivot point from the mesh
  96229. * @returns the absolute pivot point
  96230. */
  96231. getAbsolutePivotPoint(): Vector3;
  96232. /**
  96233. * Rotates the mesh
  96234. * @param axis The axis of rotation
  96235. * @param amount The amount of rotation
  96236. * @param space The space of the rotation
  96237. * @returns The rotation transform node
  96238. */
  96239. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96240. /**
  96241. * Translates the mesh
  96242. * @param axis The axis of translation
  96243. * @param distance The distance of translation
  96244. * @param space The space of the translation
  96245. * @returns The transform node
  96246. */
  96247. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96248. /**
  96249. * Sets the absolute position of the mesh
  96250. * @param absolutePosition The absolute position of the mesh
  96251. * @returns The transform node
  96252. */
  96253. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96254. /**
  96255. * Gets the class name of the mesh
  96256. * @returns The class name
  96257. */
  96258. getClassName(): string;
  96259. }
  96260. /**
  96261. * Represents a physics imposter
  96262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96263. */
  96264. export class PhysicsImpostor {
  96265. /**
  96266. * The physics-enabled object used as the physics imposter
  96267. */
  96268. object: IPhysicsEnabledObject;
  96269. /**
  96270. * The type of the physics imposter
  96271. */
  96272. type: number;
  96273. private _options;
  96274. private _scene?;
  96275. /**
  96276. * The default object size of the imposter
  96277. */
  96278. static DEFAULT_OBJECT_SIZE: Vector3;
  96279. /**
  96280. * The identity quaternion of the imposter
  96281. */
  96282. static IDENTITY_QUATERNION: Quaternion;
  96283. /** @hidden */
  96284. _pluginData: any;
  96285. private _physicsEngine;
  96286. private _physicsBody;
  96287. private _bodyUpdateRequired;
  96288. private _onBeforePhysicsStepCallbacks;
  96289. private _onAfterPhysicsStepCallbacks;
  96290. /** @hidden */
  96291. _onPhysicsCollideCallbacks: Array<{
  96292. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96293. otherImpostors: Array<PhysicsImpostor>;
  96294. }>;
  96295. private _deltaPosition;
  96296. private _deltaRotation;
  96297. private _deltaRotationConjugated;
  96298. /** @hidden */
  96299. _isFromLine: boolean;
  96300. private _parent;
  96301. private _isDisposed;
  96302. private static _tmpVecs;
  96303. private static _tmpQuat;
  96304. /**
  96305. * Specifies if the physics imposter is disposed
  96306. */
  96307. get isDisposed(): boolean;
  96308. /**
  96309. * Gets the mass of the physics imposter
  96310. */
  96311. get mass(): number;
  96312. set mass(value: number);
  96313. /**
  96314. * Gets the coefficient of friction
  96315. */
  96316. get friction(): number;
  96317. /**
  96318. * Sets the coefficient of friction
  96319. */
  96320. set friction(value: number);
  96321. /**
  96322. * Gets the coefficient of restitution
  96323. */
  96324. get restitution(): number;
  96325. /**
  96326. * Sets the coefficient of restitution
  96327. */
  96328. set restitution(value: number);
  96329. /**
  96330. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96331. */
  96332. get pressure(): number;
  96333. /**
  96334. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96335. */
  96336. set pressure(value: number);
  96337. /**
  96338. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96339. */
  96340. get stiffness(): number;
  96341. /**
  96342. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96343. */
  96344. set stiffness(value: number);
  96345. /**
  96346. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96347. */
  96348. get velocityIterations(): number;
  96349. /**
  96350. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96351. */
  96352. set velocityIterations(value: number);
  96353. /**
  96354. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96355. */
  96356. get positionIterations(): number;
  96357. /**
  96358. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96359. */
  96360. set positionIterations(value: number);
  96361. /**
  96362. * The unique id of the physics imposter
  96363. * set by the physics engine when adding this impostor to the array
  96364. */
  96365. uniqueId: number;
  96366. /**
  96367. * @hidden
  96368. */
  96369. soft: boolean;
  96370. /**
  96371. * @hidden
  96372. */
  96373. segments: number;
  96374. private _joints;
  96375. /**
  96376. * Initializes the physics imposter
  96377. * @param object The physics-enabled object used as the physics imposter
  96378. * @param type The type of the physics imposter
  96379. * @param _options The options for the physics imposter
  96380. * @param _scene The Babylon scene
  96381. */
  96382. constructor(
  96383. /**
  96384. * The physics-enabled object used as the physics imposter
  96385. */
  96386. object: IPhysicsEnabledObject,
  96387. /**
  96388. * The type of the physics imposter
  96389. */
  96390. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  96391. /**
  96392. * This function will completly initialize this impostor.
  96393. * It will create a new body - but only if this mesh has no parent.
  96394. * If it has, this impostor will not be used other than to define the impostor
  96395. * of the child mesh.
  96396. * @hidden
  96397. */
  96398. _init(): void;
  96399. private _getPhysicsParent;
  96400. /**
  96401. * Should a new body be generated.
  96402. * @returns boolean specifying if body initialization is required
  96403. */
  96404. isBodyInitRequired(): boolean;
  96405. /**
  96406. * Sets the updated scaling
  96407. * @param updated Specifies if the scaling is updated
  96408. */
  96409. setScalingUpdated(): void;
  96410. /**
  96411. * Force a regeneration of this or the parent's impostor's body.
  96412. * Use under cautious - This will remove all joints already implemented.
  96413. */
  96414. forceUpdate(): void;
  96415. /**
  96416. * Gets the body that holds this impostor. Either its own, or its parent.
  96417. */
  96418. get physicsBody(): any;
  96419. /**
  96420. * Get the parent of the physics imposter
  96421. * @returns Physics imposter or null
  96422. */
  96423. get parent(): Nullable<PhysicsImpostor>;
  96424. /**
  96425. * Sets the parent of the physics imposter
  96426. */
  96427. set parent(value: Nullable<PhysicsImpostor>);
  96428. /**
  96429. * Set the physics body. Used mainly by the physics engine/plugin
  96430. */
  96431. set physicsBody(physicsBody: any);
  96432. /**
  96433. * Resets the update flags
  96434. */
  96435. resetUpdateFlags(): void;
  96436. /**
  96437. * Gets the object extend size
  96438. * @returns the object extend size
  96439. */
  96440. getObjectExtendSize(): Vector3;
  96441. /**
  96442. * Gets the object center
  96443. * @returns The object center
  96444. */
  96445. getObjectCenter(): Vector3;
  96446. /**
  96447. * Get a specific parameter from the options parameters
  96448. * @param paramName The object parameter name
  96449. * @returns The object parameter
  96450. */
  96451. getParam(paramName: string): any;
  96452. /**
  96453. * Sets a specific parameter in the options given to the physics plugin
  96454. * @param paramName The parameter name
  96455. * @param value The value of the parameter
  96456. */
  96457. setParam(paramName: string, value: number): void;
  96458. /**
  96459. * Specifically change the body's mass option. Won't recreate the physics body object
  96460. * @param mass The mass of the physics imposter
  96461. */
  96462. setMass(mass: number): void;
  96463. /**
  96464. * Gets the linear velocity
  96465. * @returns linear velocity or null
  96466. */
  96467. getLinearVelocity(): Nullable<Vector3>;
  96468. /**
  96469. * Sets the linear velocity
  96470. * @param velocity linear velocity or null
  96471. */
  96472. setLinearVelocity(velocity: Nullable<Vector3>): void;
  96473. /**
  96474. * Gets the angular velocity
  96475. * @returns angular velocity or null
  96476. */
  96477. getAngularVelocity(): Nullable<Vector3>;
  96478. /**
  96479. * Sets the angular velocity
  96480. * @param velocity The velocity or null
  96481. */
  96482. setAngularVelocity(velocity: Nullable<Vector3>): void;
  96483. /**
  96484. * Execute a function with the physics plugin native code
  96485. * Provide a function the will have two variables - the world object and the physics body object
  96486. * @param func The function to execute with the physics plugin native code
  96487. */
  96488. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  96489. /**
  96490. * Register a function that will be executed before the physics world is stepping forward
  96491. * @param func The function to execute before the physics world is stepped forward
  96492. */
  96493. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96494. /**
  96495. * Unregister a function that will be executed before the physics world is stepping forward
  96496. * @param func The function to execute before the physics world is stepped forward
  96497. */
  96498. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96499. /**
  96500. * Register a function that will be executed after the physics step
  96501. * @param func The function to execute after physics step
  96502. */
  96503. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96504. /**
  96505. * Unregisters a function that will be executed after the physics step
  96506. * @param func The function to execute after physics step
  96507. */
  96508. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96509. /**
  96510. * register a function that will be executed when this impostor collides against a different body
  96511. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  96512. * @param func Callback that is executed on collision
  96513. */
  96514. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  96515. /**
  96516. * Unregisters the physics imposter on contact
  96517. * @param collideAgainst The physics object to collide against
  96518. * @param func Callback to execute on collision
  96519. */
  96520. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  96521. private _tmpQuat;
  96522. private _tmpQuat2;
  96523. /**
  96524. * Get the parent rotation
  96525. * @returns The parent rotation
  96526. */
  96527. getParentsRotation(): Quaternion;
  96528. /**
  96529. * this function is executed by the physics engine.
  96530. */
  96531. beforeStep: () => void;
  96532. /**
  96533. * this function is executed by the physics engine
  96534. */
  96535. afterStep: () => void;
  96536. /**
  96537. * Legacy collision detection event support
  96538. */
  96539. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  96540. /**
  96541. * event and body object due to cannon's event-based architecture.
  96542. */
  96543. onCollide: (e: {
  96544. body: any;
  96545. }) => void;
  96546. /**
  96547. * Apply a force
  96548. * @param force The force to apply
  96549. * @param contactPoint The contact point for the force
  96550. * @returns The physics imposter
  96551. */
  96552. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96553. /**
  96554. * Apply an impulse
  96555. * @param force The impulse force
  96556. * @param contactPoint The contact point for the impulse force
  96557. * @returns The physics imposter
  96558. */
  96559. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96560. /**
  96561. * A help function to create a joint
  96562. * @param otherImpostor A physics imposter used to create a joint
  96563. * @param jointType The type of joint
  96564. * @param jointData The data for the joint
  96565. * @returns The physics imposter
  96566. */
  96567. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  96568. /**
  96569. * Add a joint to this impostor with a different impostor
  96570. * @param otherImpostor A physics imposter used to add a joint
  96571. * @param joint The joint to add
  96572. * @returns The physics imposter
  96573. */
  96574. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  96575. /**
  96576. * Add an anchor to a cloth impostor
  96577. * @param otherImpostor rigid impostor to anchor to
  96578. * @param width ratio across width from 0 to 1
  96579. * @param height ratio up height from 0 to 1
  96580. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  96581. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  96582. * @returns impostor the soft imposter
  96583. */
  96584. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96585. /**
  96586. * Add a hook to a rope impostor
  96587. * @param otherImpostor rigid impostor to anchor to
  96588. * @param length ratio across rope from 0 to 1
  96589. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  96590. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  96591. * @returns impostor the rope imposter
  96592. */
  96593. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96594. /**
  96595. * Will keep this body still, in a sleep mode.
  96596. * @returns the physics imposter
  96597. */
  96598. sleep(): PhysicsImpostor;
  96599. /**
  96600. * Wake the body up.
  96601. * @returns The physics imposter
  96602. */
  96603. wakeUp(): PhysicsImpostor;
  96604. /**
  96605. * Clones the physics imposter
  96606. * @param newObject The physics imposter clones to this physics-enabled object
  96607. * @returns A nullable physics imposter
  96608. */
  96609. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96610. /**
  96611. * Disposes the physics imposter
  96612. */
  96613. dispose(): void;
  96614. /**
  96615. * Sets the delta position
  96616. * @param position The delta position amount
  96617. */
  96618. setDeltaPosition(position: Vector3): void;
  96619. /**
  96620. * Sets the delta rotation
  96621. * @param rotation The delta rotation amount
  96622. */
  96623. setDeltaRotation(rotation: Quaternion): void;
  96624. /**
  96625. * Gets the box size of the physics imposter and stores the result in the input parameter
  96626. * @param result Stores the box size
  96627. * @returns The physics imposter
  96628. */
  96629. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  96630. /**
  96631. * Gets the radius of the physics imposter
  96632. * @returns Radius of the physics imposter
  96633. */
  96634. getRadius(): number;
  96635. /**
  96636. * Sync a bone with this impostor
  96637. * @param bone The bone to sync to the impostor.
  96638. * @param boneMesh The mesh that the bone is influencing.
  96639. * @param jointPivot The pivot of the joint / bone in local space.
  96640. * @param distToJoint Optional distance from the impostor to the joint.
  96641. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96642. */
  96643. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  96644. /**
  96645. * Sync impostor to a bone
  96646. * @param bone The bone that the impostor will be synced to.
  96647. * @param boneMesh The mesh that the bone is influencing.
  96648. * @param jointPivot The pivot of the joint / bone in local space.
  96649. * @param distToJoint Optional distance from the impostor to the joint.
  96650. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96651. * @param boneAxis Optional vector3 axis the bone is aligned with
  96652. */
  96653. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  96654. /**
  96655. * No-Imposter type
  96656. */
  96657. static NoImpostor: number;
  96658. /**
  96659. * Sphere-Imposter type
  96660. */
  96661. static SphereImpostor: number;
  96662. /**
  96663. * Box-Imposter type
  96664. */
  96665. static BoxImpostor: number;
  96666. /**
  96667. * Plane-Imposter type
  96668. */
  96669. static PlaneImpostor: number;
  96670. /**
  96671. * Mesh-imposter type
  96672. */
  96673. static MeshImpostor: number;
  96674. /**
  96675. * Capsule-Impostor type (Ammo.js plugin only)
  96676. */
  96677. static CapsuleImpostor: number;
  96678. /**
  96679. * Cylinder-Imposter type
  96680. */
  96681. static CylinderImpostor: number;
  96682. /**
  96683. * Particle-Imposter type
  96684. */
  96685. static ParticleImpostor: number;
  96686. /**
  96687. * Heightmap-Imposter type
  96688. */
  96689. static HeightmapImpostor: number;
  96690. /**
  96691. * ConvexHull-Impostor type (Ammo.js plugin only)
  96692. */
  96693. static ConvexHullImpostor: number;
  96694. /**
  96695. * Custom-Imposter type (Ammo.js plugin only)
  96696. */
  96697. static CustomImpostor: number;
  96698. /**
  96699. * Rope-Imposter type
  96700. */
  96701. static RopeImpostor: number;
  96702. /**
  96703. * Cloth-Imposter type
  96704. */
  96705. static ClothImpostor: number;
  96706. /**
  96707. * Softbody-Imposter type
  96708. */
  96709. static SoftbodyImpostor: number;
  96710. }
  96711. }
  96712. declare module BABYLON {
  96713. /**
  96714. * @hidden
  96715. **/
  96716. export class _CreationDataStorage {
  96717. closePath?: boolean;
  96718. closeArray?: boolean;
  96719. idx: number[];
  96720. dashSize: number;
  96721. gapSize: number;
  96722. path3D: Path3D;
  96723. pathArray: Vector3[][];
  96724. arc: number;
  96725. radius: number;
  96726. cap: number;
  96727. tessellation: number;
  96728. }
  96729. /**
  96730. * @hidden
  96731. **/
  96732. class _InstanceDataStorage {
  96733. visibleInstances: any;
  96734. batchCache: _InstancesBatch;
  96735. instancesBufferSize: number;
  96736. instancesBuffer: Nullable<Buffer>;
  96737. instancesData: Float32Array;
  96738. overridenInstanceCount: number;
  96739. isFrozen: boolean;
  96740. previousBatch: Nullable<_InstancesBatch>;
  96741. hardwareInstancedRendering: boolean;
  96742. sideOrientation: number;
  96743. manualUpdate: boolean;
  96744. }
  96745. /**
  96746. * @hidden
  96747. **/
  96748. export class _InstancesBatch {
  96749. mustReturn: boolean;
  96750. visibleInstances: Nullable<InstancedMesh[]>[];
  96751. renderSelf: boolean[];
  96752. hardwareInstancedRendering: boolean[];
  96753. }
  96754. /**
  96755. * Class used to represent renderable models
  96756. */
  96757. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  96758. /**
  96759. * Mesh side orientation : usually the external or front surface
  96760. */
  96761. static readonly FRONTSIDE: number;
  96762. /**
  96763. * Mesh side orientation : usually the internal or back surface
  96764. */
  96765. static readonly BACKSIDE: number;
  96766. /**
  96767. * Mesh side orientation : both internal and external or front and back surfaces
  96768. */
  96769. static readonly DOUBLESIDE: number;
  96770. /**
  96771. * Mesh side orientation : by default, `FRONTSIDE`
  96772. */
  96773. static readonly DEFAULTSIDE: number;
  96774. /**
  96775. * Mesh cap setting : no cap
  96776. */
  96777. static readonly NO_CAP: number;
  96778. /**
  96779. * Mesh cap setting : one cap at the beginning of the mesh
  96780. */
  96781. static readonly CAP_START: number;
  96782. /**
  96783. * Mesh cap setting : one cap at the end of the mesh
  96784. */
  96785. static readonly CAP_END: number;
  96786. /**
  96787. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  96788. */
  96789. static readonly CAP_ALL: number;
  96790. /**
  96791. * Mesh pattern setting : no flip or rotate
  96792. */
  96793. static readonly NO_FLIP: number;
  96794. /**
  96795. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  96796. */
  96797. static readonly FLIP_TILE: number;
  96798. /**
  96799. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  96800. */
  96801. static readonly ROTATE_TILE: number;
  96802. /**
  96803. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  96804. */
  96805. static readonly FLIP_ROW: number;
  96806. /**
  96807. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  96808. */
  96809. static readonly ROTATE_ROW: number;
  96810. /**
  96811. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  96812. */
  96813. static readonly FLIP_N_ROTATE_TILE: number;
  96814. /**
  96815. * Mesh pattern setting : rotate pattern and rotate
  96816. */
  96817. static readonly FLIP_N_ROTATE_ROW: number;
  96818. /**
  96819. * Mesh tile positioning : part tiles same on left/right or top/bottom
  96820. */
  96821. static readonly CENTER: number;
  96822. /**
  96823. * Mesh tile positioning : part tiles on left
  96824. */
  96825. static readonly LEFT: number;
  96826. /**
  96827. * Mesh tile positioning : part tiles on right
  96828. */
  96829. static readonly RIGHT: number;
  96830. /**
  96831. * Mesh tile positioning : part tiles on top
  96832. */
  96833. static readonly TOP: number;
  96834. /**
  96835. * Mesh tile positioning : part tiles on bottom
  96836. */
  96837. static readonly BOTTOM: number;
  96838. /**
  96839. * Gets the default side orientation.
  96840. * @param orientation the orientation to value to attempt to get
  96841. * @returns the default orientation
  96842. * @hidden
  96843. */
  96844. static _GetDefaultSideOrientation(orientation?: number): number;
  96845. private _internalMeshDataInfo;
  96846. /**
  96847. * An event triggered before rendering the mesh
  96848. */
  96849. get onBeforeRenderObservable(): Observable<Mesh>;
  96850. /**
  96851. * An event triggered before binding the mesh
  96852. */
  96853. get onBeforeBindObservable(): Observable<Mesh>;
  96854. /**
  96855. * An event triggered after rendering the mesh
  96856. */
  96857. get onAfterRenderObservable(): Observable<Mesh>;
  96858. /**
  96859. * An event triggered before drawing the mesh
  96860. */
  96861. get onBeforeDrawObservable(): Observable<Mesh>;
  96862. private _onBeforeDrawObserver;
  96863. /**
  96864. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  96865. */
  96866. set onBeforeDraw(callback: () => void);
  96867. get hasInstances(): boolean;
  96868. /**
  96869. * Gets the delay loading state of the mesh (when delay loading is turned on)
  96870. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  96871. */
  96872. delayLoadState: number;
  96873. /**
  96874. * Gets the list of instances created from this mesh
  96875. * it is not supposed to be modified manually.
  96876. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  96877. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  96878. */
  96879. instances: InstancedMesh[];
  96880. /**
  96881. * Gets the file containing delay loading data for this mesh
  96882. */
  96883. delayLoadingFile: string;
  96884. /** @hidden */
  96885. _binaryInfo: any;
  96886. /**
  96887. * User defined function used to change how LOD level selection is done
  96888. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96889. */
  96890. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  96891. /**
  96892. * Gets or sets the morph target manager
  96893. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96894. */
  96895. get morphTargetManager(): Nullable<MorphTargetManager>;
  96896. set morphTargetManager(value: Nullable<MorphTargetManager>);
  96897. /** @hidden */
  96898. _creationDataStorage: Nullable<_CreationDataStorage>;
  96899. /** @hidden */
  96900. _geometry: Nullable<Geometry>;
  96901. /** @hidden */
  96902. _delayInfo: Array<string>;
  96903. /** @hidden */
  96904. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  96905. /** @hidden */
  96906. _instanceDataStorage: _InstanceDataStorage;
  96907. private _effectiveMaterial;
  96908. /** @hidden */
  96909. _shouldGenerateFlatShading: boolean;
  96910. /** @hidden */
  96911. _originalBuilderSideOrientation: number;
  96912. /**
  96913. * Use this property to change the original side orientation defined at construction time
  96914. */
  96915. overrideMaterialSideOrientation: Nullable<number>;
  96916. /**
  96917. * Gets the source mesh (the one used to clone this one from)
  96918. */
  96919. get source(): Nullable<Mesh>;
  96920. /**
  96921. * Gets or sets a boolean indicating that this mesh does not use index buffer
  96922. */
  96923. get isUnIndexed(): boolean;
  96924. set isUnIndexed(value: boolean);
  96925. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  96926. get worldMatrixInstancedBuffer(): Float32Array;
  96927. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  96928. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  96929. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  96930. /**
  96931. * @constructor
  96932. * @param name The value used by scene.getMeshByName() to do a lookup.
  96933. * @param scene The scene to add this mesh to.
  96934. * @param parent The parent of this mesh, if it has one
  96935. * @param source An optional Mesh from which geometry is shared, cloned.
  96936. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96937. * When false, achieved by calling a clone(), also passing False.
  96938. * This will make creation of children, recursive.
  96939. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  96940. */
  96941. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  96942. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96943. doNotInstantiate: boolean;
  96944. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96945. /**
  96946. * Gets the class name
  96947. * @returns the string "Mesh".
  96948. */
  96949. getClassName(): string;
  96950. /** @hidden */
  96951. get _isMesh(): boolean;
  96952. /**
  96953. * Returns a description of this mesh
  96954. * @param fullDetails define if full details about this mesh must be used
  96955. * @returns a descriptive string representing this mesh
  96956. */
  96957. toString(fullDetails?: boolean): string;
  96958. /** @hidden */
  96959. _unBindEffect(): void;
  96960. /**
  96961. * Gets a boolean indicating if this mesh has LOD
  96962. */
  96963. get hasLODLevels(): boolean;
  96964. /**
  96965. * Gets the list of MeshLODLevel associated with the current mesh
  96966. * @returns an array of MeshLODLevel
  96967. */
  96968. getLODLevels(): MeshLODLevel[];
  96969. private _sortLODLevels;
  96970. /**
  96971. * Add a mesh as LOD level triggered at the given distance.
  96972. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96973. * @param distance The distance from the center of the object to show this level
  96974. * @param mesh The mesh to be added as LOD level (can be null)
  96975. * @return This mesh (for chaining)
  96976. */
  96977. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  96978. /**
  96979. * Returns the LOD level mesh at the passed distance or null if not found.
  96980. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96981. * @param distance The distance from the center of the object to show this level
  96982. * @returns a Mesh or `null`
  96983. */
  96984. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  96985. /**
  96986. * Remove a mesh from the LOD array
  96987. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96988. * @param mesh defines the mesh to be removed
  96989. * @return This mesh (for chaining)
  96990. */
  96991. removeLODLevel(mesh: Mesh): Mesh;
  96992. /**
  96993. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  96994. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96995. * @param camera defines the camera to use to compute distance
  96996. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  96997. * @return This mesh (for chaining)
  96998. */
  96999. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97000. /**
  97001. * Gets the mesh internal Geometry object
  97002. */
  97003. get geometry(): Nullable<Geometry>;
  97004. /**
  97005. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97006. * @returns the total number of vertices
  97007. */
  97008. getTotalVertices(): number;
  97009. /**
  97010. * Returns the content of an associated vertex buffer
  97011. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97012. * - VertexBuffer.PositionKind
  97013. * - VertexBuffer.UVKind
  97014. * - VertexBuffer.UV2Kind
  97015. * - VertexBuffer.UV3Kind
  97016. * - VertexBuffer.UV4Kind
  97017. * - VertexBuffer.UV5Kind
  97018. * - VertexBuffer.UV6Kind
  97019. * - VertexBuffer.ColorKind
  97020. * - VertexBuffer.MatricesIndicesKind
  97021. * - VertexBuffer.MatricesIndicesExtraKind
  97022. * - VertexBuffer.MatricesWeightsKind
  97023. * - VertexBuffer.MatricesWeightsExtraKind
  97024. * @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
  97025. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97026. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97027. */
  97028. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97029. /**
  97030. * Returns the mesh VertexBuffer object from the requested `kind`
  97031. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97032. * - VertexBuffer.PositionKind
  97033. * - VertexBuffer.NormalKind
  97034. * - VertexBuffer.UVKind
  97035. * - VertexBuffer.UV2Kind
  97036. * - VertexBuffer.UV3Kind
  97037. * - VertexBuffer.UV4Kind
  97038. * - VertexBuffer.UV5Kind
  97039. * - VertexBuffer.UV6Kind
  97040. * - VertexBuffer.ColorKind
  97041. * - VertexBuffer.MatricesIndicesKind
  97042. * - VertexBuffer.MatricesIndicesExtraKind
  97043. * - VertexBuffer.MatricesWeightsKind
  97044. * - VertexBuffer.MatricesWeightsExtraKind
  97045. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97046. */
  97047. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97048. /**
  97049. * Tests if a specific vertex buffer is associated with this mesh
  97050. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97051. * - VertexBuffer.PositionKind
  97052. * - VertexBuffer.NormalKind
  97053. * - VertexBuffer.UVKind
  97054. * - VertexBuffer.UV2Kind
  97055. * - VertexBuffer.UV3Kind
  97056. * - VertexBuffer.UV4Kind
  97057. * - VertexBuffer.UV5Kind
  97058. * - VertexBuffer.UV6Kind
  97059. * - VertexBuffer.ColorKind
  97060. * - VertexBuffer.MatricesIndicesKind
  97061. * - VertexBuffer.MatricesIndicesExtraKind
  97062. * - VertexBuffer.MatricesWeightsKind
  97063. * - VertexBuffer.MatricesWeightsExtraKind
  97064. * @returns a boolean
  97065. */
  97066. isVerticesDataPresent(kind: string): boolean;
  97067. /**
  97068. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97069. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97070. * - VertexBuffer.PositionKind
  97071. * - VertexBuffer.UVKind
  97072. * - VertexBuffer.UV2Kind
  97073. * - VertexBuffer.UV3Kind
  97074. * - VertexBuffer.UV4Kind
  97075. * - VertexBuffer.UV5Kind
  97076. * - VertexBuffer.UV6Kind
  97077. * - VertexBuffer.ColorKind
  97078. * - VertexBuffer.MatricesIndicesKind
  97079. * - VertexBuffer.MatricesIndicesExtraKind
  97080. * - VertexBuffer.MatricesWeightsKind
  97081. * - VertexBuffer.MatricesWeightsExtraKind
  97082. * @returns a boolean
  97083. */
  97084. isVertexBufferUpdatable(kind: string): boolean;
  97085. /**
  97086. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97087. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97088. * - VertexBuffer.PositionKind
  97089. * - VertexBuffer.NormalKind
  97090. * - VertexBuffer.UVKind
  97091. * - VertexBuffer.UV2Kind
  97092. * - VertexBuffer.UV3Kind
  97093. * - VertexBuffer.UV4Kind
  97094. * - VertexBuffer.UV5Kind
  97095. * - VertexBuffer.UV6Kind
  97096. * - VertexBuffer.ColorKind
  97097. * - VertexBuffer.MatricesIndicesKind
  97098. * - VertexBuffer.MatricesIndicesExtraKind
  97099. * - VertexBuffer.MatricesWeightsKind
  97100. * - VertexBuffer.MatricesWeightsExtraKind
  97101. * @returns an array of strings
  97102. */
  97103. getVerticesDataKinds(): string[];
  97104. /**
  97105. * Returns a positive integer : the total number of indices in this mesh geometry.
  97106. * @returns the numner of indices or zero if the mesh has no geometry.
  97107. */
  97108. getTotalIndices(): number;
  97109. /**
  97110. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97111. * @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.
  97112. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97113. * @returns the indices array or an empty array if the mesh has no geometry
  97114. */
  97115. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97116. get isBlocked(): boolean;
  97117. /**
  97118. * Determine if the current mesh is ready to be rendered
  97119. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97120. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97121. * @returns true if all associated assets are ready (material, textures, shaders)
  97122. */
  97123. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97124. /**
  97125. * 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.
  97126. */
  97127. get areNormalsFrozen(): boolean;
  97128. /**
  97129. * 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.
  97130. * @returns the current mesh
  97131. */
  97132. freezeNormals(): Mesh;
  97133. /**
  97134. * 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
  97135. * @returns the current mesh
  97136. */
  97137. unfreezeNormals(): Mesh;
  97138. /**
  97139. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97140. */
  97141. set overridenInstanceCount(count: number);
  97142. /** @hidden */
  97143. _preActivate(): Mesh;
  97144. /** @hidden */
  97145. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97146. /** @hidden */
  97147. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97148. /**
  97149. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97150. * This means the mesh underlying bounding box and sphere are recomputed.
  97151. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97152. * @returns the current mesh
  97153. */
  97154. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97155. /** @hidden */
  97156. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97157. /**
  97158. * This function will subdivide the mesh into multiple submeshes
  97159. * @param count defines the expected number of submeshes
  97160. */
  97161. subdivide(count: number): void;
  97162. /**
  97163. * Copy a FloatArray into a specific associated vertex buffer
  97164. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97165. * - VertexBuffer.PositionKind
  97166. * - VertexBuffer.UVKind
  97167. * - VertexBuffer.UV2Kind
  97168. * - VertexBuffer.UV3Kind
  97169. * - VertexBuffer.UV4Kind
  97170. * - VertexBuffer.UV5Kind
  97171. * - VertexBuffer.UV6Kind
  97172. * - VertexBuffer.ColorKind
  97173. * - VertexBuffer.MatricesIndicesKind
  97174. * - VertexBuffer.MatricesIndicesExtraKind
  97175. * - VertexBuffer.MatricesWeightsKind
  97176. * - VertexBuffer.MatricesWeightsExtraKind
  97177. * @param data defines the data source
  97178. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97179. * @param stride defines the data stride size (can be null)
  97180. * @returns the current mesh
  97181. */
  97182. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97183. /**
  97184. * Delete a vertex buffer associated with this mesh
  97185. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97186. * - VertexBuffer.PositionKind
  97187. * - VertexBuffer.UVKind
  97188. * - VertexBuffer.UV2Kind
  97189. * - VertexBuffer.UV3Kind
  97190. * - VertexBuffer.UV4Kind
  97191. * - VertexBuffer.UV5Kind
  97192. * - VertexBuffer.UV6Kind
  97193. * - VertexBuffer.ColorKind
  97194. * - VertexBuffer.MatricesIndicesKind
  97195. * - VertexBuffer.MatricesIndicesExtraKind
  97196. * - VertexBuffer.MatricesWeightsKind
  97197. * - VertexBuffer.MatricesWeightsExtraKind
  97198. */
  97199. removeVerticesData(kind: string): void;
  97200. /**
  97201. * Flags an associated vertex buffer as updatable
  97202. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97203. * - VertexBuffer.PositionKind
  97204. * - VertexBuffer.UVKind
  97205. * - VertexBuffer.UV2Kind
  97206. * - VertexBuffer.UV3Kind
  97207. * - VertexBuffer.UV4Kind
  97208. * - VertexBuffer.UV5Kind
  97209. * - VertexBuffer.UV6Kind
  97210. * - VertexBuffer.ColorKind
  97211. * - VertexBuffer.MatricesIndicesKind
  97212. * - VertexBuffer.MatricesIndicesExtraKind
  97213. * - VertexBuffer.MatricesWeightsKind
  97214. * - VertexBuffer.MatricesWeightsExtraKind
  97215. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97216. */
  97217. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97218. /**
  97219. * Sets the mesh global Vertex Buffer
  97220. * @param buffer defines the buffer to use
  97221. * @returns the current mesh
  97222. */
  97223. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97224. /**
  97225. * Update a specific associated vertex buffer
  97226. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97227. * - VertexBuffer.PositionKind
  97228. * - VertexBuffer.UVKind
  97229. * - VertexBuffer.UV2Kind
  97230. * - VertexBuffer.UV3Kind
  97231. * - VertexBuffer.UV4Kind
  97232. * - VertexBuffer.UV5Kind
  97233. * - VertexBuffer.UV6Kind
  97234. * - VertexBuffer.ColorKind
  97235. * - VertexBuffer.MatricesIndicesKind
  97236. * - VertexBuffer.MatricesIndicesExtraKind
  97237. * - VertexBuffer.MatricesWeightsKind
  97238. * - VertexBuffer.MatricesWeightsExtraKind
  97239. * @param data defines the data source
  97240. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97241. * @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)
  97242. * @returns the current mesh
  97243. */
  97244. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97245. /**
  97246. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97247. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97248. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97249. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97250. * @returns the current mesh
  97251. */
  97252. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97253. /**
  97254. * Creates a un-shared specific occurence of the geometry for the mesh.
  97255. * @returns the current mesh
  97256. */
  97257. makeGeometryUnique(): Mesh;
  97258. /**
  97259. * Set the index buffer of this mesh
  97260. * @param indices defines the source data
  97261. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97262. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97263. * @returns the current mesh
  97264. */
  97265. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97266. /**
  97267. * Update the current index buffer
  97268. * @param indices defines the source data
  97269. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97270. * @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)
  97271. * @returns the current mesh
  97272. */
  97273. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97274. /**
  97275. * Invert the geometry to move from a right handed system to a left handed one.
  97276. * @returns the current mesh
  97277. */
  97278. toLeftHanded(): Mesh;
  97279. /** @hidden */
  97280. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97281. /** @hidden */
  97282. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97283. /**
  97284. * Registers for this mesh a javascript function called just before the rendering process
  97285. * @param func defines the function to call before rendering this mesh
  97286. * @returns the current mesh
  97287. */
  97288. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97289. /**
  97290. * Disposes a previously registered javascript function called before the rendering
  97291. * @param func defines the function to remove
  97292. * @returns the current mesh
  97293. */
  97294. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97295. /**
  97296. * Registers for this mesh a javascript function called just after the rendering is complete
  97297. * @param func defines the function to call after rendering this mesh
  97298. * @returns the current mesh
  97299. */
  97300. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97301. /**
  97302. * Disposes a previously registered javascript function called after the rendering.
  97303. * @param func defines the function to remove
  97304. * @returns the current mesh
  97305. */
  97306. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97307. /** @hidden */
  97308. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97309. /** @hidden */
  97310. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97311. /** @hidden */
  97312. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97313. /** @hidden */
  97314. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97315. /** @hidden */
  97316. _rebuild(): void;
  97317. /** @hidden */
  97318. _freeze(): void;
  97319. /** @hidden */
  97320. _unFreeze(): void;
  97321. /**
  97322. * 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
  97323. * @param subMesh defines the subMesh to render
  97324. * @param enableAlphaMode defines if alpha mode can be changed
  97325. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97326. * @returns the current mesh
  97327. */
  97328. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97329. private _onBeforeDraw;
  97330. /**
  97331. * Renormalize the mesh and patch it up if there are no weights
  97332. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97333. * However in the case of zero weights then we set just a single influence to 1.
  97334. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97335. */
  97336. cleanMatrixWeights(): void;
  97337. private normalizeSkinFourWeights;
  97338. private normalizeSkinWeightsAndExtra;
  97339. /**
  97340. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  97341. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  97342. * the user know there was an issue with importing the mesh
  97343. * @returns a validation object with skinned, valid and report string
  97344. */
  97345. validateSkinning(): {
  97346. skinned: boolean;
  97347. valid: boolean;
  97348. report: string;
  97349. };
  97350. /** @hidden */
  97351. _checkDelayState(): Mesh;
  97352. private _queueLoad;
  97353. /**
  97354. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97355. * A mesh is in the frustum if its bounding box intersects the frustum
  97356. * @param frustumPlanes defines the frustum to test
  97357. * @returns true if the mesh is in the frustum planes
  97358. */
  97359. isInFrustum(frustumPlanes: Plane[]): boolean;
  97360. /**
  97361. * Sets the mesh material by the material or multiMaterial `id` property
  97362. * @param id is a string identifying the material or the multiMaterial
  97363. * @returns the current mesh
  97364. */
  97365. setMaterialByID(id: string): Mesh;
  97366. /**
  97367. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  97368. * @returns an array of IAnimatable
  97369. */
  97370. getAnimatables(): IAnimatable[];
  97371. /**
  97372. * Modifies the mesh geometry according to the passed transformation matrix.
  97373. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  97374. * The mesh normals are modified using the same transformation.
  97375. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97376. * @param transform defines the transform matrix to use
  97377. * @see http://doc.babylonjs.com/resources/baking_transformations
  97378. * @returns the current mesh
  97379. */
  97380. bakeTransformIntoVertices(transform: Matrix): Mesh;
  97381. /**
  97382. * Modifies the mesh geometry according to its own current World Matrix.
  97383. * The mesh World Matrix is then reset.
  97384. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  97385. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97386. * @see http://doc.babylonjs.com/resources/baking_transformations
  97387. * @returns the current mesh
  97388. */
  97389. bakeCurrentTransformIntoVertices(): Mesh;
  97390. /** @hidden */
  97391. get _positions(): Nullable<Vector3[]>;
  97392. /** @hidden */
  97393. _resetPointsArrayCache(): Mesh;
  97394. /** @hidden */
  97395. _generatePointsArray(): boolean;
  97396. /**
  97397. * Returns a new Mesh object generated from the current mesh properties.
  97398. * This method must not get confused with createInstance()
  97399. * @param name is a string, the name given to the new mesh
  97400. * @param newParent can be any Node object (default `null`)
  97401. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  97402. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  97403. * @returns a new mesh
  97404. */
  97405. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  97406. /**
  97407. * Releases resources associated with this mesh.
  97408. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97409. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97410. */
  97411. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97412. /** @hidden */
  97413. _disposeInstanceSpecificData(): void;
  97414. /**
  97415. * Modifies the mesh geometry according to a displacement map.
  97416. * 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.
  97417. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97418. * @param url is a string, the URL from the image file is to be downloaded.
  97419. * @param minHeight is the lower limit of the displacement.
  97420. * @param maxHeight is the upper limit of the displacement.
  97421. * @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.
  97422. * @param uvOffset is an optional vector2 used to offset UV.
  97423. * @param uvScale is an optional vector2 used to scale UV.
  97424. * @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.
  97425. * @returns the Mesh.
  97426. */
  97427. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97428. /**
  97429. * Modifies the mesh geometry according to a displacementMap buffer.
  97430. * 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.
  97431. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97432. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  97433. * @param heightMapWidth is the width of the buffer image.
  97434. * @param heightMapHeight is the height of the buffer image.
  97435. * @param minHeight is the lower limit of the displacement.
  97436. * @param maxHeight is the upper limit of the displacement.
  97437. * @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.
  97438. * @param uvOffset is an optional vector2 used to offset UV.
  97439. * @param uvScale is an optional vector2 used to scale UV.
  97440. * @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.
  97441. * @returns the Mesh.
  97442. */
  97443. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97444. /**
  97445. * Modify the mesh to get a flat shading rendering.
  97446. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  97447. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  97448. * @returns current mesh
  97449. */
  97450. convertToFlatShadedMesh(): Mesh;
  97451. /**
  97452. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  97453. * In other words, more vertices, no more indices and a single bigger VBO.
  97454. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  97455. * @returns current mesh
  97456. */
  97457. convertToUnIndexedMesh(): Mesh;
  97458. /**
  97459. * Inverses facet orientations.
  97460. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97461. * @param flipNormals will also inverts the normals
  97462. * @returns current mesh
  97463. */
  97464. flipFaces(flipNormals?: boolean): Mesh;
  97465. /**
  97466. * Increase the number of facets and hence vertices in a mesh
  97467. * Vertex normals are interpolated from existing vertex normals
  97468. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97469. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  97470. */
  97471. increaseVertices(numberPerEdge: number): void;
  97472. /**
  97473. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  97474. * This will undo any application of covertToFlatShadedMesh
  97475. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97476. */
  97477. forceSharedVertices(): void;
  97478. /** @hidden */
  97479. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  97480. /** @hidden */
  97481. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  97482. /**
  97483. * Creates a new InstancedMesh object from the mesh model.
  97484. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97485. * @param name defines the name of the new instance
  97486. * @returns a new InstancedMesh
  97487. */
  97488. createInstance(name: string): InstancedMesh;
  97489. /**
  97490. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  97491. * After this call, all the mesh instances have the same submeshes than the current mesh.
  97492. * @returns the current mesh
  97493. */
  97494. synchronizeInstances(): Mesh;
  97495. /**
  97496. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  97497. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  97498. * This should be used together with the simplification to avoid disappearing triangles.
  97499. * @param successCallback an optional success callback to be called after the optimization finished.
  97500. * @returns the current mesh
  97501. */
  97502. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  97503. /**
  97504. * Serialize current mesh
  97505. * @param serializationObject defines the object which will receive the serialization data
  97506. */
  97507. serialize(serializationObject: any): void;
  97508. /** @hidden */
  97509. _syncGeometryWithMorphTargetManager(): void;
  97510. /** @hidden */
  97511. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  97512. /**
  97513. * Returns a new Mesh object parsed from the source provided.
  97514. * @param parsedMesh is the source
  97515. * @param scene defines the hosting scene
  97516. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  97517. * @returns a new Mesh
  97518. */
  97519. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  97520. /**
  97521. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  97522. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97523. * @param name defines the name of the mesh to create
  97524. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  97525. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  97526. * @param closePath creates a seam between the first and the last points of each path of the path array
  97527. * @param offset is taken in account only if the `pathArray` is containing a single path
  97528. * @param scene defines the hosting scene
  97529. * @param updatable defines if the mesh must be flagged as updatable
  97530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97531. * @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)
  97532. * @returns a new Mesh
  97533. */
  97534. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97535. /**
  97536. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  97537. * @param name defines the name of the mesh to create
  97538. * @param radius sets the radius size (float) of the polygon (default 0.5)
  97539. * @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
  97540. * @param scene defines the hosting scene
  97541. * @param updatable defines if the mesh must be flagged as updatable
  97542. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97543. * @returns a new Mesh
  97544. */
  97545. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97546. /**
  97547. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  97548. * @param name defines the name of the mesh to create
  97549. * @param size sets the size (float) of each box side (default 1)
  97550. * @param scene defines the hosting scene
  97551. * @param updatable defines if the mesh must be flagged as updatable
  97552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97553. * @returns a new Mesh
  97554. */
  97555. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97556. /**
  97557. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  97558. * @param name defines the name of the mesh to create
  97559. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97560. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97561. * @param scene defines the hosting scene
  97562. * @param updatable defines if the mesh must be flagged as updatable
  97563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97564. * @returns a new Mesh
  97565. */
  97566. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97567. /**
  97568. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  97569. * @param name defines the name of the mesh to create
  97570. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97571. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97572. * @param scene defines the hosting scene
  97573. * @returns a new Mesh
  97574. */
  97575. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  97576. /**
  97577. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  97578. * @param name defines the name of the mesh to create
  97579. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  97580. * @param diameterTop set the top cap diameter (floats, default 1)
  97581. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  97582. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  97583. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  97584. * @param scene defines the hosting scene
  97585. * @param updatable defines if the mesh must be flagged as updatable
  97586. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97587. * @returns a new Mesh
  97588. */
  97589. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  97590. /**
  97591. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  97592. * @param name defines the name of the mesh to create
  97593. * @param diameter sets the diameter size (float) of the torus (default 1)
  97594. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  97595. * @param tessellation sets the number of torus sides (postive integer, default 16)
  97596. * @param scene defines the hosting scene
  97597. * @param updatable defines if the mesh must be flagged as updatable
  97598. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97599. * @returns a new Mesh
  97600. */
  97601. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97602. /**
  97603. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  97604. * @param name defines the name of the mesh to create
  97605. * @param radius sets the global radius size (float) of the torus knot (default 2)
  97606. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  97607. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  97608. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  97609. * @param p the number of windings on X axis (positive integers, default 2)
  97610. * @param q the number of windings on Y axis (positive integers, default 3)
  97611. * @param scene defines the hosting scene
  97612. * @param updatable defines if the mesh must be flagged as updatable
  97613. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97614. * @returns a new Mesh
  97615. */
  97616. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97617. /**
  97618. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  97619. * @param name defines the name of the mesh to create
  97620. * @param points is an array successive Vector3
  97621. * @param scene defines the hosting scene
  97622. * @param updatable defines if the mesh must be flagged as updatable
  97623. * @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).
  97624. * @returns a new Mesh
  97625. */
  97626. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  97627. /**
  97628. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  97629. * @param name defines the name of the mesh to create
  97630. * @param points is an array successive Vector3
  97631. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  97632. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97633. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  97634. * @param scene defines the hosting scene
  97635. * @param updatable defines if the mesh must be flagged as updatable
  97636. * @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)
  97637. * @returns a new Mesh
  97638. */
  97639. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  97640. /**
  97641. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  97642. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  97643. * 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.
  97644. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97645. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97646. * Remember you can only change the shape positions, not their number when updating a polygon.
  97647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  97648. * @param name defines the name of the mesh to create
  97649. * @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
  97650. * @param scene defines the hosting scene
  97651. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97652. * @param updatable defines if the mesh must be flagged as updatable
  97653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97654. * @param earcutInjection can be used to inject your own earcut reference
  97655. * @returns a new Mesh
  97656. */
  97657. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97658. /**
  97659. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  97660. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  97661. * @param name defines the name of the mesh to create
  97662. * @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
  97663. * @param depth defines the height of extrusion
  97664. * @param scene defines the hosting scene
  97665. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97666. * @param updatable defines if the mesh must be flagged as updatable
  97667. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97668. * @param earcutInjection can be used to inject your own earcut reference
  97669. * @returns a new Mesh
  97670. */
  97671. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97672. /**
  97673. * Creates an extruded shape mesh.
  97674. * 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
  97675. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97676. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97677. * @param name defines the name of the mesh to create
  97678. * @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
  97679. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97680. * @param scale is the value to scale the shape
  97681. * @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
  97682. * @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
  97683. * @param scene defines the hosting scene
  97684. * @param updatable defines if the mesh must be flagged as updatable
  97685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97686. * @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)
  97687. * @returns a new Mesh
  97688. */
  97689. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97690. /**
  97691. * Creates an custom extruded shape mesh.
  97692. * The custom extrusion is a parametric shape.
  97693. * It has no predefined shape. Its final shape will depend on the input parameters.
  97694. * Please consider using the same method from the MeshBuilder class instead
  97695. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97696. * @param name defines the name of the mesh to create
  97697. * @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
  97698. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97699. * @param scaleFunction is a custom Javascript function called on each path point
  97700. * @param rotationFunction is a custom Javascript function called on each path point
  97701. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  97702. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  97703. * @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
  97704. * @param scene defines the hosting scene
  97705. * @param updatable defines if the mesh must be flagged as updatable
  97706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97707. * @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)
  97708. * @returns a new Mesh
  97709. */
  97710. 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;
  97711. /**
  97712. * Creates lathe mesh.
  97713. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  97714. * Please consider using the same method from the MeshBuilder class instead
  97715. * @param name defines the name of the mesh to create
  97716. * @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
  97717. * @param radius is the radius value of the lathe
  97718. * @param tessellation is the side number of the lathe.
  97719. * @param scene defines the hosting scene
  97720. * @param updatable defines if the mesh must be flagged as updatable
  97721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97722. * @returns a new Mesh
  97723. */
  97724. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97725. /**
  97726. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  97727. * @param name defines the name of the mesh to create
  97728. * @param size sets the size (float) of both sides of the plane at once (default 1)
  97729. * @param scene defines the hosting scene
  97730. * @param updatable defines if the mesh must be flagged as updatable
  97731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97732. * @returns a new Mesh
  97733. */
  97734. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97735. /**
  97736. * Creates a ground mesh.
  97737. * Please consider using the same method from the MeshBuilder class instead
  97738. * @param name defines the name of the mesh to create
  97739. * @param width set the width of the ground
  97740. * @param height set the height of the ground
  97741. * @param subdivisions sets the number of subdivisions per side
  97742. * @param scene defines the hosting scene
  97743. * @param updatable defines if the mesh must be flagged as updatable
  97744. * @returns a new Mesh
  97745. */
  97746. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  97747. /**
  97748. * Creates a tiled ground mesh.
  97749. * Please consider using the same method from the MeshBuilder class instead
  97750. * @param name defines the name of the mesh to create
  97751. * @param xmin set the ground minimum X coordinate
  97752. * @param zmin set the ground minimum Y coordinate
  97753. * @param xmax set the ground maximum X coordinate
  97754. * @param zmax set the ground maximum Z coordinate
  97755. * @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
  97756. * @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
  97757. * @param scene defines the hosting scene
  97758. * @param updatable defines if the mesh must be flagged as updatable
  97759. * @returns a new Mesh
  97760. */
  97761. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  97762. w: number;
  97763. h: number;
  97764. }, precision: {
  97765. w: number;
  97766. h: number;
  97767. }, scene: Scene, updatable?: boolean): Mesh;
  97768. /**
  97769. * Creates a ground mesh from a height map.
  97770. * Please consider using the same method from the MeshBuilder class instead
  97771. * @see http://doc.babylonjs.com/babylon101/height_map
  97772. * @param name defines the name of the mesh to create
  97773. * @param url sets the URL of the height map image resource
  97774. * @param width set the ground width size
  97775. * @param height set the ground height size
  97776. * @param subdivisions sets the number of subdivision per side
  97777. * @param minHeight is the minimum altitude on the ground
  97778. * @param maxHeight is the maximum altitude on the ground
  97779. * @param scene defines the hosting scene
  97780. * @param updatable defines if the mesh must be flagged as updatable
  97781. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  97782. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97783. * @returns a new Mesh
  97784. */
  97785. 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;
  97786. /**
  97787. * Creates a tube mesh.
  97788. * The tube is a parametric shape.
  97789. * It has no predefined shape. Its final shape will depend on the input parameters.
  97790. * Please consider using the same method from the MeshBuilder class instead
  97791. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97792. * @param name defines the name of the mesh to create
  97793. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  97794. * @param radius sets the tube radius size
  97795. * @param tessellation is the number of sides on the tubular surface
  97796. * @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
  97797. * @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
  97798. * @param scene defines the hosting scene
  97799. * @param updatable defines if the mesh must be flagged as updatable
  97800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97801. * @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)
  97802. * @returns a new Mesh
  97803. */
  97804. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  97805. (i: number, distance: number): number;
  97806. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97807. /**
  97808. * Creates a polyhedron mesh.
  97809. * Please consider using the same method from the MeshBuilder class instead.
  97810. * * 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
  97811. * * The parameter `size` (positive float, default 1) sets the polygon size
  97812. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97813. * * 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`
  97814. * * 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
  97815. * * 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)`)
  97816. * * 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
  97817. * * 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
  97818. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97819. * * If you create a double-sided mesh, you can choose what parts of 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
  97820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97821. * @param name defines the name of the mesh to create
  97822. * @param options defines the options used to create the mesh
  97823. * @param scene defines the hosting scene
  97824. * @returns a new Mesh
  97825. */
  97826. static CreatePolyhedron(name: string, options: {
  97827. type?: number;
  97828. size?: number;
  97829. sizeX?: number;
  97830. sizeY?: number;
  97831. sizeZ?: number;
  97832. custom?: any;
  97833. faceUV?: Vector4[];
  97834. faceColors?: Color4[];
  97835. updatable?: boolean;
  97836. sideOrientation?: number;
  97837. }, scene: Scene): Mesh;
  97838. /**
  97839. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  97840. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  97841. * * 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`)
  97842. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  97843. * * 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
  97844. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97845. * * If you create a double-sided mesh, you can choose what parts of 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
  97846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97847. * @param name defines the name of the mesh
  97848. * @param options defines the options used to create the mesh
  97849. * @param scene defines the hosting scene
  97850. * @returns a new Mesh
  97851. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  97852. */
  97853. static CreateIcoSphere(name: string, options: {
  97854. radius?: number;
  97855. flat?: boolean;
  97856. subdivisions?: number;
  97857. sideOrientation?: number;
  97858. updatable?: boolean;
  97859. }, scene: Scene): Mesh;
  97860. /**
  97861. * Creates a decal mesh.
  97862. * Please consider using the same method from the MeshBuilder class instead.
  97863. * A decal is a mesh usually applied as a model onto the surface of another mesh
  97864. * @param name defines the name of the mesh
  97865. * @param sourceMesh defines the mesh receiving the decal
  97866. * @param position sets the position of the decal in world coordinates
  97867. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  97868. * @param size sets the decal scaling
  97869. * @param angle sets the angle to rotate the decal
  97870. * @returns a new Mesh
  97871. */
  97872. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  97873. /**
  97874. * Prepare internal position array for software CPU skinning
  97875. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  97876. */
  97877. setPositionsForCPUSkinning(): Float32Array;
  97878. /**
  97879. * Prepare internal normal array for software CPU skinning
  97880. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  97881. */
  97882. setNormalsForCPUSkinning(): Float32Array;
  97883. /**
  97884. * Updates the vertex buffer by applying transformation from the bones
  97885. * @param skeleton defines the skeleton to apply to current mesh
  97886. * @returns the current mesh
  97887. */
  97888. applySkeleton(skeleton: Skeleton): Mesh;
  97889. /**
  97890. * 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
  97891. * @param meshes defines the list of meshes to scan
  97892. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  97893. */
  97894. static MinMax(meshes: AbstractMesh[]): {
  97895. min: Vector3;
  97896. max: Vector3;
  97897. };
  97898. /**
  97899. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  97900. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  97901. * @returns a vector3
  97902. */
  97903. static Center(meshesOrMinMaxVector: {
  97904. min: Vector3;
  97905. max: Vector3;
  97906. } | AbstractMesh[]): Vector3;
  97907. /**
  97908. * Merge the array of meshes into a single mesh for performance reasons.
  97909. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  97910. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  97911. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  97912. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  97913. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  97914. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  97915. * @returns a new mesh
  97916. */
  97917. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  97918. /** @hidden */
  97919. addInstance(instance: InstancedMesh): void;
  97920. /** @hidden */
  97921. removeInstance(instance: InstancedMesh): void;
  97922. }
  97923. }
  97924. declare module BABYLON {
  97925. /**
  97926. * This is the base class of all the camera used in the application.
  97927. * @see http://doc.babylonjs.com/features/cameras
  97928. */
  97929. export class Camera extends Node {
  97930. /** @hidden */
  97931. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  97932. /**
  97933. * This is the default projection mode used by the cameras.
  97934. * It helps recreating a feeling of perspective and better appreciate depth.
  97935. * This is the best way to simulate real life cameras.
  97936. */
  97937. static readonly PERSPECTIVE_CAMERA: number;
  97938. /**
  97939. * This helps creating camera with an orthographic mode.
  97940. * 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.
  97941. */
  97942. static readonly ORTHOGRAPHIC_CAMERA: number;
  97943. /**
  97944. * This is the default FOV mode for perspective cameras.
  97945. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  97946. */
  97947. static readonly FOVMODE_VERTICAL_FIXED: number;
  97948. /**
  97949. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  97950. */
  97951. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  97952. /**
  97953. * This specifies ther is no need for a camera rig.
  97954. * Basically only one eye is rendered corresponding to the camera.
  97955. */
  97956. static readonly RIG_MODE_NONE: number;
  97957. /**
  97958. * Simulates a camera Rig with one blue eye and one red eye.
  97959. * This can be use with 3d blue and red glasses.
  97960. */
  97961. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  97962. /**
  97963. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  97964. */
  97965. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  97966. /**
  97967. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  97968. */
  97969. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  97970. /**
  97971. * Defines that both eyes of the camera will be rendered over under each other.
  97972. */
  97973. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  97974. /**
  97975. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  97976. */
  97977. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  97978. /**
  97979. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  97980. */
  97981. static readonly RIG_MODE_VR: number;
  97982. /**
  97983. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  97984. */
  97985. static readonly RIG_MODE_WEBVR: number;
  97986. /**
  97987. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  97988. */
  97989. static readonly RIG_MODE_CUSTOM: number;
  97990. /**
  97991. * Defines if by default attaching controls should prevent the default javascript event to continue.
  97992. */
  97993. static ForceAttachControlToAlwaysPreventDefault: boolean;
  97994. /**
  97995. * Define the input manager associated with the camera.
  97996. */
  97997. inputs: CameraInputsManager<Camera>;
  97998. /** @hidden */
  97999. _position: Vector3;
  98000. /**
  98001. * Define the current local position of the camera in the scene
  98002. */
  98003. get position(): Vector3;
  98004. set position(newPosition: Vector3);
  98005. /**
  98006. * The vector the camera should consider as up.
  98007. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98008. */
  98009. upVector: Vector3;
  98010. /**
  98011. * Define the current limit on the left side for an orthographic camera
  98012. * In scene unit
  98013. */
  98014. orthoLeft: Nullable<number>;
  98015. /**
  98016. * Define the current limit on the right side for an orthographic camera
  98017. * In scene unit
  98018. */
  98019. orthoRight: Nullable<number>;
  98020. /**
  98021. * Define the current limit on the bottom side for an orthographic camera
  98022. * In scene unit
  98023. */
  98024. orthoBottom: Nullable<number>;
  98025. /**
  98026. * Define the current limit on the top side for an orthographic camera
  98027. * In scene unit
  98028. */
  98029. orthoTop: Nullable<number>;
  98030. /**
  98031. * Field Of View is set in Radians. (default is 0.8)
  98032. */
  98033. fov: number;
  98034. /**
  98035. * Define the minimum distance the camera can see from.
  98036. * This is important to note that the depth buffer are not infinite and the closer it starts
  98037. * the more your scene might encounter depth fighting issue.
  98038. */
  98039. minZ: number;
  98040. /**
  98041. * Define the maximum distance the camera can see to.
  98042. * This is important to note that the depth buffer are not infinite and the further it end
  98043. * the more your scene might encounter depth fighting issue.
  98044. */
  98045. maxZ: number;
  98046. /**
  98047. * Define the default inertia of the camera.
  98048. * This helps giving a smooth feeling to the camera movement.
  98049. */
  98050. inertia: number;
  98051. /**
  98052. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98053. */
  98054. mode: number;
  98055. /**
  98056. * Define wether the camera is intermediate.
  98057. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98058. */
  98059. isIntermediate: boolean;
  98060. /**
  98061. * Define the viewport of the camera.
  98062. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98063. */
  98064. viewport: Viewport;
  98065. /**
  98066. * Restricts the camera to viewing objects with the same layerMask.
  98067. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98068. */
  98069. layerMask: number;
  98070. /**
  98071. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98072. */
  98073. fovMode: number;
  98074. /**
  98075. * Rig mode of the camera.
  98076. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98077. * This is normally controlled byt the camera themselves as internal use.
  98078. */
  98079. cameraRigMode: number;
  98080. /**
  98081. * Defines the distance between both "eyes" in case of a RIG
  98082. */
  98083. interaxialDistance: number;
  98084. /**
  98085. * Defines if stereoscopic rendering is done side by side or over under.
  98086. */
  98087. isStereoscopicSideBySide: boolean;
  98088. /**
  98089. * 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
  98090. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98091. * else in the scene. (Eg. security camera)
  98092. *
  98093. * 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)
  98094. */
  98095. customRenderTargets: RenderTargetTexture[];
  98096. /**
  98097. * When set, the camera will render to this render target instead of the default canvas
  98098. *
  98099. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98100. */
  98101. outputRenderTarget: Nullable<RenderTargetTexture>;
  98102. /**
  98103. * Observable triggered when the camera view matrix has changed.
  98104. */
  98105. onViewMatrixChangedObservable: Observable<Camera>;
  98106. /**
  98107. * Observable triggered when the camera Projection matrix has changed.
  98108. */
  98109. onProjectionMatrixChangedObservable: Observable<Camera>;
  98110. /**
  98111. * Observable triggered when the inputs have been processed.
  98112. */
  98113. onAfterCheckInputsObservable: Observable<Camera>;
  98114. /**
  98115. * Observable triggered when reset has been called and applied to the camera.
  98116. */
  98117. onRestoreStateObservable: Observable<Camera>;
  98118. /** @hidden */
  98119. _cameraRigParams: any;
  98120. /** @hidden */
  98121. _rigCameras: Camera[];
  98122. /** @hidden */
  98123. _rigPostProcess: Nullable<PostProcess>;
  98124. protected _webvrViewMatrix: Matrix;
  98125. /** @hidden */
  98126. _skipRendering: boolean;
  98127. /** @hidden */
  98128. _projectionMatrix: Matrix;
  98129. /** @hidden */
  98130. _postProcesses: Nullable<PostProcess>[];
  98131. /** @hidden */
  98132. _activeMeshes: SmartArray<AbstractMesh>;
  98133. protected _globalPosition: Vector3;
  98134. /** @hidden */
  98135. _computedViewMatrix: Matrix;
  98136. private _doNotComputeProjectionMatrix;
  98137. private _transformMatrix;
  98138. private _frustumPlanes;
  98139. private _refreshFrustumPlanes;
  98140. private _storedFov;
  98141. private _stateStored;
  98142. /**
  98143. * Instantiates a new camera object.
  98144. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98145. * @see http://doc.babylonjs.com/features/cameras
  98146. * @param name Defines the name of the camera in the scene
  98147. * @param position Defines the position of the camera
  98148. * @param scene Defines the scene the camera belongs too
  98149. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98150. */
  98151. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98152. /**
  98153. * Store current camera state (fov, position, etc..)
  98154. * @returns the camera
  98155. */
  98156. storeState(): Camera;
  98157. /**
  98158. * Restores the camera state values if it has been stored. You must call storeState() first
  98159. */
  98160. protected _restoreStateValues(): boolean;
  98161. /**
  98162. * Restored camera state. You must call storeState() first.
  98163. * @returns true if restored and false otherwise
  98164. */
  98165. restoreState(): boolean;
  98166. /**
  98167. * Gets the class name of the camera.
  98168. * @returns the class name
  98169. */
  98170. getClassName(): string;
  98171. /** @hidden */
  98172. readonly _isCamera: boolean;
  98173. /**
  98174. * Gets a string representation of the camera useful for debug purpose.
  98175. * @param fullDetails Defines that a more verboe level of logging is required
  98176. * @returns the string representation
  98177. */
  98178. toString(fullDetails?: boolean): string;
  98179. /**
  98180. * Gets the current world space position of the camera.
  98181. */
  98182. get globalPosition(): Vector3;
  98183. /**
  98184. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98185. * @returns the active meshe list
  98186. */
  98187. getActiveMeshes(): SmartArray<AbstractMesh>;
  98188. /**
  98189. * Check wether a mesh is part of the current active mesh list of the camera
  98190. * @param mesh Defines the mesh to check
  98191. * @returns true if active, false otherwise
  98192. */
  98193. isActiveMesh(mesh: Mesh): boolean;
  98194. /**
  98195. * Is this camera ready to be used/rendered
  98196. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98197. * @return true if the camera is ready
  98198. */
  98199. isReady(completeCheck?: boolean): boolean;
  98200. /** @hidden */
  98201. _initCache(): void;
  98202. /** @hidden */
  98203. _updateCache(ignoreParentClass?: boolean): void;
  98204. /** @hidden */
  98205. _isSynchronized(): boolean;
  98206. /** @hidden */
  98207. _isSynchronizedViewMatrix(): boolean;
  98208. /** @hidden */
  98209. _isSynchronizedProjectionMatrix(): boolean;
  98210. /**
  98211. * Attach the input controls to a specific dom element to get the input from.
  98212. * @param element Defines the element the controls should be listened from
  98213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98214. */
  98215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98216. /**
  98217. * Detach the current controls from the specified dom element.
  98218. * @param element Defines the element to stop listening the inputs from
  98219. */
  98220. detachControl(element: HTMLElement): void;
  98221. /**
  98222. * Update the camera state according to the different inputs gathered during the frame.
  98223. */
  98224. update(): void;
  98225. /** @hidden */
  98226. _checkInputs(): void;
  98227. /** @hidden */
  98228. get rigCameras(): Camera[];
  98229. /**
  98230. * Gets the post process used by the rig cameras
  98231. */
  98232. get rigPostProcess(): Nullable<PostProcess>;
  98233. /**
  98234. * Internal, gets the first post proces.
  98235. * @returns the first post process to be run on this camera.
  98236. */
  98237. _getFirstPostProcess(): Nullable<PostProcess>;
  98238. private _cascadePostProcessesToRigCams;
  98239. /**
  98240. * Attach a post process to the camera.
  98241. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98242. * @param postProcess The post process to attach to the camera
  98243. * @param insertAt The position of the post process in case several of them are in use in the scene
  98244. * @returns the position the post process has been inserted at
  98245. */
  98246. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98247. /**
  98248. * Detach a post process to the camera.
  98249. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98250. * @param postProcess The post process to detach from the camera
  98251. */
  98252. detachPostProcess(postProcess: PostProcess): void;
  98253. /**
  98254. * Gets the current world matrix of the camera
  98255. */
  98256. getWorldMatrix(): Matrix;
  98257. /** @hidden */
  98258. _getViewMatrix(): Matrix;
  98259. /**
  98260. * Gets the current view matrix of the camera.
  98261. * @param force forces the camera to recompute the matrix without looking at the cached state
  98262. * @returns the view matrix
  98263. */
  98264. getViewMatrix(force?: boolean): Matrix;
  98265. /**
  98266. * Freeze the projection matrix.
  98267. * It will prevent the cache check of the camera projection compute and can speed up perf
  98268. * if no parameter of the camera are meant to change
  98269. * @param projection Defines manually a projection if necessary
  98270. */
  98271. freezeProjectionMatrix(projection?: Matrix): void;
  98272. /**
  98273. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98274. */
  98275. unfreezeProjectionMatrix(): void;
  98276. /**
  98277. * Gets the current projection matrix of the camera.
  98278. * @param force forces the camera to recompute the matrix without looking at the cached state
  98279. * @returns the projection matrix
  98280. */
  98281. getProjectionMatrix(force?: boolean): Matrix;
  98282. /**
  98283. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98284. * @returns a Matrix
  98285. */
  98286. getTransformationMatrix(): Matrix;
  98287. private _updateFrustumPlanes;
  98288. /**
  98289. * Checks if a cullable object (mesh...) is in the camera frustum
  98290. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98291. * @param target The object to check
  98292. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98293. * @returns true if the object is in frustum otherwise false
  98294. */
  98295. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98296. /**
  98297. * Checks if a cullable object (mesh...) is in the camera frustum
  98298. * Unlike isInFrustum this cheks the full bounding box
  98299. * @param target The object to check
  98300. * @returns true if the object is in frustum otherwise false
  98301. */
  98302. isCompletelyInFrustum(target: ICullable): boolean;
  98303. /**
  98304. * Gets a ray in the forward direction from the camera.
  98305. * @param length Defines the length of the ray to create
  98306. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98307. * @param origin Defines the start point of the ray which defaults to the camera position
  98308. * @returns the forward ray
  98309. */
  98310. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98311. /**
  98312. * Releases resources associated with this node.
  98313. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98314. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98315. */
  98316. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98317. /** @hidden */
  98318. _isLeftCamera: boolean;
  98319. /**
  98320. * Gets the left camera of a rig setup in case of Rigged Camera
  98321. */
  98322. get isLeftCamera(): boolean;
  98323. /** @hidden */
  98324. _isRightCamera: boolean;
  98325. /**
  98326. * Gets the right camera of a rig setup in case of Rigged Camera
  98327. */
  98328. get isRightCamera(): boolean;
  98329. /**
  98330. * Gets the left camera of a rig setup in case of Rigged Camera
  98331. */
  98332. get leftCamera(): Nullable<FreeCamera>;
  98333. /**
  98334. * Gets the right camera of a rig setup in case of Rigged Camera
  98335. */
  98336. get rightCamera(): Nullable<FreeCamera>;
  98337. /**
  98338. * Gets the left camera target of a rig setup in case of Rigged Camera
  98339. * @returns the target position
  98340. */
  98341. getLeftTarget(): Nullable<Vector3>;
  98342. /**
  98343. * Gets the right camera target of a rig setup in case of Rigged Camera
  98344. * @returns the target position
  98345. */
  98346. getRightTarget(): Nullable<Vector3>;
  98347. /**
  98348. * @hidden
  98349. */
  98350. setCameraRigMode(mode: number, rigParams: any): void;
  98351. /** @hidden */
  98352. static _setStereoscopicRigMode(camera: Camera): void;
  98353. /** @hidden */
  98354. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  98355. /** @hidden */
  98356. static _setVRRigMode(camera: Camera, rigParams: any): void;
  98357. /** @hidden */
  98358. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  98359. /** @hidden */
  98360. _getVRProjectionMatrix(): Matrix;
  98361. protected _updateCameraRotationMatrix(): void;
  98362. protected _updateWebVRCameraRotationMatrix(): void;
  98363. /**
  98364. * This function MUST be overwritten by the different WebVR cameras available.
  98365. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98366. * @hidden
  98367. */
  98368. _getWebVRProjectionMatrix(): Matrix;
  98369. /**
  98370. * This function MUST be overwritten by the different WebVR cameras available.
  98371. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98372. * @hidden
  98373. */
  98374. _getWebVRViewMatrix(): Matrix;
  98375. /** @hidden */
  98376. setCameraRigParameter(name: string, value: any): void;
  98377. /**
  98378. * needs to be overridden by children so sub has required properties to be copied
  98379. * @hidden
  98380. */
  98381. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98382. /**
  98383. * May need to be overridden by children
  98384. * @hidden
  98385. */
  98386. _updateRigCameras(): void;
  98387. /** @hidden */
  98388. _setupInputs(): void;
  98389. /**
  98390. * Serialiaze the camera setup to a json represention
  98391. * @returns the JSON representation
  98392. */
  98393. serialize(): any;
  98394. /**
  98395. * Clones the current camera.
  98396. * @param name The cloned camera name
  98397. * @returns the cloned camera
  98398. */
  98399. clone(name: string): Camera;
  98400. /**
  98401. * Gets the direction of the camera relative to a given local axis.
  98402. * @param localAxis Defines the reference axis to provide a relative direction.
  98403. * @return the direction
  98404. */
  98405. getDirection(localAxis: Vector3): Vector3;
  98406. /**
  98407. * Returns the current camera absolute rotation
  98408. */
  98409. get absoluteRotation(): Quaternion;
  98410. /**
  98411. * Gets the direction of the camera relative to a given local axis into a passed vector.
  98412. * @param localAxis Defines the reference axis to provide a relative direction.
  98413. * @param result Defines the vector to store the result in
  98414. */
  98415. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  98416. /**
  98417. * Gets a camera constructor for a given camera type
  98418. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  98419. * @param name The name of the camera the result will be able to instantiate
  98420. * @param scene The scene the result will construct the camera in
  98421. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  98422. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  98423. * @returns a factory method to construc the camera
  98424. */
  98425. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  98426. /**
  98427. * Compute the world matrix of the camera.
  98428. * @returns the camera world matrix
  98429. */
  98430. computeWorldMatrix(): Matrix;
  98431. /**
  98432. * Parse a JSON and creates the camera from the parsed information
  98433. * @param parsedCamera The JSON to parse
  98434. * @param scene The scene to instantiate the camera in
  98435. * @returns the newly constructed camera
  98436. */
  98437. static Parse(parsedCamera: any, scene: Scene): Camera;
  98438. }
  98439. }
  98440. declare module BABYLON {
  98441. /**
  98442. * Class containing static functions to help procedurally build meshes
  98443. */
  98444. export class DiscBuilder {
  98445. /**
  98446. * Creates a plane polygonal mesh. By default, this is a disc
  98447. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  98448. * * 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
  98449. * * 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
  98450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98453. * @param name defines the name of the mesh
  98454. * @param options defines the options used to create the mesh
  98455. * @param scene defines the hosting scene
  98456. * @returns the plane polygonal mesh
  98457. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  98458. */
  98459. static CreateDisc(name: string, options: {
  98460. radius?: number;
  98461. tessellation?: number;
  98462. arc?: number;
  98463. updatable?: boolean;
  98464. sideOrientation?: number;
  98465. frontUVs?: Vector4;
  98466. backUVs?: Vector4;
  98467. }, scene?: Nullable<Scene>): Mesh;
  98468. }
  98469. }
  98470. declare module BABYLON {
  98471. /**
  98472. * This represents all the required information to add a fresnel effect on a material:
  98473. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98474. */
  98475. export class FresnelParameters {
  98476. private _isEnabled;
  98477. /**
  98478. * Define if the fresnel effect is enable or not.
  98479. */
  98480. get isEnabled(): boolean;
  98481. set isEnabled(value: boolean);
  98482. /**
  98483. * Define the color used on edges (grazing angle)
  98484. */
  98485. leftColor: Color3;
  98486. /**
  98487. * Define the color used on center
  98488. */
  98489. rightColor: Color3;
  98490. /**
  98491. * Define bias applied to computed fresnel term
  98492. */
  98493. bias: number;
  98494. /**
  98495. * Defined the power exponent applied to fresnel term
  98496. */
  98497. power: number;
  98498. /**
  98499. * Clones the current fresnel and its valuues
  98500. * @returns a clone fresnel configuration
  98501. */
  98502. clone(): FresnelParameters;
  98503. /**
  98504. * Serializes the current fresnel parameters to a JSON representation.
  98505. * @return the JSON serialization
  98506. */
  98507. serialize(): any;
  98508. /**
  98509. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  98510. * @param parsedFresnelParameters Define the JSON representation
  98511. * @returns the parsed parameters
  98512. */
  98513. static Parse(parsedFresnelParameters: any): FresnelParameters;
  98514. }
  98515. }
  98516. declare module BABYLON {
  98517. /**
  98518. * Base class of materials working in push mode in babylon JS
  98519. * @hidden
  98520. */
  98521. export class PushMaterial extends Material {
  98522. protected _activeEffect: Effect;
  98523. protected _normalMatrix: Matrix;
  98524. /**
  98525. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98526. * This means that the material can keep using a previous shader while a new one is being compiled.
  98527. * This is mostly used when shader parallel compilation is supported (true by default)
  98528. */
  98529. allowShaderHotSwapping: boolean;
  98530. constructor(name: string, scene: Scene);
  98531. getEffect(): Effect;
  98532. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98533. /**
  98534. * Binds the given world matrix to the active effect
  98535. *
  98536. * @param world the matrix to bind
  98537. */
  98538. bindOnlyWorldMatrix(world: Matrix): void;
  98539. /**
  98540. * Binds the given normal matrix to the active effect
  98541. *
  98542. * @param normalMatrix the matrix to bind
  98543. */
  98544. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98545. bind(world: Matrix, mesh?: Mesh): void;
  98546. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98547. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98548. }
  98549. }
  98550. declare module BABYLON {
  98551. /**
  98552. * This groups all the flags used to control the materials channel.
  98553. */
  98554. export class MaterialFlags {
  98555. private static _DiffuseTextureEnabled;
  98556. /**
  98557. * Are diffuse textures enabled in the application.
  98558. */
  98559. static get DiffuseTextureEnabled(): boolean;
  98560. static set DiffuseTextureEnabled(value: boolean);
  98561. private static _AmbientTextureEnabled;
  98562. /**
  98563. * Are ambient textures enabled in the application.
  98564. */
  98565. static get AmbientTextureEnabled(): boolean;
  98566. static set AmbientTextureEnabled(value: boolean);
  98567. private static _OpacityTextureEnabled;
  98568. /**
  98569. * Are opacity textures enabled in the application.
  98570. */
  98571. static get OpacityTextureEnabled(): boolean;
  98572. static set OpacityTextureEnabled(value: boolean);
  98573. private static _ReflectionTextureEnabled;
  98574. /**
  98575. * Are reflection textures enabled in the application.
  98576. */
  98577. static get ReflectionTextureEnabled(): boolean;
  98578. static set ReflectionTextureEnabled(value: boolean);
  98579. private static _EmissiveTextureEnabled;
  98580. /**
  98581. * Are emissive textures enabled in the application.
  98582. */
  98583. static get EmissiveTextureEnabled(): boolean;
  98584. static set EmissiveTextureEnabled(value: boolean);
  98585. private static _SpecularTextureEnabled;
  98586. /**
  98587. * Are specular textures enabled in the application.
  98588. */
  98589. static get SpecularTextureEnabled(): boolean;
  98590. static set SpecularTextureEnabled(value: boolean);
  98591. private static _BumpTextureEnabled;
  98592. /**
  98593. * Are bump textures enabled in the application.
  98594. */
  98595. static get BumpTextureEnabled(): boolean;
  98596. static set BumpTextureEnabled(value: boolean);
  98597. private static _LightmapTextureEnabled;
  98598. /**
  98599. * Are lightmap textures enabled in the application.
  98600. */
  98601. static get LightmapTextureEnabled(): boolean;
  98602. static set LightmapTextureEnabled(value: boolean);
  98603. private static _RefractionTextureEnabled;
  98604. /**
  98605. * Are refraction textures enabled in the application.
  98606. */
  98607. static get RefractionTextureEnabled(): boolean;
  98608. static set RefractionTextureEnabled(value: boolean);
  98609. private static _ColorGradingTextureEnabled;
  98610. /**
  98611. * Are color grading textures enabled in the application.
  98612. */
  98613. static get ColorGradingTextureEnabled(): boolean;
  98614. static set ColorGradingTextureEnabled(value: boolean);
  98615. private static _FresnelEnabled;
  98616. /**
  98617. * Are fresnels enabled in the application.
  98618. */
  98619. static get FresnelEnabled(): boolean;
  98620. static set FresnelEnabled(value: boolean);
  98621. private static _ClearCoatTextureEnabled;
  98622. /**
  98623. * Are clear coat textures enabled in the application.
  98624. */
  98625. static get ClearCoatTextureEnabled(): boolean;
  98626. static set ClearCoatTextureEnabled(value: boolean);
  98627. private static _ClearCoatBumpTextureEnabled;
  98628. /**
  98629. * Are clear coat bump textures enabled in the application.
  98630. */
  98631. static get ClearCoatBumpTextureEnabled(): boolean;
  98632. static set ClearCoatBumpTextureEnabled(value: boolean);
  98633. private static _ClearCoatTintTextureEnabled;
  98634. /**
  98635. * Are clear coat tint textures enabled in the application.
  98636. */
  98637. static get ClearCoatTintTextureEnabled(): boolean;
  98638. static set ClearCoatTintTextureEnabled(value: boolean);
  98639. private static _SheenTextureEnabled;
  98640. /**
  98641. * Are sheen textures enabled in the application.
  98642. */
  98643. static get SheenTextureEnabled(): boolean;
  98644. static set SheenTextureEnabled(value: boolean);
  98645. private static _AnisotropicTextureEnabled;
  98646. /**
  98647. * Are anisotropic textures enabled in the application.
  98648. */
  98649. static get AnisotropicTextureEnabled(): boolean;
  98650. static set AnisotropicTextureEnabled(value: boolean);
  98651. private static _ThicknessTextureEnabled;
  98652. /**
  98653. * Are thickness textures enabled in the application.
  98654. */
  98655. static get ThicknessTextureEnabled(): boolean;
  98656. static set ThicknessTextureEnabled(value: boolean);
  98657. }
  98658. }
  98659. declare module BABYLON {
  98660. /** @hidden */
  98661. export var defaultFragmentDeclaration: {
  98662. name: string;
  98663. shader: string;
  98664. };
  98665. }
  98666. declare module BABYLON {
  98667. /** @hidden */
  98668. export var defaultUboDeclaration: {
  98669. name: string;
  98670. shader: string;
  98671. };
  98672. }
  98673. declare module BABYLON {
  98674. /** @hidden */
  98675. export var lightFragmentDeclaration: {
  98676. name: string;
  98677. shader: string;
  98678. };
  98679. }
  98680. declare module BABYLON {
  98681. /** @hidden */
  98682. export var lightUboDeclaration: {
  98683. name: string;
  98684. shader: string;
  98685. };
  98686. }
  98687. declare module BABYLON {
  98688. /** @hidden */
  98689. export var lightsFragmentFunctions: {
  98690. name: string;
  98691. shader: string;
  98692. };
  98693. }
  98694. declare module BABYLON {
  98695. /** @hidden */
  98696. export var shadowsFragmentFunctions: {
  98697. name: string;
  98698. shader: string;
  98699. };
  98700. }
  98701. declare module BABYLON {
  98702. /** @hidden */
  98703. export var fresnelFunction: {
  98704. name: string;
  98705. shader: string;
  98706. };
  98707. }
  98708. declare module BABYLON {
  98709. /** @hidden */
  98710. export var reflectionFunction: {
  98711. name: string;
  98712. shader: string;
  98713. };
  98714. }
  98715. declare module BABYLON {
  98716. /** @hidden */
  98717. export var bumpFragmentFunctions: {
  98718. name: string;
  98719. shader: string;
  98720. };
  98721. }
  98722. declare module BABYLON {
  98723. /** @hidden */
  98724. export var logDepthDeclaration: {
  98725. name: string;
  98726. shader: string;
  98727. };
  98728. }
  98729. declare module BABYLON {
  98730. /** @hidden */
  98731. export var bumpFragment: {
  98732. name: string;
  98733. shader: string;
  98734. };
  98735. }
  98736. declare module BABYLON {
  98737. /** @hidden */
  98738. export var depthPrePass: {
  98739. name: string;
  98740. shader: string;
  98741. };
  98742. }
  98743. declare module BABYLON {
  98744. /** @hidden */
  98745. export var lightFragment: {
  98746. name: string;
  98747. shader: string;
  98748. };
  98749. }
  98750. declare module BABYLON {
  98751. /** @hidden */
  98752. export var logDepthFragment: {
  98753. name: string;
  98754. shader: string;
  98755. };
  98756. }
  98757. declare module BABYLON {
  98758. /** @hidden */
  98759. export var defaultPixelShader: {
  98760. name: string;
  98761. shader: string;
  98762. };
  98763. }
  98764. declare module BABYLON {
  98765. /** @hidden */
  98766. export var defaultVertexDeclaration: {
  98767. name: string;
  98768. shader: string;
  98769. };
  98770. }
  98771. declare module BABYLON {
  98772. /** @hidden */
  98773. export var bumpVertexDeclaration: {
  98774. name: string;
  98775. shader: string;
  98776. };
  98777. }
  98778. declare module BABYLON {
  98779. /** @hidden */
  98780. export var bumpVertex: {
  98781. name: string;
  98782. shader: string;
  98783. };
  98784. }
  98785. declare module BABYLON {
  98786. /** @hidden */
  98787. export var fogVertex: {
  98788. name: string;
  98789. shader: string;
  98790. };
  98791. }
  98792. declare module BABYLON {
  98793. /** @hidden */
  98794. export var shadowsVertex: {
  98795. name: string;
  98796. shader: string;
  98797. };
  98798. }
  98799. declare module BABYLON {
  98800. /** @hidden */
  98801. export var pointCloudVertex: {
  98802. name: string;
  98803. shader: string;
  98804. };
  98805. }
  98806. declare module BABYLON {
  98807. /** @hidden */
  98808. export var logDepthVertex: {
  98809. name: string;
  98810. shader: string;
  98811. };
  98812. }
  98813. declare module BABYLON {
  98814. /** @hidden */
  98815. export var defaultVertexShader: {
  98816. name: string;
  98817. shader: string;
  98818. };
  98819. }
  98820. declare module BABYLON {
  98821. /** @hidden */
  98822. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98823. MAINUV1: boolean;
  98824. MAINUV2: boolean;
  98825. DIFFUSE: boolean;
  98826. DIFFUSEDIRECTUV: number;
  98827. AMBIENT: boolean;
  98828. AMBIENTDIRECTUV: number;
  98829. OPACITY: boolean;
  98830. OPACITYDIRECTUV: number;
  98831. OPACITYRGB: boolean;
  98832. REFLECTION: boolean;
  98833. EMISSIVE: boolean;
  98834. EMISSIVEDIRECTUV: number;
  98835. SPECULAR: boolean;
  98836. SPECULARDIRECTUV: number;
  98837. BUMP: boolean;
  98838. BUMPDIRECTUV: number;
  98839. PARALLAX: boolean;
  98840. PARALLAXOCCLUSION: boolean;
  98841. SPECULAROVERALPHA: boolean;
  98842. CLIPPLANE: boolean;
  98843. CLIPPLANE2: boolean;
  98844. CLIPPLANE3: boolean;
  98845. CLIPPLANE4: boolean;
  98846. CLIPPLANE5: boolean;
  98847. CLIPPLANE6: boolean;
  98848. ALPHATEST: boolean;
  98849. DEPTHPREPASS: boolean;
  98850. ALPHAFROMDIFFUSE: boolean;
  98851. POINTSIZE: boolean;
  98852. FOG: boolean;
  98853. SPECULARTERM: boolean;
  98854. DIFFUSEFRESNEL: boolean;
  98855. OPACITYFRESNEL: boolean;
  98856. REFLECTIONFRESNEL: boolean;
  98857. REFRACTIONFRESNEL: boolean;
  98858. EMISSIVEFRESNEL: boolean;
  98859. FRESNEL: boolean;
  98860. NORMAL: boolean;
  98861. UV1: boolean;
  98862. UV2: boolean;
  98863. VERTEXCOLOR: boolean;
  98864. VERTEXALPHA: boolean;
  98865. NUM_BONE_INFLUENCERS: number;
  98866. BonesPerMesh: number;
  98867. BONETEXTURE: boolean;
  98868. INSTANCES: boolean;
  98869. GLOSSINESS: boolean;
  98870. ROUGHNESS: boolean;
  98871. EMISSIVEASILLUMINATION: boolean;
  98872. LINKEMISSIVEWITHDIFFUSE: boolean;
  98873. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98874. LIGHTMAP: boolean;
  98875. LIGHTMAPDIRECTUV: number;
  98876. OBJECTSPACE_NORMALMAP: boolean;
  98877. USELIGHTMAPASSHADOWMAP: boolean;
  98878. REFLECTIONMAP_3D: boolean;
  98879. REFLECTIONMAP_SPHERICAL: boolean;
  98880. REFLECTIONMAP_PLANAR: boolean;
  98881. REFLECTIONMAP_CUBIC: boolean;
  98882. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98883. REFLECTIONMAP_PROJECTION: boolean;
  98884. REFLECTIONMAP_SKYBOX: boolean;
  98885. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98886. REFLECTIONMAP_EXPLICIT: boolean;
  98887. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98888. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98889. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98890. INVERTCUBICMAP: boolean;
  98891. LOGARITHMICDEPTH: boolean;
  98892. REFRACTION: boolean;
  98893. REFRACTIONMAP_3D: boolean;
  98894. REFLECTIONOVERALPHA: boolean;
  98895. TWOSIDEDLIGHTING: boolean;
  98896. SHADOWFLOAT: boolean;
  98897. MORPHTARGETS: boolean;
  98898. MORPHTARGETS_NORMAL: boolean;
  98899. MORPHTARGETS_TANGENT: boolean;
  98900. MORPHTARGETS_UV: boolean;
  98901. NUM_MORPH_INFLUENCERS: number;
  98902. NONUNIFORMSCALING: boolean;
  98903. PREMULTIPLYALPHA: boolean;
  98904. IMAGEPROCESSING: boolean;
  98905. VIGNETTE: boolean;
  98906. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98907. VIGNETTEBLENDMODEOPAQUE: boolean;
  98908. TONEMAPPING: boolean;
  98909. TONEMAPPING_ACES: boolean;
  98910. CONTRAST: boolean;
  98911. COLORCURVES: boolean;
  98912. COLORGRADING: boolean;
  98913. COLORGRADING3D: boolean;
  98914. SAMPLER3DGREENDEPTH: boolean;
  98915. SAMPLER3DBGRMAP: boolean;
  98916. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98917. MULTIVIEW: boolean;
  98918. /**
  98919. * If the reflection texture on this material is in linear color space
  98920. * @hidden
  98921. */
  98922. IS_REFLECTION_LINEAR: boolean;
  98923. /**
  98924. * If the refraction texture on this material is in linear color space
  98925. * @hidden
  98926. */
  98927. IS_REFRACTION_LINEAR: boolean;
  98928. EXPOSURE: boolean;
  98929. constructor();
  98930. setReflectionMode(modeToEnable: string): void;
  98931. }
  98932. /**
  98933. * This is the default material used in Babylon. It is the best trade off between quality
  98934. * and performances.
  98935. * @see http://doc.babylonjs.com/babylon101/materials
  98936. */
  98937. export class StandardMaterial extends PushMaterial {
  98938. private _diffuseTexture;
  98939. /**
  98940. * The basic texture of the material as viewed under a light.
  98941. */
  98942. diffuseTexture: Nullable<BaseTexture>;
  98943. private _ambientTexture;
  98944. /**
  98945. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98946. */
  98947. ambientTexture: Nullable<BaseTexture>;
  98948. private _opacityTexture;
  98949. /**
  98950. * Define the transparency of the material from a texture.
  98951. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98952. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98953. */
  98954. opacityTexture: Nullable<BaseTexture>;
  98955. private _reflectionTexture;
  98956. /**
  98957. * Define the texture used to display the reflection.
  98958. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98959. */
  98960. reflectionTexture: Nullable<BaseTexture>;
  98961. private _emissiveTexture;
  98962. /**
  98963. * Define texture of the material as if self lit.
  98964. * This will be mixed in the final result even in the absence of light.
  98965. */
  98966. emissiveTexture: Nullable<BaseTexture>;
  98967. private _specularTexture;
  98968. /**
  98969. * Define how the color and intensity of the highlight given by the light in the material.
  98970. */
  98971. specularTexture: Nullable<BaseTexture>;
  98972. private _bumpTexture;
  98973. /**
  98974. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98975. * 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.
  98976. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98977. */
  98978. bumpTexture: Nullable<BaseTexture>;
  98979. private _lightmapTexture;
  98980. /**
  98981. * Complex lighting can be computationally expensive to compute at runtime.
  98982. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98983. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98984. */
  98985. lightmapTexture: Nullable<BaseTexture>;
  98986. private _refractionTexture;
  98987. /**
  98988. * Define the texture used to display the refraction.
  98989. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98990. */
  98991. refractionTexture: Nullable<BaseTexture>;
  98992. /**
  98993. * The color of the material lit by the environmental background lighting.
  98994. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98995. */
  98996. ambientColor: Color3;
  98997. /**
  98998. * The basic color of the material as viewed under a light.
  98999. */
  99000. diffuseColor: Color3;
  99001. /**
  99002. * Define how the color and intensity of the highlight given by the light in the material.
  99003. */
  99004. specularColor: Color3;
  99005. /**
  99006. * Define the color of the material as if self lit.
  99007. * This will be mixed in the final result even in the absence of light.
  99008. */
  99009. emissiveColor: Color3;
  99010. /**
  99011. * Defines how sharp are the highlights in the material.
  99012. * The bigger the value the sharper giving a more glossy feeling to the result.
  99013. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99014. */
  99015. specularPower: number;
  99016. private _useAlphaFromDiffuseTexture;
  99017. /**
  99018. * Does the transparency come from the diffuse texture alpha channel.
  99019. */
  99020. useAlphaFromDiffuseTexture: boolean;
  99021. private _useEmissiveAsIllumination;
  99022. /**
  99023. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99024. */
  99025. useEmissiveAsIllumination: boolean;
  99026. private _linkEmissiveWithDiffuse;
  99027. /**
  99028. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99029. * the emissive level when the final color is close to one.
  99030. */
  99031. linkEmissiveWithDiffuse: boolean;
  99032. private _useSpecularOverAlpha;
  99033. /**
  99034. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99035. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99036. */
  99037. useSpecularOverAlpha: boolean;
  99038. private _useReflectionOverAlpha;
  99039. /**
  99040. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99041. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99042. */
  99043. useReflectionOverAlpha: boolean;
  99044. private _disableLighting;
  99045. /**
  99046. * Does lights from the scene impacts this material.
  99047. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99048. */
  99049. disableLighting: boolean;
  99050. private _useObjectSpaceNormalMap;
  99051. /**
  99052. * Allows using an object space normal map (instead of tangent space).
  99053. */
  99054. useObjectSpaceNormalMap: boolean;
  99055. private _useParallax;
  99056. /**
  99057. * Is parallax enabled or not.
  99058. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99059. */
  99060. useParallax: boolean;
  99061. private _useParallaxOcclusion;
  99062. /**
  99063. * Is parallax occlusion enabled or not.
  99064. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99065. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99066. */
  99067. useParallaxOcclusion: boolean;
  99068. /**
  99069. * 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.
  99070. */
  99071. parallaxScaleBias: number;
  99072. private _roughness;
  99073. /**
  99074. * Helps to define how blurry the reflections should appears in the material.
  99075. */
  99076. roughness: number;
  99077. /**
  99078. * In case of refraction, define the value of the index of refraction.
  99079. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99080. */
  99081. indexOfRefraction: number;
  99082. /**
  99083. * Invert the refraction texture alongside the y axis.
  99084. * It can be useful with procedural textures or probe for instance.
  99085. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99086. */
  99087. invertRefractionY: boolean;
  99088. /**
  99089. * Defines the alpha limits in alpha test mode.
  99090. */
  99091. alphaCutOff: number;
  99092. private _useLightmapAsShadowmap;
  99093. /**
  99094. * In case of light mapping, define whether the map contains light or shadow informations.
  99095. */
  99096. useLightmapAsShadowmap: boolean;
  99097. private _diffuseFresnelParameters;
  99098. /**
  99099. * Define the diffuse fresnel parameters of the material.
  99100. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99101. */
  99102. diffuseFresnelParameters: FresnelParameters;
  99103. private _opacityFresnelParameters;
  99104. /**
  99105. * Define the opacity fresnel parameters of the material.
  99106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99107. */
  99108. opacityFresnelParameters: FresnelParameters;
  99109. private _reflectionFresnelParameters;
  99110. /**
  99111. * Define the reflection fresnel parameters of the material.
  99112. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99113. */
  99114. reflectionFresnelParameters: FresnelParameters;
  99115. private _refractionFresnelParameters;
  99116. /**
  99117. * Define the refraction fresnel parameters of the material.
  99118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99119. */
  99120. refractionFresnelParameters: FresnelParameters;
  99121. private _emissiveFresnelParameters;
  99122. /**
  99123. * Define the emissive fresnel parameters of the material.
  99124. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99125. */
  99126. emissiveFresnelParameters: FresnelParameters;
  99127. private _useReflectionFresnelFromSpecular;
  99128. /**
  99129. * If true automatically deducts the fresnels values from the material specularity.
  99130. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99131. */
  99132. useReflectionFresnelFromSpecular: boolean;
  99133. private _useGlossinessFromSpecularMapAlpha;
  99134. /**
  99135. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99136. */
  99137. useGlossinessFromSpecularMapAlpha: boolean;
  99138. private _maxSimultaneousLights;
  99139. /**
  99140. * Defines the maximum number of lights that can be used in the material
  99141. */
  99142. maxSimultaneousLights: number;
  99143. private _invertNormalMapX;
  99144. /**
  99145. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99146. */
  99147. invertNormalMapX: boolean;
  99148. private _invertNormalMapY;
  99149. /**
  99150. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99151. */
  99152. invertNormalMapY: boolean;
  99153. private _twoSidedLighting;
  99154. /**
  99155. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99156. */
  99157. twoSidedLighting: boolean;
  99158. /**
  99159. * Default configuration related to image processing available in the standard Material.
  99160. */
  99161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99162. /**
  99163. * Gets the image processing configuration used either in this material.
  99164. */
  99165. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99166. /**
  99167. * Sets the Default image processing configuration used either in the this material.
  99168. *
  99169. * If sets to null, the scene one is in use.
  99170. */
  99171. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99172. /**
  99173. * Keep track of the image processing observer to allow dispose and replace.
  99174. */
  99175. private _imageProcessingObserver;
  99176. /**
  99177. * Attaches a new image processing configuration to the Standard Material.
  99178. * @param configuration
  99179. */
  99180. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99181. /**
  99182. * Gets wether the color curves effect is enabled.
  99183. */
  99184. get cameraColorCurvesEnabled(): boolean;
  99185. /**
  99186. * Sets wether the color curves effect is enabled.
  99187. */
  99188. set cameraColorCurvesEnabled(value: boolean);
  99189. /**
  99190. * Gets wether the color grading effect is enabled.
  99191. */
  99192. get cameraColorGradingEnabled(): boolean;
  99193. /**
  99194. * Gets wether the color grading effect is enabled.
  99195. */
  99196. set cameraColorGradingEnabled(value: boolean);
  99197. /**
  99198. * Gets wether tonemapping is enabled or not.
  99199. */
  99200. get cameraToneMappingEnabled(): boolean;
  99201. /**
  99202. * Sets wether tonemapping is enabled or not
  99203. */
  99204. set cameraToneMappingEnabled(value: boolean);
  99205. /**
  99206. * The camera exposure used on this material.
  99207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99208. * This corresponds to a photographic exposure.
  99209. */
  99210. get cameraExposure(): number;
  99211. /**
  99212. * The camera exposure used on this material.
  99213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99214. * This corresponds to a photographic exposure.
  99215. */
  99216. set cameraExposure(value: number);
  99217. /**
  99218. * Gets The camera contrast used on this material.
  99219. */
  99220. get cameraContrast(): number;
  99221. /**
  99222. * Sets The camera contrast used on this material.
  99223. */
  99224. set cameraContrast(value: number);
  99225. /**
  99226. * Gets the Color Grading 2D Lookup Texture.
  99227. */
  99228. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99229. /**
  99230. * Sets the Color Grading 2D Lookup Texture.
  99231. */
  99232. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99233. /**
  99234. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99235. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99236. * 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;
  99237. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99238. */
  99239. get cameraColorCurves(): Nullable<ColorCurves>;
  99240. /**
  99241. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99242. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99243. * 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;
  99244. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99245. */
  99246. set cameraColorCurves(value: Nullable<ColorCurves>);
  99247. /**
  99248. * Custom callback helping to override the default shader used in the material.
  99249. */
  99250. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99251. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99252. protected _worldViewProjectionMatrix: Matrix;
  99253. protected _globalAmbientColor: Color3;
  99254. protected _useLogarithmicDepth: boolean;
  99255. protected _rebuildInParallel: boolean;
  99256. /**
  99257. * Instantiates a new standard material.
  99258. * This is the default material used in Babylon. It is the best trade off between quality
  99259. * and performances.
  99260. * @see http://doc.babylonjs.com/babylon101/materials
  99261. * @param name Define the name of the material in the scene
  99262. * @param scene Define the scene the material belong to
  99263. */
  99264. constructor(name: string, scene: Scene);
  99265. /**
  99266. * Gets a boolean indicating that current material needs to register RTT
  99267. */
  99268. get hasRenderTargetTextures(): boolean;
  99269. /**
  99270. * Gets the current class name of the material e.g. "StandardMaterial"
  99271. * Mainly use in serialization.
  99272. * @returns the class name
  99273. */
  99274. getClassName(): string;
  99275. /**
  99276. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99277. * You can try switching to logarithmic depth.
  99278. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99279. */
  99280. get useLogarithmicDepth(): boolean;
  99281. set useLogarithmicDepth(value: boolean);
  99282. /**
  99283. * Specifies if the material will require alpha blending
  99284. * @returns a boolean specifying if alpha blending is needed
  99285. */
  99286. needAlphaBlending(): boolean;
  99287. /**
  99288. * Specifies if this material should be rendered in alpha test mode
  99289. * @returns a boolean specifying if an alpha test is needed.
  99290. */
  99291. needAlphaTesting(): boolean;
  99292. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99293. /**
  99294. * Get the texture used for alpha test purpose.
  99295. * @returns the diffuse texture in case of the standard material.
  99296. */
  99297. getAlphaTestTexture(): Nullable<BaseTexture>;
  99298. /**
  99299. * Get if the submesh is ready to be used and all its information available.
  99300. * Child classes can use it to update shaders
  99301. * @param mesh defines the mesh to check
  99302. * @param subMesh defines which submesh to check
  99303. * @param useInstances specifies that instances should be used
  99304. * @returns a boolean indicating that the submesh is ready or not
  99305. */
  99306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99307. /**
  99308. * Builds the material UBO layouts.
  99309. * Used internally during the effect preparation.
  99310. */
  99311. buildUniformLayout(): void;
  99312. /**
  99313. * Unbinds the material from the mesh
  99314. */
  99315. unbind(): void;
  99316. /**
  99317. * Binds the submesh to this material by preparing the effect and shader to draw
  99318. * @param world defines the world transformation matrix
  99319. * @param mesh defines the mesh containing the submesh
  99320. * @param subMesh defines the submesh to bind the material to
  99321. */
  99322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99323. /**
  99324. * Get the list of animatables in the material.
  99325. * @returns the list of animatables object used in the material
  99326. */
  99327. getAnimatables(): IAnimatable[];
  99328. /**
  99329. * Gets the active textures from the material
  99330. * @returns an array of textures
  99331. */
  99332. getActiveTextures(): BaseTexture[];
  99333. /**
  99334. * Specifies if the material uses a texture
  99335. * @param texture defines the texture to check against the material
  99336. * @returns a boolean specifying if the material uses the texture
  99337. */
  99338. hasTexture(texture: BaseTexture): boolean;
  99339. /**
  99340. * Disposes the material
  99341. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99342. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99343. */
  99344. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99345. /**
  99346. * Makes a duplicate of the material, and gives it a new name
  99347. * @param name defines the new name for the duplicated material
  99348. * @returns the cloned material
  99349. */
  99350. clone(name: string): StandardMaterial;
  99351. /**
  99352. * Serializes this material in a JSON representation
  99353. * @returns the serialized material object
  99354. */
  99355. serialize(): any;
  99356. /**
  99357. * Creates a standard material from parsed material data
  99358. * @param source defines the JSON representation of the material
  99359. * @param scene defines the hosting scene
  99360. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99361. * @returns a new standard material
  99362. */
  99363. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99364. /**
  99365. * Are diffuse textures enabled in the application.
  99366. */
  99367. static get DiffuseTextureEnabled(): boolean;
  99368. static set DiffuseTextureEnabled(value: boolean);
  99369. /**
  99370. * Are ambient textures enabled in the application.
  99371. */
  99372. static get AmbientTextureEnabled(): boolean;
  99373. static set AmbientTextureEnabled(value: boolean);
  99374. /**
  99375. * Are opacity textures enabled in the application.
  99376. */
  99377. static get OpacityTextureEnabled(): boolean;
  99378. static set OpacityTextureEnabled(value: boolean);
  99379. /**
  99380. * Are reflection textures enabled in the application.
  99381. */
  99382. static get ReflectionTextureEnabled(): boolean;
  99383. static set ReflectionTextureEnabled(value: boolean);
  99384. /**
  99385. * Are emissive textures enabled in the application.
  99386. */
  99387. static get EmissiveTextureEnabled(): boolean;
  99388. static set EmissiveTextureEnabled(value: boolean);
  99389. /**
  99390. * Are specular textures enabled in the application.
  99391. */
  99392. static get SpecularTextureEnabled(): boolean;
  99393. static set SpecularTextureEnabled(value: boolean);
  99394. /**
  99395. * Are bump textures enabled in the application.
  99396. */
  99397. static get BumpTextureEnabled(): boolean;
  99398. static set BumpTextureEnabled(value: boolean);
  99399. /**
  99400. * Are lightmap textures enabled in the application.
  99401. */
  99402. static get LightmapTextureEnabled(): boolean;
  99403. static set LightmapTextureEnabled(value: boolean);
  99404. /**
  99405. * Are refraction textures enabled in the application.
  99406. */
  99407. static get RefractionTextureEnabled(): boolean;
  99408. static set RefractionTextureEnabled(value: boolean);
  99409. /**
  99410. * Are color grading textures enabled in the application.
  99411. */
  99412. static get ColorGradingTextureEnabled(): boolean;
  99413. static set ColorGradingTextureEnabled(value: boolean);
  99414. /**
  99415. * Are fresnels enabled in the application.
  99416. */
  99417. static get FresnelEnabled(): boolean;
  99418. static set FresnelEnabled(value: boolean);
  99419. }
  99420. }
  99421. declare module BABYLON {
  99422. /**
  99423. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  99424. *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.
  99425. * The SPS is also a particle system. It provides some methods to manage the particles.
  99426. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  99427. *
  99428. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  99429. */
  99430. export class SolidParticleSystem implements IDisposable {
  99431. /**
  99432. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  99433. * Example : var p = SPS.particles[i];
  99434. */
  99435. particles: SolidParticle[];
  99436. /**
  99437. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  99438. */
  99439. nbParticles: number;
  99440. /**
  99441. * If the particles must ever face the camera (default false). Useful for planar particles.
  99442. */
  99443. billboard: boolean;
  99444. /**
  99445. * Recompute normals when adding a shape
  99446. */
  99447. recomputeNormals: boolean;
  99448. /**
  99449. * This a counter ofr your own usage. It's not set by any SPS functions.
  99450. */
  99451. counter: number;
  99452. /**
  99453. * The SPS name. This name is also given to the underlying mesh.
  99454. */
  99455. name: string;
  99456. /**
  99457. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  99458. */
  99459. mesh: Mesh;
  99460. /**
  99461. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  99462. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  99463. */
  99464. vars: any;
  99465. /**
  99466. * This array is populated when the SPS is set as 'pickable'.
  99467. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  99468. * Each element of this array is an object `{idx: int, faceId: int}`.
  99469. * `idx` is the picked particle index in the `SPS.particles` array
  99470. * `faceId` is the picked face index counted within this particle.
  99471. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  99472. */
  99473. pickedParticles: {
  99474. idx: number;
  99475. faceId: number;
  99476. }[];
  99477. /**
  99478. * This array is populated when `enableDepthSort` is set to true.
  99479. * Each element of this array is an instance of the class DepthSortedParticle.
  99480. */
  99481. depthSortedParticles: DepthSortedParticle[];
  99482. /**
  99483. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  99484. * @hidden
  99485. */
  99486. _bSphereOnly: boolean;
  99487. /**
  99488. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  99489. * @hidden
  99490. */
  99491. _bSphereRadiusFactor: number;
  99492. private _scene;
  99493. private _positions;
  99494. private _indices;
  99495. private _normals;
  99496. private _colors;
  99497. private _uvs;
  99498. private _indices32;
  99499. private _positions32;
  99500. private _normals32;
  99501. private _fixedNormal32;
  99502. private _colors32;
  99503. private _uvs32;
  99504. private _index;
  99505. private _updatable;
  99506. private _pickable;
  99507. private _isVisibilityBoxLocked;
  99508. private _alwaysVisible;
  99509. private _depthSort;
  99510. private _expandable;
  99511. private _shapeCounter;
  99512. private _copy;
  99513. private _color;
  99514. private _computeParticleColor;
  99515. private _computeParticleTexture;
  99516. private _computeParticleRotation;
  99517. private _computeParticleVertex;
  99518. private _computeBoundingBox;
  99519. private _depthSortParticles;
  99520. private _camera;
  99521. private _mustUnrotateFixedNormals;
  99522. private _particlesIntersect;
  99523. private _needs32Bits;
  99524. private _isNotBuilt;
  99525. private _lastParticleId;
  99526. private _idxOfId;
  99527. private _multimaterialEnabled;
  99528. private _useModelMaterial;
  99529. private _indicesByMaterial;
  99530. private _materialIndexes;
  99531. private _depthSortFunction;
  99532. private _materialSortFunction;
  99533. private _materials;
  99534. private _multimaterial;
  99535. private _materialIndexesById;
  99536. private _defaultMaterial;
  99537. private _autoUpdateSubMeshes;
  99538. /**
  99539. * Creates a SPS (Solid Particle System) object.
  99540. * @param name (String) is the SPS name, this will be the underlying mesh name.
  99541. * @param scene (Scene) is the scene in which the SPS is added.
  99542. * @param options defines the options of the sps e.g.
  99543. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  99544. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  99545. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  99546. * * 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.
  99547. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  99548. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  99549. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  99550. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  99551. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  99552. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  99553. */
  99554. constructor(name: string, scene: Scene, options?: {
  99555. updatable?: boolean;
  99556. isPickable?: boolean;
  99557. enableDepthSort?: boolean;
  99558. particleIntersection?: boolean;
  99559. boundingSphereOnly?: boolean;
  99560. bSphereRadiusFactor?: number;
  99561. expandable?: boolean;
  99562. useModelMaterial?: boolean;
  99563. enableMultiMaterial?: boolean;
  99564. });
  99565. /**
  99566. * Builds the SPS underlying mesh. Returns a standard Mesh.
  99567. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  99568. * @returns the created mesh
  99569. */
  99570. buildMesh(): Mesh;
  99571. /**
  99572. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  99573. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  99574. * Thus the particles generated from `digest()` have their property `position` set yet.
  99575. * @param mesh ( Mesh ) is the mesh to be digested
  99576. * @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
  99577. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  99578. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  99579. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99580. * @returns the current SPS
  99581. */
  99582. digest(mesh: Mesh, options?: {
  99583. facetNb?: number;
  99584. number?: number;
  99585. delta?: number;
  99586. storage?: [];
  99587. }): SolidParticleSystem;
  99588. /**
  99589. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  99590. * @hidden
  99591. */
  99592. private _unrotateFixedNormals;
  99593. /**
  99594. * Resets the temporary working copy particle
  99595. * @hidden
  99596. */
  99597. private _resetCopy;
  99598. /**
  99599. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  99600. * @param p the current index in the positions array to be updated
  99601. * @param ind the current index in the indices array
  99602. * @param shape a Vector3 array, the shape geometry
  99603. * @param positions the positions array to be updated
  99604. * @param meshInd the shape indices array
  99605. * @param indices the indices array to be updated
  99606. * @param meshUV the shape uv array
  99607. * @param uvs the uv array to be updated
  99608. * @param meshCol the shape color array
  99609. * @param colors the color array to be updated
  99610. * @param meshNor the shape normals array
  99611. * @param normals the normals array to be updated
  99612. * @param idx the particle index
  99613. * @param idxInShape the particle index in its shape
  99614. * @param options the addShape() method passed options
  99615. * @model the particle model
  99616. * @hidden
  99617. */
  99618. private _meshBuilder;
  99619. /**
  99620. * Returns a shape Vector3 array from positions float array
  99621. * @param positions float array
  99622. * @returns a vector3 array
  99623. * @hidden
  99624. */
  99625. private _posToShape;
  99626. /**
  99627. * Returns a shapeUV array from a float uvs (array deep copy)
  99628. * @param uvs as a float array
  99629. * @returns a shapeUV array
  99630. * @hidden
  99631. */
  99632. private _uvsToShapeUV;
  99633. /**
  99634. * Adds a new particle object in the particles array
  99635. * @param idx particle index in particles array
  99636. * @param id particle id
  99637. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  99638. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  99639. * @param model particle ModelShape object
  99640. * @param shapeId model shape identifier
  99641. * @param idxInShape index of the particle in the current model
  99642. * @param bInfo model bounding info object
  99643. * @param storage target storage array, if any
  99644. * @hidden
  99645. */
  99646. private _addParticle;
  99647. /**
  99648. * Adds some particles to the SPS from the model shape. Returns the shape id.
  99649. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  99650. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  99651. * @param nb (positive integer) the number of particles to be created from this model
  99652. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  99653. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  99654. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99655. * @returns the number of shapes in the system
  99656. */
  99657. addShape(mesh: Mesh, nb: number, options?: {
  99658. positionFunction?: any;
  99659. vertexFunction?: any;
  99660. storage?: [];
  99661. }): number;
  99662. /**
  99663. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  99664. * @hidden
  99665. */
  99666. private _rebuildParticle;
  99667. /**
  99668. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  99669. * @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.
  99670. * @returns the SPS.
  99671. */
  99672. rebuildMesh(reset?: boolean): SolidParticleSystem;
  99673. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  99674. * Returns an array with the removed particles.
  99675. * 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.
  99676. * The SPS can't be empty so at least one particle needs to remain in place.
  99677. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  99678. * @param start index of the first particle to remove
  99679. * @param end index of the last particle to remove (included)
  99680. * @returns an array populated with the removed particles
  99681. */
  99682. removeParticles(start: number, end: number): SolidParticle[];
  99683. /**
  99684. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  99685. * @param solidParticleArray an array populated with Solid Particles objects
  99686. * @returns the SPS
  99687. */
  99688. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  99689. /**
  99690. * Creates a new particle and modifies the SPS mesh geometry :
  99691. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  99692. * - calls _addParticle() to populate the particle array
  99693. * factorized code from addShape() and insertParticlesFromArray()
  99694. * @param idx particle index in the particles array
  99695. * @param i particle index in its shape
  99696. * @param modelShape particle ModelShape object
  99697. * @param shape shape vertex array
  99698. * @param meshInd shape indices array
  99699. * @param meshUV shape uv array
  99700. * @param meshCol shape color array
  99701. * @param meshNor shape normals array
  99702. * @param bbInfo shape bounding info
  99703. * @param storage target particle storage
  99704. * @options addShape() passed options
  99705. * @hidden
  99706. */
  99707. private _insertNewParticle;
  99708. /**
  99709. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  99710. * This method calls `updateParticle()` for each particle of the SPS.
  99711. * For an animated SPS, it is usually called within the render loop.
  99712. * 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.
  99713. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  99714. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  99715. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  99716. * @returns the SPS.
  99717. */
  99718. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  99719. /**
  99720. * Disposes the SPS.
  99721. */
  99722. dispose(): void;
  99723. /**
  99724. * Returns a SolidParticle object from its identifier : particle.id
  99725. * @param id (integer) the particle Id
  99726. * @returns the searched particle or null if not found in the SPS.
  99727. */
  99728. getParticleById(id: number): Nullable<SolidParticle>;
  99729. /**
  99730. * Returns a new array populated with the particles having the passed shapeId.
  99731. * @param shapeId (integer) the shape identifier
  99732. * @returns a new solid particle array
  99733. */
  99734. getParticlesByShapeId(shapeId: number): SolidParticle[];
  99735. /**
  99736. * Populates the passed array "ref" with the particles having the passed shapeId.
  99737. * @param shapeId the shape identifier
  99738. * @returns the SPS
  99739. * @param ref
  99740. */
  99741. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  99742. /**
  99743. * Computes the required SubMeshes according the materials assigned to the particles.
  99744. * @returns the solid particle system.
  99745. * Does nothing if called before the SPS mesh is built.
  99746. */
  99747. computeSubMeshes(): SolidParticleSystem;
  99748. /**
  99749. * Sorts the solid particles by material when MultiMaterial is enabled.
  99750. * Updates the indices32 array.
  99751. * Updates the indicesByMaterial array.
  99752. * Updates the mesh indices array.
  99753. * @returns the SPS
  99754. * @hidden
  99755. */
  99756. private _sortParticlesByMaterial;
  99757. /**
  99758. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  99759. * @hidden
  99760. */
  99761. private _setMaterialIndexesById;
  99762. /**
  99763. * Returns an array with unique values of Materials from the passed array
  99764. * @param array the material array to be checked and filtered
  99765. * @hidden
  99766. */
  99767. private _filterUniqueMaterialId;
  99768. /**
  99769. * Sets a new Standard Material as _defaultMaterial if not already set.
  99770. * @hidden
  99771. */
  99772. private _setDefaultMaterial;
  99773. /**
  99774. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  99775. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99776. * @returns the SPS.
  99777. */
  99778. refreshVisibleSize(): SolidParticleSystem;
  99779. /**
  99780. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  99781. * @param size the size (float) of the visibility box
  99782. * note : this doesn't lock the SPS mesh bounding box.
  99783. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99784. */
  99785. setVisibilityBox(size: number): void;
  99786. /**
  99787. * Gets whether the SPS as always visible or not
  99788. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99789. */
  99790. get isAlwaysVisible(): boolean;
  99791. /**
  99792. * Sets the SPS as always visible or not
  99793. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99794. */
  99795. set isAlwaysVisible(val: boolean);
  99796. /**
  99797. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99798. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99799. */
  99800. set isVisibilityBoxLocked(val: boolean);
  99801. /**
  99802. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99803. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99804. */
  99805. get isVisibilityBoxLocked(): boolean;
  99806. /**
  99807. * Tells to `setParticles()` to compute the particle rotations or not.
  99808. * Default value : true. The SPS is faster when it's set to false.
  99809. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99810. */
  99811. set computeParticleRotation(val: boolean);
  99812. /**
  99813. * Tells to `setParticles()` to compute the particle colors or not.
  99814. * Default value : true. The SPS is faster when it's set to false.
  99815. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99816. */
  99817. set computeParticleColor(val: boolean);
  99818. set computeParticleTexture(val: boolean);
  99819. /**
  99820. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  99821. * Default value : false. The SPS is faster when it's set to false.
  99822. * Note : the particle custom vertex positions aren't stored values.
  99823. */
  99824. set computeParticleVertex(val: boolean);
  99825. /**
  99826. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  99827. */
  99828. set computeBoundingBox(val: boolean);
  99829. /**
  99830. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  99831. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99832. * Default : `true`
  99833. */
  99834. set depthSortParticles(val: boolean);
  99835. /**
  99836. * Gets if `setParticles()` computes the particle rotations or not.
  99837. * Default value : true. The SPS is faster when it's set to false.
  99838. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99839. */
  99840. get computeParticleRotation(): boolean;
  99841. /**
  99842. * Gets if `setParticles()` computes the particle colors or not.
  99843. * Default value : true. The SPS is faster when it's set to false.
  99844. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99845. */
  99846. get computeParticleColor(): boolean;
  99847. /**
  99848. * Gets if `setParticles()` computes the particle textures or not.
  99849. * Default value : true. The SPS is faster when it's set to false.
  99850. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  99851. */
  99852. get computeParticleTexture(): boolean;
  99853. /**
  99854. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  99855. * Default value : false. The SPS is faster when it's set to false.
  99856. * Note : the particle custom vertex positions aren't stored values.
  99857. */
  99858. get computeParticleVertex(): boolean;
  99859. /**
  99860. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  99861. */
  99862. get computeBoundingBox(): boolean;
  99863. /**
  99864. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  99865. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99866. * Default : `true`
  99867. */
  99868. get depthSortParticles(): boolean;
  99869. /**
  99870. * Gets if the SPS is created as expandable at construction time.
  99871. * Default : `false`
  99872. */
  99873. get expandable(): boolean;
  99874. /**
  99875. * Gets if the SPS supports the Multi Materials
  99876. */
  99877. get multimaterialEnabled(): boolean;
  99878. /**
  99879. * Gets if the SPS uses the model materials for its own multimaterial.
  99880. */
  99881. get useModelMaterial(): boolean;
  99882. /**
  99883. * The SPS used material array.
  99884. */
  99885. get materials(): Material[];
  99886. /**
  99887. * Sets the SPS MultiMaterial from the passed materials.
  99888. * Note : the passed array is internally copied and not used then by reference.
  99889. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  99890. */
  99891. setMultiMaterial(materials: Material[]): void;
  99892. /**
  99893. * The SPS computed multimaterial object
  99894. */
  99895. get multimaterial(): MultiMaterial;
  99896. set multimaterial(mm: MultiMaterial);
  99897. /**
  99898. * If the subMeshes must be updated on the next call to setParticles()
  99899. */
  99900. get autoUpdateSubMeshes(): boolean;
  99901. set autoUpdateSubMeshes(val: boolean);
  99902. /**
  99903. * This function does nothing. It may be overwritten to set all the particle first values.
  99904. * The SPS doesn't call this function, you may have to call it by your own.
  99905. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99906. */
  99907. initParticles(): void;
  99908. /**
  99909. * This function does nothing. It may be overwritten to recycle a particle.
  99910. * The SPS doesn't call this function, you may have to call it by your own.
  99911. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99912. * @param particle The particle to recycle
  99913. * @returns the recycled particle
  99914. */
  99915. recycleParticle(particle: SolidParticle): SolidParticle;
  99916. /**
  99917. * Updates a particle : this function should be overwritten by the user.
  99918. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  99919. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99920. * @example : just set a particle position or velocity and recycle conditions
  99921. * @param particle The particle to update
  99922. * @returns the updated particle
  99923. */
  99924. updateParticle(particle: SolidParticle): SolidParticle;
  99925. /**
  99926. * Updates a vertex of a particle : it can be overwritten by the user.
  99927. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  99928. * @param particle the current particle
  99929. * @param vertex the current index of the current particle
  99930. * @param pt the index of the current vertex in the particle shape
  99931. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  99932. * @example : just set a vertex particle position
  99933. * @returns the updated vertex
  99934. */
  99935. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  99936. /**
  99937. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  99938. * This does nothing and may be overwritten by the user.
  99939. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99940. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99941. * @param update the boolean update value actually passed to setParticles()
  99942. */
  99943. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99944. /**
  99945. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  99946. * This will be passed three parameters.
  99947. * This does nothing and may be overwritten by the user.
  99948. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99949. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99950. * @param update the boolean update value actually passed to setParticles()
  99951. */
  99952. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99953. }
  99954. }
  99955. declare module BABYLON {
  99956. /**
  99957. * Represents one particle of a solid particle system.
  99958. */
  99959. export class SolidParticle {
  99960. /**
  99961. * particle global index
  99962. */
  99963. idx: number;
  99964. /**
  99965. * particle identifier
  99966. */
  99967. id: number;
  99968. /**
  99969. * The color of the particle
  99970. */
  99971. color: Nullable<Color4>;
  99972. /**
  99973. * The world space position of the particle.
  99974. */
  99975. position: Vector3;
  99976. /**
  99977. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  99978. */
  99979. rotation: Vector3;
  99980. /**
  99981. * The world space rotation quaternion of the particle.
  99982. */
  99983. rotationQuaternion: Nullable<Quaternion>;
  99984. /**
  99985. * The scaling of the particle.
  99986. */
  99987. scaling: Vector3;
  99988. /**
  99989. * The uvs of the particle.
  99990. */
  99991. uvs: Vector4;
  99992. /**
  99993. * The current speed of the particle.
  99994. */
  99995. velocity: Vector3;
  99996. /**
  99997. * The pivot point in the particle local space.
  99998. */
  99999. pivot: Vector3;
  100000. /**
  100001. * Must the particle be translated from its pivot point in its local space ?
  100002. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100003. * Default : false
  100004. */
  100005. translateFromPivot: boolean;
  100006. /**
  100007. * Is the particle active or not ?
  100008. */
  100009. alive: boolean;
  100010. /**
  100011. * Is the particle visible or not ?
  100012. */
  100013. isVisible: boolean;
  100014. /**
  100015. * Index of this particle in the global "positions" array (Internal use)
  100016. * @hidden
  100017. */
  100018. _pos: number;
  100019. /**
  100020. * @hidden Index of this particle in the global "indices" array (Internal use)
  100021. */
  100022. _ind: number;
  100023. /**
  100024. * @hidden ModelShape of this particle (Internal use)
  100025. */
  100026. _model: ModelShape;
  100027. /**
  100028. * ModelShape id of this particle
  100029. */
  100030. shapeId: number;
  100031. /**
  100032. * Index of the particle in its shape id
  100033. */
  100034. idxInShape: number;
  100035. /**
  100036. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100037. */
  100038. _modelBoundingInfo: BoundingInfo;
  100039. /**
  100040. * @hidden Particle BoundingInfo object (Internal use)
  100041. */
  100042. _boundingInfo: BoundingInfo;
  100043. /**
  100044. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100045. */
  100046. _sps: SolidParticleSystem;
  100047. /**
  100048. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100049. */
  100050. _stillInvisible: boolean;
  100051. /**
  100052. * @hidden Last computed particle rotation matrix
  100053. */
  100054. _rotationMatrix: number[];
  100055. /**
  100056. * Parent particle Id, if any.
  100057. * Default null.
  100058. */
  100059. parentId: Nullable<number>;
  100060. /**
  100061. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100062. */
  100063. materialIndex: Nullable<number>;
  100064. /**
  100065. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100066. * The possible values are :
  100067. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100068. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100069. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100070. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100071. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100072. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100073. * */
  100074. cullingStrategy: number;
  100075. /**
  100076. * @hidden Internal global position in the SPS.
  100077. */
  100078. _globalPosition: Vector3;
  100079. /**
  100080. * Creates a Solid Particle object.
  100081. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100082. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100083. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100084. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100085. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100086. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100087. * @param shapeId (integer) is the model shape identifier in the SPS.
  100088. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100089. * @param sps defines the sps it is associated to
  100090. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100091. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100092. */
  100093. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100094. /**
  100095. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100096. * @param target the particle target
  100097. * @returns the current particle
  100098. */
  100099. copyToRef(target: SolidParticle): SolidParticle;
  100100. /**
  100101. * Legacy support, changed scale to scaling
  100102. */
  100103. get scale(): Vector3;
  100104. /**
  100105. * Legacy support, changed scale to scaling
  100106. */
  100107. set scale(scale: Vector3);
  100108. /**
  100109. * Legacy support, changed quaternion to rotationQuaternion
  100110. */
  100111. get quaternion(): Nullable<Quaternion>;
  100112. /**
  100113. * Legacy support, changed quaternion to rotationQuaternion
  100114. */
  100115. set quaternion(q: Nullable<Quaternion>);
  100116. /**
  100117. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100118. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100119. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100120. * @returns true if it intersects
  100121. */
  100122. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100123. /**
  100124. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100125. * A particle is in the frustum if its bounding box intersects the frustum
  100126. * @param frustumPlanes defines the frustum to test
  100127. * @returns true if the particle is in the frustum planes
  100128. */
  100129. isInFrustum(frustumPlanes: Plane[]): boolean;
  100130. /**
  100131. * get the rotation matrix of the particle
  100132. * @hidden
  100133. */
  100134. getRotationMatrix(m: Matrix): void;
  100135. }
  100136. /**
  100137. * Represents the shape of the model used by one particle of a solid particle system.
  100138. * SPS internal tool, don't use it manually.
  100139. */
  100140. export class ModelShape {
  100141. /**
  100142. * The shape id
  100143. * @hidden
  100144. */
  100145. shapeID: number;
  100146. /**
  100147. * flat array of model positions (internal use)
  100148. * @hidden
  100149. */
  100150. _shape: Vector3[];
  100151. /**
  100152. * flat array of model UVs (internal use)
  100153. * @hidden
  100154. */
  100155. _shapeUV: number[];
  100156. /**
  100157. * color array of the model
  100158. * @hidden
  100159. */
  100160. _shapeColors: number[];
  100161. /**
  100162. * indices array of the model
  100163. * @hidden
  100164. */
  100165. _indices: number[];
  100166. /**
  100167. * normals array of the model
  100168. * @hidden
  100169. */
  100170. _normals: number[];
  100171. /**
  100172. * length of the shape in the model indices array (internal use)
  100173. * @hidden
  100174. */
  100175. _indicesLength: number;
  100176. /**
  100177. * Custom position function (internal use)
  100178. * @hidden
  100179. */
  100180. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100181. /**
  100182. * Custom vertex function (internal use)
  100183. * @hidden
  100184. */
  100185. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100186. /**
  100187. * Model material (internal use)
  100188. * @hidden
  100189. */
  100190. _material: Nullable<Material>;
  100191. /**
  100192. * 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.
  100193. * SPS internal tool, don't use it manually.
  100194. * @hidden
  100195. */
  100196. 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>);
  100197. }
  100198. /**
  100199. * Represents a Depth Sorted Particle in the solid particle system.
  100200. * @hidden
  100201. */
  100202. export class DepthSortedParticle {
  100203. /**
  100204. * Index of the particle in the "indices" array
  100205. */
  100206. ind: number;
  100207. /**
  100208. * Length of the particle shape in the "indices" array
  100209. */
  100210. indicesLength: number;
  100211. /**
  100212. * Squared distance from the particle to the camera
  100213. */
  100214. sqDistance: number;
  100215. /**
  100216. * Material index when used with MultiMaterials
  100217. */
  100218. materialIndex: number;
  100219. /**
  100220. * Creates a new sorted particle
  100221. * @param materialIndex
  100222. */
  100223. constructor(ind: number, indLength: number, materialIndex: number);
  100224. }
  100225. }
  100226. declare module BABYLON {
  100227. /**
  100228. * @hidden
  100229. */
  100230. export class _MeshCollisionData {
  100231. _checkCollisions: boolean;
  100232. _collisionMask: number;
  100233. _collisionGroup: number;
  100234. _collider: Nullable<Collider>;
  100235. _oldPositionForCollisions: Vector3;
  100236. _diffPositionForCollisions: Vector3;
  100237. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100238. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100239. }
  100240. }
  100241. declare module BABYLON {
  100242. /** @hidden */
  100243. class _FacetDataStorage {
  100244. facetPositions: Vector3[];
  100245. facetNormals: Vector3[];
  100246. facetPartitioning: number[][];
  100247. facetNb: number;
  100248. partitioningSubdivisions: number;
  100249. partitioningBBoxRatio: number;
  100250. facetDataEnabled: boolean;
  100251. facetParameters: any;
  100252. bbSize: Vector3;
  100253. subDiv: {
  100254. max: number;
  100255. X: number;
  100256. Y: number;
  100257. Z: number;
  100258. };
  100259. facetDepthSort: boolean;
  100260. facetDepthSortEnabled: boolean;
  100261. depthSortedIndices: IndicesArray;
  100262. depthSortedFacets: {
  100263. ind: number;
  100264. sqDistance: number;
  100265. }[];
  100266. facetDepthSortFunction: (f1: {
  100267. ind: number;
  100268. sqDistance: number;
  100269. }, f2: {
  100270. ind: number;
  100271. sqDistance: number;
  100272. }) => number;
  100273. facetDepthSortFrom: Vector3;
  100274. facetDepthSortOrigin: Vector3;
  100275. invertedMatrix: Matrix;
  100276. }
  100277. /**
  100278. * @hidden
  100279. **/
  100280. class _InternalAbstractMeshDataInfo {
  100281. _hasVertexAlpha: boolean;
  100282. _useVertexColors: boolean;
  100283. _numBoneInfluencers: number;
  100284. _applyFog: boolean;
  100285. _receiveShadows: boolean;
  100286. _facetData: _FacetDataStorage;
  100287. _visibility: number;
  100288. _skeleton: Nullable<Skeleton>;
  100289. _layerMask: number;
  100290. _computeBonesUsingShaders: boolean;
  100291. _isActive: boolean;
  100292. _onlyForInstances: boolean;
  100293. _isActiveIntermediate: boolean;
  100294. _onlyForInstancesIntermediate: boolean;
  100295. _actAsRegularMesh: boolean;
  100296. }
  100297. /**
  100298. * Class used to store all common mesh properties
  100299. */
  100300. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100301. /** No occlusion */
  100302. static OCCLUSION_TYPE_NONE: number;
  100303. /** Occlusion set to optimisitic */
  100304. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100305. /** Occlusion set to strict */
  100306. static OCCLUSION_TYPE_STRICT: number;
  100307. /** Use an accurante occlusion algorithm */
  100308. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100309. /** Use a conservative occlusion algorithm */
  100310. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100311. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100312. * Test order :
  100313. * Is the bounding sphere outside the frustum ?
  100314. * If not, are the bounding box vertices outside the frustum ?
  100315. * It not, then the cullable object is in the frustum.
  100316. */
  100317. static readonly CULLINGSTRATEGY_STANDARD: number;
  100318. /** Culling strategy : Bounding Sphere Only.
  100319. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100320. * It's also less accurate than the standard because some not visible objects can still be selected.
  100321. * Test : is the bounding sphere outside the frustum ?
  100322. * If not, then the cullable object is in the frustum.
  100323. */
  100324. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100325. /** Culling strategy : Optimistic Inclusion.
  100326. * This in an inclusion test first, then the standard exclusion test.
  100327. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  100328. * 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.
  100329. * Anyway, it's as accurate as the standard strategy.
  100330. * Test :
  100331. * Is the cullable object bounding sphere center in the frustum ?
  100332. * If not, apply the default culling strategy.
  100333. */
  100334. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  100335. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  100336. * This in an inclusion test first, then the bounding sphere only exclusion test.
  100337. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  100338. * 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.
  100339. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  100340. * Test :
  100341. * Is the cullable object bounding sphere center in the frustum ?
  100342. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  100343. */
  100344. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  100345. /**
  100346. * No billboard
  100347. */
  100348. static get BILLBOARDMODE_NONE(): number;
  100349. /** Billboard on X axis */
  100350. static get BILLBOARDMODE_X(): number;
  100351. /** Billboard on Y axis */
  100352. static get BILLBOARDMODE_Y(): number;
  100353. /** Billboard on Z axis */
  100354. static get BILLBOARDMODE_Z(): number;
  100355. /** Billboard on all axes */
  100356. static get BILLBOARDMODE_ALL(): number;
  100357. /** Billboard on using position instead of orientation */
  100358. static get BILLBOARDMODE_USE_POSITION(): number;
  100359. /** @hidden */
  100360. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  100361. /**
  100362. * The culling strategy to use to check whether the mesh must be rendered or not.
  100363. * This value can be changed at any time and will be used on the next render mesh selection.
  100364. * The possible values are :
  100365. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100366. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100367. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100368. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100369. * Please read each static variable documentation to get details about the culling process.
  100370. * */
  100371. cullingStrategy: number;
  100372. /**
  100373. * Gets the number of facets in the mesh
  100374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100375. */
  100376. get facetNb(): number;
  100377. /**
  100378. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  100379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100380. */
  100381. get partitioningSubdivisions(): number;
  100382. set partitioningSubdivisions(nb: number);
  100383. /**
  100384. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  100385. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  100386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100387. */
  100388. get partitioningBBoxRatio(): number;
  100389. set partitioningBBoxRatio(ratio: number);
  100390. /**
  100391. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  100392. * Works only for updatable meshes.
  100393. * Doesn't work with multi-materials
  100394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100395. */
  100396. get mustDepthSortFacets(): boolean;
  100397. set mustDepthSortFacets(sort: boolean);
  100398. /**
  100399. * The location (Vector3) where the facet depth sort must be computed from.
  100400. * By default, the active camera position.
  100401. * Used only when facet depth sort is enabled
  100402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100403. */
  100404. get facetDepthSortFrom(): Vector3;
  100405. set facetDepthSortFrom(location: Vector3);
  100406. /**
  100407. * gets a boolean indicating if facetData is enabled
  100408. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100409. */
  100410. get isFacetDataEnabled(): boolean;
  100411. /** @hidden */
  100412. _updateNonUniformScalingState(value: boolean): boolean;
  100413. /**
  100414. * An event triggered when this mesh collides with another one
  100415. */
  100416. onCollideObservable: Observable<AbstractMesh>;
  100417. /** Set a function to call when this mesh collides with another one */
  100418. set onCollide(callback: () => void);
  100419. /**
  100420. * An event triggered when the collision's position changes
  100421. */
  100422. onCollisionPositionChangeObservable: Observable<Vector3>;
  100423. /** Set a function to call when the collision's position changes */
  100424. set onCollisionPositionChange(callback: () => void);
  100425. /**
  100426. * An event triggered when material is changed
  100427. */
  100428. onMaterialChangedObservable: Observable<AbstractMesh>;
  100429. /**
  100430. * Gets or sets the orientation for POV movement & rotation
  100431. */
  100432. definedFacingForward: boolean;
  100433. /** @hidden */
  100434. _occlusionQuery: Nullable<WebGLQuery>;
  100435. /** @hidden */
  100436. _renderingGroup: Nullable<RenderingGroup>;
  100437. /**
  100438. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100439. */
  100440. get visibility(): number;
  100441. /**
  100442. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100443. */
  100444. set visibility(value: number);
  100445. /** Gets or sets the alpha index used to sort transparent meshes
  100446. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  100447. */
  100448. alphaIndex: number;
  100449. /**
  100450. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  100451. */
  100452. isVisible: boolean;
  100453. /**
  100454. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  100455. */
  100456. isPickable: boolean;
  100457. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  100458. showSubMeshesBoundingBox: boolean;
  100459. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  100460. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100461. */
  100462. isBlocker: boolean;
  100463. /**
  100464. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  100465. */
  100466. enablePointerMoveEvents: boolean;
  100467. /**
  100468. * Specifies the rendering group id for this mesh (0 by default)
  100469. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  100470. */
  100471. renderingGroupId: number;
  100472. private _material;
  100473. /** Gets or sets current material */
  100474. get material(): Nullable<Material>;
  100475. set material(value: Nullable<Material>);
  100476. /**
  100477. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  100478. * @see http://doc.babylonjs.com/babylon101/shadows
  100479. */
  100480. get receiveShadows(): boolean;
  100481. set receiveShadows(value: boolean);
  100482. /** Defines color to use when rendering outline */
  100483. outlineColor: Color3;
  100484. /** Define width to use when rendering outline */
  100485. outlineWidth: number;
  100486. /** Defines color to use when rendering overlay */
  100487. overlayColor: Color3;
  100488. /** Defines alpha to use when rendering overlay */
  100489. overlayAlpha: number;
  100490. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  100491. get hasVertexAlpha(): boolean;
  100492. set hasVertexAlpha(value: boolean);
  100493. /** 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) */
  100494. get useVertexColors(): boolean;
  100495. set useVertexColors(value: boolean);
  100496. /**
  100497. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  100498. */
  100499. get computeBonesUsingShaders(): boolean;
  100500. set computeBonesUsingShaders(value: boolean);
  100501. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  100502. get numBoneInfluencers(): number;
  100503. set numBoneInfluencers(value: number);
  100504. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  100505. get applyFog(): boolean;
  100506. set applyFog(value: boolean);
  100507. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  100508. useOctreeForRenderingSelection: boolean;
  100509. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  100510. useOctreeForPicking: boolean;
  100511. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  100512. useOctreeForCollisions: boolean;
  100513. /**
  100514. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  100515. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  100516. */
  100517. get layerMask(): number;
  100518. set layerMask(value: number);
  100519. /**
  100520. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  100521. */
  100522. alwaysSelectAsActiveMesh: boolean;
  100523. /**
  100524. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  100525. */
  100526. doNotSyncBoundingInfo: boolean;
  100527. /**
  100528. * Gets or sets the current action manager
  100529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100530. */
  100531. actionManager: Nullable<AbstractActionManager>;
  100532. private _meshCollisionData;
  100533. /**
  100534. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  100535. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100536. */
  100537. ellipsoid: Vector3;
  100538. /**
  100539. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  100540. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100541. */
  100542. ellipsoidOffset: Vector3;
  100543. /**
  100544. * Gets or sets a collision mask used to mask collisions (default is -1).
  100545. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100546. */
  100547. get collisionMask(): number;
  100548. set collisionMask(mask: number);
  100549. /**
  100550. * Gets or sets the current collision group mask (-1 by default).
  100551. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100552. */
  100553. get collisionGroup(): number;
  100554. set collisionGroup(mask: number);
  100555. /**
  100556. * Defines edge width used when edgesRenderer is enabled
  100557. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100558. */
  100559. edgesWidth: number;
  100560. /**
  100561. * Defines edge color used when edgesRenderer is enabled
  100562. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100563. */
  100564. edgesColor: Color4;
  100565. /** @hidden */
  100566. _edgesRenderer: Nullable<IEdgesRenderer>;
  100567. /** @hidden */
  100568. _masterMesh: Nullable<AbstractMesh>;
  100569. /** @hidden */
  100570. _boundingInfo: Nullable<BoundingInfo>;
  100571. /** @hidden */
  100572. _renderId: number;
  100573. /**
  100574. * Gets or sets the list of subMeshes
  100575. * @see http://doc.babylonjs.com/how_to/multi_materials
  100576. */
  100577. subMeshes: SubMesh[];
  100578. /** @hidden */
  100579. _intersectionsInProgress: AbstractMesh[];
  100580. /** @hidden */
  100581. _unIndexed: boolean;
  100582. /** @hidden */
  100583. _lightSources: Light[];
  100584. /** Gets the list of lights affecting that mesh */
  100585. get lightSources(): Light[];
  100586. /** @hidden */
  100587. get _positions(): Nullable<Vector3[]>;
  100588. /** @hidden */
  100589. _waitingData: {
  100590. lods: Nullable<any>;
  100591. actions: Nullable<any>;
  100592. freezeWorldMatrix: Nullable<boolean>;
  100593. };
  100594. /** @hidden */
  100595. _bonesTransformMatrices: Nullable<Float32Array>;
  100596. /** @hidden */
  100597. _transformMatrixTexture: Nullable<RawTexture>;
  100598. /**
  100599. * Gets or sets a skeleton to apply skining transformations
  100600. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100601. */
  100602. set skeleton(value: Nullable<Skeleton>);
  100603. get skeleton(): Nullable<Skeleton>;
  100604. /**
  100605. * An event triggered when the mesh is rebuilt.
  100606. */
  100607. onRebuildObservable: Observable<AbstractMesh>;
  100608. /**
  100609. * Creates a new AbstractMesh
  100610. * @param name defines the name of the mesh
  100611. * @param scene defines the hosting scene
  100612. */
  100613. constructor(name: string, scene?: Nullable<Scene>);
  100614. /**
  100615. * Returns the string "AbstractMesh"
  100616. * @returns "AbstractMesh"
  100617. */
  100618. getClassName(): string;
  100619. /**
  100620. * Gets a string representation of the current mesh
  100621. * @param fullDetails defines a boolean indicating if full details must be included
  100622. * @returns a string representation of the current mesh
  100623. */
  100624. toString(fullDetails?: boolean): string;
  100625. /**
  100626. * @hidden
  100627. */
  100628. protected _getEffectiveParent(): Nullable<Node>;
  100629. /** @hidden */
  100630. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100631. /** @hidden */
  100632. _rebuild(): void;
  100633. /** @hidden */
  100634. _resyncLightSources(): void;
  100635. /** @hidden */
  100636. _resyncLightSource(light: Light): void;
  100637. /** @hidden */
  100638. _unBindEffect(): void;
  100639. /** @hidden */
  100640. _removeLightSource(light: Light, dispose: boolean): void;
  100641. private _markSubMeshesAsDirty;
  100642. /** @hidden */
  100643. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  100644. /** @hidden */
  100645. _markSubMeshesAsAttributesDirty(): void;
  100646. /** @hidden */
  100647. _markSubMeshesAsMiscDirty(): void;
  100648. /**
  100649. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  100650. */
  100651. get scaling(): Vector3;
  100652. set scaling(newScaling: Vector3);
  100653. /**
  100654. * Returns true if the mesh is blocked. Implemented by child classes
  100655. */
  100656. get isBlocked(): boolean;
  100657. /**
  100658. * Returns the mesh itself by default. Implemented by child classes
  100659. * @param camera defines the camera to use to pick the right LOD level
  100660. * @returns the currentAbstractMesh
  100661. */
  100662. getLOD(camera: Camera): Nullable<AbstractMesh>;
  100663. /**
  100664. * Returns 0 by default. Implemented by child classes
  100665. * @returns an integer
  100666. */
  100667. getTotalVertices(): number;
  100668. /**
  100669. * Returns a positive integer : the total number of indices in this mesh geometry.
  100670. * @returns the numner of indices or zero if the mesh has no geometry.
  100671. */
  100672. getTotalIndices(): number;
  100673. /**
  100674. * Returns null by default. Implemented by child classes
  100675. * @returns null
  100676. */
  100677. getIndices(): Nullable<IndicesArray>;
  100678. /**
  100679. * Returns the array of the requested vertex data kind. Implemented by child classes
  100680. * @param kind defines the vertex data kind to use
  100681. * @returns null
  100682. */
  100683. getVerticesData(kind: string): Nullable<FloatArray>;
  100684. /**
  100685. * Sets the vertex data of the mesh geometry for the requested `kind`.
  100686. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  100687. * Note that a new underlying VertexBuffer object is created each call.
  100688. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  100689. * @param kind defines vertex data kind:
  100690. * * VertexBuffer.PositionKind
  100691. * * VertexBuffer.UVKind
  100692. * * VertexBuffer.UV2Kind
  100693. * * VertexBuffer.UV3Kind
  100694. * * VertexBuffer.UV4Kind
  100695. * * VertexBuffer.UV5Kind
  100696. * * VertexBuffer.UV6Kind
  100697. * * VertexBuffer.ColorKind
  100698. * * VertexBuffer.MatricesIndicesKind
  100699. * * VertexBuffer.MatricesIndicesExtraKind
  100700. * * VertexBuffer.MatricesWeightsKind
  100701. * * VertexBuffer.MatricesWeightsExtraKind
  100702. * @param data defines the data source
  100703. * @param updatable defines if the data must be flagged as updatable (or static)
  100704. * @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
  100705. * @returns the current mesh
  100706. */
  100707. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100708. /**
  100709. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  100710. * If the mesh has no geometry, it is simply returned as it is.
  100711. * @param kind defines vertex data kind:
  100712. * * VertexBuffer.PositionKind
  100713. * * VertexBuffer.UVKind
  100714. * * VertexBuffer.UV2Kind
  100715. * * VertexBuffer.UV3Kind
  100716. * * VertexBuffer.UV4Kind
  100717. * * VertexBuffer.UV5Kind
  100718. * * VertexBuffer.UV6Kind
  100719. * * VertexBuffer.ColorKind
  100720. * * VertexBuffer.MatricesIndicesKind
  100721. * * VertexBuffer.MatricesIndicesExtraKind
  100722. * * VertexBuffer.MatricesWeightsKind
  100723. * * VertexBuffer.MatricesWeightsExtraKind
  100724. * @param data defines the data source
  100725. * @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
  100726. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  100727. * @returns the current mesh
  100728. */
  100729. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100730. /**
  100731. * Sets the mesh indices,
  100732. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  100733. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  100734. * @param totalVertices Defines the total number of vertices
  100735. * @returns the current mesh
  100736. */
  100737. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  100738. /**
  100739. * Gets a boolean indicating if specific vertex data is present
  100740. * @param kind defines the vertex data kind to use
  100741. * @returns true is data kind is present
  100742. */
  100743. isVerticesDataPresent(kind: string): boolean;
  100744. /**
  100745. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  100746. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  100747. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  100748. * @returns a BoundingInfo
  100749. */
  100750. getBoundingInfo(): BoundingInfo;
  100751. /**
  100752. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  100753. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  100754. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  100755. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  100756. * @returns the current mesh
  100757. */
  100758. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  100759. /**
  100760. * Overwrite the current bounding info
  100761. * @param boundingInfo defines the new bounding info
  100762. * @returns the current mesh
  100763. */
  100764. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  100765. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  100766. get useBones(): boolean;
  100767. /** @hidden */
  100768. _preActivate(): void;
  100769. /** @hidden */
  100770. _preActivateForIntermediateRendering(renderId: number): void;
  100771. /** @hidden */
  100772. _activate(renderId: number, intermediateRendering: boolean): boolean;
  100773. /** @hidden */
  100774. _postActivate(): void;
  100775. /** @hidden */
  100776. _freeze(): void;
  100777. /** @hidden */
  100778. _unFreeze(): void;
  100779. /**
  100780. * Gets the current world matrix
  100781. * @returns a Matrix
  100782. */
  100783. getWorldMatrix(): Matrix;
  100784. /** @hidden */
  100785. _getWorldMatrixDeterminant(): number;
  100786. /**
  100787. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  100788. */
  100789. get isAnInstance(): boolean;
  100790. /**
  100791. * Gets a boolean indicating if this mesh has instances
  100792. */
  100793. get hasInstances(): boolean;
  100794. /**
  100795. * Perform relative position change from the point of view of behind the front of the mesh.
  100796. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100797. * Supports definition of mesh facing forward or backward
  100798. * @param amountRight defines the distance on the right axis
  100799. * @param amountUp defines the distance on the up axis
  100800. * @param amountForward defines the distance on the forward axis
  100801. * @returns the current mesh
  100802. */
  100803. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  100804. /**
  100805. * Calculate relative position change from the point of view of behind the front of the mesh.
  100806. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100807. * Supports definition of mesh facing forward or backward
  100808. * @param amountRight defines the distance on the right axis
  100809. * @param amountUp defines the distance on the up axis
  100810. * @param amountForward defines the distance on the forward axis
  100811. * @returns the new displacement vector
  100812. */
  100813. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  100814. /**
  100815. * Perform relative rotation change from the point of view of behind the front of the mesh.
  100816. * Supports definition of mesh facing forward or backward
  100817. * @param flipBack defines the flip
  100818. * @param twirlClockwise defines the twirl
  100819. * @param tiltRight defines the tilt
  100820. * @returns the current mesh
  100821. */
  100822. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  100823. /**
  100824. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  100825. * Supports definition of mesh facing forward or backward.
  100826. * @param flipBack defines the flip
  100827. * @param twirlClockwise defines the twirl
  100828. * @param tiltRight defines the tilt
  100829. * @returns the new rotation vector
  100830. */
  100831. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  100832. /**
  100833. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  100834. * This means the mesh underlying bounding box and sphere are recomputed.
  100835. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  100836. * @returns the current mesh
  100837. */
  100838. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  100839. /** @hidden */
  100840. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  100841. /** @hidden */
  100842. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  100843. /** @hidden */
  100844. _updateBoundingInfo(): AbstractMesh;
  100845. /** @hidden */
  100846. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  100847. /** @hidden */
  100848. protected _afterComputeWorldMatrix(): void;
  100849. /** @hidden */
  100850. get _effectiveMesh(): AbstractMesh;
  100851. /**
  100852. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  100853. * A mesh is in the frustum if its bounding box intersects the frustum
  100854. * @param frustumPlanes defines the frustum to test
  100855. * @returns true if the mesh is in the frustum planes
  100856. */
  100857. isInFrustum(frustumPlanes: Plane[]): boolean;
  100858. /**
  100859. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  100860. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  100861. * @param frustumPlanes defines the frustum to test
  100862. * @returns true if the mesh is completely in the frustum planes
  100863. */
  100864. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  100865. /**
  100866. * True if the mesh intersects another mesh or a SolidParticle object
  100867. * @param mesh defines a target mesh or SolidParticle to test
  100868. * @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)
  100869. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  100870. * @returns true if there is an intersection
  100871. */
  100872. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  100873. /**
  100874. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  100875. * @param point defines the point to test
  100876. * @returns true if there is an intersection
  100877. */
  100878. intersectsPoint(point: Vector3): boolean;
  100879. /**
  100880. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  100881. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100882. */
  100883. get checkCollisions(): boolean;
  100884. set checkCollisions(collisionEnabled: boolean);
  100885. /**
  100886. * Gets Collider object used to compute collisions (not physics)
  100887. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100888. */
  100889. get collider(): Nullable<Collider>;
  100890. /**
  100891. * Move the mesh using collision engine
  100892. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100893. * @param displacement defines the requested displacement vector
  100894. * @returns the current mesh
  100895. */
  100896. moveWithCollisions(displacement: Vector3): AbstractMesh;
  100897. private _onCollisionPositionChange;
  100898. /** @hidden */
  100899. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  100900. /** @hidden */
  100901. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  100902. /** @hidden */
  100903. _checkCollision(collider: Collider): AbstractMesh;
  100904. /** @hidden */
  100905. _generatePointsArray(): boolean;
  100906. /**
  100907. * Checks if the passed Ray intersects with the mesh
  100908. * @param ray defines the ray to use
  100909. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  100910. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100911. * @returns the picking info
  100912. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  100913. */
  100914. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  100915. /**
  100916. * Clones the current mesh
  100917. * @param name defines the mesh name
  100918. * @param newParent defines the new mesh parent
  100919. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  100920. * @returns the new mesh
  100921. */
  100922. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  100923. /**
  100924. * Disposes all the submeshes of the current meshnp
  100925. * @returns the current mesh
  100926. */
  100927. releaseSubMeshes(): AbstractMesh;
  100928. /**
  100929. * Releases resources associated with this abstract mesh.
  100930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100932. */
  100933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100934. /**
  100935. * Adds the passed mesh as a child to the current mesh
  100936. * @param mesh defines the child mesh
  100937. * @returns the current mesh
  100938. */
  100939. addChild(mesh: AbstractMesh): AbstractMesh;
  100940. /**
  100941. * Removes the passed mesh from the current mesh children list
  100942. * @param mesh defines the child mesh
  100943. * @returns the current mesh
  100944. */
  100945. removeChild(mesh: AbstractMesh): AbstractMesh;
  100946. /** @hidden */
  100947. private _initFacetData;
  100948. /**
  100949. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  100950. * This method can be called within the render loop.
  100951. * 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
  100952. * @returns the current mesh
  100953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100954. */
  100955. updateFacetData(): AbstractMesh;
  100956. /**
  100957. * Returns the facetLocalNormals array.
  100958. * The normals are expressed in the mesh local spac
  100959. * @returns an array of Vector3
  100960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100961. */
  100962. getFacetLocalNormals(): Vector3[];
  100963. /**
  100964. * Returns the facetLocalPositions array.
  100965. * The facet positions are expressed in the mesh local space
  100966. * @returns an array of Vector3
  100967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100968. */
  100969. getFacetLocalPositions(): Vector3[];
  100970. /**
  100971. * Returns the facetLocalPartioning array
  100972. * @returns an array of array of numbers
  100973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100974. */
  100975. getFacetLocalPartitioning(): number[][];
  100976. /**
  100977. * Returns the i-th facet position in the world system.
  100978. * This method allocates a new Vector3 per call
  100979. * @param i defines the facet index
  100980. * @returns a new Vector3
  100981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100982. */
  100983. getFacetPosition(i: number): Vector3;
  100984. /**
  100985. * Sets the reference Vector3 with the i-th facet position in the world system
  100986. * @param i defines the facet index
  100987. * @param ref defines the target vector
  100988. * @returns the current mesh
  100989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100990. */
  100991. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  100992. /**
  100993. * Returns the i-th facet normal in the world system.
  100994. * This method allocates a new Vector3 per call
  100995. * @param i defines the facet index
  100996. * @returns a new Vector3
  100997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100998. */
  100999. getFacetNormal(i: number): Vector3;
  101000. /**
  101001. * Sets the reference Vector3 with the i-th facet normal in the world system
  101002. * @param i defines the facet index
  101003. * @param ref defines the target vector
  101004. * @returns the current mesh
  101005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101006. */
  101007. getFacetNormalToRef(i: number, ref: Vector3): this;
  101008. /**
  101009. * 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)
  101010. * @param x defines x coordinate
  101011. * @param y defines y coordinate
  101012. * @param z defines z coordinate
  101013. * @returns the array of facet indexes
  101014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101015. */
  101016. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101017. /**
  101018. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101019. * @param projected sets as the (x,y,z) world projection on the facet
  101020. * @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
  101021. * @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
  101022. * @param x defines x coordinate
  101023. * @param y defines y coordinate
  101024. * @param z defines z coordinate
  101025. * @returns the face index if found (or null instead)
  101026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101027. */
  101028. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101029. /**
  101030. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101031. * @param projected sets as the (x,y,z) local projection on the facet
  101032. * @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
  101033. * @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
  101034. * @param x defines x coordinate
  101035. * @param y defines y coordinate
  101036. * @param z defines z coordinate
  101037. * @returns the face index if found (or null instead)
  101038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101039. */
  101040. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101041. /**
  101042. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101043. * @returns the parameters
  101044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101045. */
  101046. getFacetDataParameters(): any;
  101047. /**
  101048. * Disables the feature FacetData and frees the related memory
  101049. * @returns the current mesh
  101050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101051. */
  101052. disableFacetData(): AbstractMesh;
  101053. /**
  101054. * Updates the AbstractMesh indices array
  101055. * @param indices defines the data source
  101056. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101057. * @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)
  101058. * @returns the current mesh
  101059. */
  101060. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101061. /**
  101062. * Creates new normals data for the mesh
  101063. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101064. * @returns the current mesh
  101065. */
  101066. createNormals(updatable: boolean): AbstractMesh;
  101067. /**
  101068. * Align the mesh with a normal
  101069. * @param normal defines the normal to use
  101070. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101071. * @returns the current mesh
  101072. */
  101073. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101074. /** @hidden */
  101075. _checkOcclusionQuery(): boolean;
  101076. /**
  101077. * Disables the mesh edge rendering mode
  101078. * @returns the currentAbstractMesh
  101079. */
  101080. disableEdgesRendering(): AbstractMesh;
  101081. /**
  101082. * Enables the edge rendering mode on the mesh.
  101083. * This mode makes the mesh edges visible
  101084. * @param epsilon defines the maximal distance between two angles to detect a face
  101085. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101086. * @returns the currentAbstractMesh
  101087. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101088. */
  101089. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101090. }
  101091. }
  101092. declare module BABYLON {
  101093. /**
  101094. * Interface used to define ActionEvent
  101095. */
  101096. export interface IActionEvent {
  101097. /** The mesh or sprite that triggered the action */
  101098. source: any;
  101099. /** The X mouse cursor position at the time of the event */
  101100. pointerX: number;
  101101. /** The Y mouse cursor position at the time of the event */
  101102. pointerY: number;
  101103. /** The mesh that is currently pointed at (can be null) */
  101104. meshUnderPointer: Nullable<AbstractMesh>;
  101105. /** the original (browser) event that triggered the ActionEvent */
  101106. sourceEvent?: any;
  101107. /** additional data for the event */
  101108. additionalData?: any;
  101109. }
  101110. /**
  101111. * ActionEvent is the event being sent when an action is triggered.
  101112. */
  101113. export class ActionEvent implements IActionEvent {
  101114. /** The mesh or sprite that triggered the action */
  101115. source: any;
  101116. /** The X mouse cursor position at the time of the event */
  101117. pointerX: number;
  101118. /** The Y mouse cursor position at the time of the event */
  101119. pointerY: number;
  101120. /** The mesh that is currently pointed at (can be null) */
  101121. meshUnderPointer: Nullable<AbstractMesh>;
  101122. /** the original (browser) event that triggered the ActionEvent */
  101123. sourceEvent?: any;
  101124. /** additional data for the event */
  101125. additionalData?: any;
  101126. /**
  101127. * Creates a new ActionEvent
  101128. * @param source The mesh or sprite that triggered the action
  101129. * @param pointerX The X mouse cursor position at the time of the event
  101130. * @param pointerY The Y mouse cursor position at the time of the event
  101131. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101132. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101133. * @param additionalData additional data for the event
  101134. */
  101135. constructor(
  101136. /** The mesh or sprite that triggered the action */
  101137. source: any,
  101138. /** The X mouse cursor position at the time of the event */
  101139. pointerX: number,
  101140. /** The Y mouse cursor position at the time of the event */
  101141. pointerY: number,
  101142. /** The mesh that is currently pointed at (can be null) */
  101143. meshUnderPointer: Nullable<AbstractMesh>,
  101144. /** the original (browser) event that triggered the ActionEvent */
  101145. sourceEvent?: any,
  101146. /** additional data for the event */
  101147. additionalData?: any);
  101148. /**
  101149. * Helper function to auto-create an ActionEvent from a source mesh.
  101150. * @param source The source mesh that triggered the event
  101151. * @param evt The original (browser) event
  101152. * @param additionalData additional data for the event
  101153. * @returns the new ActionEvent
  101154. */
  101155. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101156. /**
  101157. * Helper function to auto-create an ActionEvent from a source sprite
  101158. * @param source The source sprite that triggered the event
  101159. * @param scene Scene associated with the sprite
  101160. * @param evt The original (browser) event
  101161. * @param additionalData additional data for the event
  101162. * @returns the new ActionEvent
  101163. */
  101164. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101165. /**
  101166. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101167. * @param scene the scene where the event occurred
  101168. * @param evt The original (browser) event
  101169. * @returns the new ActionEvent
  101170. */
  101171. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101172. /**
  101173. * Helper function to auto-create an ActionEvent from a primitive
  101174. * @param prim defines the target primitive
  101175. * @param pointerPos defines the pointer position
  101176. * @param evt The original (browser) event
  101177. * @param additionalData additional data for the event
  101178. * @returns the new ActionEvent
  101179. */
  101180. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101181. }
  101182. }
  101183. declare module BABYLON {
  101184. /**
  101185. * Abstract class used to decouple action Manager from scene and meshes.
  101186. * Do not instantiate.
  101187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101188. */
  101189. export abstract class AbstractActionManager implements IDisposable {
  101190. /** Gets the list of active triggers */
  101191. static Triggers: {
  101192. [key: string]: number;
  101193. };
  101194. /** Gets the cursor to use when hovering items */
  101195. hoverCursor: string;
  101196. /** Gets the list of actions */
  101197. actions: IAction[];
  101198. /**
  101199. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101200. */
  101201. isRecursive: boolean;
  101202. /**
  101203. * Releases all associated resources
  101204. */
  101205. abstract dispose(): void;
  101206. /**
  101207. * Does this action manager has pointer triggers
  101208. */
  101209. abstract get hasPointerTriggers(): boolean;
  101210. /**
  101211. * Does this action manager has pick triggers
  101212. */
  101213. abstract get hasPickTriggers(): boolean;
  101214. /**
  101215. * Process a specific trigger
  101216. * @param trigger defines the trigger to process
  101217. * @param evt defines the event details to be processed
  101218. */
  101219. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101220. /**
  101221. * Does this action manager handles actions of any of the given triggers
  101222. * @param triggers defines the triggers to be tested
  101223. * @return a boolean indicating whether one (or more) of the triggers is handled
  101224. */
  101225. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101226. /**
  101227. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101228. * speed.
  101229. * @param triggerA defines the trigger to be tested
  101230. * @param triggerB defines the trigger to be tested
  101231. * @return a boolean indicating whether one (or more) of the triggers is handled
  101232. */
  101233. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101234. /**
  101235. * Does this action manager handles actions of a given trigger
  101236. * @param trigger defines the trigger to be tested
  101237. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101238. * @return whether the trigger is handled
  101239. */
  101240. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101241. /**
  101242. * Serialize this manager to a JSON object
  101243. * @param name defines the property name to store this manager
  101244. * @returns a JSON representation of this manager
  101245. */
  101246. abstract serialize(name: string): any;
  101247. /**
  101248. * Registers an action to this action manager
  101249. * @param action defines the action to be registered
  101250. * @return the action amended (prepared) after registration
  101251. */
  101252. abstract registerAction(action: IAction): Nullable<IAction>;
  101253. /**
  101254. * Unregisters an action to this action manager
  101255. * @param action defines the action to be unregistered
  101256. * @return a boolean indicating whether the action has been unregistered
  101257. */
  101258. abstract unregisterAction(action: IAction): Boolean;
  101259. /**
  101260. * Does exist one action manager with at least one trigger
  101261. **/
  101262. static get HasTriggers(): boolean;
  101263. /**
  101264. * Does exist one action manager with at least one pick trigger
  101265. **/
  101266. static get HasPickTriggers(): boolean;
  101267. /**
  101268. * Does exist one action manager that handles actions of a given trigger
  101269. * @param trigger defines the trigger to be tested
  101270. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101271. **/
  101272. static HasSpecificTrigger(trigger: number): boolean;
  101273. }
  101274. }
  101275. declare module BABYLON {
  101276. /**
  101277. * Defines how a node can be built from a string name.
  101278. */
  101279. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101280. /**
  101281. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101282. */
  101283. export class Node implements IBehaviorAware<Node> {
  101284. /** @hidden */
  101285. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101286. private static _NodeConstructors;
  101287. /**
  101288. * Add a new node constructor
  101289. * @param type defines the type name of the node to construct
  101290. * @param constructorFunc defines the constructor function
  101291. */
  101292. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101293. /**
  101294. * Returns a node constructor based on type name
  101295. * @param type defines the type name
  101296. * @param name defines the new node name
  101297. * @param scene defines the hosting scene
  101298. * @param options defines optional options to transmit to constructors
  101299. * @returns the new constructor or null
  101300. */
  101301. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101302. /**
  101303. * Gets or sets the name of the node
  101304. */
  101305. name: string;
  101306. /**
  101307. * Gets or sets the id of the node
  101308. */
  101309. id: string;
  101310. /**
  101311. * Gets or sets the unique id of the node
  101312. */
  101313. uniqueId: number;
  101314. /**
  101315. * Gets or sets a string used to store user defined state for the node
  101316. */
  101317. state: string;
  101318. /**
  101319. * Gets or sets an object used to store user defined information for the node
  101320. */
  101321. metadata: any;
  101322. /**
  101323. * For internal use only. Please do not use.
  101324. */
  101325. reservedDataStore: any;
  101326. /**
  101327. * List of inspectable custom properties (used by the Inspector)
  101328. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101329. */
  101330. inspectableCustomProperties: IInspectable[];
  101331. private _doNotSerialize;
  101332. /**
  101333. * Gets or sets a boolean used to define if the node must be serialized
  101334. */
  101335. get doNotSerialize(): boolean;
  101336. set doNotSerialize(value: boolean);
  101337. /** @hidden */
  101338. _isDisposed: boolean;
  101339. /**
  101340. * Gets a list of Animations associated with the node
  101341. */
  101342. animations: Animation[];
  101343. protected _ranges: {
  101344. [name: string]: Nullable<AnimationRange>;
  101345. };
  101346. /**
  101347. * Callback raised when the node is ready to be used
  101348. */
  101349. onReady: Nullable<(node: Node) => void>;
  101350. private _isEnabled;
  101351. private _isParentEnabled;
  101352. private _isReady;
  101353. /** @hidden */
  101354. _currentRenderId: number;
  101355. private _parentUpdateId;
  101356. /** @hidden */
  101357. _childUpdateId: number;
  101358. /** @hidden */
  101359. _waitingParentId: Nullable<string>;
  101360. /** @hidden */
  101361. _scene: Scene;
  101362. /** @hidden */
  101363. _cache: any;
  101364. private _parentNode;
  101365. private _children;
  101366. /** @hidden */
  101367. _worldMatrix: Matrix;
  101368. /** @hidden */
  101369. _worldMatrixDeterminant: number;
  101370. /** @hidden */
  101371. _worldMatrixDeterminantIsDirty: boolean;
  101372. /** @hidden */
  101373. private _sceneRootNodesIndex;
  101374. /**
  101375. * Gets a boolean indicating if the node has been disposed
  101376. * @returns true if the node was disposed
  101377. */
  101378. isDisposed(): boolean;
  101379. /**
  101380. * Gets or sets the parent of the node (without keeping the current position in the scene)
  101381. * @see https://doc.babylonjs.com/how_to/parenting
  101382. */
  101383. set parent(parent: Nullable<Node>);
  101384. get parent(): Nullable<Node>;
  101385. /** @hidden */
  101386. _addToSceneRootNodes(): void;
  101387. /** @hidden */
  101388. _removeFromSceneRootNodes(): void;
  101389. private _animationPropertiesOverride;
  101390. /**
  101391. * Gets or sets the animation properties override
  101392. */
  101393. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  101394. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  101395. /**
  101396. * Gets a string idenfifying the name of the class
  101397. * @returns "Node" string
  101398. */
  101399. getClassName(): string;
  101400. /** @hidden */
  101401. readonly _isNode: boolean;
  101402. /**
  101403. * An event triggered when the mesh is disposed
  101404. */
  101405. onDisposeObservable: Observable<Node>;
  101406. private _onDisposeObserver;
  101407. /**
  101408. * Sets a callback that will be raised when the node will be disposed
  101409. */
  101410. set onDispose(callback: () => void);
  101411. /**
  101412. * Creates a new Node
  101413. * @param name the name and id to be given to this node
  101414. * @param scene the scene this node will be added to
  101415. */
  101416. constructor(name: string, scene?: Nullable<Scene>);
  101417. /**
  101418. * Gets the scene of the node
  101419. * @returns a scene
  101420. */
  101421. getScene(): Scene;
  101422. /**
  101423. * Gets the engine of the node
  101424. * @returns a Engine
  101425. */
  101426. getEngine(): Engine;
  101427. private _behaviors;
  101428. /**
  101429. * Attach a behavior to the node
  101430. * @see http://doc.babylonjs.com/features/behaviour
  101431. * @param behavior defines the behavior to attach
  101432. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  101433. * @returns the current Node
  101434. */
  101435. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  101436. /**
  101437. * Remove an attached behavior
  101438. * @see http://doc.babylonjs.com/features/behaviour
  101439. * @param behavior defines the behavior to attach
  101440. * @returns the current Node
  101441. */
  101442. removeBehavior(behavior: Behavior<Node>): Node;
  101443. /**
  101444. * Gets the list of attached behaviors
  101445. * @see http://doc.babylonjs.com/features/behaviour
  101446. */
  101447. get behaviors(): Behavior<Node>[];
  101448. /**
  101449. * Gets an attached behavior by name
  101450. * @param name defines the name of the behavior to look for
  101451. * @see http://doc.babylonjs.com/features/behaviour
  101452. * @returns null if behavior was not found else the requested behavior
  101453. */
  101454. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  101455. /**
  101456. * Returns the latest update of the World matrix
  101457. * @returns a Matrix
  101458. */
  101459. getWorldMatrix(): Matrix;
  101460. /** @hidden */
  101461. _getWorldMatrixDeterminant(): number;
  101462. /**
  101463. * Returns directly the latest state of the mesh World matrix.
  101464. * A Matrix is returned.
  101465. */
  101466. get worldMatrixFromCache(): Matrix;
  101467. /** @hidden */
  101468. _initCache(): void;
  101469. /** @hidden */
  101470. updateCache(force?: boolean): void;
  101471. /** @hidden */
  101472. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101473. /** @hidden */
  101474. _updateCache(ignoreParentClass?: boolean): void;
  101475. /** @hidden */
  101476. _isSynchronized(): boolean;
  101477. /** @hidden */
  101478. _markSyncedWithParent(): void;
  101479. /** @hidden */
  101480. isSynchronizedWithParent(): boolean;
  101481. /** @hidden */
  101482. isSynchronized(): boolean;
  101483. /**
  101484. * Is this node ready to be used/rendered
  101485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101486. * @return true if the node is ready
  101487. */
  101488. isReady(completeCheck?: boolean): boolean;
  101489. /**
  101490. * Is this node enabled?
  101491. * 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
  101492. * @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
  101493. * @return whether this node (and its parent) is enabled
  101494. */
  101495. isEnabled(checkAncestors?: boolean): boolean;
  101496. /** @hidden */
  101497. protected _syncParentEnabledState(): void;
  101498. /**
  101499. * Set the enabled state of this node
  101500. * @param value defines the new enabled state
  101501. */
  101502. setEnabled(value: boolean): void;
  101503. /**
  101504. * Is this node a descendant of the given node?
  101505. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  101506. * @param ancestor defines the parent node to inspect
  101507. * @returns a boolean indicating if this node is a descendant of the given node
  101508. */
  101509. isDescendantOf(ancestor: Node): boolean;
  101510. /** @hidden */
  101511. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  101512. /**
  101513. * Will return all nodes that have this node as ascendant
  101514. * @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
  101515. * @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
  101516. * @return all children nodes of all types
  101517. */
  101518. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  101519. /**
  101520. * Get all child-meshes of this node
  101521. * @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)
  101522. * @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
  101523. * @returns an array of AbstractMesh
  101524. */
  101525. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  101526. /**
  101527. * Get all direct children of this node
  101528. * @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
  101529. * @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)
  101530. * @returns an array of Node
  101531. */
  101532. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  101533. /** @hidden */
  101534. _setReady(state: boolean): void;
  101535. /**
  101536. * Get an animation by name
  101537. * @param name defines the name of the animation to look for
  101538. * @returns null if not found else the requested animation
  101539. */
  101540. getAnimationByName(name: string): Nullable<Animation>;
  101541. /**
  101542. * Creates an animation range for this node
  101543. * @param name defines the name of the range
  101544. * @param from defines the starting key
  101545. * @param to defines the end key
  101546. */
  101547. createAnimationRange(name: string, from: number, to: number): void;
  101548. /**
  101549. * Delete a specific animation range
  101550. * @param name defines the name of the range to delete
  101551. * @param deleteFrames defines if animation frames from the range must be deleted as well
  101552. */
  101553. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  101554. /**
  101555. * Get an animation range by name
  101556. * @param name defines the name of the animation range to look for
  101557. * @returns null if not found else the requested animation range
  101558. */
  101559. getAnimationRange(name: string): Nullable<AnimationRange>;
  101560. /**
  101561. * Gets the list of all animation ranges defined on this node
  101562. * @returns an array
  101563. */
  101564. getAnimationRanges(): Nullable<AnimationRange>[];
  101565. /**
  101566. * Will start the animation sequence
  101567. * @param name defines the range frames for animation sequence
  101568. * @param loop defines if the animation should loop (false by default)
  101569. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  101570. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  101571. * @returns the object created for this animation. If range does not exist, it will return null
  101572. */
  101573. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  101574. /**
  101575. * Serialize animation ranges into a JSON compatible object
  101576. * @returns serialization object
  101577. */
  101578. serializeAnimationRanges(): any;
  101579. /**
  101580. * Computes the world matrix of the node
  101581. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101582. * @returns the world matrix
  101583. */
  101584. computeWorldMatrix(force?: boolean): Matrix;
  101585. /**
  101586. * Releases resources associated with this node.
  101587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101589. */
  101590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101591. /**
  101592. * Parse animation range data from a serialization object and store them into a given node
  101593. * @param node defines where to store the animation ranges
  101594. * @param parsedNode defines the serialization object to read data from
  101595. * @param scene defines the hosting scene
  101596. */
  101597. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  101598. /**
  101599. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  101600. * @param includeDescendants Include bounding info from descendants as well (true by default)
  101601. * @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
  101602. * @returns the new bounding vectors
  101603. */
  101604. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  101605. min: Vector3;
  101606. max: Vector3;
  101607. };
  101608. }
  101609. }
  101610. declare module BABYLON {
  101611. /**
  101612. * @hidden
  101613. */
  101614. export class _IAnimationState {
  101615. key: number;
  101616. repeatCount: number;
  101617. workValue?: any;
  101618. loopMode?: number;
  101619. offsetValue?: any;
  101620. highLimitValue?: any;
  101621. }
  101622. /**
  101623. * Class used to store any kind of animation
  101624. */
  101625. export class Animation {
  101626. /**Name of the animation */
  101627. name: string;
  101628. /**Property to animate */
  101629. targetProperty: string;
  101630. /**The frames per second of the animation */
  101631. framePerSecond: number;
  101632. /**The data type of the animation */
  101633. dataType: number;
  101634. /**The loop mode of the animation */
  101635. loopMode?: number | undefined;
  101636. /**Specifies if blending should be enabled */
  101637. enableBlending?: boolean | undefined;
  101638. /**
  101639. * Use matrix interpolation instead of using direct key value when animating matrices
  101640. */
  101641. static AllowMatricesInterpolation: boolean;
  101642. /**
  101643. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  101644. */
  101645. static AllowMatrixDecomposeForInterpolation: boolean;
  101646. /**
  101647. * Stores the key frames of the animation
  101648. */
  101649. private _keys;
  101650. /**
  101651. * Stores the easing function of the animation
  101652. */
  101653. private _easingFunction;
  101654. /**
  101655. * @hidden Internal use only
  101656. */
  101657. _runtimeAnimations: RuntimeAnimation[];
  101658. /**
  101659. * The set of event that will be linked to this animation
  101660. */
  101661. private _events;
  101662. /**
  101663. * Stores an array of target property paths
  101664. */
  101665. targetPropertyPath: string[];
  101666. /**
  101667. * Stores the blending speed of the animation
  101668. */
  101669. blendingSpeed: number;
  101670. /**
  101671. * Stores the animation ranges for the animation
  101672. */
  101673. private _ranges;
  101674. /**
  101675. * @hidden Internal use
  101676. */
  101677. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  101678. /**
  101679. * Sets up an animation
  101680. * @param property The property to animate
  101681. * @param animationType The animation type to apply
  101682. * @param framePerSecond The frames per second of the animation
  101683. * @param easingFunction The easing function used in the animation
  101684. * @returns The created animation
  101685. */
  101686. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  101687. /**
  101688. * Create and start an animation on a node
  101689. * @param name defines the name of the global animation that will be run on all nodes
  101690. * @param node defines the root node where the animation will take place
  101691. * @param targetProperty defines property to animate
  101692. * @param framePerSecond defines the number of frame per second yo use
  101693. * @param totalFrame defines the number of frames in total
  101694. * @param from defines the initial value
  101695. * @param to defines the final value
  101696. * @param loopMode defines which loop mode you want to use (off by default)
  101697. * @param easingFunction defines the easing function to use (linear by default)
  101698. * @param onAnimationEnd defines the callback to call when animation end
  101699. * @returns the animatable created for this animation
  101700. */
  101701. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101702. /**
  101703. * Create and start an animation on a node and its descendants
  101704. * @param name defines the name of the global animation that will be run on all nodes
  101705. * @param node defines the root node where the animation will take place
  101706. * @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
  101707. * @param targetProperty defines property to animate
  101708. * @param framePerSecond defines the number of frame per second to use
  101709. * @param totalFrame defines the number of frames in total
  101710. * @param from defines the initial value
  101711. * @param to defines the final value
  101712. * @param loopMode defines which loop mode you want to use (off by default)
  101713. * @param easingFunction defines the easing function to use (linear by default)
  101714. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  101715. * @returns the list of animatables created for all nodes
  101716. * @example https://www.babylonjs-playground.com/#MH0VLI
  101717. */
  101718. 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[]>;
  101719. /**
  101720. * Creates a new animation, merges it with the existing animations and starts it
  101721. * @param name Name of the animation
  101722. * @param node Node which contains the scene that begins the animations
  101723. * @param targetProperty Specifies which property to animate
  101724. * @param framePerSecond The frames per second of the animation
  101725. * @param totalFrame The total number of frames
  101726. * @param from The frame at the beginning of the animation
  101727. * @param to The frame at the end of the animation
  101728. * @param loopMode Specifies the loop mode of the animation
  101729. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  101730. * @param onAnimationEnd Callback to run once the animation is complete
  101731. * @returns Nullable animation
  101732. */
  101733. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101734. /**
  101735. * Transition property of an host to the target Value
  101736. * @param property The property to transition
  101737. * @param targetValue The target Value of the property
  101738. * @param host The object where the property to animate belongs
  101739. * @param scene Scene used to run the animation
  101740. * @param frameRate Framerate (in frame/s) to use
  101741. * @param transition The transition type we want to use
  101742. * @param duration The duration of the animation, in milliseconds
  101743. * @param onAnimationEnd Callback trigger at the end of the animation
  101744. * @returns Nullable animation
  101745. */
  101746. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  101747. /**
  101748. * Return the array of runtime animations currently using this animation
  101749. */
  101750. get runtimeAnimations(): RuntimeAnimation[];
  101751. /**
  101752. * Specifies if any of the runtime animations are currently running
  101753. */
  101754. get hasRunningRuntimeAnimations(): boolean;
  101755. /**
  101756. * Initializes the animation
  101757. * @param name Name of the animation
  101758. * @param targetProperty Property to animate
  101759. * @param framePerSecond The frames per second of the animation
  101760. * @param dataType The data type of the animation
  101761. * @param loopMode The loop mode of the animation
  101762. * @param enableBlending Specifies if blending should be enabled
  101763. */
  101764. constructor(
  101765. /**Name of the animation */
  101766. name: string,
  101767. /**Property to animate */
  101768. targetProperty: string,
  101769. /**The frames per second of the animation */
  101770. framePerSecond: number,
  101771. /**The data type of the animation */
  101772. dataType: number,
  101773. /**The loop mode of the animation */
  101774. loopMode?: number | undefined,
  101775. /**Specifies if blending should be enabled */
  101776. enableBlending?: boolean | undefined);
  101777. /**
  101778. * Converts the animation to a string
  101779. * @param fullDetails support for multiple levels of logging within scene loading
  101780. * @returns String form of the animation
  101781. */
  101782. toString(fullDetails?: boolean): string;
  101783. /**
  101784. * Add an event to this animation
  101785. * @param event Event to add
  101786. */
  101787. addEvent(event: AnimationEvent): void;
  101788. /**
  101789. * Remove all events found at the given frame
  101790. * @param frame The frame to remove events from
  101791. */
  101792. removeEvents(frame: number): void;
  101793. /**
  101794. * Retrieves all the events from the animation
  101795. * @returns Events from the animation
  101796. */
  101797. getEvents(): AnimationEvent[];
  101798. /**
  101799. * Creates an animation range
  101800. * @param name Name of the animation range
  101801. * @param from Starting frame of the animation range
  101802. * @param to Ending frame of the animation
  101803. */
  101804. createRange(name: string, from: number, to: number): void;
  101805. /**
  101806. * Deletes an animation range by name
  101807. * @param name Name of the animation range to delete
  101808. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  101809. */
  101810. deleteRange(name: string, deleteFrames?: boolean): void;
  101811. /**
  101812. * Gets the animation range by name, or null if not defined
  101813. * @param name Name of the animation range
  101814. * @returns Nullable animation range
  101815. */
  101816. getRange(name: string): Nullable<AnimationRange>;
  101817. /**
  101818. * Gets the key frames from the animation
  101819. * @returns The key frames of the animation
  101820. */
  101821. getKeys(): Array<IAnimationKey>;
  101822. /**
  101823. * Gets the highest frame rate of the animation
  101824. * @returns Highest frame rate of the animation
  101825. */
  101826. getHighestFrame(): number;
  101827. /**
  101828. * Gets the easing function of the animation
  101829. * @returns Easing function of the animation
  101830. */
  101831. getEasingFunction(): IEasingFunction;
  101832. /**
  101833. * Sets the easing function of the animation
  101834. * @param easingFunction A custom mathematical formula for animation
  101835. */
  101836. setEasingFunction(easingFunction: EasingFunction): void;
  101837. /**
  101838. * Interpolates a scalar linearly
  101839. * @param startValue Start value of the animation curve
  101840. * @param endValue End value of the animation curve
  101841. * @param gradient Scalar amount to interpolate
  101842. * @returns Interpolated scalar value
  101843. */
  101844. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  101845. /**
  101846. * Interpolates a scalar cubically
  101847. * @param startValue Start value of the animation curve
  101848. * @param outTangent End tangent of the animation
  101849. * @param endValue End value of the animation curve
  101850. * @param inTangent Start tangent of the animation curve
  101851. * @param gradient Scalar amount to interpolate
  101852. * @returns Interpolated scalar value
  101853. */
  101854. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  101855. /**
  101856. * Interpolates a quaternion using a spherical linear interpolation
  101857. * @param startValue Start value of the animation curve
  101858. * @param endValue End value of the animation curve
  101859. * @param gradient Scalar amount to interpolate
  101860. * @returns Interpolated quaternion value
  101861. */
  101862. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  101863. /**
  101864. * Interpolates a quaternion cubically
  101865. * @param startValue Start value of the animation curve
  101866. * @param outTangent End tangent of the animation curve
  101867. * @param endValue End value of the animation curve
  101868. * @param inTangent Start tangent of the animation curve
  101869. * @param gradient Scalar amount to interpolate
  101870. * @returns Interpolated quaternion value
  101871. */
  101872. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  101873. /**
  101874. * Interpolates a Vector3 linearl
  101875. * @param startValue Start value of the animation curve
  101876. * @param endValue End value of the animation curve
  101877. * @param gradient Scalar amount to interpolate
  101878. * @returns Interpolated scalar value
  101879. */
  101880. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  101881. /**
  101882. * Interpolates a Vector3 cubically
  101883. * @param startValue Start value of the animation curve
  101884. * @param outTangent End tangent of the animation
  101885. * @param endValue End value of the animation curve
  101886. * @param inTangent Start tangent of the animation curve
  101887. * @param gradient Scalar amount to interpolate
  101888. * @returns InterpolatedVector3 value
  101889. */
  101890. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  101891. /**
  101892. * Interpolates a Vector2 linearly
  101893. * @param startValue Start value of the animation curve
  101894. * @param endValue End value of the animation curve
  101895. * @param gradient Scalar amount to interpolate
  101896. * @returns Interpolated Vector2 value
  101897. */
  101898. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  101899. /**
  101900. * Interpolates a Vector2 cubically
  101901. * @param startValue Start value of the animation curve
  101902. * @param outTangent End tangent of the animation
  101903. * @param endValue End value of the animation curve
  101904. * @param inTangent Start tangent of the animation curve
  101905. * @param gradient Scalar amount to interpolate
  101906. * @returns Interpolated Vector2 value
  101907. */
  101908. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  101909. /**
  101910. * Interpolates a size linearly
  101911. * @param startValue Start value of the animation curve
  101912. * @param endValue End value of the animation curve
  101913. * @param gradient Scalar amount to interpolate
  101914. * @returns Interpolated Size value
  101915. */
  101916. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  101917. /**
  101918. * Interpolates a Color3 linearly
  101919. * @param startValue Start value of the animation curve
  101920. * @param endValue End value of the animation curve
  101921. * @param gradient Scalar amount to interpolate
  101922. * @returns Interpolated Color3 value
  101923. */
  101924. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  101925. /**
  101926. * Interpolates a Color4 linearly
  101927. * @param startValue Start value of the animation curve
  101928. * @param endValue End value of the animation curve
  101929. * @param gradient Scalar amount to interpolate
  101930. * @returns Interpolated Color3 value
  101931. */
  101932. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  101933. /**
  101934. * @hidden Internal use only
  101935. */
  101936. _getKeyValue(value: any): any;
  101937. /**
  101938. * @hidden Internal use only
  101939. */
  101940. _interpolate(currentFrame: number, state: _IAnimationState): any;
  101941. /**
  101942. * Defines the function to use to interpolate matrices
  101943. * @param startValue defines the start matrix
  101944. * @param endValue defines the end matrix
  101945. * @param gradient defines the gradient between both matrices
  101946. * @param result defines an optional target matrix where to store the interpolation
  101947. * @returns the interpolated matrix
  101948. */
  101949. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  101950. /**
  101951. * Makes a copy of the animation
  101952. * @returns Cloned animation
  101953. */
  101954. clone(): Animation;
  101955. /**
  101956. * Sets the key frames of the animation
  101957. * @param values The animation key frames to set
  101958. */
  101959. setKeys(values: Array<IAnimationKey>): void;
  101960. /**
  101961. * Serializes the animation to an object
  101962. * @returns Serialized object
  101963. */
  101964. serialize(): any;
  101965. /**
  101966. * Float animation type
  101967. */
  101968. static readonly ANIMATIONTYPE_FLOAT: number;
  101969. /**
  101970. * Vector3 animation type
  101971. */
  101972. static readonly ANIMATIONTYPE_VECTOR3: number;
  101973. /**
  101974. * Quaternion animation type
  101975. */
  101976. static readonly ANIMATIONTYPE_QUATERNION: number;
  101977. /**
  101978. * Matrix animation type
  101979. */
  101980. static readonly ANIMATIONTYPE_MATRIX: number;
  101981. /**
  101982. * Color3 animation type
  101983. */
  101984. static readonly ANIMATIONTYPE_COLOR3: number;
  101985. /**
  101986. * Color3 animation type
  101987. */
  101988. static readonly ANIMATIONTYPE_COLOR4: number;
  101989. /**
  101990. * Vector2 animation type
  101991. */
  101992. static readonly ANIMATIONTYPE_VECTOR2: number;
  101993. /**
  101994. * Size animation type
  101995. */
  101996. static readonly ANIMATIONTYPE_SIZE: number;
  101997. /**
  101998. * Relative Loop Mode
  101999. */
  102000. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102001. /**
  102002. * Cycle Loop Mode
  102003. */
  102004. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102005. /**
  102006. * Constant Loop Mode
  102007. */
  102008. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102009. /** @hidden */
  102010. static _UniversalLerp(left: any, right: any, amount: number): any;
  102011. /**
  102012. * Parses an animation object and creates an animation
  102013. * @param parsedAnimation Parsed animation object
  102014. * @returns Animation object
  102015. */
  102016. static Parse(parsedAnimation: any): Animation;
  102017. /**
  102018. * Appends the serialized animations from the source animations
  102019. * @param source Source containing the animations
  102020. * @param destination Target to store the animations
  102021. */
  102022. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102023. }
  102024. }
  102025. declare module BABYLON {
  102026. /**
  102027. * Interface containing an array of animations
  102028. */
  102029. export interface IAnimatable {
  102030. /**
  102031. * Array of animations
  102032. */
  102033. animations: Nullable<Array<Animation>>;
  102034. }
  102035. }
  102036. declare module BABYLON {
  102037. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102038. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102039. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102040. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102041. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102042. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102043. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102044. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102045. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102046. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102047. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102048. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102049. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102050. /**
  102051. * Decorator used to define property that can be serialized as reference to a camera
  102052. * @param sourceName defines the name of the property to decorate
  102053. */
  102054. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102055. /**
  102056. * Class used to help serialization objects
  102057. */
  102058. export class SerializationHelper {
  102059. /** @hidden */
  102060. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102061. /** @hidden */
  102062. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102063. /** @hidden */
  102064. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102065. /** @hidden */
  102066. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102067. /**
  102068. * Appends the serialized animations from the source animations
  102069. * @param source Source containing the animations
  102070. * @param destination Target to store the animations
  102071. */
  102072. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102073. /**
  102074. * Static function used to serialized a specific entity
  102075. * @param entity defines the entity to serialize
  102076. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102077. * @returns a JSON compatible object representing the serialization of the entity
  102078. */
  102079. static Serialize<T>(entity: T, serializationObject?: any): any;
  102080. /**
  102081. * Creates a new entity from a serialization data object
  102082. * @param creationFunction defines a function used to instanciated the new entity
  102083. * @param source defines the source serialization data
  102084. * @param scene defines the hosting scene
  102085. * @param rootUrl defines the root url for resources
  102086. * @returns a new entity
  102087. */
  102088. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102089. /**
  102090. * Clones an object
  102091. * @param creationFunction defines the function used to instanciate the new object
  102092. * @param source defines the source object
  102093. * @returns the cloned object
  102094. */
  102095. static Clone<T>(creationFunction: () => T, source: T): T;
  102096. /**
  102097. * Instanciates a new object based on a source one (some data will be shared between both object)
  102098. * @param creationFunction defines the function used to instanciate the new object
  102099. * @param source defines the source object
  102100. * @returns the new object
  102101. */
  102102. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102103. }
  102104. }
  102105. declare module BABYLON {
  102106. /**
  102107. * Class used to manipulate GUIDs
  102108. */
  102109. export class GUID {
  102110. /**
  102111. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102112. * Be aware Math.random() could cause collisions, but:
  102113. * "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"
  102114. * @returns a pseudo random id
  102115. */
  102116. static RandomId(): string;
  102117. }
  102118. }
  102119. declare module BABYLON {
  102120. /**
  102121. * Base class of all the textures in babylon.
  102122. * It groups all the common properties the materials, post process, lights... might need
  102123. * in order to make a correct use of the texture.
  102124. */
  102125. export class BaseTexture implements IAnimatable {
  102126. /**
  102127. * Default anisotropic filtering level for the application.
  102128. * It is set to 4 as a good tradeoff between perf and quality.
  102129. */
  102130. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102131. /**
  102132. * Gets or sets the unique id of the texture
  102133. */
  102134. uniqueId: number;
  102135. /**
  102136. * Define the name of the texture.
  102137. */
  102138. name: string;
  102139. /**
  102140. * Gets or sets an object used to store user defined information.
  102141. */
  102142. metadata: any;
  102143. /**
  102144. * For internal use only. Please do not use.
  102145. */
  102146. reservedDataStore: any;
  102147. private _hasAlpha;
  102148. /**
  102149. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102150. */
  102151. set hasAlpha(value: boolean);
  102152. get hasAlpha(): boolean;
  102153. /**
  102154. * Defines if the alpha value should be determined via the rgb values.
  102155. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102156. */
  102157. getAlphaFromRGB: boolean;
  102158. /**
  102159. * Intensity or strength of the texture.
  102160. * It is commonly used by materials to fine tune the intensity of the texture
  102161. */
  102162. level: number;
  102163. /**
  102164. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102165. * This is part of the texture as textures usually maps to one uv set.
  102166. */
  102167. coordinatesIndex: number;
  102168. private _coordinatesMode;
  102169. /**
  102170. * How a texture is mapped.
  102171. *
  102172. * | Value | Type | Description |
  102173. * | ----- | ----------------------------------- | ----------- |
  102174. * | 0 | EXPLICIT_MODE | |
  102175. * | 1 | SPHERICAL_MODE | |
  102176. * | 2 | PLANAR_MODE | |
  102177. * | 3 | CUBIC_MODE | |
  102178. * | 4 | PROJECTION_MODE | |
  102179. * | 5 | SKYBOX_MODE | |
  102180. * | 6 | INVCUBIC_MODE | |
  102181. * | 7 | EQUIRECTANGULAR_MODE | |
  102182. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102183. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102184. */
  102185. set coordinatesMode(value: number);
  102186. get coordinatesMode(): number;
  102187. /**
  102188. * | Value | Type | Description |
  102189. * | ----- | ------------------ | ----------- |
  102190. * | 0 | CLAMP_ADDRESSMODE | |
  102191. * | 1 | WRAP_ADDRESSMODE | |
  102192. * | 2 | MIRROR_ADDRESSMODE | |
  102193. */
  102194. wrapU: number;
  102195. /**
  102196. * | Value | Type | Description |
  102197. * | ----- | ------------------ | ----------- |
  102198. * | 0 | CLAMP_ADDRESSMODE | |
  102199. * | 1 | WRAP_ADDRESSMODE | |
  102200. * | 2 | MIRROR_ADDRESSMODE | |
  102201. */
  102202. wrapV: number;
  102203. /**
  102204. * | Value | Type | Description |
  102205. * | ----- | ------------------ | ----------- |
  102206. * | 0 | CLAMP_ADDRESSMODE | |
  102207. * | 1 | WRAP_ADDRESSMODE | |
  102208. * | 2 | MIRROR_ADDRESSMODE | |
  102209. */
  102210. wrapR: number;
  102211. /**
  102212. * With compliant hardware and browser (supporting anisotropic filtering)
  102213. * this defines the level of anisotropic filtering in the texture.
  102214. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102215. */
  102216. anisotropicFilteringLevel: number;
  102217. /**
  102218. * Define if the texture is a cube texture or if false a 2d texture.
  102219. */
  102220. get isCube(): boolean;
  102221. set isCube(value: boolean);
  102222. /**
  102223. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102224. */
  102225. get is3D(): boolean;
  102226. set is3D(value: boolean);
  102227. /**
  102228. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102229. */
  102230. get is2DArray(): boolean;
  102231. set is2DArray(value: boolean);
  102232. /**
  102233. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102234. * HDR texture are usually stored in linear space.
  102235. * This only impacts the PBR and Background materials
  102236. */
  102237. gammaSpace: boolean;
  102238. /**
  102239. * Gets or sets whether or not the texture contains RGBD data.
  102240. */
  102241. get isRGBD(): boolean;
  102242. set isRGBD(value: boolean);
  102243. /**
  102244. * Is Z inverted in the texture (useful in a cube texture).
  102245. */
  102246. invertZ: boolean;
  102247. /**
  102248. * Are mip maps generated for this texture or not.
  102249. */
  102250. get noMipmap(): boolean;
  102251. /**
  102252. * @hidden
  102253. */
  102254. lodLevelInAlpha: boolean;
  102255. /**
  102256. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102257. */
  102258. get lodGenerationOffset(): number;
  102259. set lodGenerationOffset(value: number);
  102260. /**
  102261. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102262. */
  102263. get lodGenerationScale(): number;
  102264. set lodGenerationScale(value: number);
  102265. /**
  102266. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102267. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102268. * average roughness values.
  102269. */
  102270. get linearSpecularLOD(): boolean;
  102271. set linearSpecularLOD(value: boolean);
  102272. /**
  102273. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102274. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102275. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102276. */
  102277. get irradianceTexture(): Nullable<BaseTexture>;
  102278. set irradianceTexture(value: Nullable<BaseTexture>);
  102279. /**
  102280. * Define if the texture is a render target.
  102281. */
  102282. isRenderTarget: boolean;
  102283. /**
  102284. * Define the unique id of the texture in the scene.
  102285. */
  102286. get uid(): string;
  102287. /**
  102288. * Return a string representation of the texture.
  102289. * @returns the texture as a string
  102290. */
  102291. toString(): string;
  102292. /**
  102293. * Get the class name of the texture.
  102294. * @returns "BaseTexture"
  102295. */
  102296. getClassName(): string;
  102297. /**
  102298. * Define the list of animation attached to the texture.
  102299. */
  102300. animations: Animation[];
  102301. /**
  102302. * An event triggered when the texture is disposed.
  102303. */
  102304. onDisposeObservable: Observable<BaseTexture>;
  102305. private _onDisposeObserver;
  102306. /**
  102307. * Callback triggered when the texture has been disposed.
  102308. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102309. */
  102310. set onDispose(callback: () => void);
  102311. /**
  102312. * Define the current state of the loading sequence when in delayed load mode.
  102313. */
  102314. delayLoadState: number;
  102315. private _scene;
  102316. /** @hidden */
  102317. _texture: Nullable<InternalTexture>;
  102318. private _uid;
  102319. /**
  102320. * Define if the texture is preventinga material to render or not.
  102321. * If not and the texture is not ready, the engine will use a default black texture instead.
  102322. */
  102323. get isBlocking(): boolean;
  102324. /**
  102325. * Instantiates a new BaseTexture.
  102326. * Base class of all the textures in babylon.
  102327. * It groups all the common properties the materials, post process, lights... might need
  102328. * in order to make a correct use of the texture.
  102329. * @param scene Define the scene the texture blongs to
  102330. */
  102331. constructor(scene: Nullable<Scene>);
  102332. /**
  102333. * Get the scene the texture belongs to.
  102334. * @returns the scene or null if undefined
  102335. */
  102336. getScene(): Nullable<Scene>;
  102337. /**
  102338. * Get the texture transform matrix used to offset tile the texture for istance.
  102339. * @returns the transformation matrix
  102340. */
  102341. getTextureMatrix(): Matrix;
  102342. /**
  102343. * Get the texture reflection matrix used to rotate/transform the reflection.
  102344. * @returns the reflection matrix
  102345. */
  102346. getReflectionTextureMatrix(): Matrix;
  102347. /**
  102348. * Get the underlying lower level texture from Babylon.
  102349. * @returns the insternal texture
  102350. */
  102351. getInternalTexture(): Nullable<InternalTexture>;
  102352. /**
  102353. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  102354. * @returns true if ready or not blocking
  102355. */
  102356. isReadyOrNotBlocking(): boolean;
  102357. /**
  102358. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  102359. * @returns true if fully ready
  102360. */
  102361. isReady(): boolean;
  102362. private _cachedSize;
  102363. /**
  102364. * Get the size of the texture.
  102365. * @returns the texture size.
  102366. */
  102367. getSize(): ISize;
  102368. /**
  102369. * Get the base size of the texture.
  102370. * It can be different from the size if the texture has been resized for POT for instance
  102371. * @returns the base size
  102372. */
  102373. getBaseSize(): ISize;
  102374. /**
  102375. * Update the sampling mode of the texture.
  102376. * Default is Trilinear mode.
  102377. *
  102378. * | Value | Type | Description |
  102379. * | ----- | ------------------ | ----------- |
  102380. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  102381. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  102382. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  102383. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  102384. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  102385. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  102386. * | 7 | NEAREST_LINEAR | |
  102387. * | 8 | NEAREST_NEAREST | |
  102388. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  102389. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  102390. * | 11 | LINEAR_LINEAR | |
  102391. * | 12 | LINEAR_NEAREST | |
  102392. *
  102393. * > _mag_: magnification filter (close to the viewer)
  102394. * > _min_: minification filter (far from the viewer)
  102395. * > _mip_: filter used between mip map levels
  102396. *@param samplingMode Define the new sampling mode of the texture
  102397. */
  102398. updateSamplingMode(samplingMode: number): void;
  102399. /**
  102400. * Scales the texture if is `canRescale()`
  102401. * @param ratio the resize factor we want to use to rescale
  102402. */
  102403. scale(ratio: number): void;
  102404. /**
  102405. * Get if the texture can rescale.
  102406. */
  102407. get canRescale(): boolean;
  102408. /** @hidden */
  102409. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  102410. /** @hidden */
  102411. _rebuild(): void;
  102412. /**
  102413. * Triggers the load sequence in delayed load mode.
  102414. */
  102415. delayLoad(): void;
  102416. /**
  102417. * Clones the texture.
  102418. * @returns the cloned texture
  102419. */
  102420. clone(): Nullable<BaseTexture>;
  102421. /**
  102422. * Get the texture underlying type (INT, FLOAT...)
  102423. */
  102424. get textureType(): number;
  102425. /**
  102426. * Get the texture underlying format (RGB, RGBA...)
  102427. */
  102428. get textureFormat(): number;
  102429. /**
  102430. * Indicates that textures need to be re-calculated for all materials
  102431. */
  102432. protected _markAllSubMeshesAsTexturesDirty(): void;
  102433. /**
  102434. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  102435. * This will returns an RGBA array buffer containing either in values (0-255) or
  102436. * float values (0-1) depending of the underlying buffer type.
  102437. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  102438. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  102439. * @param buffer defines a user defined buffer to fill with data (can be null)
  102440. * @returns The Array buffer containing the pixels data.
  102441. */
  102442. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  102443. /**
  102444. * Release and destroy the underlying lower level texture aka internalTexture.
  102445. */
  102446. releaseInternalTexture(): void;
  102447. /** @hidden */
  102448. get _lodTextureHigh(): Nullable<BaseTexture>;
  102449. /** @hidden */
  102450. get _lodTextureMid(): Nullable<BaseTexture>;
  102451. /** @hidden */
  102452. get _lodTextureLow(): Nullable<BaseTexture>;
  102453. /**
  102454. * Dispose the texture and release its associated resources.
  102455. */
  102456. dispose(): void;
  102457. /**
  102458. * Serialize the texture into a JSON representation that can be parsed later on.
  102459. * @returns the JSON representation of the texture
  102460. */
  102461. serialize(): any;
  102462. /**
  102463. * Helper function to be called back once a list of texture contains only ready textures.
  102464. * @param textures Define the list of textures to wait for
  102465. * @param callback Define the callback triggered once the entire list will be ready
  102466. */
  102467. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  102468. }
  102469. }
  102470. declare module BABYLON {
  102471. /**
  102472. * Options to be used when creating an effect.
  102473. */
  102474. export interface IEffectCreationOptions {
  102475. /**
  102476. * Atrributes that will be used in the shader.
  102477. */
  102478. attributes: string[];
  102479. /**
  102480. * Uniform varible names that will be set in the shader.
  102481. */
  102482. uniformsNames: string[];
  102483. /**
  102484. * Uniform buffer variable names that will be set in the shader.
  102485. */
  102486. uniformBuffersNames: string[];
  102487. /**
  102488. * Sampler texture variable names that will be set in the shader.
  102489. */
  102490. samplers: string[];
  102491. /**
  102492. * Define statements that will be set in the shader.
  102493. */
  102494. defines: any;
  102495. /**
  102496. * Possible fallbacks for this effect to improve performance when needed.
  102497. */
  102498. fallbacks: Nullable<IEffectFallbacks>;
  102499. /**
  102500. * Callback that will be called when the shader is compiled.
  102501. */
  102502. onCompiled: Nullable<(effect: Effect) => void>;
  102503. /**
  102504. * Callback that will be called if an error occurs during shader compilation.
  102505. */
  102506. onError: Nullable<(effect: Effect, errors: string) => void>;
  102507. /**
  102508. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102509. */
  102510. indexParameters?: any;
  102511. /**
  102512. * Max number of lights that can be used in the shader.
  102513. */
  102514. maxSimultaneousLights?: number;
  102515. /**
  102516. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  102517. */
  102518. transformFeedbackVaryings?: Nullable<string[]>;
  102519. }
  102520. /**
  102521. * Effect containing vertex and fragment shader that can be executed on an object.
  102522. */
  102523. export class Effect implements IDisposable {
  102524. /**
  102525. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102526. */
  102527. static ShadersRepository: string;
  102528. /**
  102529. * Name of the effect.
  102530. */
  102531. name: any;
  102532. /**
  102533. * String container all the define statements that should be set on the shader.
  102534. */
  102535. defines: string;
  102536. /**
  102537. * Callback that will be called when the shader is compiled.
  102538. */
  102539. onCompiled: Nullable<(effect: Effect) => void>;
  102540. /**
  102541. * Callback that will be called if an error occurs during shader compilation.
  102542. */
  102543. onError: Nullable<(effect: Effect, errors: string) => void>;
  102544. /**
  102545. * Callback that will be called when effect is bound.
  102546. */
  102547. onBind: Nullable<(effect: Effect) => void>;
  102548. /**
  102549. * Unique ID of the effect.
  102550. */
  102551. uniqueId: number;
  102552. /**
  102553. * Observable that will be called when the shader is compiled.
  102554. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  102555. */
  102556. onCompileObservable: Observable<Effect>;
  102557. /**
  102558. * Observable that will be called if an error occurs during shader compilation.
  102559. */
  102560. onErrorObservable: Observable<Effect>;
  102561. /** @hidden */
  102562. _onBindObservable: Nullable<Observable<Effect>>;
  102563. /**
  102564. * @hidden
  102565. * Specifies if the effect was previously ready
  102566. */
  102567. _wasPreviouslyReady: boolean;
  102568. /**
  102569. * Observable that will be called when effect is bound.
  102570. */
  102571. get onBindObservable(): Observable<Effect>;
  102572. /** @hidden */
  102573. _bonesComputationForcedToCPU: boolean;
  102574. private static _uniqueIdSeed;
  102575. private _engine;
  102576. private _uniformBuffersNames;
  102577. private _uniformsNames;
  102578. private _samplerList;
  102579. private _samplers;
  102580. private _isReady;
  102581. private _compilationError;
  102582. private _allFallbacksProcessed;
  102583. private _attributesNames;
  102584. private _attributes;
  102585. private _attributeLocationByName;
  102586. private _uniforms;
  102587. /**
  102588. * Key for the effect.
  102589. * @hidden
  102590. */
  102591. _key: string;
  102592. private _indexParameters;
  102593. private _fallbacks;
  102594. private _vertexSourceCode;
  102595. private _fragmentSourceCode;
  102596. private _vertexSourceCodeOverride;
  102597. private _fragmentSourceCodeOverride;
  102598. private _transformFeedbackVaryings;
  102599. /**
  102600. * Compiled shader to webGL program.
  102601. * @hidden
  102602. */
  102603. _pipelineContext: Nullable<IPipelineContext>;
  102604. private _valueCache;
  102605. private static _baseCache;
  102606. /**
  102607. * Instantiates an effect.
  102608. * An effect can be used to create/manage/execute vertex and fragment shaders.
  102609. * @param baseName Name of the effect.
  102610. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  102611. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  102612. * @param samplers List of sampler variables that will be passed to the shader.
  102613. * @param engine Engine to be used to render the effect
  102614. * @param defines Define statements to be added to the shader.
  102615. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  102616. * @param onCompiled Callback that will be called when the shader is compiled.
  102617. * @param onError Callback that will be called if an error occurs during shader compilation.
  102618. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102619. */
  102620. 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);
  102621. private _useFinalCode;
  102622. /**
  102623. * Unique key for this effect
  102624. */
  102625. get key(): string;
  102626. /**
  102627. * If the effect has been compiled and prepared.
  102628. * @returns if the effect is compiled and prepared.
  102629. */
  102630. isReady(): boolean;
  102631. private _isReadyInternal;
  102632. /**
  102633. * The engine the effect was initialized with.
  102634. * @returns the engine.
  102635. */
  102636. getEngine(): Engine;
  102637. /**
  102638. * The pipeline context for this effect
  102639. * @returns the associated pipeline context
  102640. */
  102641. getPipelineContext(): Nullable<IPipelineContext>;
  102642. /**
  102643. * The set of names of attribute variables for the shader.
  102644. * @returns An array of attribute names.
  102645. */
  102646. getAttributesNames(): string[];
  102647. /**
  102648. * Returns the attribute at the given index.
  102649. * @param index The index of the attribute.
  102650. * @returns The location of the attribute.
  102651. */
  102652. getAttributeLocation(index: number): number;
  102653. /**
  102654. * Returns the attribute based on the name of the variable.
  102655. * @param name of the attribute to look up.
  102656. * @returns the attribute location.
  102657. */
  102658. getAttributeLocationByName(name: string): number;
  102659. /**
  102660. * The number of attributes.
  102661. * @returns the numnber of attributes.
  102662. */
  102663. getAttributesCount(): number;
  102664. /**
  102665. * Gets the index of a uniform variable.
  102666. * @param uniformName of the uniform to look up.
  102667. * @returns the index.
  102668. */
  102669. getUniformIndex(uniformName: string): number;
  102670. /**
  102671. * Returns the attribute based on the name of the variable.
  102672. * @param uniformName of the uniform to look up.
  102673. * @returns the location of the uniform.
  102674. */
  102675. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  102676. /**
  102677. * Returns an array of sampler variable names
  102678. * @returns The array of sampler variable neames.
  102679. */
  102680. getSamplers(): string[];
  102681. /**
  102682. * The error from the last compilation.
  102683. * @returns the error string.
  102684. */
  102685. getCompilationError(): string;
  102686. /**
  102687. * Gets a boolean indicating that all fallbacks were used during compilation
  102688. * @returns true if all fallbacks were used
  102689. */
  102690. allFallbacksProcessed(): boolean;
  102691. /**
  102692. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  102693. * @param func The callback to be used.
  102694. */
  102695. executeWhenCompiled(func: (effect: Effect) => void): void;
  102696. private _checkIsReady;
  102697. private _loadShader;
  102698. /**
  102699. * Recompiles the webGL program
  102700. * @param vertexSourceCode The source code for the vertex shader.
  102701. * @param fragmentSourceCode The source code for the fragment shader.
  102702. * @param onCompiled Callback called when completed.
  102703. * @param onError Callback called on error.
  102704. * @hidden
  102705. */
  102706. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  102707. /**
  102708. * Prepares the effect
  102709. * @hidden
  102710. */
  102711. _prepareEffect(): void;
  102712. private _processCompilationErrors;
  102713. /**
  102714. * Checks if the effect is supported. (Must be called after compilation)
  102715. */
  102716. get isSupported(): boolean;
  102717. /**
  102718. * Binds a texture to the engine to be used as output of the shader.
  102719. * @param channel Name of the output variable.
  102720. * @param texture Texture to bind.
  102721. * @hidden
  102722. */
  102723. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  102724. /**
  102725. * Sets a texture on the engine to be used in the shader.
  102726. * @param channel Name of the sampler variable.
  102727. * @param texture Texture to set.
  102728. */
  102729. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  102730. /**
  102731. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  102732. * @param channel Name of the sampler variable.
  102733. * @param texture Texture to set.
  102734. */
  102735. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  102736. /**
  102737. * Sets an array of textures on the engine to be used in the shader.
  102738. * @param channel Name of the variable.
  102739. * @param textures Textures to set.
  102740. */
  102741. setTextureArray(channel: string, textures: BaseTexture[]): void;
  102742. /**
  102743. * 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)
  102744. * @param channel Name of the sampler variable.
  102745. * @param postProcess Post process to get the input texture from.
  102746. */
  102747. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  102748. /**
  102749. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  102750. * 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)
  102751. * @param channel Name of the sampler variable.
  102752. * @param postProcess Post process to get the output texture from.
  102753. */
  102754. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  102755. /** @hidden */
  102756. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  102757. /** @hidden */
  102758. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  102759. /** @hidden */
  102760. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  102761. /** @hidden */
  102762. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  102763. /**
  102764. * Binds a buffer to a uniform.
  102765. * @param buffer Buffer to bind.
  102766. * @param name Name of the uniform variable to bind to.
  102767. */
  102768. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  102769. /**
  102770. * Binds block to a uniform.
  102771. * @param blockName Name of the block to bind.
  102772. * @param index Index to bind.
  102773. */
  102774. bindUniformBlock(blockName: string, index: number): void;
  102775. /**
  102776. * Sets an interger value on a uniform variable.
  102777. * @param uniformName Name of the variable.
  102778. * @param value Value to be set.
  102779. * @returns this effect.
  102780. */
  102781. setInt(uniformName: string, value: number): Effect;
  102782. /**
  102783. * Sets an int array on a uniform variable.
  102784. * @param uniformName Name of the variable.
  102785. * @param array array to be set.
  102786. * @returns this effect.
  102787. */
  102788. setIntArray(uniformName: string, array: Int32Array): Effect;
  102789. /**
  102790. * 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)
  102791. * @param uniformName Name of the variable.
  102792. * @param array array to be set.
  102793. * @returns this effect.
  102794. */
  102795. setIntArray2(uniformName: string, array: Int32Array): Effect;
  102796. /**
  102797. * 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)
  102798. * @param uniformName Name of the variable.
  102799. * @param array array to be set.
  102800. * @returns this effect.
  102801. */
  102802. setIntArray3(uniformName: string, array: Int32Array): Effect;
  102803. /**
  102804. * 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)
  102805. * @param uniformName Name of the variable.
  102806. * @param array array to be set.
  102807. * @returns this effect.
  102808. */
  102809. setIntArray4(uniformName: string, array: Int32Array): Effect;
  102810. /**
  102811. * Sets an float array on a uniform variable.
  102812. * @param uniformName Name of the variable.
  102813. * @param array array to be set.
  102814. * @returns this effect.
  102815. */
  102816. setFloatArray(uniformName: string, array: Float32Array): Effect;
  102817. /**
  102818. * 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)
  102819. * @param uniformName Name of the variable.
  102820. * @param array array to be set.
  102821. * @returns this effect.
  102822. */
  102823. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  102824. /**
  102825. * 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)
  102826. * @param uniformName Name of the variable.
  102827. * @param array array to be set.
  102828. * @returns this effect.
  102829. */
  102830. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  102831. /**
  102832. * 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)
  102833. * @param uniformName Name of the variable.
  102834. * @param array array to be set.
  102835. * @returns this effect.
  102836. */
  102837. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  102838. /**
  102839. * Sets an array on a uniform variable.
  102840. * @param uniformName Name of the variable.
  102841. * @param array array to be set.
  102842. * @returns this effect.
  102843. */
  102844. setArray(uniformName: string, array: number[]): Effect;
  102845. /**
  102846. * 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)
  102847. * @param uniformName Name of the variable.
  102848. * @param array array to be set.
  102849. * @returns this effect.
  102850. */
  102851. setArray2(uniformName: string, array: number[]): Effect;
  102852. /**
  102853. * 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)
  102854. * @param uniformName Name of the variable.
  102855. * @param array array to be set.
  102856. * @returns this effect.
  102857. */
  102858. setArray3(uniformName: string, array: number[]): Effect;
  102859. /**
  102860. * 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)
  102861. * @param uniformName Name of the variable.
  102862. * @param array array to be set.
  102863. * @returns this effect.
  102864. */
  102865. setArray4(uniformName: string, array: number[]): Effect;
  102866. /**
  102867. * Sets matrices on a uniform variable.
  102868. * @param uniformName Name of the variable.
  102869. * @param matrices matrices to be set.
  102870. * @returns this effect.
  102871. */
  102872. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  102873. /**
  102874. * Sets matrix on a uniform variable.
  102875. * @param uniformName Name of the variable.
  102876. * @param matrix matrix to be set.
  102877. * @returns this effect.
  102878. */
  102879. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  102880. /**
  102881. * 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)
  102882. * @param uniformName Name of the variable.
  102883. * @param matrix matrix to be set.
  102884. * @returns this effect.
  102885. */
  102886. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  102887. /**
  102888. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  102889. * @param uniformName Name of the variable.
  102890. * @param matrix matrix to be set.
  102891. * @returns this effect.
  102892. */
  102893. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  102894. /**
  102895. * Sets a float on a uniform variable.
  102896. * @param uniformName Name of the variable.
  102897. * @param value value to be set.
  102898. * @returns this effect.
  102899. */
  102900. setFloat(uniformName: string, value: number): Effect;
  102901. /**
  102902. * Sets a boolean on a uniform variable.
  102903. * @param uniformName Name of the variable.
  102904. * @param bool value to be set.
  102905. * @returns this effect.
  102906. */
  102907. setBool(uniformName: string, bool: boolean): Effect;
  102908. /**
  102909. * Sets a Vector2 on a uniform variable.
  102910. * @param uniformName Name of the variable.
  102911. * @param vector2 vector2 to be set.
  102912. * @returns this effect.
  102913. */
  102914. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  102915. /**
  102916. * Sets a float2 on a uniform variable.
  102917. * @param uniformName Name of the variable.
  102918. * @param x First float in float2.
  102919. * @param y Second float in float2.
  102920. * @returns this effect.
  102921. */
  102922. setFloat2(uniformName: string, x: number, y: number): Effect;
  102923. /**
  102924. * Sets a Vector3 on a uniform variable.
  102925. * @param uniformName Name of the variable.
  102926. * @param vector3 Value to be set.
  102927. * @returns this effect.
  102928. */
  102929. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  102930. /**
  102931. * Sets a float3 on a uniform variable.
  102932. * @param uniformName Name of the variable.
  102933. * @param x First float in float3.
  102934. * @param y Second float in float3.
  102935. * @param z Third float in float3.
  102936. * @returns this effect.
  102937. */
  102938. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  102939. /**
  102940. * Sets a Vector4 on a uniform variable.
  102941. * @param uniformName Name of the variable.
  102942. * @param vector4 Value to be set.
  102943. * @returns this effect.
  102944. */
  102945. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  102946. /**
  102947. * Sets a float4 on a uniform variable.
  102948. * @param uniformName Name of the variable.
  102949. * @param x First float in float4.
  102950. * @param y Second float in float4.
  102951. * @param z Third float in float4.
  102952. * @param w Fourth float in float4.
  102953. * @returns this effect.
  102954. */
  102955. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  102956. /**
  102957. * Sets a Color3 on a uniform variable.
  102958. * @param uniformName Name of the variable.
  102959. * @param color3 Value to be set.
  102960. * @returns this effect.
  102961. */
  102962. setColor3(uniformName: string, color3: IColor3Like): Effect;
  102963. /**
  102964. * Sets a Color4 on a uniform variable.
  102965. * @param uniformName Name of the variable.
  102966. * @param color3 Value to be set.
  102967. * @param alpha Alpha value to be set.
  102968. * @returns this effect.
  102969. */
  102970. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  102971. /**
  102972. * Sets a Color4 on a uniform variable
  102973. * @param uniformName defines the name of the variable
  102974. * @param color4 defines the value to be set
  102975. * @returns this effect.
  102976. */
  102977. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  102978. /** Release all associated resources */
  102979. dispose(): void;
  102980. /**
  102981. * This function will add a new shader to the shader store
  102982. * @param name the name of the shader
  102983. * @param pixelShader optional pixel shader content
  102984. * @param vertexShader optional vertex shader content
  102985. */
  102986. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  102987. /**
  102988. * Store of each shader (The can be looked up using effect.key)
  102989. */
  102990. static ShadersStore: {
  102991. [key: string]: string;
  102992. };
  102993. /**
  102994. * Store of each included file for a shader (The can be looked up using effect.key)
  102995. */
  102996. static IncludesShadersStore: {
  102997. [key: string]: string;
  102998. };
  102999. /**
  103000. * Resets the cache of effects.
  103001. */
  103002. static ResetCache(): void;
  103003. }
  103004. }
  103005. declare module BABYLON {
  103006. /**
  103007. * Interface used to describe the capabilities of the engine relatively to the current browser
  103008. */
  103009. export interface EngineCapabilities {
  103010. /** Maximum textures units per fragment shader */
  103011. maxTexturesImageUnits: number;
  103012. /** Maximum texture units per vertex shader */
  103013. maxVertexTextureImageUnits: number;
  103014. /** Maximum textures units in the entire pipeline */
  103015. maxCombinedTexturesImageUnits: number;
  103016. /** Maximum texture size */
  103017. maxTextureSize: number;
  103018. /** Maximum texture samples */
  103019. maxSamples?: number;
  103020. /** Maximum cube texture size */
  103021. maxCubemapTextureSize: number;
  103022. /** Maximum render texture size */
  103023. maxRenderTextureSize: number;
  103024. /** Maximum number of vertex attributes */
  103025. maxVertexAttribs: number;
  103026. /** Maximum number of varyings */
  103027. maxVaryingVectors: number;
  103028. /** Maximum number of uniforms per vertex shader */
  103029. maxVertexUniformVectors: number;
  103030. /** Maximum number of uniforms per fragment shader */
  103031. maxFragmentUniformVectors: number;
  103032. /** Defines if standard derivates (dx/dy) are supported */
  103033. standardDerivatives: boolean;
  103034. /** Defines if s3tc texture compression is supported */
  103035. s3tc?: WEBGL_compressed_texture_s3tc;
  103036. /** Defines if pvrtc texture compression is supported */
  103037. pvrtc: any;
  103038. /** Defines if etc1 texture compression is supported */
  103039. etc1: any;
  103040. /** Defines if etc2 texture compression is supported */
  103041. etc2: any;
  103042. /** Defines if astc texture compression is supported */
  103043. astc: any;
  103044. /** Defines if float textures are supported */
  103045. textureFloat: boolean;
  103046. /** Defines if vertex array objects are supported */
  103047. vertexArrayObject: boolean;
  103048. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103049. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103050. /** Gets the maximum level of anisotropy supported */
  103051. maxAnisotropy: number;
  103052. /** Defines if instancing is supported */
  103053. instancedArrays: boolean;
  103054. /** Defines if 32 bits indices are supported */
  103055. uintIndices: boolean;
  103056. /** Defines if high precision shaders are supported */
  103057. highPrecisionShaderSupported: boolean;
  103058. /** Defines if depth reading in the fragment shader is supported */
  103059. fragmentDepthSupported: boolean;
  103060. /** Defines if float texture linear filtering is supported*/
  103061. textureFloatLinearFiltering: boolean;
  103062. /** Defines if rendering to float textures is supported */
  103063. textureFloatRender: boolean;
  103064. /** Defines if half float textures are supported*/
  103065. textureHalfFloat: boolean;
  103066. /** Defines if half float texture linear filtering is supported*/
  103067. textureHalfFloatLinearFiltering: boolean;
  103068. /** Defines if rendering to half float textures is supported */
  103069. textureHalfFloatRender: boolean;
  103070. /** Defines if textureLOD shader command is supported */
  103071. textureLOD: boolean;
  103072. /** Defines if draw buffers extension is supported */
  103073. drawBuffersExtension: boolean;
  103074. /** Defines if depth textures are supported */
  103075. depthTextureExtension: boolean;
  103076. /** Defines if float color buffer are supported */
  103077. colorBufferFloat: boolean;
  103078. /** Gets disjoint timer query extension (null if not supported) */
  103079. timerQuery?: EXT_disjoint_timer_query;
  103080. /** Defines if timestamp can be used with timer query */
  103081. canUseTimestampForTimerQuery: boolean;
  103082. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103083. multiview?: any;
  103084. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103085. oculusMultiview?: any;
  103086. /** Function used to let the system compiles shaders in background */
  103087. parallelShaderCompile?: {
  103088. COMPLETION_STATUS_KHR: number;
  103089. };
  103090. /** Max number of texture samples for MSAA */
  103091. maxMSAASamples: number;
  103092. /** Defines if the blend min max extension is supported */
  103093. blendMinMax: boolean;
  103094. }
  103095. }
  103096. declare module BABYLON {
  103097. /**
  103098. * @hidden
  103099. **/
  103100. export class DepthCullingState {
  103101. private _isDepthTestDirty;
  103102. private _isDepthMaskDirty;
  103103. private _isDepthFuncDirty;
  103104. private _isCullFaceDirty;
  103105. private _isCullDirty;
  103106. private _isZOffsetDirty;
  103107. private _isFrontFaceDirty;
  103108. private _depthTest;
  103109. private _depthMask;
  103110. private _depthFunc;
  103111. private _cull;
  103112. private _cullFace;
  103113. private _zOffset;
  103114. private _frontFace;
  103115. /**
  103116. * Initializes the state.
  103117. */
  103118. constructor();
  103119. get isDirty(): boolean;
  103120. get zOffset(): number;
  103121. set zOffset(value: number);
  103122. get cullFace(): Nullable<number>;
  103123. set cullFace(value: Nullable<number>);
  103124. get cull(): Nullable<boolean>;
  103125. set cull(value: Nullable<boolean>);
  103126. get depthFunc(): Nullable<number>;
  103127. set depthFunc(value: Nullable<number>);
  103128. get depthMask(): boolean;
  103129. set depthMask(value: boolean);
  103130. get depthTest(): boolean;
  103131. set depthTest(value: boolean);
  103132. get frontFace(): Nullable<number>;
  103133. set frontFace(value: Nullable<number>);
  103134. reset(): void;
  103135. apply(gl: WebGLRenderingContext): void;
  103136. }
  103137. }
  103138. declare module BABYLON {
  103139. /**
  103140. * @hidden
  103141. **/
  103142. export class StencilState {
  103143. /** 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 */
  103144. static readonly ALWAYS: number;
  103145. /** Passed to stencilOperation to specify that stencil value must be kept */
  103146. static readonly KEEP: number;
  103147. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103148. static readonly REPLACE: number;
  103149. private _isStencilTestDirty;
  103150. private _isStencilMaskDirty;
  103151. private _isStencilFuncDirty;
  103152. private _isStencilOpDirty;
  103153. private _stencilTest;
  103154. private _stencilMask;
  103155. private _stencilFunc;
  103156. private _stencilFuncRef;
  103157. private _stencilFuncMask;
  103158. private _stencilOpStencilFail;
  103159. private _stencilOpDepthFail;
  103160. private _stencilOpStencilDepthPass;
  103161. get isDirty(): boolean;
  103162. get stencilFunc(): number;
  103163. set stencilFunc(value: number);
  103164. get stencilFuncRef(): number;
  103165. set stencilFuncRef(value: number);
  103166. get stencilFuncMask(): number;
  103167. set stencilFuncMask(value: number);
  103168. get stencilOpStencilFail(): number;
  103169. set stencilOpStencilFail(value: number);
  103170. get stencilOpDepthFail(): number;
  103171. set stencilOpDepthFail(value: number);
  103172. get stencilOpStencilDepthPass(): number;
  103173. set stencilOpStencilDepthPass(value: number);
  103174. get stencilMask(): number;
  103175. set stencilMask(value: number);
  103176. get stencilTest(): boolean;
  103177. set stencilTest(value: boolean);
  103178. constructor();
  103179. reset(): void;
  103180. apply(gl: WebGLRenderingContext): void;
  103181. }
  103182. }
  103183. declare module BABYLON {
  103184. /**
  103185. * @hidden
  103186. **/
  103187. export class AlphaState {
  103188. private _isAlphaBlendDirty;
  103189. private _isBlendFunctionParametersDirty;
  103190. private _isBlendEquationParametersDirty;
  103191. private _isBlendConstantsDirty;
  103192. private _alphaBlend;
  103193. private _blendFunctionParameters;
  103194. private _blendEquationParameters;
  103195. private _blendConstants;
  103196. /**
  103197. * Initializes the state.
  103198. */
  103199. constructor();
  103200. get isDirty(): boolean;
  103201. get alphaBlend(): boolean;
  103202. set alphaBlend(value: boolean);
  103203. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103204. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103205. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103206. reset(): void;
  103207. apply(gl: WebGLRenderingContext): void;
  103208. }
  103209. }
  103210. declare module BABYLON {
  103211. /** @hidden */
  103212. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103213. attributeProcessor(attribute: string): string;
  103214. varyingProcessor(varying: string, isFragment: boolean): string;
  103215. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103216. }
  103217. }
  103218. declare module BABYLON {
  103219. /**
  103220. * Interface for attribute information associated with buffer instanciation
  103221. */
  103222. export interface InstancingAttributeInfo {
  103223. /**
  103224. * Name of the GLSL attribute
  103225. * if attribute index is not specified, this is used to retrieve the index from the effect
  103226. */
  103227. attributeName: string;
  103228. /**
  103229. * Index/offset of the attribute in the vertex shader
  103230. * if not specified, this will be computes from the name.
  103231. */
  103232. index?: number;
  103233. /**
  103234. * size of the attribute, 1, 2, 3 or 4
  103235. */
  103236. attributeSize: number;
  103237. /**
  103238. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103239. */
  103240. offset: number;
  103241. /**
  103242. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103243. * default to 1
  103244. */
  103245. divisor?: number;
  103246. /**
  103247. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103248. * default is FLOAT
  103249. */
  103250. attributeType?: number;
  103251. /**
  103252. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103253. */
  103254. normalized?: boolean;
  103255. }
  103256. }
  103257. declare module BABYLON {
  103258. interface ThinEngine {
  103259. /**
  103260. * Update a video texture
  103261. * @param texture defines the texture to update
  103262. * @param video defines the video element to use
  103263. * @param invertY defines if data must be stored with Y axis inverted
  103264. */
  103265. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103266. }
  103267. }
  103268. declare module BABYLON {
  103269. /**
  103270. * Settings for finer control over video usage
  103271. */
  103272. export interface VideoTextureSettings {
  103273. /**
  103274. * Applies `autoplay` to video, if specified
  103275. */
  103276. autoPlay?: boolean;
  103277. /**
  103278. * Applies `loop` to video, if specified
  103279. */
  103280. loop?: boolean;
  103281. /**
  103282. * Automatically updates internal texture from video at every frame in the render loop
  103283. */
  103284. autoUpdateTexture: boolean;
  103285. /**
  103286. * Image src displayed during the video loading or until the user interacts with the video.
  103287. */
  103288. poster?: string;
  103289. }
  103290. /**
  103291. * If you want to display a video in your scene, this is the special texture for that.
  103292. * This special texture works similar to other textures, with the exception of a few parameters.
  103293. * @see https://doc.babylonjs.com/how_to/video_texture
  103294. */
  103295. export class VideoTexture extends Texture {
  103296. /**
  103297. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103298. */
  103299. readonly autoUpdateTexture: boolean;
  103300. /**
  103301. * The video instance used by the texture internally
  103302. */
  103303. readonly video: HTMLVideoElement;
  103304. private _onUserActionRequestedObservable;
  103305. /**
  103306. * Event triggerd when a dom action is required by the user to play the video.
  103307. * This happens due to recent changes in browser policies preventing video to auto start.
  103308. */
  103309. get onUserActionRequestedObservable(): Observable<Texture>;
  103310. private _generateMipMaps;
  103311. private _engine;
  103312. private _stillImageCaptured;
  103313. private _displayingPosterTexture;
  103314. private _settings;
  103315. private _createInternalTextureOnEvent;
  103316. private _frameId;
  103317. private _currentSrc;
  103318. /**
  103319. * Creates a video texture.
  103320. * If you want to display a video in your scene, this is the special texture for that.
  103321. * This special texture works similar to other textures, with the exception of a few parameters.
  103322. * @see https://doc.babylonjs.com/how_to/video_texture
  103323. * @param name optional name, will detect from video source, if not defined
  103324. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103325. * @param scene is obviously the current scene.
  103326. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103327. * @param invertY is false by default but can be used to invert video on Y axis
  103328. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  103329. * @param settings allows finer control over video usage
  103330. */
  103331. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  103332. private _getName;
  103333. private _getVideo;
  103334. private _createInternalTexture;
  103335. private reset;
  103336. /**
  103337. * @hidden Internal method to initiate `update`.
  103338. */
  103339. _rebuild(): void;
  103340. /**
  103341. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  103342. */
  103343. update(): void;
  103344. /**
  103345. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  103346. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  103347. */
  103348. updateTexture(isVisible: boolean): void;
  103349. protected _updateInternalTexture: () => void;
  103350. /**
  103351. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  103352. * @param url New url.
  103353. */
  103354. updateURL(url: string): void;
  103355. /**
  103356. * Clones the texture.
  103357. * @returns the cloned texture
  103358. */
  103359. clone(): VideoTexture;
  103360. /**
  103361. * Dispose the texture and release its associated resources.
  103362. */
  103363. dispose(): void;
  103364. /**
  103365. * Creates a video texture straight from a stream.
  103366. * @param scene Define the scene the texture should be created in
  103367. * @param stream Define the stream the texture should be created from
  103368. * @returns The created video texture as a promise
  103369. */
  103370. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  103371. /**
  103372. * Creates a video texture straight from your WebCam video feed.
  103373. * @param scene Define the scene the texture should be created in
  103374. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103375. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103376. * @returns The created video texture as a promise
  103377. */
  103378. static CreateFromWebCamAsync(scene: Scene, constraints: {
  103379. minWidth: number;
  103380. maxWidth: number;
  103381. minHeight: number;
  103382. maxHeight: number;
  103383. deviceId: string;
  103384. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  103385. /**
  103386. * Creates a video texture straight from your WebCam video feed.
  103387. * @param scene Define the scene the texture should be created in
  103388. * @param onReady Define a callback to triggered once the texture will be ready
  103389. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103390. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103391. */
  103392. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  103393. minWidth: number;
  103394. maxWidth: number;
  103395. minHeight: number;
  103396. maxHeight: number;
  103397. deviceId: string;
  103398. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  103399. }
  103400. }
  103401. declare module BABYLON {
  103402. /**
  103403. * Defines the interface used by objects working like Scene
  103404. * @hidden
  103405. */
  103406. interface ISceneLike {
  103407. _addPendingData(data: any): void;
  103408. _removePendingData(data: any): void;
  103409. offlineProvider: IOfflineProvider;
  103410. }
  103411. /** Interface defining initialization parameters for Engine class */
  103412. export interface EngineOptions extends WebGLContextAttributes {
  103413. /**
  103414. * Defines if the engine should no exceed a specified device ratio
  103415. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  103416. */
  103417. limitDeviceRatio?: number;
  103418. /**
  103419. * Defines if webvr should be enabled automatically
  103420. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103421. */
  103422. autoEnableWebVR?: boolean;
  103423. /**
  103424. * Defines if webgl2 should be turned off even if supported
  103425. * @see http://doc.babylonjs.com/features/webgl2
  103426. */
  103427. disableWebGL2Support?: boolean;
  103428. /**
  103429. * Defines if webaudio should be initialized as well
  103430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103431. */
  103432. audioEngine?: boolean;
  103433. /**
  103434. * Defines if animations should run using a deterministic lock step
  103435. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103436. */
  103437. deterministicLockstep?: boolean;
  103438. /** Defines the maximum steps to use with deterministic lock step mode */
  103439. lockstepMaxSteps?: number;
  103440. /** Defines the seconds between each deterministic lock step */
  103441. timeStep?: number;
  103442. /**
  103443. * Defines that engine should ignore context lost events
  103444. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  103445. */
  103446. doNotHandleContextLost?: boolean;
  103447. /**
  103448. * Defines that engine should ignore modifying touch action attribute and style
  103449. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  103450. */
  103451. doNotHandleTouchAction?: boolean;
  103452. /**
  103453. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  103454. */
  103455. useHighPrecisionFloats?: boolean;
  103456. }
  103457. /**
  103458. * The base engine class (root of all engines)
  103459. */
  103460. export class ThinEngine {
  103461. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  103462. static ExceptionList: ({
  103463. key: string;
  103464. capture: string;
  103465. captureConstraint: number;
  103466. targets: string[];
  103467. } | {
  103468. key: string;
  103469. capture: null;
  103470. captureConstraint: null;
  103471. targets: string[];
  103472. })[];
  103473. /** @hidden */
  103474. static _TextureLoaders: IInternalTextureLoader[];
  103475. /**
  103476. * Returns the current npm package of the sdk
  103477. */
  103478. static get NpmPackage(): string;
  103479. /**
  103480. * Returns the current version of the framework
  103481. */
  103482. static get Version(): string;
  103483. /**
  103484. * Returns a string describing the current engine
  103485. */
  103486. get description(): string;
  103487. /**
  103488. * Gets or sets the epsilon value used by collision engine
  103489. */
  103490. static CollisionsEpsilon: number;
  103491. /**
  103492. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103493. */
  103494. static get ShadersRepository(): string;
  103495. static set ShadersRepository(value: string);
  103496. /**
  103497. * Gets or sets the textures that the engine should not attempt to load as compressed
  103498. */
  103499. protected _excludedCompressedTextures: string[];
  103500. /**
  103501. * Filters the compressed texture formats to only include
  103502. * files that are not included in the skippable list
  103503. *
  103504. * @param url the current extension
  103505. * @param textureFormatInUse the current compressed texture format
  103506. * @returns "format" string
  103507. */
  103508. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  103509. /** @hidden */
  103510. _shaderProcessor: IShaderProcessor;
  103511. /**
  103512. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  103513. */
  103514. forcePOTTextures: boolean;
  103515. /**
  103516. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  103517. */
  103518. isFullscreen: boolean;
  103519. /**
  103520. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  103521. */
  103522. cullBackFaces: boolean;
  103523. /**
  103524. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  103525. */
  103526. renderEvenInBackground: boolean;
  103527. /**
  103528. * Gets or sets a boolean indicating that cache can be kept between frames
  103529. */
  103530. preventCacheWipeBetweenFrames: boolean;
  103531. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  103532. validateShaderPrograms: boolean;
  103533. /**
  103534. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  103535. * This can provide greater z depth for distant objects.
  103536. */
  103537. useReverseDepthBuffer: boolean;
  103538. /**
  103539. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  103540. */
  103541. disableUniformBuffers: boolean;
  103542. /** @hidden */
  103543. _uniformBuffers: UniformBuffer[];
  103544. /**
  103545. * Gets a boolean indicating that the engine supports uniform buffers
  103546. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  103547. */
  103548. get supportsUniformBuffers(): boolean;
  103549. /** @hidden */
  103550. _gl: WebGLRenderingContext;
  103551. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  103552. protected _windowIsBackground: boolean;
  103553. protected _webGLVersion: number;
  103554. protected _creationOptions: EngineOptions;
  103555. protected _highPrecisionShadersAllowed: boolean;
  103556. /** @hidden */
  103557. get _shouldUseHighPrecisionShader(): boolean;
  103558. /**
  103559. * Gets a boolean indicating that only power of 2 textures are supported
  103560. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  103561. */
  103562. get needPOTTextures(): boolean;
  103563. /** @hidden */
  103564. _badOS: boolean;
  103565. /** @hidden */
  103566. _badDesktopOS: boolean;
  103567. private _hardwareScalingLevel;
  103568. /** @hidden */
  103569. _caps: EngineCapabilities;
  103570. private _isStencilEnable;
  103571. private _glVersion;
  103572. private _glRenderer;
  103573. private _glVendor;
  103574. /** @hidden */
  103575. _videoTextureSupported: boolean;
  103576. protected _renderingQueueLaunched: boolean;
  103577. protected _activeRenderLoops: (() => void)[];
  103578. /**
  103579. * Observable signaled when a context lost event is raised
  103580. */
  103581. onContextLostObservable: Observable<ThinEngine>;
  103582. /**
  103583. * Observable signaled when a context restored event is raised
  103584. */
  103585. onContextRestoredObservable: Observable<ThinEngine>;
  103586. private _onContextLost;
  103587. private _onContextRestored;
  103588. protected _contextWasLost: boolean;
  103589. /** @hidden */
  103590. _doNotHandleContextLost: boolean;
  103591. /**
  103592. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  103593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  103594. */
  103595. get doNotHandleContextLost(): boolean;
  103596. set doNotHandleContextLost(value: boolean);
  103597. /**
  103598. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  103599. */
  103600. disableVertexArrayObjects: boolean;
  103601. /** @hidden */
  103602. protected _colorWrite: boolean;
  103603. /** @hidden */
  103604. protected _colorWriteChanged: boolean;
  103605. /** @hidden */
  103606. protected _depthCullingState: DepthCullingState;
  103607. /** @hidden */
  103608. protected _stencilState: StencilState;
  103609. /** @hidden */
  103610. _alphaState: AlphaState;
  103611. /** @hidden */
  103612. _alphaMode: number;
  103613. /** @hidden */
  103614. _alphaEquation: number;
  103615. /** @hidden */
  103616. _internalTexturesCache: InternalTexture[];
  103617. /** @hidden */
  103618. protected _activeChannel: number;
  103619. private _currentTextureChannel;
  103620. /** @hidden */
  103621. protected _boundTexturesCache: {
  103622. [key: string]: Nullable<InternalTexture>;
  103623. };
  103624. /** @hidden */
  103625. protected _currentEffect: Nullable<Effect>;
  103626. /** @hidden */
  103627. protected _currentProgram: Nullable<WebGLProgram>;
  103628. private _compiledEffects;
  103629. private _vertexAttribArraysEnabled;
  103630. /** @hidden */
  103631. protected _cachedViewport: Nullable<IViewportLike>;
  103632. private _cachedVertexArrayObject;
  103633. /** @hidden */
  103634. protected _cachedVertexBuffers: any;
  103635. /** @hidden */
  103636. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  103637. /** @hidden */
  103638. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  103639. /** @hidden */
  103640. _currentRenderTarget: Nullable<InternalTexture>;
  103641. private _uintIndicesCurrentlySet;
  103642. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  103643. /** @hidden */
  103644. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  103645. private _currentBufferPointers;
  103646. private _currentInstanceLocations;
  103647. private _currentInstanceBuffers;
  103648. private _textureUnits;
  103649. /** @hidden */
  103650. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103651. /** @hidden */
  103652. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103653. /** @hidden */
  103654. _boundRenderFunction: any;
  103655. private _vaoRecordInProgress;
  103656. private _mustWipeVertexAttributes;
  103657. private _emptyTexture;
  103658. private _emptyCubeTexture;
  103659. private _emptyTexture3D;
  103660. private _emptyTexture2DArray;
  103661. /** @hidden */
  103662. _frameHandler: number;
  103663. private _nextFreeTextureSlots;
  103664. private _maxSimultaneousTextures;
  103665. private _activeRequests;
  103666. protected _texturesSupported: string[];
  103667. /** @hidden */
  103668. _textureFormatInUse: Nullable<string>;
  103669. protected get _supportsHardwareTextureRescaling(): boolean;
  103670. /**
  103671. * Gets the list of texture formats supported
  103672. */
  103673. get texturesSupported(): Array<string>;
  103674. /**
  103675. * Gets the list of texture formats in use
  103676. */
  103677. get textureFormatInUse(): Nullable<string>;
  103678. /**
  103679. * Gets the current viewport
  103680. */
  103681. get currentViewport(): Nullable<IViewportLike>;
  103682. /**
  103683. * Gets the default empty texture
  103684. */
  103685. get emptyTexture(): InternalTexture;
  103686. /**
  103687. * Gets the default empty 3D texture
  103688. */
  103689. get emptyTexture3D(): InternalTexture;
  103690. /**
  103691. * Gets the default empty 2D array texture
  103692. */
  103693. get emptyTexture2DArray(): InternalTexture;
  103694. /**
  103695. * Gets the default empty cube texture
  103696. */
  103697. get emptyCubeTexture(): InternalTexture;
  103698. /**
  103699. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  103700. */
  103701. readonly premultipliedAlpha: boolean;
  103702. /**
  103703. * Observable event triggered before each texture is initialized
  103704. */
  103705. onBeforeTextureInitObservable: Observable<Texture>;
  103706. /**
  103707. * Creates a new engine
  103708. * @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
  103709. * @param antialias defines enable antialiasing (default: false)
  103710. * @param options defines further options to be sent to the getContext() function
  103711. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103712. */
  103713. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103714. private _rebuildInternalTextures;
  103715. private _rebuildEffects;
  103716. /**
  103717. * Gets a boolean indicating if all created effects are ready
  103718. * @returns true if all effects are ready
  103719. */
  103720. areAllEffectsReady(): boolean;
  103721. protected _rebuildBuffers(): void;
  103722. private _initGLContext;
  103723. /**
  103724. * Gets version of the current webGL context
  103725. */
  103726. get webGLVersion(): number;
  103727. /**
  103728. * Gets a string idenfifying the name of the class
  103729. * @returns "Engine" string
  103730. */
  103731. getClassName(): string;
  103732. /**
  103733. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  103734. */
  103735. get isStencilEnable(): boolean;
  103736. /** @hidden */
  103737. _prepareWorkingCanvas(): void;
  103738. /**
  103739. * Reset the texture cache to empty state
  103740. */
  103741. resetTextureCache(): void;
  103742. /**
  103743. * Gets an object containing information about the current webGL context
  103744. * @returns an object containing the vender, the renderer and the version of the current webGL context
  103745. */
  103746. getGlInfo(): {
  103747. vendor: string;
  103748. renderer: string;
  103749. version: string;
  103750. };
  103751. /**
  103752. * Defines the hardware scaling level.
  103753. * By default the hardware scaling level is computed from the window device ratio.
  103754. * 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.
  103755. * @param level defines the level to use
  103756. */
  103757. setHardwareScalingLevel(level: number): void;
  103758. /**
  103759. * Gets the current hardware scaling level.
  103760. * By default the hardware scaling level is computed from the window device ratio.
  103761. * 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.
  103762. * @returns a number indicating the current hardware scaling level
  103763. */
  103764. getHardwareScalingLevel(): number;
  103765. /**
  103766. * Gets the list of loaded textures
  103767. * @returns an array containing all loaded textures
  103768. */
  103769. getLoadedTexturesCache(): InternalTexture[];
  103770. /**
  103771. * Gets the object containing all engine capabilities
  103772. * @returns the EngineCapabilities object
  103773. */
  103774. getCaps(): EngineCapabilities;
  103775. /**
  103776. * stop executing a render loop function and remove it from the execution array
  103777. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  103778. */
  103779. stopRenderLoop(renderFunction?: () => void): void;
  103780. /** @hidden */
  103781. _renderLoop(): void;
  103782. /**
  103783. * Gets the HTML canvas attached with the current webGL context
  103784. * @returns a HTML canvas
  103785. */
  103786. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  103787. /**
  103788. * Gets host window
  103789. * @returns the host window object
  103790. */
  103791. getHostWindow(): Nullable<Window>;
  103792. /**
  103793. * Gets the current render width
  103794. * @param useScreen defines if screen size must be used (or the current render target if any)
  103795. * @returns a number defining the current render width
  103796. */
  103797. getRenderWidth(useScreen?: boolean): number;
  103798. /**
  103799. * Gets the current render height
  103800. * @param useScreen defines if screen size must be used (or the current render target if any)
  103801. * @returns a number defining the current render height
  103802. */
  103803. getRenderHeight(useScreen?: boolean): number;
  103804. /**
  103805. * Can be used to override the current requestAnimationFrame requester.
  103806. * @hidden
  103807. */
  103808. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  103809. /**
  103810. * Register and execute a render loop. The engine can have more than one render function
  103811. * @param renderFunction defines the function to continuously execute
  103812. */
  103813. runRenderLoop(renderFunction: () => void): void;
  103814. /**
  103815. * Clear the current render buffer or the current render target (if any is set up)
  103816. * @param color defines the color to use
  103817. * @param backBuffer defines if the back buffer must be cleared
  103818. * @param depth defines if the depth buffer must be cleared
  103819. * @param stencil defines if the stencil buffer must be cleared
  103820. */
  103821. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  103822. private _viewportCached;
  103823. /** @hidden */
  103824. _viewport(x: number, y: number, width: number, height: number): void;
  103825. /**
  103826. * Set the WebGL's viewport
  103827. * @param viewport defines the viewport element to be used
  103828. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  103829. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  103830. */
  103831. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  103832. /**
  103833. * Begin a new frame
  103834. */
  103835. beginFrame(): void;
  103836. /**
  103837. * Enf the current frame
  103838. */
  103839. endFrame(): void;
  103840. /**
  103841. * Resize the view according to the canvas' size
  103842. */
  103843. resize(): void;
  103844. /**
  103845. * Force a specific size of the canvas
  103846. * @param width defines the new canvas' width
  103847. * @param height defines the new canvas' height
  103848. */
  103849. setSize(width: number, height: number): void;
  103850. /**
  103851. * Binds the frame buffer to the specified texture.
  103852. * @param texture The texture to render to or null for the default canvas
  103853. * @param faceIndex The face of the texture to render to in case of cube texture
  103854. * @param requiredWidth The width of the target to render to
  103855. * @param requiredHeight The height of the target to render to
  103856. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  103857. * @param lodLevel defines the lod level to bind to the frame buffer
  103858. * @param layer defines the 2d array index to bind to frame buffer to
  103859. */
  103860. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  103861. /** @hidden */
  103862. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  103863. /**
  103864. * Unbind the current render target texture from the webGL context
  103865. * @param texture defines the render target texture to unbind
  103866. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103867. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103868. */
  103869. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  103870. /**
  103871. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  103872. */
  103873. flushFramebuffer(): void;
  103874. /**
  103875. * Unbind the current render target and bind the default framebuffer
  103876. */
  103877. restoreDefaultFramebuffer(): void;
  103878. /** @hidden */
  103879. protected _resetVertexBufferBinding(): void;
  103880. /**
  103881. * Creates a vertex buffer
  103882. * @param data the data for the vertex buffer
  103883. * @returns the new WebGL static buffer
  103884. */
  103885. createVertexBuffer(data: DataArray): DataBuffer;
  103886. private _createVertexBuffer;
  103887. /**
  103888. * Creates a dynamic vertex buffer
  103889. * @param data the data for the dynamic vertex buffer
  103890. * @returns the new WebGL dynamic buffer
  103891. */
  103892. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  103893. protected _resetIndexBufferBinding(): void;
  103894. /**
  103895. * Creates a new index buffer
  103896. * @param indices defines the content of the index buffer
  103897. * @param updatable defines if the index buffer must be updatable
  103898. * @returns a new webGL buffer
  103899. */
  103900. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  103901. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  103902. /**
  103903. * Bind a webGL buffer to the webGL context
  103904. * @param buffer defines the buffer to bind
  103905. */
  103906. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  103907. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  103908. private bindBuffer;
  103909. /**
  103910. * update the bound buffer with the given data
  103911. * @param data defines the data to update
  103912. */
  103913. updateArrayBuffer(data: Float32Array): void;
  103914. private _vertexAttribPointer;
  103915. private _bindIndexBufferWithCache;
  103916. private _bindVertexBuffersAttributes;
  103917. /**
  103918. * Records a vertex array object
  103919. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103920. * @param vertexBuffers defines the list of vertex buffers to store
  103921. * @param indexBuffer defines the index buffer to store
  103922. * @param effect defines the effect to store
  103923. * @returns the new vertex array object
  103924. */
  103925. recordVertexArrayObject(vertexBuffers: {
  103926. [key: string]: VertexBuffer;
  103927. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  103928. /**
  103929. * Bind a specific vertex array object
  103930. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103931. * @param vertexArrayObject defines the vertex array object to bind
  103932. * @param indexBuffer defines the index buffer to bind
  103933. */
  103934. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  103935. /**
  103936. * Bind webGl buffers directly to the webGL context
  103937. * @param vertexBuffer defines the vertex buffer to bind
  103938. * @param indexBuffer defines the index buffer to bind
  103939. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  103940. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  103941. * @param effect defines the effect associated with the vertex buffer
  103942. */
  103943. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  103944. private _unbindVertexArrayObject;
  103945. /**
  103946. * Bind a list of vertex buffers to the webGL context
  103947. * @param vertexBuffers defines the list of vertex buffers to bind
  103948. * @param indexBuffer defines the index buffer to bind
  103949. * @param effect defines the effect associated with the vertex buffers
  103950. */
  103951. bindBuffers(vertexBuffers: {
  103952. [key: string]: Nullable<VertexBuffer>;
  103953. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  103954. /**
  103955. * Unbind all instance attributes
  103956. */
  103957. unbindInstanceAttributes(): void;
  103958. /**
  103959. * Release and free the memory of a vertex array object
  103960. * @param vao defines the vertex array object to delete
  103961. */
  103962. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  103963. /** @hidden */
  103964. _releaseBuffer(buffer: DataBuffer): boolean;
  103965. protected _deleteBuffer(buffer: DataBuffer): void;
  103966. /**
  103967. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  103968. * @param instancesBuffer defines the webGL buffer to update and bind
  103969. * @param data defines the data to store in the buffer
  103970. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  103971. */
  103972. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  103973. /**
  103974. * Bind the content of a webGL buffer used with instanciation
  103975. * @param instancesBuffer defines the webGL buffer to bind
  103976. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  103977. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  103978. */
  103979. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  103980. /**
  103981. * Disable the instance attribute corresponding to the name in parameter
  103982. * @param name defines the name of the attribute to disable
  103983. */
  103984. disableInstanceAttributeByName(name: string): void;
  103985. /**
  103986. * Disable the instance attribute corresponding to the location in parameter
  103987. * @param attributeLocation defines the attribute location of the attribute to disable
  103988. */
  103989. disableInstanceAttribute(attributeLocation: number): void;
  103990. /**
  103991. * Disable the attribute corresponding to the location in parameter
  103992. * @param attributeLocation defines the attribute location of the attribute to disable
  103993. */
  103994. disableAttributeByIndex(attributeLocation: number): void;
  103995. /**
  103996. * Send a draw order
  103997. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  103998. * @param indexStart defines the starting index
  103999. * @param indexCount defines the number of index to draw
  104000. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104001. */
  104002. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104003. /**
  104004. * Draw a list of points
  104005. * @param verticesStart defines the index of first vertex to draw
  104006. * @param verticesCount defines the count of vertices to draw
  104007. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104008. */
  104009. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104010. /**
  104011. * Draw a list of unindexed primitives
  104012. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104013. * @param verticesStart defines the index of first vertex to draw
  104014. * @param verticesCount defines the count of vertices to draw
  104015. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104016. */
  104017. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104018. /**
  104019. * Draw a list of indexed primitives
  104020. * @param fillMode defines the primitive to use
  104021. * @param indexStart defines the starting index
  104022. * @param indexCount defines the number of index to draw
  104023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104024. */
  104025. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104026. /**
  104027. * Draw a list of unindexed primitives
  104028. * @param fillMode defines the primitive to use
  104029. * @param verticesStart defines the index of first vertex to draw
  104030. * @param verticesCount defines the count of vertices to draw
  104031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104032. */
  104033. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104034. private _drawMode;
  104035. /** @hidden */
  104036. protected _reportDrawCall(): void;
  104037. /** @hidden */
  104038. _releaseEffect(effect: Effect): void;
  104039. /** @hidden */
  104040. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104041. /**
  104042. * Create a new effect (used to store vertex/fragment shaders)
  104043. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104044. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104045. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104046. * @param samplers defines an array of string used to represent textures
  104047. * @param defines defines the string containing the defines to use to compile the shaders
  104048. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104049. * @param onCompiled defines a function to call when the effect creation is successful
  104050. * @param onError defines a function to call when the effect creation has failed
  104051. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104052. * @returns the new Effect
  104053. */
  104054. 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;
  104055. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104056. private _compileShader;
  104057. private _compileRawShader;
  104058. /**
  104059. * Directly creates a webGL program
  104060. * @param pipelineContext defines the pipeline context to attach to
  104061. * @param vertexCode defines the vertex shader code to use
  104062. * @param fragmentCode defines the fragment shader code to use
  104063. * @param context defines the webGL context to use (if not set, the current one will be used)
  104064. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104065. * @returns the new webGL program
  104066. */
  104067. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104068. /**
  104069. * Creates a webGL program
  104070. * @param pipelineContext defines the pipeline context to attach to
  104071. * @param vertexCode defines the vertex shader code to use
  104072. * @param fragmentCode defines the fragment shader code to use
  104073. * @param defines defines the string containing the defines to use to compile the shaders
  104074. * @param context defines the webGL context to use (if not set, the current one will be used)
  104075. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104076. * @returns the new webGL program
  104077. */
  104078. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104079. /**
  104080. * Creates a new pipeline context
  104081. * @returns the new pipeline
  104082. */
  104083. createPipelineContext(): IPipelineContext;
  104084. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104085. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104086. /** @hidden */
  104087. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104088. /** @hidden */
  104089. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104090. /** @hidden */
  104091. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104092. /**
  104093. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104094. * @param pipelineContext defines the pipeline context to use
  104095. * @param uniformsNames defines the list of uniform names
  104096. * @returns an array of webGL uniform locations
  104097. */
  104098. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104099. /**
  104100. * Gets the lsit of active attributes for a given webGL program
  104101. * @param pipelineContext defines the pipeline context to use
  104102. * @param attributesNames defines the list of attribute names to get
  104103. * @returns an array of indices indicating the offset of each attribute
  104104. */
  104105. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104106. /**
  104107. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104108. * @param effect defines the effect to activate
  104109. */
  104110. enableEffect(effect: Nullable<Effect>): void;
  104111. /**
  104112. * Set the value of an uniform to a number (int)
  104113. * @param uniform defines the webGL uniform location where to store the value
  104114. * @param value defines the int number to store
  104115. */
  104116. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104117. /**
  104118. * Set the value of an uniform to an array of int32
  104119. * @param uniform defines the webGL uniform location where to store the value
  104120. * @param array defines the array of int32 to store
  104121. */
  104122. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104123. /**
  104124. * Set the value of an uniform to an array of int32 (stored as vec2)
  104125. * @param uniform defines the webGL uniform location where to store the value
  104126. * @param array defines the array of int32 to store
  104127. */
  104128. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104129. /**
  104130. * Set the value of an uniform to an array of int32 (stored as vec3)
  104131. * @param uniform defines the webGL uniform location where to store the value
  104132. * @param array defines the array of int32 to store
  104133. */
  104134. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104135. /**
  104136. * Set the value of an uniform to an array of int32 (stored as vec4)
  104137. * @param uniform defines the webGL uniform location where to store the value
  104138. * @param array defines the array of int32 to store
  104139. */
  104140. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104141. /**
  104142. * Set the value of an uniform to an array of number
  104143. * @param uniform defines the webGL uniform location where to store the value
  104144. * @param array defines the array of number to store
  104145. */
  104146. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104147. /**
  104148. * Set the value of an uniform to an array of number (stored as vec2)
  104149. * @param uniform defines the webGL uniform location where to store the value
  104150. * @param array defines the array of number to store
  104151. */
  104152. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104153. /**
  104154. * Set the value of an uniform to an array of number (stored as vec3)
  104155. * @param uniform defines the webGL uniform location where to store the value
  104156. * @param array defines the array of number to store
  104157. */
  104158. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104159. /**
  104160. * Set the value of an uniform to an array of number (stored as vec4)
  104161. * @param uniform defines the webGL uniform location where to store the value
  104162. * @param array defines the array of number to store
  104163. */
  104164. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104165. /**
  104166. * Set the value of an uniform to an array of float32 (stored as matrices)
  104167. * @param uniform defines the webGL uniform location where to store the value
  104168. * @param matrices defines the array of float32 to store
  104169. */
  104170. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104171. /**
  104172. * Set the value of an uniform to a matrix (3x3)
  104173. * @param uniform defines the webGL uniform location where to store the value
  104174. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104175. */
  104176. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104177. /**
  104178. * Set the value of an uniform to a matrix (2x2)
  104179. * @param uniform defines the webGL uniform location where to store the value
  104180. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104181. */
  104182. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104183. /**
  104184. * Set the value of an uniform to a number (float)
  104185. * @param uniform defines the webGL uniform location where to store the value
  104186. * @param value defines the float number to store
  104187. */
  104188. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104189. /**
  104190. * Set the value of an uniform to a vec2
  104191. * @param uniform defines the webGL uniform location where to store the value
  104192. * @param x defines the 1st component of the value
  104193. * @param y defines the 2nd component of the value
  104194. */
  104195. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104196. /**
  104197. * Set the value of an uniform to a vec3
  104198. * @param uniform defines the webGL uniform location where to store the value
  104199. * @param x defines the 1st component of the value
  104200. * @param y defines the 2nd component of the value
  104201. * @param z defines the 3rd component of the value
  104202. */
  104203. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104204. /**
  104205. * Set the value of an uniform to a vec4
  104206. * @param uniform defines the webGL uniform location where to store the value
  104207. * @param x defines the 1st component of the value
  104208. * @param y defines the 2nd component of the value
  104209. * @param z defines the 3rd component of the value
  104210. * @param w defines the 4th component of the value
  104211. */
  104212. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104213. /**
  104214. * Apply all cached states (depth, culling, stencil and alpha)
  104215. */
  104216. applyStates(): void;
  104217. /**
  104218. * Enable or disable color writing
  104219. * @param enable defines the state to set
  104220. */
  104221. setColorWrite(enable: boolean): void;
  104222. /**
  104223. * Gets a boolean indicating if color writing is enabled
  104224. * @returns the current color writing state
  104225. */
  104226. getColorWrite(): boolean;
  104227. /**
  104228. * Gets the depth culling state manager
  104229. */
  104230. get depthCullingState(): DepthCullingState;
  104231. /**
  104232. * Gets the alpha state manager
  104233. */
  104234. get alphaState(): AlphaState;
  104235. /**
  104236. * Gets the stencil state manager
  104237. */
  104238. get stencilState(): StencilState;
  104239. /**
  104240. * Clears the list of texture accessible through engine.
  104241. * This can help preventing texture load conflict due to name collision.
  104242. */
  104243. clearInternalTexturesCache(): void;
  104244. /**
  104245. * Force the entire cache to be cleared
  104246. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104247. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104248. */
  104249. wipeCaches(bruteForce?: boolean): void;
  104250. /** @hidden */
  104251. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104252. min: number;
  104253. mag: number;
  104254. };
  104255. /** @hidden */
  104256. _createTexture(): WebGLTexture;
  104257. /**
  104258. * Usually called from Texture.ts.
  104259. * Passed information to create a WebGLTexture
  104260. * @param urlArg defines a value which contains one of the following:
  104261. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104262. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104263. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104264. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104265. * @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)
  104266. * @param scene needed for loading to the correct scene
  104267. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104268. * @param onLoad optional callback to be called upon successful completion
  104269. * @param onError optional callback to be called upon failure
  104270. * @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
  104271. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104272. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104273. * @param forcedExtension defines the extension to use to pick the right loader
  104274. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104275. * @param mimeType defines an optional mime type
  104276. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104277. */
  104278. 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;
  104279. /**
  104280. * Loads an image as an HTMLImageElement.
  104281. * @param input url string, ArrayBuffer, or Blob to load
  104282. * @param onLoad callback called when the image successfully loads
  104283. * @param onError callback called when the image fails to load
  104284. * @param offlineProvider offline provider for caching
  104285. * @param mimeType optional mime type
  104286. * @returns the HTMLImageElement of the loaded image
  104287. * @hidden
  104288. */
  104289. 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>;
  104290. /**
  104291. * @hidden
  104292. */
  104293. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104294. /**
  104295. * Creates a raw texture
  104296. * @param data defines the data to store in the texture
  104297. * @param width defines the width of the texture
  104298. * @param height defines the height of the texture
  104299. * @param format defines the format of the data
  104300. * @param generateMipMaps defines if the engine should generate the mip levels
  104301. * @param invertY defines if data must be stored with Y axis inverted
  104302. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104303. * @param compression defines the compression used (null by default)
  104304. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104305. * @returns the raw texture inside an InternalTexture
  104306. */
  104307. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104308. /**
  104309. * Creates a new raw cube texture
  104310. * @param data defines the array of data to use to create each face
  104311. * @param size defines the size of the textures
  104312. * @param format defines the format of the data
  104313. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104314. * @param generateMipMaps defines if the engine should generate the mip levels
  104315. * @param invertY defines if data must be stored with Y axis inverted
  104316. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104317. * @param compression defines the compression used (null by default)
  104318. * @returns the cube texture as an InternalTexture
  104319. */
  104320. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104321. /**
  104322. * Creates a new raw 3D texture
  104323. * @param data defines the data used to create the texture
  104324. * @param width defines the width of the texture
  104325. * @param height defines the height of the texture
  104326. * @param depth defines the depth of the texture
  104327. * @param format defines the format of the texture
  104328. * @param generateMipMaps defines if the engine must generate mip levels
  104329. * @param invertY defines if data must be stored with Y axis inverted
  104330. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104331. * @param compression defines the compressed used (can be null)
  104332. * @param textureType defines the compressed used (can be null)
  104333. * @returns a new raw 3D texture (stored in an InternalTexture)
  104334. */
  104335. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104336. /**
  104337. * Creates a new raw 2D array texture
  104338. * @param data defines the data used to create the texture
  104339. * @param width defines the width of the texture
  104340. * @param height defines the height of the texture
  104341. * @param depth defines the number of layers of the texture
  104342. * @param format defines the format of the texture
  104343. * @param generateMipMaps defines if the engine must generate mip levels
  104344. * @param invertY defines if data must be stored with Y axis inverted
  104345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104346. * @param compression defines the compressed used (can be null)
  104347. * @param textureType defines the compressed used (can be null)
  104348. * @returns a new raw 2D array texture (stored in an InternalTexture)
  104349. */
  104350. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104351. private _unpackFlipYCached;
  104352. /**
  104353. * In case you are sharing the context with other applications, it might
  104354. * be interested to not cache the unpack flip y state to ensure a consistent
  104355. * value would be set.
  104356. */
  104357. enableUnpackFlipYCached: boolean;
  104358. /** @hidden */
  104359. _unpackFlipY(value: boolean): void;
  104360. /** @hidden */
  104361. _getUnpackAlignement(): number;
  104362. private _getTextureTarget;
  104363. /**
  104364. * Update the sampling mode of a given texture
  104365. * @param samplingMode defines the required sampling mode
  104366. * @param texture defines the texture to update
  104367. * @param generateMipMaps defines whether to generate mipmaps for the texture
  104368. */
  104369. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  104370. /**
  104371. * Update the sampling mode of a given texture
  104372. * @param texture defines the texture to update
  104373. * @param wrapU defines the texture wrap mode of the u coordinates
  104374. * @param wrapV defines the texture wrap mode of the v coordinates
  104375. * @param wrapR defines the texture wrap mode of the r coordinates
  104376. */
  104377. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  104378. /** @hidden */
  104379. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  104380. width: number;
  104381. height: number;
  104382. layers?: number;
  104383. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  104384. /** @hidden */
  104385. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104386. /** @hidden */
  104387. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  104388. /**
  104389. * Update a portion of an internal texture
  104390. * @param texture defines the texture to update
  104391. * @param imageData defines the data to store into the texture
  104392. * @param xOffset defines the x coordinates of the update rectangle
  104393. * @param yOffset defines the y coordinates of the update rectangle
  104394. * @param width defines the width of the update rectangle
  104395. * @param height defines the height of the update rectangle
  104396. * @param faceIndex defines the face index if texture is a cube (0 by default)
  104397. * @param lod defines the lod level to update (0 by default)
  104398. */
  104399. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  104400. /** @hidden */
  104401. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104402. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  104403. private _prepareWebGLTexture;
  104404. /** @hidden */
  104405. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  104406. private _getDepthStencilBuffer;
  104407. /** @hidden */
  104408. _releaseFramebufferObjects(texture: InternalTexture): void;
  104409. /** @hidden */
  104410. _releaseTexture(texture: InternalTexture): void;
  104411. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  104412. protected _setProgram(program: WebGLProgram): void;
  104413. protected _boundUniforms: {
  104414. [key: number]: WebGLUniformLocation;
  104415. };
  104416. /**
  104417. * Binds an effect to the webGL context
  104418. * @param effect defines the effect to bind
  104419. */
  104420. bindSamplers(effect: Effect): void;
  104421. private _activateCurrentTexture;
  104422. /** @hidden */
  104423. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  104424. /** @hidden */
  104425. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  104426. /**
  104427. * Unbind all textures from the webGL context
  104428. */
  104429. unbindAllTextures(): void;
  104430. /**
  104431. * Sets a texture to the according uniform.
  104432. * @param channel The texture channel
  104433. * @param uniform The uniform to set
  104434. * @param texture The texture to apply
  104435. */
  104436. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  104437. private _bindSamplerUniformToChannel;
  104438. private _getTextureWrapMode;
  104439. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  104440. /**
  104441. * Sets an array of texture to the webGL context
  104442. * @param channel defines the channel where the texture array must be set
  104443. * @param uniform defines the associated uniform location
  104444. * @param textures defines the array of textures to bind
  104445. */
  104446. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  104447. /** @hidden */
  104448. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  104449. private _setTextureParameterFloat;
  104450. private _setTextureParameterInteger;
  104451. /**
  104452. * Unbind all vertex attributes from the webGL context
  104453. */
  104454. unbindAllAttributes(): void;
  104455. /**
  104456. * 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
  104457. */
  104458. releaseEffects(): void;
  104459. /**
  104460. * Dispose and release all associated resources
  104461. */
  104462. dispose(): void;
  104463. /**
  104464. * Attach a new callback raised when context lost event is fired
  104465. * @param callback defines the callback to call
  104466. */
  104467. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104468. /**
  104469. * Attach a new callback raised when context restored event is fired
  104470. * @param callback defines the callback to call
  104471. */
  104472. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104473. /**
  104474. * Get the current error code of the webGL context
  104475. * @returns the error code
  104476. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104477. */
  104478. getError(): number;
  104479. private _canRenderToFloatFramebuffer;
  104480. private _canRenderToHalfFloatFramebuffer;
  104481. private _canRenderToFramebuffer;
  104482. /** @hidden */
  104483. _getWebGLTextureType(type: number): number;
  104484. /** @hidden */
  104485. _getInternalFormat(format: number): number;
  104486. /** @hidden */
  104487. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  104488. /** @hidden */
  104489. _getRGBAMultiSampleBufferFormat(type: number): number;
  104490. /** @hidden */
  104491. _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;
  104492. /**
  104493. * Loads a file from a url
  104494. * @param url url to load
  104495. * @param onSuccess callback called when the file successfully loads
  104496. * @param onProgress callback called while file is loading (if the server supports this mode)
  104497. * @param offlineProvider defines the offline provider for caching
  104498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104499. * @param onError callback called when the file fails to load
  104500. * @returns a file request object
  104501. * @hidden
  104502. */
  104503. 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;
  104504. /**
  104505. * Reads pixels from the current frame buffer. Please note that this function can be slow
  104506. * @param x defines the x coordinate of the rectangle where pixels must be read
  104507. * @param y defines the y coordinate of the rectangle where pixels must be read
  104508. * @param width defines the width of the rectangle where pixels must be read
  104509. * @param height defines the height of the rectangle where pixels must be read
  104510. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  104511. * @returns a Uint8Array containing RGBA colors
  104512. */
  104513. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  104514. private static _isSupported;
  104515. /**
  104516. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  104517. * @returns true if the engine can be created
  104518. * @ignorenaming
  104519. */
  104520. static isSupported(): boolean;
  104521. /**
  104522. * Find the next highest power of two.
  104523. * @param x Number to start search from.
  104524. * @return Next highest power of two.
  104525. */
  104526. static CeilingPOT(x: number): number;
  104527. /**
  104528. * Find the next lowest power of two.
  104529. * @param x Number to start search from.
  104530. * @return Next lowest power of two.
  104531. */
  104532. static FloorPOT(x: number): number;
  104533. /**
  104534. * Find the nearest power of two.
  104535. * @param x Number to start search from.
  104536. * @return Next nearest power of two.
  104537. */
  104538. static NearestPOT(x: number): number;
  104539. /**
  104540. * Get the closest exponent of two
  104541. * @param value defines the value to approximate
  104542. * @param max defines the maximum value to return
  104543. * @param mode defines how to define the closest value
  104544. * @returns closest exponent of two of the given value
  104545. */
  104546. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  104547. /**
  104548. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  104549. * @param func - the function to be called
  104550. * @param requester - the object that will request the next frame. Falls back to window.
  104551. * @returns frame number
  104552. */
  104553. static QueueNewFrame(func: () => void, requester?: any): number;
  104554. /**
  104555. * Gets host document
  104556. * @returns the host document object
  104557. */
  104558. getHostDocument(): Nullable<Document>;
  104559. }
  104560. }
  104561. declare module BABYLON {
  104562. /**
  104563. * Class representing spherical harmonics coefficients to the 3rd degree
  104564. */
  104565. export class SphericalHarmonics {
  104566. /**
  104567. * Defines whether or not the harmonics have been prescaled for rendering.
  104568. */
  104569. preScaled: boolean;
  104570. /**
  104571. * The l0,0 coefficients of the spherical harmonics
  104572. */
  104573. l00: Vector3;
  104574. /**
  104575. * The l1,-1 coefficients of the spherical harmonics
  104576. */
  104577. l1_1: Vector3;
  104578. /**
  104579. * The l1,0 coefficients of the spherical harmonics
  104580. */
  104581. l10: Vector3;
  104582. /**
  104583. * The l1,1 coefficients of the spherical harmonics
  104584. */
  104585. l11: Vector3;
  104586. /**
  104587. * The l2,-2 coefficients of the spherical harmonics
  104588. */
  104589. l2_2: Vector3;
  104590. /**
  104591. * The l2,-1 coefficients of the spherical harmonics
  104592. */
  104593. l2_1: Vector3;
  104594. /**
  104595. * The l2,0 coefficients of the spherical harmonics
  104596. */
  104597. l20: Vector3;
  104598. /**
  104599. * The l2,1 coefficients of the spherical harmonics
  104600. */
  104601. l21: Vector3;
  104602. /**
  104603. * The l2,2 coefficients of the spherical harmonics
  104604. */
  104605. l22: Vector3;
  104606. /**
  104607. * Adds a light to the spherical harmonics
  104608. * @param direction the direction of the light
  104609. * @param color the color of the light
  104610. * @param deltaSolidAngle the delta solid angle of the light
  104611. */
  104612. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  104613. /**
  104614. * Scales the spherical harmonics by the given amount
  104615. * @param scale the amount to scale
  104616. */
  104617. scaleInPlace(scale: number): void;
  104618. /**
  104619. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  104620. *
  104621. * ```
  104622. * E_lm = A_l * L_lm
  104623. * ```
  104624. *
  104625. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  104626. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  104627. * the scaling factors are given in equation 9.
  104628. */
  104629. convertIncidentRadianceToIrradiance(): void;
  104630. /**
  104631. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  104632. *
  104633. * ```
  104634. * L = (1/pi) * E * rho
  104635. * ```
  104636. *
  104637. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  104638. */
  104639. convertIrradianceToLambertianRadiance(): void;
  104640. /**
  104641. * Integrates the reconstruction coefficients directly in to the SH preventing further
  104642. * required operations at run time.
  104643. *
  104644. * This is simply done by scaling back the SH with Ylm constants parameter.
  104645. * The trigonometric part being applied by the shader at run time.
  104646. */
  104647. preScaleForRendering(): void;
  104648. /**
  104649. * Constructs a spherical harmonics from an array.
  104650. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  104651. * @returns the spherical harmonics
  104652. */
  104653. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  104654. /**
  104655. * Gets the spherical harmonics from polynomial
  104656. * @param polynomial the spherical polynomial
  104657. * @returns the spherical harmonics
  104658. */
  104659. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  104660. }
  104661. /**
  104662. * Class representing spherical polynomial coefficients to the 3rd degree
  104663. */
  104664. export class SphericalPolynomial {
  104665. private _harmonics;
  104666. /**
  104667. * The spherical harmonics used to create the polynomials.
  104668. */
  104669. get preScaledHarmonics(): SphericalHarmonics;
  104670. /**
  104671. * The x coefficients of the spherical polynomial
  104672. */
  104673. x: Vector3;
  104674. /**
  104675. * The y coefficients of the spherical polynomial
  104676. */
  104677. y: Vector3;
  104678. /**
  104679. * The z coefficients of the spherical polynomial
  104680. */
  104681. z: Vector3;
  104682. /**
  104683. * The xx coefficients of the spherical polynomial
  104684. */
  104685. xx: Vector3;
  104686. /**
  104687. * The yy coefficients of the spherical polynomial
  104688. */
  104689. yy: Vector3;
  104690. /**
  104691. * The zz coefficients of the spherical polynomial
  104692. */
  104693. zz: Vector3;
  104694. /**
  104695. * The xy coefficients of the spherical polynomial
  104696. */
  104697. xy: Vector3;
  104698. /**
  104699. * The yz coefficients of the spherical polynomial
  104700. */
  104701. yz: Vector3;
  104702. /**
  104703. * The zx coefficients of the spherical polynomial
  104704. */
  104705. zx: Vector3;
  104706. /**
  104707. * Adds an ambient color to the spherical polynomial
  104708. * @param color the color to add
  104709. */
  104710. addAmbient(color: Color3): void;
  104711. /**
  104712. * Scales the spherical polynomial by the given amount
  104713. * @param scale the amount to scale
  104714. */
  104715. scaleInPlace(scale: number): void;
  104716. /**
  104717. * Gets the spherical polynomial from harmonics
  104718. * @param harmonics the spherical harmonics
  104719. * @returns the spherical polynomial
  104720. */
  104721. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  104722. /**
  104723. * Constructs a spherical polynomial from an array.
  104724. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  104725. * @returns the spherical polynomial
  104726. */
  104727. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  104728. }
  104729. }
  104730. declare module BABYLON {
  104731. /**
  104732. * Defines the source of the internal texture
  104733. */
  104734. export enum InternalTextureSource {
  104735. /**
  104736. * The source of the texture data is unknown
  104737. */
  104738. Unknown = 0,
  104739. /**
  104740. * Texture data comes from an URL
  104741. */
  104742. Url = 1,
  104743. /**
  104744. * Texture data is only used for temporary storage
  104745. */
  104746. Temp = 2,
  104747. /**
  104748. * Texture data comes from raw data (ArrayBuffer)
  104749. */
  104750. Raw = 3,
  104751. /**
  104752. * Texture content is dynamic (video or dynamic texture)
  104753. */
  104754. Dynamic = 4,
  104755. /**
  104756. * Texture content is generated by rendering to it
  104757. */
  104758. RenderTarget = 5,
  104759. /**
  104760. * Texture content is part of a multi render target process
  104761. */
  104762. MultiRenderTarget = 6,
  104763. /**
  104764. * Texture data comes from a cube data file
  104765. */
  104766. Cube = 7,
  104767. /**
  104768. * Texture data comes from a raw cube data
  104769. */
  104770. CubeRaw = 8,
  104771. /**
  104772. * Texture data come from a prefiltered cube data file
  104773. */
  104774. CubePrefiltered = 9,
  104775. /**
  104776. * Texture content is raw 3D data
  104777. */
  104778. Raw3D = 10,
  104779. /**
  104780. * Texture content is raw 2D array data
  104781. */
  104782. Raw2DArray = 11,
  104783. /**
  104784. * Texture content is a depth texture
  104785. */
  104786. Depth = 12,
  104787. /**
  104788. * Texture data comes from a raw cube data encoded with RGBD
  104789. */
  104790. CubeRawRGBD = 13
  104791. }
  104792. /**
  104793. * Class used to store data associated with WebGL texture data for the engine
  104794. * This class should not be used directly
  104795. */
  104796. export class InternalTexture {
  104797. /** @hidden */
  104798. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  104799. /**
  104800. * Defines if the texture is ready
  104801. */
  104802. isReady: boolean;
  104803. /**
  104804. * Defines if the texture is a cube texture
  104805. */
  104806. isCube: boolean;
  104807. /**
  104808. * Defines if the texture contains 3D data
  104809. */
  104810. is3D: boolean;
  104811. /**
  104812. * Defines if the texture contains 2D array data
  104813. */
  104814. is2DArray: boolean;
  104815. /**
  104816. * Defines if the texture contains multiview data
  104817. */
  104818. isMultiview: boolean;
  104819. /**
  104820. * Gets the URL used to load this texture
  104821. */
  104822. url: string;
  104823. /**
  104824. * Gets the sampling mode of the texture
  104825. */
  104826. samplingMode: number;
  104827. /**
  104828. * Gets a boolean indicating if the texture needs mipmaps generation
  104829. */
  104830. generateMipMaps: boolean;
  104831. /**
  104832. * Gets the number of samples used by the texture (WebGL2+ only)
  104833. */
  104834. samples: number;
  104835. /**
  104836. * Gets the type of the texture (int, float...)
  104837. */
  104838. type: number;
  104839. /**
  104840. * Gets the format of the texture (RGB, RGBA...)
  104841. */
  104842. format: number;
  104843. /**
  104844. * Observable called when the texture is loaded
  104845. */
  104846. onLoadedObservable: Observable<InternalTexture>;
  104847. /**
  104848. * Gets the width of the texture
  104849. */
  104850. width: number;
  104851. /**
  104852. * Gets the height of the texture
  104853. */
  104854. height: number;
  104855. /**
  104856. * Gets the depth of the texture
  104857. */
  104858. depth: number;
  104859. /**
  104860. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  104861. */
  104862. baseWidth: number;
  104863. /**
  104864. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  104865. */
  104866. baseHeight: number;
  104867. /**
  104868. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  104869. */
  104870. baseDepth: number;
  104871. /**
  104872. * Gets a boolean indicating if the texture is inverted on Y axis
  104873. */
  104874. invertY: boolean;
  104875. /** @hidden */
  104876. _invertVScale: boolean;
  104877. /** @hidden */
  104878. _associatedChannel: number;
  104879. /** @hidden */
  104880. _source: InternalTextureSource;
  104881. /** @hidden */
  104882. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104883. /** @hidden */
  104884. _bufferView: Nullable<ArrayBufferView>;
  104885. /** @hidden */
  104886. _bufferViewArray: Nullable<ArrayBufferView[]>;
  104887. /** @hidden */
  104888. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  104889. /** @hidden */
  104890. _size: number;
  104891. /** @hidden */
  104892. _extension: string;
  104893. /** @hidden */
  104894. _files: Nullable<string[]>;
  104895. /** @hidden */
  104896. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104897. /** @hidden */
  104898. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104899. /** @hidden */
  104900. _framebuffer: Nullable<WebGLFramebuffer>;
  104901. /** @hidden */
  104902. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  104903. /** @hidden */
  104904. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  104905. /** @hidden */
  104906. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  104907. /** @hidden */
  104908. _attachments: Nullable<number[]>;
  104909. /** @hidden */
  104910. _cachedCoordinatesMode: Nullable<number>;
  104911. /** @hidden */
  104912. _cachedWrapU: Nullable<number>;
  104913. /** @hidden */
  104914. _cachedWrapV: Nullable<number>;
  104915. /** @hidden */
  104916. _cachedWrapR: Nullable<number>;
  104917. /** @hidden */
  104918. _cachedAnisotropicFilteringLevel: Nullable<number>;
  104919. /** @hidden */
  104920. _isDisabled: boolean;
  104921. /** @hidden */
  104922. _compression: Nullable<string>;
  104923. /** @hidden */
  104924. _generateStencilBuffer: boolean;
  104925. /** @hidden */
  104926. _generateDepthBuffer: boolean;
  104927. /** @hidden */
  104928. _comparisonFunction: number;
  104929. /** @hidden */
  104930. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  104931. /** @hidden */
  104932. _lodGenerationScale: number;
  104933. /** @hidden */
  104934. _lodGenerationOffset: number;
  104935. /** @hidden */
  104936. _depthStencilTexture: Nullable<InternalTexture>;
  104937. /** @hidden */
  104938. _colorTextureArray: Nullable<WebGLTexture>;
  104939. /** @hidden */
  104940. _depthStencilTextureArray: Nullable<WebGLTexture>;
  104941. /** @hidden */
  104942. _lodTextureHigh: Nullable<BaseTexture>;
  104943. /** @hidden */
  104944. _lodTextureMid: Nullable<BaseTexture>;
  104945. /** @hidden */
  104946. _lodTextureLow: Nullable<BaseTexture>;
  104947. /** @hidden */
  104948. _isRGBD: boolean;
  104949. /** @hidden */
  104950. _linearSpecularLOD: boolean;
  104951. /** @hidden */
  104952. _irradianceTexture: Nullable<BaseTexture>;
  104953. /** @hidden */
  104954. _webGLTexture: Nullable<WebGLTexture>;
  104955. /** @hidden */
  104956. _references: number;
  104957. private _engine;
  104958. /**
  104959. * Gets the Engine the texture belongs to.
  104960. * @returns The babylon engine
  104961. */
  104962. getEngine(): ThinEngine;
  104963. /**
  104964. * Gets the data source type of the texture
  104965. */
  104966. get source(): InternalTextureSource;
  104967. /**
  104968. * Creates a new InternalTexture
  104969. * @param engine defines the engine to use
  104970. * @param source defines the type of data that will be used
  104971. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104972. */
  104973. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  104974. /**
  104975. * Increments the number of references (ie. the number of Texture that point to it)
  104976. */
  104977. incrementReferences(): void;
  104978. /**
  104979. * Change the size of the texture (not the size of the content)
  104980. * @param width defines the new width
  104981. * @param height defines the new height
  104982. * @param depth defines the new depth (1 by default)
  104983. */
  104984. updateSize(width: int, height: int, depth?: int): void;
  104985. /** @hidden */
  104986. _rebuild(): void;
  104987. /** @hidden */
  104988. _swapAndDie(target: InternalTexture): void;
  104989. /**
  104990. * Dispose the current allocated resources
  104991. */
  104992. dispose(): void;
  104993. }
  104994. }
  104995. declare module BABYLON {
  104996. /**
  104997. * Class used to work with sound analyzer using fast fourier transform (FFT)
  104998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104999. */
  105000. export class Analyser {
  105001. /**
  105002. * Gets or sets the smoothing
  105003. * @ignorenaming
  105004. */
  105005. SMOOTHING: number;
  105006. /**
  105007. * Gets or sets the FFT table size
  105008. * @ignorenaming
  105009. */
  105010. FFT_SIZE: number;
  105011. /**
  105012. * Gets or sets the bar graph amplitude
  105013. * @ignorenaming
  105014. */
  105015. BARGRAPHAMPLITUDE: number;
  105016. /**
  105017. * Gets or sets the position of the debug canvas
  105018. * @ignorenaming
  105019. */
  105020. DEBUGCANVASPOS: {
  105021. x: number;
  105022. y: number;
  105023. };
  105024. /**
  105025. * Gets or sets the debug canvas size
  105026. * @ignorenaming
  105027. */
  105028. DEBUGCANVASSIZE: {
  105029. width: number;
  105030. height: number;
  105031. };
  105032. private _byteFreqs;
  105033. private _byteTime;
  105034. private _floatFreqs;
  105035. private _webAudioAnalyser;
  105036. private _debugCanvas;
  105037. private _debugCanvasContext;
  105038. private _scene;
  105039. private _registerFunc;
  105040. private _audioEngine;
  105041. /**
  105042. * Creates a new analyser
  105043. * @param scene defines hosting scene
  105044. */
  105045. constructor(scene: Scene);
  105046. /**
  105047. * Get the number of data values you will have to play with for the visualization
  105048. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105049. * @returns a number
  105050. */
  105051. getFrequencyBinCount(): number;
  105052. /**
  105053. * Gets the current frequency data as a byte array
  105054. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105055. * @returns a Uint8Array
  105056. */
  105057. getByteFrequencyData(): Uint8Array;
  105058. /**
  105059. * Gets the current waveform as a byte array
  105060. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105061. * @returns a Uint8Array
  105062. */
  105063. getByteTimeDomainData(): Uint8Array;
  105064. /**
  105065. * Gets the current frequency data as a float array
  105066. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105067. * @returns a Float32Array
  105068. */
  105069. getFloatFrequencyData(): Float32Array;
  105070. /**
  105071. * Renders the debug canvas
  105072. */
  105073. drawDebugCanvas(): void;
  105074. /**
  105075. * Stops rendering the debug canvas and removes it
  105076. */
  105077. stopDebugCanvas(): void;
  105078. /**
  105079. * Connects two audio nodes
  105080. * @param inputAudioNode defines first node to connect
  105081. * @param outputAudioNode defines second node to connect
  105082. */
  105083. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105084. /**
  105085. * Releases all associated resources
  105086. */
  105087. dispose(): void;
  105088. }
  105089. }
  105090. declare module BABYLON {
  105091. /**
  105092. * This represents an audio engine and it is responsible
  105093. * to play, synchronize and analyse sounds throughout the application.
  105094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105095. */
  105096. export interface IAudioEngine extends IDisposable {
  105097. /**
  105098. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105099. */
  105100. readonly canUseWebAudio: boolean;
  105101. /**
  105102. * Gets the current AudioContext if available.
  105103. */
  105104. readonly audioContext: Nullable<AudioContext>;
  105105. /**
  105106. * The master gain node defines the global audio volume of your audio engine.
  105107. */
  105108. readonly masterGain: GainNode;
  105109. /**
  105110. * Gets whether or not mp3 are supported by your browser.
  105111. */
  105112. readonly isMP3supported: boolean;
  105113. /**
  105114. * Gets whether or not ogg are supported by your browser.
  105115. */
  105116. readonly isOGGsupported: boolean;
  105117. /**
  105118. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105119. * @ignoreNaming
  105120. */
  105121. WarnedWebAudioUnsupported: boolean;
  105122. /**
  105123. * Defines if the audio engine relies on a custom unlocked button.
  105124. * In this case, the embedded button will not be displayed.
  105125. */
  105126. useCustomUnlockedButton: boolean;
  105127. /**
  105128. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105129. */
  105130. readonly unlocked: boolean;
  105131. /**
  105132. * Event raised when audio has been unlocked on the browser.
  105133. */
  105134. onAudioUnlockedObservable: Observable<AudioEngine>;
  105135. /**
  105136. * Event raised when audio has been locked on the browser.
  105137. */
  105138. onAudioLockedObservable: Observable<AudioEngine>;
  105139. /**
  105140. * Flags the audio engine in Locked state.
  105141. * This happens due to new browser policies preventing audio to autoplay.
  105142. */
  105143. lock(): void;
  105144. /**
  105145. * Unlocks the audio engine once a user action has been done on the dom.
  105146. * This is helpful to resume play once browser policies have been satisfied.
  105147. */
  105148. unlock(): void;
  105149. }
  105150. /**
  105151. * This represents the default audio engine used in babylon.
  105152. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105154. */
  105155. export class AudioEngine implements IAudioEngine {
  105156. private _audioContext;
  105157. private _audioContextInitialized;
  105158. private _muteButton;
  105159. private _hostElement;
  105160. /**
  105161. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105162. */
  105163. canUseWebAudio: boolean;
  105164. /**
  105165. * The master gain node defines the global audio volume of your audio engine.
  105166. */
  105167. masterGain: GainNode;
  105168. /**
  105169. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105170. * @ignoreNaming
  105171. */
  105172. WarnedWebAudioUnsupported: boolean;
  105173. /**
  105174. * Gets whether or not mp3 are supported by your browser.
  105175. */
  105176. isMP3supported: boolean;
  105177. /**
  105178. * Gets whether or not ogg are supported by your browser.
  105179. */
  105180. isOGGsupported: boolean;
  105181. /**
  105182. * Gets whether audio has been unlocked on the device.
  105183. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105184. * a user interaction has happened.
  105185. */
  105186. unlocked: boolean;
  105187. /**
  105188. * Defines if the audio engine relies on a custom unlocked button.
  105189. * In this case, the embedded button will not be displayed.
  105190. */
  105191. useCustomUnlockedButton: boolean;
  105192. /**
  105193. * Event raised when audio has been unlocked on the browser.
  105194. */
  105195. onAudioUnlockedObservable: Observable<AudioEngine>;
  105196. /**
  105197. * Event raised when audio has been locked on the browser.
  105198. */
  105199. onAudioLockedObservable: Observable<AudioEngine>;
  105200. /**
  105201. * Gets the current AudioContext if available.
  105202. */
  105203. get audioContext(): Nullable<AudioContext>;
  105204. private _connectedAnalyser;
  105205. /**
  105206. * Instantiates a new audio engine.
  105207. *
  105208. * There should be only one per page as some browsers restrict the number
  105209. * of audio contexts you can create.
  105210. * @param hostElement defines the host element where to display the mute icon if necessary
  105211. */
  105212. constructor(hostElement?: Nullable<HTMLElement>);
  105213. /**
  105214. * Flags the audio engine in Locked state.
  105215. * This happens due to new browser policies preventing audio to autoplay.
  105216. */
  105217. lock(): void;
  105218. /**
  105219. * Unlocks the audio engine once a user action has been done on the dom.
  105220. * This is helpful to resume play once browser policies have been satisfied.
  105221. */
  105222. unlock(): void;
  105223. private _resumeAudioContext;
  105224. private _initializeAudioContext;
  105225. private _tryToRun;
  105226. private _triggerRunningState;
  105227. private _triggerSuspendedState;
  105228. private _displayMuteButton;
  105229. private _moveButtonToTopLeft;
  105230. private _onResize;
  105231. private _hideMuteButton;
  105232. /**
  105233. * Destroy and release the resources associated with the audio ccontext.
  105234. */
  105235. dispose(): void;
  105236. /**
  105237. * Gets the global volume sets on the master gain.
  105238. * @returns the global volume if set or -1 otherwise
  105239. */
  105240. getGlobalVolume(): number;
  105241. /**
  105242. * Sets the global volume of your experience (sets on the master gain).
  105243. * @param newVolume Defines the new global volume of the application
  105244. */
  105245. setGlobalVolume(newVolume: number): void;
  105246. /**
  105247. * Connect the audio engine to an audio analyser allowing some amazing
  105248. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105250. * @param analyser The analyser to connect to the engine
  105251. */
  105252. connectToAnalyser(analyser: Analyser): void;
  105253. }
  105254. }
  105255. declare module BABYLON {
  105256. /**
  105257. * Interface used to present a loading screen while loading a scene
  105258. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105259. */
  105260. export interface ILoadingScreen {
  105261. /**
  105262. * Function called to display the loading screen
  105263. */
  105264. displayLoadingUI: () => void;
  105265. /**
  105266. * Function called to hide the loading screen
  105267. */
  105268. hideLoadingUI: () => void;
  105269. /**
  105270. * Gets or sets the color to use for the background
  105271. */
  105272. loadingUIBackgroundColor: string;
  105273. /**
  105274. * Gets or sets the text to display while loading
  105275. */
  105276. loadingUIText: string;
  105277. }
  105278. /**
  105279. * Class used for the default loading screen
  105280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105281. */
  105282. export class DefaultLoadingScreen implements ILoadingScreen {
  105283. private _renderingCanvas;
  105284. private _loadingText;
  105285. private _loadingDivBackgroundColor;
  105286. private _loadingDiv;
  105287. private _loadingTextDiv;
  105288. /** Gets or sets the logo url to use for the default loading screen */
  105289. static DefaultLogoUrl: string;
  105290. /** Gets or sets the spinner url to use for the default loading screen */
  105291. static DefaultSpinnerUrl: string;
  105292. /**
  105293. * Creates a new default loading screen
  105294. * @param _renderingCanvas defines the canvas used to render the scene
  105295. * @param _loadingText defines the default text to display
  105296. * @param _loadingDivBackgroundColor defines the default background color
  105297. */
  105298. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105299. /**
  105300. * Function called to display the loading screen
  105301. */
  105302. displayLoadingUI(): void;
  105303. /**
  105304. * Function called to hide the loading screen
  105305. */
  105306. hideLoadingUI(): void;
  105307. /**
  105308. * Gets or sets the text to display while loading
  105309. */
  105310. set loadingUIText(text: string);
  105311. get loadingUIText(): string;
  105312. /**
  105313. * Gets or sets the color to use for the background
  105314. */
  105315. get loadingUIBackgroundColor(): string;
  105316. set loadingUIBackgroundColor(color: string);
  105317. private _resizeLoadingUI;
  105318. }
  105319. }
  105320. declare module BABYLON {
  105321. /**
  105322. * Interface for any object that can request an animation frame
  105323. */
  105324. export interface ICustomAnimationFrameRequester {
  105325. /**
  105326. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105327. */
  105328. renderFunction?: Function;
  105329. /**
  105330. * Called to request the next frame to render to
  105331. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105332. */
  105333. requestAnimationFrame: Function;
  105334. /**
  105335. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105336. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105337. */
  105338. requestID?: number;
  105339. }
  105340. }
  105341. declare module BABYLON {
  105342. /**
  105343. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  105344. */
  105345. export class PerformanceMonitor {
  105346. private _enabled;
  105347. private _rollingFrameTime;
  105348. private _lastFrameTimeMs;
  105349. /**
  105350. * constructor
  105351. * @param frameSampleSize The number of samples required to saturate the sliding window
  105352. */
  105353. constructor(frameSampleSize?: number);
  105354. /**
  105355. * Samples current frame
  105356. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  105357. */
  105358. sampleFrame(timeMs?: number): void;
  105359. /**
  105360. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105361. */
  105362. get averageFrameTime(): number;
  105363. /**
  105364. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105365. */
  105366. get averageFrameTimeVariance(): number;
  105367. /**
  105368. * Returns the frame time of the most recent frame
  105369. */
  105370. get instantaneousFrameTime(): number;
  105371. /**
  105372. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  105373. */
  105374. get averageFPS(): number;
  105375. /**
  105376. * Returns the average framerate in frames per second using the most recent frame time
  105377. */
  105378. get instantaneousFPS(): number;
  105379. /**
  105380. * Returns true if enough samples have been taken to completely fill the sliding window
  105381. */
  105382. get isSaturated(): boolean;
  105383. /**
  105384. * Enables contributions to the sliding window sample set
  105385. */
  105386. enable(): void;
  105387. /**
  105388. * Disables contributions to the sliding window sample set
  105389. * Samples will not be interpolated over the disabled period
  105390. */
  105391. disable(): void;
  105392. /**
  105393. * Returns true if sampling is enabled
  105394. */
  105395. get isEnabled(): boolean;
  105396. /**
  105397. * Resets performance monitor
  105398. */
  105399. reset(): void;
  105400. }
  105401. /**
  105402. * RollingAverage
  105403. *
  105404. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  105405. */
  105406. export class RollingAverage {
  105407. /**
  105408. * Current average
  105409. */
  105410. average: number;
  105411. /**
  105412. * Current variance
  105413. */
  105414. variance: number;
  105415. protected _samples: Array<number>;
  105416. protected _sampleCount: number;
  105417. protected _pos: number;
  105418. protected _m2: number;
  105419. /**
  105420. * constructor
  105421. * @param length The number of samples required to saturate the sliding window
  105422. */
  105423. constructor(length: number);
  105424. /**
  105425. * Adds a sample to the sample set
  105426. * @param v The sample value
  105427. */
  105428. add(v: number): void;
  105429. /**
  105430. * Returns previously added values or null if outside of history or outside the sliding window domain
  105431. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  105432. * @return Value previously recorded with add() or null if outside of range
  105433. */
  105434. history(i: number): number;
  105435. /**
  105436. * Returns true if enough samples have been taken to completely fill the sliding window
  105437. * @return true if sample-set saturated
  105438. */
  105439. isSaturated(): boolean;
  105440. /**
  105441. * Resets the rolling average (equivalent to 0 samples taken so far)
  105442. */
  105443. reset(): void;
  105444. /**
  105445. * Wraps a value around the sample range boundaries
  105446. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  105447. * @return Wrapped position in sample range
  105448. */
  105449. protected _wrapPosition(i: number): number;
  105450. }
  105451. }
  105452. declare module BABYLON {
  105453. /**
  105454. * This class is used to track a performance counter which is number based.
  105455. * The user has access to many properties which give statistics of different nature.
  105456. *
  105457. * The implementer can track two kinds of Performance Counter: time and count.
  105458. * 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.
  105459. * 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.
  105460. */
  105461. export class PerfCounter {
  105462. /**
  105463. * Gets or sets a global boolean to turn on and off all the counters
  105464. */
  105465. static Enabled: boolean;
  105466. /**
  105467. * Returns the smallest value ever
  105468. */
  105469. get min(): number;
  105470. /**
  105471. * Returns the biggest value ever
  105472. */
  105473. get max(): number;
  105474. /**
  105475. * Returns the average value since the performance counter is running
  105476. */
  105477. get average(): number;
  105478. /**
  105479. * Returns the average value of the last second the counter was monitored
  105480. */
  105481. get lastSecAverage(): number;
  105482. /**
  105483. * Returns the current value
  105484. */
  105485. get current(): number;
  105486. /**
  105487. * Gets the accumulated total
  105488. */
  105489. get total(): number;
  105490. /**
  105491. * Gets the total value count
  105492. */
  105493. get count(): number;
  105494. /**
  105495. * Creates a new counter
  105496. */
  105497. constructor();
  105498. /**
  105499. * Call this method to start monitoring a new frame.
  105500. * 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.
  105501. */
  105502. fetchNewFrame(): void;
  105503. /**
  105504. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  105505. * @param newCount the count value to add to the monitored count
  105506. * @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.
  105507. */
  105508. addCount(newCount: number, fetchResult: boolean): void;
  105509. /**
  105510. * Start monitoring this performance counter
  105511. */
  105512. beginMonitoring(): void;
  105513. /**
  105514. * Compute the time lapsed since the previous beginMonitoring() call.
  105515. * @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
  105516. */
  105517. endMonitoring(newFrame?: boolean): void;
  105518. private _fetchResult;
  105519. private _startMonitoringTime;
  105520. private _min;
  105521. private _max;
  105522. private _average;
  105523. private _current;
  105524. private _totalValueCount;
  105525. private _totalAccumulated;
  105526. private _lastSecAverage;
  105527. private _lastSecAccumulated;
  105528. private _lastSecTime;
  105529. private _lastSecValueCount;
  105530. }
  105531. }
  105532. declare module BABYLON {
  105533. interface ThinEngine {
  105534. /**
  105535. * Sets alpha constants used by some alpha blending modes
  105536. * @param r defines the red component
  105537. * @param g defines the green component
  105538. * @param b defines the blue component
  105539. * @param a defines the alpha component
  105540. */
  105541. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  105542. /**
  105543. * Sets the current alpha mode
  105544. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  105545. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  105546. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105547. */
  105548. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105549. /**
  105550. * Gets the current alpha mode
  105551. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105552. * @returns the current alpha mode
  105553. */
  105554. getAlphaMode(): number;
  105555. /**
  105556. * Sets the current alpha equation
  105557. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  105558. */
  105559. setAlphaEquation(equation: number): void;
  105560. /**
  105561. * Gets the current alpha equation.
  105562. * @returns the current alpha equation
  105563. */
  105564. getAlphaEquation(): number;
  105565. }
  105566. }
  105567. declare module BABYLON {
  105568. /**
  105569. * Defines the interface used by display changed events
  105570. */
  105571. export interface IDisplayChangedEventArgs {
  105572. /** Gets the vrDisplay object (if any) */
  105573. vrDisplay: Nullable<any>;
  105574. /** Gets a boolean indicating if webVR is supported */
  105575. vrSupported: boolean;
  105576. }
  105577. /**
  105578. * Defines the interface used by objects containing a viewport (like a camera)
  105579. */
  105580. interface IViewportOwnerLike {
  105581. /**
  105582. * Gets or sets the viewport
  105583. */
  105584. viewport: IViewportLike;
  105585. }
  105586. /**
  105587. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  105588. */
  105589. export class Engine extends ThinEngine {
  105590. /** Defines that alpha blending is disabled */
  105591. static readonly ALPHA_DISABLE: number;
  105592. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  105593. static readonly ALPHA_ADD: number;
  105594. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  105595. static readonly ALPHA_COMBINE: number;
  105596. /** Defines that alpha blending to DEST - SRC * DEST */
  105597. static readonly ALPHA_SUBTRACT: number;
  105598. /** Defines that alpha blending to SRC * DEST */
  105599. static readonly ALPHA_MULTIPLY: number;
  105600. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  105601. static readonly ALPHA_MAXIMIZED: number;
  105602. /** Defines that alpha blending to SRC + DEST */
  105603. static readonly ALPHA_ONEONE: number;
  105604. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  105605. static readonly ALPHA_PREMULTIPLIED: number;
  105606. /**
  105607. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  105608. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  105609. */
  105610. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  105611. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  105612. static readonly ALPHA_INTERPOLATE: number;
  105613. /**
  105614. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  105615. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  105616. */
  105617. static readonly ALPHA_SCREENMODE: number;
  105618. /** Defines that the ressource is not delayed*/
  105619. static readonly DELAYLOADSTATE_NONE: number;
  105620. /** Defines that the ressource was successfully delay loaded */
  105621. static readonly DELAYLOADSTATE_LOADED: number;
  105622. /** Defines that the ressource is currently delay loading */
  105623. static readonly DELAYLOADSTATE_LOADING: number;
  105624. /** Defines that the ressource is delayed and has not started loading */
  105625. static readonly DELAYLOADSTATE_NOTLOADED: number;
  105626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  105627. static readonly NEVER: number;
  105628. /** 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 */
  105629. static readonly ALWAYS: number;
  105630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  105631. static readonly LESS: number;
  105632. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  105633. static readonly EQUAL: number;
  105634. /** 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 */
  105635. static readonly LEQUAL: number;
  105636. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  105637. static readonly GREATER: number;
  105638. /** 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 */
  105639. static readonly GEQUAL: number;
  105640. /** 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 */
  105641. static readonly NOTEQUAL: number;
  105642. /** Passed to stencilOperation to specify that stencil value must be kept */
  105643. static readonly KEEP: number;
  105644. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105645. static readonly REPLACE: number;
  105646. /** Passed to stencilOperation to specify that stencil value must be incremented */
  105647. static readonly INCR: number;
  105648. /** Passed to stencilOperation to specify that stencil value must be decremented */
  105649. static readonly DECR: number;
  105650. /** Passed to stencilOperation to specify that stencil value must be inverted */
  105651. static readonly INVERT: number;
  105652. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  105653. static readonly INCR_WRAP: number;
  105654. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  105655. static readonly DECR_WRAP: number;
  105656. /** Texture is not repeating outside of 0..1 UVs */
  105657. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  105658. /** Texture is repeating outside of 0..1 UVs */
  105659. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  105660. /** Texture is repeating and mirrored */
  105661. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  105662. /** ALPHA */
  105663. static readonly TEXTUREFORMAT_ALPHA: number;
  105664. /** LUMINANCE */
  105665. static readonly TEXTUREFORMAT_LUMINANCE: number;
  105666. /** LUMINANCE_ALPHA */
  105667. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  105668. /** RGB */
  105669. static readonly TEXTUREFORMAT_RGB: number;
  105670. /** RGBA */
  105671. static readonly TEXTUREFORMAT_RGBA: number;
  105672. /** RED */
  105673. static readonly TEXTUREFORMAT_RED: number;
  105674. /** RED (2nd reference) */
  105675. static readonly TEXTUREFORMAT_R: number;
  105676. /** RG */
  105677. static readonly TEXTUREFORMAT_RG: number;
  105678. /** RED_INTEGER */
  105679. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  105680. /** RED_INTEGER (2nd reference) */
  105681. static readonly TEXTUREFORMAT_R_INTEGER: number;
  105682. /** RG_INTEGER */
  105683. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  105684. /** RGB_INTEGER */
  105685. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  105686. /** RGBA_INTEGER */
  105687. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  105688. /** UNSIGNED_BYTE */
  105689. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  105690. /** UNSIGNED_BYTE (2nd reference) */
  105691. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  105692. /** FLOAT */
  105693. static readonly TEXTURETYPE_FLOAT: number;
  105694. /** HALF_FLOAT */
  105695. static readonly TEXTURETYPE_HALF_FLOAT: number;
  105696. /** BYTE */
  105697. static readonly TEXTURETYPE_BYTE: number;
  105698. /** SHORT */
  105699. static readonly TEXTURETYPE_SHORT: number;
  105700. /** UNSIGNED_SHORT */
  105701. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  105702. /** INT */
  105703. static readonly TEXTURETYPE_INT: number;
  105704. /** UNSIGNED_INT */
  105705. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  105706. /** UNSIGNED_SHORT_4_4_4_4 */
  105707. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  105708. /** UNSIGNED_SHORT_5_5_5_1 */
  105709. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  105710. /** UNSIGNED_SHORT_5_6_5 */
  105711. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  105712. /** UNSIGNED_INT_2_10_10_10_REV */
  105713. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  105714. /** UNSIGNED_INT_24_8 */
  105715. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  105716. /** UNSIGNED_INT_10F_11F_11F_REV */
  105717. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  105718. /** UNSIGNED_INT_5_9_9_9_REV */
  105719. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  105720. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  105721. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  105722. /** nearest is mag = nearest and min = nearest and mip = linear */
  105723. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  105724. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105725. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  105726. /** Trilinear is mag = linear and min = linear and mip = linear */
  105727. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  105728. /** nearest is mag = nearest and min = nearest and mip = linear */
  105729. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  105730. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105731. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  105732. /** Trilinear is mag = linear and min = linear and mip = linear */
  105733. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  105734. /** mag = nearest and min = nearest and mip = nearest */
  105735. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  105736. /** mag = nearest and min = linear and mip = nearest */
  105737. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  105738. /** mag = nearest and min = linear and mip = linear */
  105739. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  105740. /** mag = nearest and min = linear and mip = none */
  105741. static readonly TEXTURE_NEAREST_LINEAR: number;
  105742. /** mag = nearest and min = nearest and mip = none */
  105743. static readonly TEXTURE_NEAREST_NEAREST: number;
  105744. /** mag = linear and min = nearest and mip = nearest */
  105745. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  105746. /** mag = linear and min = nearest and mip = linear */
  105747. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  105748. /** mag = linear and min = linear and mip = none */
  105749. static readonly TEXTURE_LINEAR_LINEAR: number;
  105750. /** mag = linear and min = nearest and mip = none */
  105751. static readonly TEXTURE_LINEAR_NEAREST: number;
  105752. /** Explicit coordinates mode */
  105753. static readonly TEXTURE_EXPLICIT_MODE: number;
  105754. /** Spherical coordinates mode */
  105755. static readonly TEXTURE_SPHERICAL_MODE: number;
  105756. /** Planar coordinates mode */
  105757. static readonly TEXTURE_PLANAR_MODE: number;
  105758. /** Cubic coordinates mode */
  105759. static readonly TEXTURE_CUBIC_MODE: number;
  105760. /** Projection coordinates mode */
  105761. static readonly TEXTURE_PROJECTION_MODE: number;
  105762. /** Skybox coordinates mode */
  105763. static readonly TEXTURE_SKYBOX_MODE: number;
  105764. /** Inverse Cubic coordinates mode */
  105765. static readonly TEXTURE_INVCUBIC_MODE: number;
  105766. /** Equirectangular coordinates mode */
  105767. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  105768. /** Equirectangular Fixed coordinates mode */
  105769. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  105770. /** Equirectangular Fixed Mirrored coordinates mode */
  105771. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  105772. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  105773. static readonly SCALEMODE_FLOOR: number;
  105774. /** Defines that texture rescaling will look for the nearest power of 2 size */
  105775. static readonly SCALEMODE_NEAREST: number;
  105776. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  105777. static readonly SCALEMODE_CEILING: number;
  105778. /**
  105779. * Returns the current npm package of the sdk
  105780. */
  105781. static get NpmPackage(): string;
  105782. /**
  105783. * Returns the current version of the framework
  105784. */
  105785. static get Version(): string;
  105786. /** Gets the list of created engines */
  105787. static get Instances(): Engine[];
  105788. /**
  105789. * Gets the latest created engine
  105790. */
  105791. static get LastCreatedEngine(): Nullable<Engine>;
  105792. /**
  105793. * Gets the latest created scene
  105794. */
  105795. static get LastCreatedScene(): Nullable<Scene>;
  105796. /**
  105797. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  105798. * @param flag defines which part of the materials must be marked as dirty
  105799. * @param predicate defines a predicate used to filter which materials should be affected
  105800. */
  105801. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105802. /**
  105803. * Method called to create the default loading screen.
  105804. * This can be overriden in your own app.
  105805. * @param canvas The rendering canvas element
  105806. * @returns The loading screen
  105807. */
  105808. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  105809. /**
  105810. * Method called to create the default rescale post process on each engine.
  105811. */
  105812. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  105813. /**
  105814. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  105815. **/
  105816. enableOfflineSupport: boolean;
  105817. /**
  105818. * 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)
  105819. **/
  105820. disableManifestCheck: boolean;
  105821. /**
  105822. * Gets the list of created scenes
  105823. */
  105824. scenes: Scene[];
  105825. /**
  105826. * Event raised when a new scene is created
  105827. */
  105828. onNewSceneAddedObservable: Observable<Scene>;
  105829. /**
  105830. * Gets the list of created postprocesses
  105831. */
  105832. postProcesses: PostProcess[];
  105833. /**
  105834. * Gets a boolean indicating if the pointer is currently locked
  105835. */
  105836. isPointerLock: boolean;
  105837. /**
  105838. * Observable event triggered each time the rendering canvas is resized
  105839. */
  105840. onResizeObservable: Observable<Engine>;
  105841. /**
  105842. * Observable event triggered each time the canvas loses focus
  105843. */
  105844. onCanvasBlurObservable: Observable<Engine>;
  105845. /**
  105846. * Observable event triggered each time the canvas gains focus
  105847. */
  105848. onCanvasFocusObservable: Observable<Engine>;
  105849. /**
  105850. * Observable event triggered each time the canvas receives pointerout event
  105851. */
  105852. onCanvasPointerOutObservable: Observable<PointerEvent>;
  105853. /**
  105854. * Observable raised when the engine begins a new frame
  105855. */
  105856. onBeginFrameObservable: Observable<Engine>;
  105857. /**
  105858. * If set, will be used to request the next animation frame for the render loop
  105859. */
  105860. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  105861. /**
  105862. * Observable raised when the engine ends the current frame
  105863. */
  105864. onEndFrameObservable: Observable<Engine>;
  105865. /**
  105866. * Observable raised when the engine is about to compile a shader
  105867. */
  105868. onBeforeShaderCompilationObservable: Observable<Engine>;
  105869. /**
  105870. * Observable raised when the engine has jsut compiled a shader
  105871. */
  105872. onAfterShaderCompilationObservable: Observable<Engine>;
  105873. /**
  105874. * Gets the audio engine
  105875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105876. * @ignorenaming
  105877. */
  105878. static audioEngine: IAudioEngine;
  105879. /**
  105880. * Default AudioEngine factory responsible of creating the Audio Engine.
  105881. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  105882. */
  105883. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  105884. /**
  105885. * Default offline support factory responsible of creating a tool used to store data locally.
  105886. * By default, this will create a Database object if the workload has been embedded.
  105887. */
  105888. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  105889. private _loadingScreen;
  105890. private _pointerLockRequested;
  105891. private _dummyFramebuffer;
  105892. private _rescalePostProcess;
  105893. private _deterministicLockstep;
  105894. private _lockstepMaxSteps;
  105895. private _timeStep;
  105896. protected get _supportsHardwareTextureRescaling(): boolean;
  105897. private _fps;
  105898. private _deltaTime;
  105899. /** @hidden */
  105900. _drawCalls: PerfCounter;
  105901. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  105902. canvasTabIndex: number;
  105903. /**
  105904. * Turn this value on if you want to pause FPS computation when in background
  105905. */
  105906. disablePerformanceMonitorInBackground: boolean;
  105907. private _performanceMonitor;
  105908. /**
  105909. * Gets the performance monitor attached to this engine
  105910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105911. */
  105912. get performanceMonitor(): PerformanceMonitor;
  105913. private _onFocus;
  105914. private _onBlur;
  105915. private _onCanvasPointerOut;
  105916. private _onCanvasBlur;
  105917. private _onCanvasFocus;
  105918. private _onFullscreenChange;
  105919. private _onPointerLockChange;
  105920. /**
  105921. * Gets the HTML element used to attach event listeners
  105922. * @returns a HTML element
  105923. */
  105924. getInputElement(): Nullable<HTMLElement>;
  105925. /**
  105926. * Creates a new engine
  105927. * @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
  105928. * @param antialias defines enable antialiasing (default: false)
  105929. * @param options defines further options to be sent to the getContext() function
  105930. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105931. */
  105932. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105933. /**
  105934. * Gets current aspect ratio
  105935. * @param viewportOwner defines the camera to use to get the aspect ratio
  105936. * @param useScreen defines if screen size must be used (or the current render target if any)
  105937. * @returns a number defining the aspect ratio
  105938. */
  105939. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  105940. /**
  105941. * Gets current screen aspect ratio
  105942. * @returns a number defining the aspect ratio
  105943. */
  105944. getScreenAspectRatio(): number;
  105945. /**
  105946. * Gets the client rect of the HTML canvas attached with the current webGL context
  105947. * @returns a client rectanglee
  105948. */
  105949. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  105950. /**
  105951. * Gets the client rect of the HTML element used for events
  105952. * @returns a client rectanglee
  105953. */
  105954. getInputElementClientRect(): Nullable<ClientRect>;
  105955. /**
  105956. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  105957. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105958. * @returns true if engine is in deterministic lock step mode
  105959. */
  105960. isDeterministicLockStep(): boolean;
  105961. /**
  105962. * Gets the max steps when engine is running in deterministic lock step
  105963. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105964. * @returns the max steps
  105965. */
  105966. getLockstepMaxSteps(): number;
  105967. /**
  105968. * Returns the time in ms between steps when using deterministic lock step.
  105969. * @returns time step in (ms)
  105970. */
  105971. getTimeStep(): number;
  105972. /**
  105973. * Force the mipmap generation for the given render target texture
  105974. * @param texture defines the render target texture to use
  105975. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  105976. */
  105977. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  105978. /** States */
  105979. /**
  105980. * Set various states to the webGL context
  105981. * @param culling defines backface culling state
  105982. * @param zOffset defines the value to apply to zOffset (0 by default)
  105983. * @param force defines if states must be applied even if cache is up to date
  105984. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  105985. */
  105986. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  105987. /**
  105988. * Set the z offset to apply to current rendering
  105989. * @param value defines the offset to apply
  105990. */
  105991. setZOffset(value: number): void;
  105992. /**
  105993. * Gets the current value of the zOffset
  105994. * @returns the current zOffset state
  105995. */
  105996. getZOffset(): number;
  105997. /**
  105998. * Enable or disable depth buffering
  105999. * @param enable defines the state to set
  106000. */
  106001. setDepthBuffer(enable: boolean): void;
  106002. /**
  106003. * Gets a boolean indicating if depth writing is enabled
  106004. * @returns the current depth writing state
  106005. */
  106006. getDepthWrite(): boolean;
  106007. /**
  106008. * Enable or disable depth writing
  106009. * @param enable defines the state to set
  106010. */
  106011. setDepthWrite(enable: boolean): void;
  106012. /**
  106013. * Gets a boolean indicating if stencil buffer is enabled
  106014. * @returns the current stencil buffer state
  106015. */
  106016. getStencilBuffer(): boolean;
  106017. /**
  106018. * Enable or disable the stencil buffer
  106019. * @param enable defines if the stencil buffer must be enabled or disabled
  106020. */
  106021. setStencilBuffer(enable: boolean): void;
  106022. /**
  106023. * Gets the current stencil mask
  106024. * @returns a number defining the new stencil mask to use
  106025. */
  106026. getStencilMask(): number;
  106027. /**
  106028. * Sets the current stencil mask
  106029. * @param mask defines the new stencil mask to use
  106030. */
  106031. setStencilMask(mask: number): void;
  106032. /**
  106033. * Gets the current stencil function
  106034. * @returns a number defining the stencil function to use
  106035. */
  106036. getStencilFunction(): number;
  106037. /**
  106038. * Gets the current stencil reference value
  106039. * @returns a number defining the stencil reference value to use
  106040. */
  106041. getStencilFunctionReference(): number;
  106042. /**
  106043. * Gets the current stencil mask
  106044. * @returns a number defining the stencil mask to use
  106045. */
  106046. getStencilFunctionMask(): number;
  106047. /**
  106048. * Sets the current stencil function
  106049. * @param stencilFunc defines the new stencil function to use
  106050. */
  106051. setStencilFunction(stencilFunc: number): void;
  106052. /**
  106053. * Sets the current stencil reference
  106054. * @param reference defines the new stencil reference to use
  106055. */
  106056. setStencilFunctionReference(reference: number): void;
  106057. /**
  106058. * Sets the current stencil mask
  106059. * @param mask defines the new stencil mask to use
  106060. */
  106061. setStencilFunctionMask(mask: number): void;
  106062. /**
  106063. * Gets the current stencil operation when stencil fails
  106064. * @returns a number defining stencil operation to use when stencil fails
  106065. */
  106066. getStencilOperationFail(): number;
  106067. /**
  106068. * Gets the current stencil operation when depth fails
  106069. * @returns a number defining stencil operation to use when depth fails
  106070. */
  106071. getStencilOperationDepthFail(): number;
  106072. /**
  106073. * Gets the current stencil operation when stencil passes
  106074. * @returns a number defining stencil operation to use when stencil passes
  106075. */
  106076. getStencilOperationPass(): number;
  106077. /**
  106078. * Sets the stencil operation to use when stencil fails
  106079. * @param operation defines the stencil operation to use when stencil fails
  106080. */
  106081. setStencilOperationFail(operation: number): void;
  106082. /**
  106083. * Sets the stencil operation to use when depth fails
  106084. * @param operation defines the stencil operation to use when depth fails
  106085. */
  106086. setStencilOperationDepthFail(operation: number): void;
  106087. /**
  106088. * Sets the stencil operation to use when stencil passes
  106089. * @param operation defines the stencil operation to use when stencil passes
  106090. */
  106091. setStencilOperationPass(operation: number): void;
  106092. /**
  106093. * Sets a boolean indicating if the dithering state is enabled or disabled
  106094. * @param value defines the dithering state
  106095. */
  106096. setDitheringState(value: boolean): void;
  106097. /**
  106098. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106099. * @param value defines the rasterizer state
  106100. */
  106101. setRasterizerState(value: boolean): void;
  106102. /**
  106103. * Gets the current depth function
  106104. * @returns a number defining the depth function
  106105. */
  106106. getDepthFunction(): Nullable<number>;
  106107. /**
  106108. * Sets the current depth function
  106109. * @param depthFunc defines the function to use
  106110. */
  106111. setDepthFunction(depthFunc: number): void;
  106112. /**
  106113. * Sets the current depth function to GREATER
  106114. */
  106115. setDepthFunctionToGreater(): void;
  106116. /**
  106117. * Sets the current depth function to GEQUAL
  106118. */
  106119. setDepthFunctionToGreaterOrEqual(): void;
  106120. /**
  106121. * Sets the current depth function to LESS
  106122. */
  106123. setDepthFunctionToLess(): void;
  106124. /**
  106125. * Sets the current depth function to LEQUAL
  106126. */
  106127. setDepthFunctionToLessOrEqual(): void;
  106128. private _cachedStencilBuffer;
  106129. private _cachedStencilFunction;
  106130. private _cachedStencilMask;
  106131. private _cachedStencilOperationPass;
  106132. private _cachedStencilOperationFail;
  106133. private _cachedStencilOperationDepthFail;
  106134. private _cachedStencilReference;
  106135. /**
  106136. * Caches the the state of the stencil buffer
  106137. */
  106138. cacheStencilState(): void;
  106139. /**
  106140. * Restores the state of the stencil buffer
  106141. */
  106142. restoreStencilState(): void;
  106143. /**
  106144. * Directly set the WebGL Viewport
  106145. * @param x defines the x coordinate of the viewport (in screen space)
  106146. * @param y defines the y coordinate of the viewport (in screen space)
  106147. * @param width defines the width of the viewport (in screen space)
  106148. * @param height defines the height of the viewport (in screen space)
  106149. * @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
  106150. */
  106151. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106152. /**
  106153. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106154. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106155. * @param y defines the y-coordinate of the corner of the clear rectangle
  106156. * @param width defines the width of the clear rectangle
  106157. * @param height defines the height of the clear rectangle
  106158. * @param clearColor defines the clear color
  106159. */
  106160. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106161. /**
  106162. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106163. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106164. * @param y defines the y-coordinate of the corner of the clear rectangle
  106165. * @param width defines the width of the clear rectangle
  106166. * @param height defines the height of the clear rectangle
  106167. */
  106168. enableScissor(x: number, y: number, width: number, height: number): void;
  106169. /**
  106170. * Disable previously set scissor test rectangle
  106171. */
  106172. disableScissor(): void;
  106173. protected _reportDrawCall(): void;
  106174. /**
  106175. * Initializes a webVR display and starts listening to display change events
  106176. * The onVRDisplayChangedObservable will be notified upon these changes
  106177. * @returns The onVRDisplayChangedObservable
  106178. */
  106179. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106180. /** @hidden */
  106181. _prepareVRComponent(): void;
  106182. /** @hidden */
  106183. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106184. /** @hidden */
  106185. _submitVRFrame(): void;
  106186. /**
  106187. * Call this function to leave webVR mode
  106188. * Will do nothing if webVR is not supported or if there is no webVR device
  106189. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106190. */
  106191. disableVR(): void;
  106192. /**
  106193. * Gets a boolean indicating that the system is in VR mode and is presenting
  106194. * @returns true if VR mode is engaged
  106195. */
  106196. isVRPresenting(): boolean;
  106197. /** @hidden */
  106198. _requestVRFrame(): void;
  106199. /** @hidden */
  106200. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106201. /**
  106202. * Gets the source code of the vertex shader associated with a specific webGL program
  106203. * @param program defines the program to use
  106204. * @returns a string containing the source code of the vertex shader associated with the program
  106205. */
  106206. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106207. /**
  106208. * Gets the source code of the fragment shader associated with a specific webGL program
  106209. * @param program defines the program to use
  106210. * @returns a string containing the source code of the fragment shader associated with the program
  106211. */
  106212. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106213. /**
  106214. * Sets a depth stencil texture from a render target to the according uniform.
  106215. * @param channel The texture channel
  106216. * @param uniform The uniform to set
  106217. * @param texture The render target texture containing the depth stencil texture to apply
  106218. */
  106219. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106220. /**
  106221. * Sets a texture to the webGL context from a postprocess
  106222. * @param channel defines the channel to use
  106223. * @param postProcess defines the source postprocess
  106224. */
  106225. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106226. /**
  106227. * Binds the output of the passed in post process to the texture channel specified
  106228. * @param channel The channel the texture should be bound to
  106229. * @param postProcess The post process which's output should be bound
  106230. */
  106231. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106232. /** @hidden */
  106233. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106234. protected _rebuildBuffers(): void;
  106235. /** @hidden */
  106236. _renderFrame(): void;
  106237. _renderLoop(): void;
  106238. /** @hidden */
  106239. _renderViews(): boolean;
  106240. /**
  106241. * Toggle full screen mode
  106242. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106243. */
  106244. switchFullscreen(requestPointerLock: boolean): void;
  106245. /**
  106246. * Enters full screen mode
  106247. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106248. */
  106249. enterFullscreen(requestPointerLock: boolean): void;
  106250. /**
  106251. * Exits full screen mode
  106252. */
  106253. exitFullscreen(): void;
  106254. /**
  106255. * Enters Pointerlock mode
  106256. */
  106257. enterPointerlock(): void;
  106258. /**
  106259. * Exits Pointerlock mode
  106260. */
  106261. exitPointerlock(): void;
  106262. /**
  106263. * Begin a new frame
  106264. */
  106265. beginFrame(): void;
  106266. /**
  106267. * Enf the current frame
  106268. */
  106269. endFrame(): void;
  106270. resize(): void;
  106271. /**
  106272. * Set the compressed texture format to use, based on the formats you have, and the formats
  106273. * supported by the hardware / browser.
  106274. *
  106275. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106276. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106277. * to API arguments needed to compressed textures. This puts the burden on the container
  106278. * generator to house the arcane code for determining these for current & future formats.
  106279. *
  106280. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106281. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106282. *
  106283. * Note: The result of this call is not taken into account when a texture is base64.
  106284. *
  106285. * @param formatsAvailable defines the list of those format families you have created
  106286. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106287. *
  106288. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106289. * @returns The extension selected.
  106290. */
  106291. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106292. /**
  106293. * Set the compressed texture extensions or file names to skip.
  106294. *
  106295. * @param skippedFiles defines the list of those texture files you want to skip
  106296. * Example: [".dds", ".env", "myfile.png"]
  106297. */
  106298. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106299. /**
  106300. * Force a specific size of the canvas
  106301. * @param width defines the new canvas' width
  106302. * @param height defines the new canvas' height
  106303. */
  106304. setSize(width: number, height: number): void;
  106305. /**
  106306. * Updates a dynamic vertex buffer.
  106307. * @param vertexBuffer the vertex buffer to update
  106308. * @param data the data used to update the vertex buffer
  106309. * @param byteOffset the byte offset of the data
  106310. * @param byteLength the byte length of the data
  106311. */
  106312. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106313. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106314. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106315. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106316. _releaseTexture(texture: InternalTexture): void;
  106317. /**
  106318. * @hidden
  106319. * Rescales a texture
  106320. * @param source input texutre
  106321. * @param destination destination texture
  106322. * @param scene scene to use to render the resize
  106323. * @param internalFormat format to use when resizing
  106324. * @param onComplete callback to be called when resize has completed
  106325. */
  106326. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106327. /**
  106328. * Gets the current framerate
  106329. * @returns a number representing the framerate
  106330. */
  106331. getFps(): number;
  106332. /**
  106333. * Gets the time spent between current and previous frame
  106334. * @returns a number representing the delta time in ms
  106335. */
  106336. getDeltaTime(): number;
  106337. private _measureFps;
  106338. /** @hidden */
  106339. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106340. /**
  106341. * Update a dynamic index buffer
  106342. * @param indexBuffer defines the target index buffer
  106343. * @param indices defines the data to update
  106344. * @param offset defines the offset in the target index buffer where update should start
  106345. */
  106346. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106347. /**
  106348. * Updates the sample count of a render target texture
  106349. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106350. * @param texture defines the texture to update
  106351. * @param samples defines the sample count to set
  106352. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106353. */
  106354. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106355. /**
  106356. * Updates a depth texture Comparison Mode and Function.
  106357. * If the comparison Function is equal to 0, the mode will be set to none.
  106358. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106359. * @param texture The texture to set the comparison function for
  106360. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106361. */
  106362. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106363. /**
  106364. * Creates a webGL buffer to use with instanciation
  106365. * @param capacity defines the size of the buffer
  106366. * @returns the webGL buffer
  106367. */
  106368. createInstancesBuffer(capacity: number): DataBuffer;
  106369. /**
  106370. * Delete a webGL buffer used with instanciation
  106371. * @param buffer defines the webGL buffer to delete
  106372. */
  106373. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  106374. /** @hidden */
  106375. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  106376. dispose(): void;
  106377. private _disableTouchAction;
  106378. /**
  106379. * Display the loading screen
  106380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106381. */
  106382. displayLoadingUI(): void;
  106383. /**
  106384. * Hide the loading screen
  106385. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106386. */
  106387. hideLoadingUI(): void;
  106388. /**
  106389. * Gets the current loading screen object
  106390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106391. */
  106392. get loadingScreen(): ILoadingScreen;
  106393. /**
  106394. * Sets the current loading screen object
  106395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106396. */
  106397. set loadingScreen(loadingScreen: ILoadingScreen);
  106398. /**
  106399. * Sets the current loading screen text
  106400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106401. */
  106402. set loadingUIText(text: string);
  106403. /**
  106404. * Sets the current loading screen background color
  106405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106406. */
  106407. set loadingUIBackgroundColor(color: string);
  106408. /** Pointerlock and fullscreen */
  106409. /**
  106410. * Ask the browser to promote the current element to pointerlock mode
  106411. * @param element defines the DOM element to promote
  106412. */
  106413. static _RequestPointerlock(element: HTMLElement): void;
  106414. /**
  106415. * Asks the browser to exit pointerlock mode
  106416. */
  106417. static _ExitPointerlock(): void;
  106418. /**
  106419. * Ask the browser to promote the current element to fullscreen rendering mode
  106420. * @param element defines the DOM element to promote
  106421. */
  106422. static _RequestFullscreen(element: HTMLElement): void;
  106423. /**
  106424. * Asks the browser to exit fullscreen mode
  106425. */
  106426. static _ExitFullscreen(): void;
  106427. }
  106428. }
  106429. declare module BABYLON {
  106430. /**
  106431. * The engine store class is responsible to hold all the instances of Engine and Scene created
  106432. * during the life time of the application.
  106433. */
  106434. export class EngineStore {
  106435. /** Gets the list of created engines */
  106436. static Instances: Engine[];
  106437. /** @hidden */
  106438. static _LastCreatedScene: Nullable<Scene>;
  106439. /**
  106440. * Gets the latest created engine
  106441. */
  106442. static get LastCreatedEngine(): Nullable<Engine>;
  106443. /**
  106444. * Gets the latest created scene
  106445. */
  106446. static get LastCreatedScene(): Nullable<Scene>;
  106447. /**
  106448. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106449. * @ignorenaming
  106450. */
  106451. static UseFallbackTexture: boolean;
  106452. /**
  106453. * Texture content used if a texture cannot loaded
  106454. * @ignorenaming
  106455. */
  106456. static FallbackTexture: string;
  106457. }
  106458. }
  106459. declare module BABYLON {
  106460. /**
  106461. * Helper class that provides a small promise polyfill
  106462. */
  106463. export class PromisePolyfill {
  106464. /**
  106465. * Static function used to check if the polyfill is required
  106466. * If this is the case then the function will inject the polyfill to window.Promise
  106467. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  106468. */
  106469. static Apply(force?: boolean): void;
  106470. }
  106471. }
  106472. declare module BABYLON {
  106473. /**
  106474. * Interface for screenshot methods with describe argument called `size` as object with options
  106475. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  106476. */
  106477. export interface IScreenshotSize {
  106478. /**
  106479. * number in pixels for canvas height
  106480. */
  106481. height?: number;
  106482. /**
  106483. * multiplier allowing render at a higher or lower resolution
  106484. * If value is defined then height and width will be ignored and taken from camera
  106485. */
  106486. precision?: number;
  106487. /**
  106488. * number in pixels for canvas width
  106489. */
  106490. width?: number;
  106491. }
  106492. }
  106493. declare module BABYLON {
  106494. interface IColor4Like {
  106495. r: float;
  106496. g: float;
  106497. b: float;
  106498. a: float;
  106499. }
  106500. /**
  106501. * Class containing a set of static utilities functions
  106502. */
  106503. export class Tools {
  106504. /**
  106505. * Gets or sets the base URL to use to load assets
  106506. */
  106507. static get BaseUrl(): string;
  106508. static set BaseUrl(value: string);
  106509. /**
  106510. * Enable/Disable Custom HTTP Request Headers globally.
  106511. * default = false
  106512. * @see CustomRequestHeaders
  106513. */
  106514. static UseCustomRequestHeaders: boolean;
  106515. /**
  106516. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  106517. * i.e. when loading files, where the server/service expects an Authorization header
  106518. */
  106519. static CustomRequestHeaders: {
  106520. [key: string]: string;
  106521. };
  106522. /**
  106523. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  106524. */
  106525. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  106526. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  106527. /**
  106528. * Default behaviour for cors in the application.
  106529. * It can be a string if the expected behavior is identical in the entire app.
  106530. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  106531. */
  106532. static CorsBehavior: string | ((url: string | string[]) => string);
  106533. /**
  106534. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106535. * @ignorenaming
  106536. */
  106537. static get UseFallbackTexture(): boolean;
  106538. static set UseFallbackTexture(value: boolean);
  106539. /**
  106540. * Use this object to register external classes like custom textures or material
  106541. * to allow the laoders to instantiate them
  106542. */
  106543. static get RegisteredExternalClasses(): {
  106544. [key: string]: Object;
  106545. };
  106546. static set RegisteredExternalClasses(classes: {
  106547. [key: string]: Object;
  106548. });
  106549. /**
  106550. * Texture content used if a texture cannot loaded
  106551. * @ignorenaming
  106552. */
  106553. static get fallbackTexture(): string;
  106554. static set fallbackTexture(value: string);
  106555. /**
  106556. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  106557. * @param u defines the coordinate on X axis
  106558. * @param v defines the coordinate on Y axis
  106559. * @param width defines the width of the source data
  106560. * @param height defines the height of the source data
  106561. * @param pixels defines the source byte array
  106562. * @param color defines the output color
  106563. */
  106564. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  106565. /**
  106566. * Interpolates between a and b via alpha
  106567. * @param a The lower value (returned when alpha = 0)
  106568. * @param b The upper value (returned when alpha = 1)
  106569. * @param alpha The interpolation-factor
  106570. * @return The mixed value
  106571. */
  106572. static Mix(a: number, b: number, alpha: number): number;
  106573. /**
  106574. * Tries to instantiate a new object from a given class name
  106575. * @param className defines the class name to instantiate
  106576. * @returns the new object or null if the system was not able to do the instantiation
  106577. */
  106578. static Instantiate(className: string): any;
  106579. /**
  106580. * Provides a slice function that will work even on IE
  106581. * @param data defines the array to slice
  106582. * @param start defines the start of the data (optional)
  106583. * @param end defines the end of the data (optional)
  106584. * @returns the new sliced array
  106585. */
  106586. static Slice<T>(data: T, start?: number, end?: number): T;
  106587. /**
  106588. * Polyfill for setImmediate
  106589. * @param action defines the action to execute after the current execution block
  106590. */
  106591. static SetImmediate(action: () => void): void;
  106592. /**
  106593. * Function indicating if a number is an exponent of 2
  106594. * @param value defines the value to test
  106595. * @returns true if the value is an exponent of 2
  106596. */
  106597. static IsExponentOfTwo(value: number): boolean;
  106598. private static _tmpFloatArray;
  106599. /**
  106600. * Returns the nearest 32-bit single precision float representation of a Number
  106601. * @param value A Number. If the parameter is of a different type, it will get converted
  106602. * to a number or to NaN if it cannot be converted
  106603. * @returns number
  106604. */
  106605. static FloatRound(value: number): number;
  106606. /**
  106607. * Extracts the filename from a path
  106608. * @param path defines the path to use
  106609. * @returns the filename
  106610. */
  106611. static GetFilename(path: string): string;
  106612. /**
  106613. * Extracts the "folder" part of a path (everything before the filename).
  106614. * @param uri The URI to extract the info from
  106615. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  106616. * @returns The "folder" part of the path
  106617. */
  106618. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  106619. /**
  106620. * Extracts text content from a DOM element hierarchy
  106621. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  106622. */
  106623. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  106624. /**
  106625. * Convert an angle in radians to degrees
  106626. * @param angle defines the angle to convert
  106627. * @returns the angle in degrees
  106628. */
  106629. static ToDegrees(angle: number): number;
  106630. /**
  106631. * Convert an angle in degrees to radians
  106632. * @param angle defines the angle to convert
  106633. * @returns the angle in radians
  106634. */
  106635. static ToRadians(angle: number): number;
  106636. /**
  106637. * Returns an array if obj is not an array
  106638. * @param obj defines the object to evaluate as an array
  106639. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  106640. * @returns either obj directly if obj is an array or a new array containing obj
  106641. */
  106642. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  106643. /**
  106644. * Gets the pointer prefix to use
  106645. * @returns "pointer" if touch is enabled. Else returns "mouse"
  106646. */
  106647. static GetPointerPrefix(): string;
  106648. /**
  106649. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  106650. * @param url define the url we are trying
  106651. * @param element define the dom element where to configure the cors policy
  106652. */
  106653. static SetCorsBehavior(url: string | string[], element: {
  106654. crossOrigin: string | null;
  106655. }): void;
  106656. /**
  106657. * Removes unwanted characters from an url
  106658. * @param url defines the url to clean
  106659. * @returns the cleaned url
  106660. */
  106661. static CleanUrl(url: string): string;
  106662. /**
  106663. * Gets or sets a function used to pre-process url before using them to load assets
  106664. */
  106665. static get PreprocessUrl(): (url: string) => string;
  106666. static set PreprocessUrl(processor: (url: string) => string);
  106667. /**
  106668. * Loads an image as an HTMLImageElement.
  106669. * @param input url string, ArrayBuffer, or Blob to load
  106670. * @param onLoad callback called when the image successfully loads
  106671. * @param onError callback called when the image fails to load
  106672. * @param offlineProvider offline provider for caching
  106673. * @param mimeType optional mime type
  106674. * @returns the HTMLImageElement of the loaded image
  106675. */
  106676. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  106677. /**
  106678. * Loads a file from a url
  106679. * @param url url string, ArrayBuffer, or Blob to load
  106680. * @param onSuccess callback called when the file successfully loads
  106681. * @param onProgress callback called while file is loading (if the server supports this mode)
  106682. * @param offlineProvider defines the offline provider for caching
  106683. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106684. * @param onError callback called when the file fails to load
  106685. * @returns a file request object
  106686. */
  106687. 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;
  106688. /**
  106689. * Loads a file from a url
  106690. * @param url the file url to load
  106691. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  106692. */
  106693. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  106694. /**
  106695. * Load a script (identified by an url). When the url returns, the
  106696. * content of this file is added into a new script element, attached to the DOM (body element)
  106697. * @param scriptUrl defines the url of the script to laod
  106698. * @param onSuccess defines the callback called when the script is loaded
  106699. * @param onError defines the callback to call if an error occurs
  106700. * @param scriptId defines the id of the script element
  106701. */
  106702. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  106703. /**
  106704. * Load an asynchronous script (identified by an url). When the url returns, the
  106705. * content of this file is added into a new script element, attached to the DOM (body element)
  106706. * @param scriptUrl defines the url of the script to laod
  106707. * @param scriptId defines the id of the script element
  106708. * @returns a promise request object
  106709. */
  106710. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  106711. /**
  106712. * Loads a file from a blob
  106713. * @param fileToLoad defines the blob to use
  106714. * @param callback defines the callback to call when data is loaded
  106715. * @param progressCallback defines the callback to call during loading process
  106716. * @returns a file request object
  106717. */
  106718. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  106719. /**
  106720. * Reads a file from a File object
  106721. * @param file defines the file to load
  106722. * @param onSuccess defines the callback to call when data is loaded
  106723. * @param onProgress defines the callback to call during loading process
  106724. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  106725. * @param onError defines the callback to call when an error occurs
  106726. * @returns a file request object
  106727. */
  106728. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  106729. /**
  106730. * Creates a data url from a given string content
  106731. * @param content defines the content to convert
  106732. * @returns the new data url link
  106733. */
  106734. static FileAsURL(content: string): string;
  106735. /**
  106736. * Format the given number to a specific decimal format
  106737. * @param value defines the number to format
  106738. * @param decimals defines the number of decimals to use
  106739. * @returns the formatted string
  106740. */
  106741. static Format(value: number, decimals?: number): string;
  106742. /**
  106743. * Tries to copy an object by duplicating every property
  106744. * @param source defines the source object
  106745. * @param destination defines the target object
  106746. * @param doNotCopyList defines a list of properties to avoid
  106747. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  106748. */
  106749. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  106750. /**
  106751. * Gets a boolean indicating if the given object has no own property
  106752. * @param obj defines the object to test
  106753. * @returns true if object has no own property
  106754. */
  106755. static IsEmpty(obj: any): boolean;
  106756. /**
  106757. * Function used to register events at window level
  106758. * @param windowElement defines the Window object to use
  106759. * @param events defines the events to register
  106760. */
  106761. static RegisterTopRootEvents(windowElement: Window, events: {
  106762. name: string;
  106763. handler: Nullable<(e: FocusEvent) => any>;
  106764. }[]): void;
  106765. /**
  106766. * Function used to unregister events from window level
  106767. * @param windowElement defines the Window object to use
  106768. * @param events defines the events to unregister
  106769. */
  106770. static UnregisterTopRootEvents(windowElement: Window, events: {
  106771. name: string;
  106772. handler: Nullable<(e: FocusEvent) => any>;
  106773. }[]): void;
  106774. /**
  106775. * @ignore
  106776. */
  106777. static _ScreenshotCanvas: HTMLCanvasElement;
  106778. /**
  106779. * Dumps the current bound framebuffer
  106780. * @param width defines the rendering width
  106781. * @param height defines the rendering height
  106782. * @param engine defines the hosting engine
  106783. * @param successCallback defines the callback triggered once the data are available
  106784. * @param mimeType defines the mime type of the result
  106785. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  106786. */
  106787. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106788. /**
  106789. * Converts the canvas data to blob.
  106790. * This acts as a polyfill for browsers not supporting the to blob function.
  106791. * @param canvas Defines the canvas to extract the data from
  106792. * @param successCallback Defines the callback triggered once the data are available
  106793. * @param mimeType Defines the mime type of the result
  106794. */
  106795. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  106796. /**
  106797. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  106798. * @param successCallback defines the callback triggered once the data are available
  106799. * @param mimeType defines the mime type of the result
  106800. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  106801. */
  106802. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106803. /**
  106804. * Downloads a blob in the browser
  106805. * @param blob defines the blob to download
  106806. * @param fileName defines the name of the downloaded file
  106807. */
  106808. static Download(blob: Blob, fileName: string): void;
  106809. /**
  106810. * Captures a screenshot of the current rendering
  106811. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106812. * @param engine defines the rendering engine
  106813. * @param camera defines the source camera
  106814. * @param size This parameter can be set to a single number or to an object with the
  106815. * following (optional) properties: precision, width, height. If a single number is passed,
  106816. * it will be used for both width and height. If an object is passed, the screenshot size
  106817. * will be derived from the parameters. The precision property is a multiplier allowing
  106818. * rendering at a higher or lower resolution
  106819. * @param successCallback defines the callback receives a single parameter which contains the
  106820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106821. * src parameter of an <img> to display it
  106822. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106823. * Check your browser for supported MIME types
  106824. */
  106825. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  106826. /**
  106827. * Captures a screenshot of the current rendering
  106828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106829. * @param engine defines the rendering engine
  106830. * @param camera defines the source camera
  106831. * @param size This parameter can be set to a single number or to an object with the
  106832. * following (optional) properties: precision, width, height. If a single number is passed,
  106833. * it will be used for both width and height. If an object is passed, the screenshot size
  106834. * will be derived from the parameters. The precision property is a multiplier allowing
  106835. * rendering at a higher or lower resolution
  106836. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106837. * Check your browser for supported MIME types
  106838. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106839. * to the src parameter of an <img> to display it
  106840. */
  106841. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  106842. /**
  106843. * Generates an image screenshot from the specified camera.
  106844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106845. * @param engine The engine to use for rendering
  106846. * @param camera The camera to use for rendering
  106847. * @param size This parameter can be set to a single number or to an object with the
  106848. * following (optional) properties: precision, width, height. If a single number is passed,
  106849. * it will be used for both width and height. If an object is passed, the screenshot size
  106850. * will be derived from the parameters. The precision property is a multiplier allowing
  106851. * rendering at a higher or lower resolution
  106852. * @param successCallback The callback receives a single parameter which contains the
  106853. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106854. * src parameter of an <img> to display it
  106855. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106856. * Check your browser for supported MIME types
  106857. * @param samples Texture samples (default: 1)
  106858. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106859. * @param fileName A name for for the downloaded file.
  106860. */
  106861. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  106862. /**
  106863. * Generates an image screenshot from the specified camera.
  106864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106865. * @param engine The engine to use for rendering
  106866. * @param camera The camera to use for rendering
  106867. * @param size This parameter can be set to a single number or to an object with the
  106868. * following (optional) properties: precision, width, height. If a single number is passed,
  106869. * it will be used for both width and height. If an object is passed, the screenshot size
  106870. * will be derived from the parameters. The precision property is a multiplier allowing
  106871. * rendering at a higher or lower resolution
  106872. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106873. * Check your browser for supported MIME types
  106874. * @param samples Texture samples (default: 1)
  106875. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106876. * @param fileName A name for for the downloaded file.
  106877. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106878. * to the src parameter of an <img> to display it
  106879. */
  106880. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  106881. /**
  106882. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106883. * Be aware Math.random() could cause collisions, but:
  106884. * "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"
  106885. * @returns a pseudo random id
  106886. */
  106887. static RandomId(): string;
  106888. /**
  106889. * Test if the given uri is a base64 string
  106890. * @param uri The uri to test
  106891. * @return True if the uri is a base64 string or false otherwise
  106892. */
  106893. static IsBase64(uri: string): boolean;
  106894. /**
  106895. * Decode the given base64 uri.
  106896. * @param uri The uri to decode
  106897. * @return The decoded base64 data.
  106898. */
  106899. static DecodeBase64(uri: string): ArrayBuffer;
  106900. /**
  106901. * Gets the absolute url.
  106902. * @param url the input url
  106903. * @return the absolute url
  106904. */
  106905. static GetAbsoluteUrl(url: string): string;
  106906. /**
  106907. * No log
  106908. */
  106909. static readonly NoneLogLevel: number;
  106910. /**
  106911. * Only message logs
  106912. */
  106913. static readonly MessageLogLevel: number;
  106914. /**
  106915. * Only warning logs
  106916. */
  106917. static readonly WarningLogLevel: number;
  106918. /**
  106919. * Only error logs
  106920. */
  106921. static readonly ErrorLogLevel: number;
  106922. /**
  106923. * All logs
  106924. */
  106925. static readonly AllLogLevel: number;
  106926. /**
  106927. * Gets a value indicating the number of loading errors
  106928. * @ignorenaming
  106929. */
  106930. static get errorsCount(): number;
  106931. /**
  106932. * Callback called when a new log is added
  106933. */
  106934. static OnNewCacheEntry: (entry: string) => void;
  106935. /**
  106936. * Log a message to the console
  106937. * @param message defines the message to log
  106938. */
  106939. static Log(message: string): void;
  106940. /**
  106941. * Write a warning message to the console
  106942. * @param message defines the message to log
  106943. */
  106944. static Warn(message: string): void;
  106945. /**
  106946. * Write an error message to the console
  106947. * @param message defines the message to log
  106948. */
  106949. static Error(message: string): void;
  106950. /**
  106951. * Gets current log cache (list of logs)
  106952. */
  106953. static get LogCache(): string;
  106954. /**
  106955. * Clears the log cache
  106956. */
  106957. static ClearLogCache(): void;
  106958. /**
  106959. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  106960. */
  106961. static set LogLevels(level: number);
  106962. /**
  106963. * Checks if the window object exists
  106964. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  106965. */
  106966. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  106967. /**
  106968. * No performance log
  106969. */
  106970. static readonly PerformanceNoneLogLevel: number;
  106971. /**
  106972. * Use user marks to log performance
  106973. */
  106974. static readonly PerformanceUserMarkLogLevel: number;
  106975. /**
  106976. * Log performance to the console
  106977. */
  106978. static readonly PerformanceConsoleLogLevel: number;
  106979. private static _performance;
  106980. /**
  106981. * Sets the current performance log level
  106982. */
  106983. static set PerformanceLogLevel(level: number);
  106984. private static _StartPerformanceCounterDisabled;
  106985. private static _EndPerformanceCounterDisabled;
  106986. private static _StartUserMark;
  106987. private static _EndUserMark;
  106988. private static _StartPerformanceConsole;
  106989. private static _EndPerformanceConsole;
  106990. /**
  106991. * Starts a performance counter
  106992. */
  106993. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106994. /**
  106995. * Ends a specific performance coutner
  106996. */
  106997. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106998. /**
  106999. * Gets either window.performance.now() if supported or Date.now() else
  107000. */
  107001. static get Now(): number;
  107002. /**
  107003. * This method will return the name of the class used to create the instance of the given object.
  107004. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107005. * @param object the object to get the class name from
  107006. * @param isType defines if the object is actually a type
  107007. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107008. */
  107009. static GetClassName(object: any, isType?: boolean): string;
  107010. /**
  107011. * Gets the first element of an array satisfying a given predicate
  107012. * @param array defines the array to browse
  107013. * @param predicate defines the predicate to use
  107014. * @returns null if not found or the element
  107015. */
  107016. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107017. /**
  107018. * This method will return the name of the full name of the class, including its owning module (if any).
  107019. * 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).
  107020. * @param object the object to get the class name from
  107021. * @param isType defines if the object is actually a type
  107022. * @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.
  107023. * @ignorenaming
  107024. */
  107025. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107026. /**
  107027. * Returns a promise that resolves after the given amount of time.
  107028. * @param delay Number of milliseconds to delay
  107029. * @returns Promise that resolves after the given amount of time
  107030. */
  107031. static DelayAsync(delay: number): Promise<void>;
  107032. /**
  107033. * Utility function to detect if the current user agent is Safari
  107034. * @returns whether or not the current user agent is safari
  107035. */
  107036. static IsSafari(): boolean;
  107037. }
  107038. /**
  107039. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107040. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107041. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107042. * @param name The name of the class, case should be preserved
  107043. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107044. */
  107045. export function className(name: string, module?: string): (target: Object) => void;
  107046. /**
  107047. * An implementation of a loop for asynchronous functions.
  107048. */
  107049. export class AsyncLoop {
  107050. /**
  107051. * Defines the number of iterations for the loop
  107052. */
  107053. iterations: number;
  107054. /**
  107055. * Defines the current index of the loop.
  107056. */
  107057. index: number;
  107058. private _done;
  107059. private _fn;
  107060. private _successCallback;
  107061. /**
  107062. * Constructor.
  107063. * @param iterations the number of iterations.
  107064. * @param func the function to run each iteration
  107065. * @param successCallback the callback that will be called upon succesful execution
  107066. * @param offset starting offset.
  107067. */
  107068. constructor(
  107069. /**
  107070. * Defines the number of iterations for the loop
  107071. */
  107072. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107073. /**
  107074. * Execute the next iteration. Must be called after the last iteration was finished.
  107075. */
  107076. executeNext(): void;
  107077. /**
  107078. * Break the loop and run the success callback.
  107079. */
  107080. breakLoop(): void;
  107081. /**
  107082. * Create and run an async loop.
  107083. * @param iterations the number of iterations.
  107084. * @param fn the function to run each iteration
  107085. * @param successCallback the callback that will be called upon succesful execution
  107086. * @param offset starting offset.
  107087. * @returns the created async loop object
  107088. */
  107089. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107090. /**
  107091. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107092. * @param iterations total number of iterations
  107093. * @param syncedIterations number of synchronous iterations in each async iteration.
  107094. * @param fn the function to call each iteration.
  107095. * @param callback a success call back that will be called when iterating stops.
  107096. * @param breakFunction a break condition (optional)
  107097. * @param timeout timeout settings for the setTimeout function. default - 0.
  107098. * @returns the created async loop object
  107099. */
  107100. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107101. }
  107102. }
  107103. declare module BABYLON {
  107104. /**
  107105. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107106. * The underlying implementation relies on an associative array to ensure the best performances.
  107107. * The value can be anything including 'null' but except 'undefined'
  107108. */
  107109. export class StringDictionary<T> {
  107110. /**
  107111. * This will clear this dictionary and copy the content from the 'source' one.
  107112. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107113. * @param source the dictionary to take the content from and copy to this dictionary
  107114. */
  107115. copyFrom(source: StringDictionary<T>): void;
  107116. /**
  107117. * Get a value based from its key
  107118. * @param key the given key to get the matching value from
  107119. * @return the value if found, otherwise undefined is returned
  107120. */
  107121. get(key: string): T | undefined;
  107122. /**
  107123. * Get a value from its key or add it if it doesn't exist.
  107124. * This method will ensure you that a given key/data will be present in the dictionary.
  107125. * @param key the given key to get the matching value from
  107126. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107127. * The factory will only be invoked if there's no data for the given key.
  107128. * @return the value corresponding to the key.
  107129. */
  107130. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107131. /**
  107132. * Get a value from its key if present in the dictionary otherwise add it
  107133. * @param key the key to get the value from
  107134. * @param val if there's no such key/value pair in the dictionary add it with this value
  107135. * @return the value corresponding to the key
  107136. */
  107137. getOrAdd(key: string, val: T): T;
  107138. /**
  107139. * Check if there's a given key in the dictionary
  107140. * @param key the key to check for
  107141. * @return true if the key is present, false otherwise
  107142. */
  107143. contains(key: string): boolean;
  107144. /**
  107145. * Add a new key and its corresponding value
  107146. * @param key the key to add
  107147. * @param value the value corresponding to the key
  107148. * @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
  107149. */
  107150. add(key: string, value: T): boolean;
  107151. /**
  107152. * Update a specific value associated to a key
  107153. * @param key defines the key to use
  107154. * @param value defines the value to store
  107155. * @returns true if the value was updated (or false if the key was not found)
  107156. */
  107157. set(key: string, value: T): boolean;
  107158. /**
  107159. * Get the element of the given key and remove it from the dictionary
  107160. * @param key defines the key to search
  107161. * @returns the value associated with the key or null if not found
  107162. */
  107163. getAndRemove(key: string): Nullable<T>;
  107164. /**
  107165. * Remove a key/value from the dictionary.
  107166. * @param key the key to remove
  107167. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107168. */
  107169. remove(key: string): boolean;
  107170. /**
  107171. * Clear the whole content of the dictionary
  107172. */
  107173. clear(): void;
  107174. /**
  107175. * Gets the current count
  107176. */
  107177. get count(): number;
  107178. /**
  107179. * Execute a callback on each key/val of the dictionary.
  107180. * Note that you can remove any element in this dictionary in the callback implementation
  107181. * @param callback the callback to execute on a given key/value pair
  107182. */
  107183. forEach(callback: (key: string, val: T) => void): void;
  107184. /**
  107185. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107186. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107187. * Note that you can remove any element in this dictionary in the callback implementation
  107188. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107189. * @returns the first item
  107190. */
  107191. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107192. private _count;
  107193. private _data;
  107194. }
  107195. }
  107196. declare module BABYLON {
  107197. /** @hidden */
  107198. export interface ICollisionCoordinator {
  107199. createCollider(): Collider;
  107200. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107201. init(scene: Scene): void;
  107202. }
  107203. /** @hidden */
  107204. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107205. private _scene;
  107206. private _scaledPosition;
  107207. private _scaledVelocity;
  107208. private _finalPosition;
  107209. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107210. createCollider(): Collider;
  107211. init(scene: Scene): void;
  107212. private _collideWithWorld;
  107213. }
  107214. }
  107215. declare module BABYLON {
  107216. /**
  107217. * Class used to manage all inputs for the scene.
  107218. */
  107219. export class InputManager {
  107220. /** The distance in pixel that you have to move to prevent some events */
  107221. static DragMovementThreshold: number;
  107222. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107223. static LongPressDelay: number;
  107224. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107225. static DoubleClickDelay: number;
  107226. /** If you need to check double click without raising a single click at first click, enable this flag */
  107227. static ExclusiveDoubleClickMode: boolean;
  107228. private _wheelEventName;
  107229. private _onPointerMove;
  107230. private _onPointerDown;
  107231. private _onPointerUp;
  107232. private _initClickEvent;
  107233. private _initActionManager;
  107234. private _delayedSimpleClick;
  107235. private _delayedSimpleClickTimeout;
  107236. private _previousDelayedSimpleClickTimeout;
  107237. private _meshPickProceed;
  107238. private _previousButtonPressed;
  107239. private _currentPickResult;
  107240. private _previousPickResult;
  107241. private _totalPointersPressed;
  107242. private _doubleClickOccured;
  107243. private _pointerOverMesh;
  107244. private _pickedDownMesh;
  107245. private _pickedUpMesh;
  107246. private _pointerX;
  107247. private _pointerY;
  107248. private _unTranslatedPointerX;
  107249. private _unTranslatedPointerY;
  107250. private _startingPointerPosition;
  107251. private _previousStartingPointerPosition;
  107252. private _startingPointerTime;
  107253. private _previousStartingPointerTime;
  107254. private _pointerCaptures;
  107255. private _onKeyDown;
  107256. private _onKeyUp;
  107257. private _onCanvasFocusObserver;
  107258. private _onCanvasBlurObserver;
  107259. private _scene;
  107260. /**
  107261. * Creates a new InputManager
  107262. * @param scene defines the hosting scene
  107263. */
  107264. constructor(scene: Scene);
  107265. /**
  107266. * Gets the mesh that is currently under the pointer
  107267. */
  107268. get meshUnderPointer(): Nullable<AbstractMesh>;
  107269. /**
  107270. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107271. */
  107272. get unTranslatedPointer(): Vector2;
  107273. /**
  107274. * Gets or sets the current on-screen X position of the pointer
  107275. */
  107276. get pointerX(): number;
  107277. set pointerX(value: number);
  107278. /**
  107279. * Gets or sets the current on-screen Y position of the pointer
  107280. */
  107281. get pointerY(): number;
  107282. set pointerY(value: number);
  107283. private _updatePointerPosition;
  107284. private _processPointerMove;
  107285. private _setRayOnPointerInfo;
  107286. private _checkPrePointerObservable;
  107287. /**
  107288. * Use this method to simulate a pointer move on a mesh
  107289. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107290. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107291. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107292. */
  107293. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107294. /**
  107295. * Use this method to simulate a pointer down on a mesh
  107296. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107297. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107298. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107299. */
  107300. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107301. private _processPointerDown;
  107302. /** @hidden */
  107303. _isPointerSwiping(): boolean;
  107304. /**
  107305. * Use this method to simulate a pointer up on a mesh
  107306. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107307. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107308. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107309. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107310. */
  107311. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107312. private _processPointerUp;
  107313. /**
  107314. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107315. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107316. * @returns true if the pointer was captured
  107317. */
  107318. isPointerCaptured(pointerId?: number): boolean;
  107319. /**
  107320. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107321. * @param attachUp defines if you want to attach events to pointerup
  107322. * @param attachDown defines if you want to attach events to pointerdown
  107323. * @param attachMove defines if you want to attach events to pointermove
  107324. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107325. */
  107326. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107327. /**
  107328. * Detaches all event handlers
  107329. */
  107330. detachControl(): void;
  107331. /**
  107332. * Force the value of meshUnderPointer
  107333. * @param mesh defines the mesh to use
  107334. */
  107335. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107336. /**
  107337. * Gets the mesh under the pointer
  107338. * @returns a Mesh or null if no mesh is under the pointer
  107339. */
  107340. getPointerOverMesh(): Nullable<AbstractMesh>;
  107341. }
  107342. }
  107343. declare module BABYLON {
  107344. /**
  107345. * Helper class used to generate session unique ID
  107346. */
  107347. export class UniqueIdGenerator {
  107348. private static _UniqueIdCounter;
  107349. /**
  107350. * Gets an unique (relatively to the current scene) Id
  107351. */
  107352. static get UniqueId(): number;
  107353. }
  107354. }
  107355. declare module BABYLON {
  107356. /**
  107357. * This class defines the direct association between an animation and a target
  107358. */
  107359. export class TargetedAnimation {
  107360. /**
  107361. * Animation to perform
  107362. */
  107363. animation: Animation;
  107364. /**
  107365. * Target to animate
  107366. */
  107367. target: any;
  107368. /**
  107369. * Serialize the object
  107370. * @returns the JSON object representing the current entity
  107371. */
  107372. serialize(): any;
  107373. }
  107374. /**
  107375. * Use this class to create coordinated animations on multiple targets
  107376. */
  107377. export class AnimationGroup implements IDisposable {
  107378. /** The name of the animation group */
  107379. name: string;
  107380. private _scene;
  107381. private _targetedAnimations;
  107382. private _animatables;
  107383. private _from;
  107384. private _to;
  107385. private _isStarted;
  107386. private _isPaused;
  107387. private _speedRatio;
  107388. private _loopAnimation;
  107389. /**
  107390. * Gets or sets the unique id of the node
  107391. */
  107392. uniqueId: number;
  107393. /**
  107394. * This observable will notify when one animation have ended
  107395. */
  107396. onAnimationEndObservable: Observable<TargetedAnimation>;
  107397. /**
  107398. * Observer raised when one animation loops
  107399. */
  107400. onAnimationLoopObservable: Observable<TargetedAnimation>;
  107401. /**
  107402. * Observer raised when all animations have looped
  107403. */
  107404. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  107405. /**
  107406. * This observable will notify when all animations have ended.
  107407. */
  107408. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  107409. /**
  107410. * This observable will notify when all animations have paused.
  107411. */
  107412. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  107413. /**
  107414. * This observable will notify when all animations are playing.
  107415. */
  107416. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  107417. /**
  107418. * Gets the first frame
  107419. */
  107420. get from(): number;
  107421. /**
  107422. * Gets the last frame
  107423. */
  107424. get to(): number;
  107425. /**
  107426. * Define if the animations are started
  107427. */
  107428. get isStarted(): boolean;
  107429. /**
  107430. * Gets a value indicating that the current group is playing
  107431. */
  107432. get isPlaying(): boolean;
  107433. /**
  107434. * Gets or sets the speed ratio to use for all animations
  107435. */
  107436. get speedRatio(): number;
  107437. /**
  107438. * Gets or sets the speed ratio to use for all animations
  107439. */
  107440. set speedRatio(value: number);
  107441. /**
  107442. * Gets or sets if all animations should loop or not
  107443. */
  107444. get loopAnimation(): boolean;
  107445. set loopAnimation(value: boolean);
  107446. /**
  107447. * Gets the targeted animations for this animation group
  107448. */
  107449. get targetedAnimations(): Array<TargetedAnimation>;
  107450. /**
  107451. * returning the list of animatables controlled by this animation group.
  107452. */
  107453. get animatables(): Array<Animatable>;
  107454. /**
  107455. * Instantiates a new Animation Group.
  107456. * This helps managing several animations at once.
  107457. * @see http://doc.babylonjs.com/how_to/group
  107458. * @param name Defines the name of the group
  107459. * @param scene Defines the scene the group belongs to
  107460. */
  107461. constructor(
  107462. /** The name of the animation group */
  107463. name: string, scene?: Nullable<Scene>);
  107464. /**
  107465. * Add an animation (with its target) in the group
  107466. * @param animation defines the animation we want to add
  107467. * @param target defines the target of the animation
  107468. * @returns the TargetedAnimation object
  107469. */
  107470. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  107471. /**
  107472. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  107473. * It can add constant keys at begin or end
  107474. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  107475. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  107476. * @returns the animation group
  107477. */
  107478. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  107479. private _animationLoopCount;
  107480. private _animationLoopFlags;
  107481. private _processLoop;
  107482. /**
  107483. * Start all animations on given targets
  107484. * @param loop defines if animations must loop
  107485. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  107486. * @param from defines the from key (optional)
  107487. * @param to defines the to key (optional)
  107488. * @returns the current animation group
  107489. */
  107490. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  107491. /**
  107492. * Pause all animations
  107493. * @returns the animation group
  107494. */
  107495. pause(): AnimationGroup;
  107496. /**
  107497. * Play all animations to initial state
  107498. * This function will start() the animations if they were not started or will restart() them if they were paused
  107499. * @param loop defines if animations must loop
  107500. * @returns the animation group
  107501. */
  107502. play(loop?: boolean): AnimationGroup;
  107503. /**
  107504. * Reset all animations to initial state
  107505. * @returns the animation group
  107506. */
  107507. reset(): AnimationGroup;
  107508. /**
  107509. * Restart animations from key 0
  107510. * @returns the animation group
  107511. */
  107512. restart(): AnimationGroup;
  107513. /**
  107514. * Stop all animations
  107515. * @returns the animation group
  107516. */
  107517. stop(): AnimationGroup;
  107518. /**
  107519. * Set animation weight for all animatables
  107520. * @param weight defines the weight to use
  107521. * @return the animationGroup
  107522. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107523. */
  107524. setWeightForAllAnimatables(weight: number): AnimationGroup;
  107525. /**
  107526. * Synchronize and normalize all animatables with a source animatable
  107527. * @param root defines the root animatable to synchronize with
  107528. * @return the animationGroup
  107529. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107530. */
  107531. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  107532. /**
  107533. * Goes to a specific frame in this animation group
  107534. * @param frame the frame number to go to
  107535. * @return the animationGroup
  107536. */
  107537. goToFrame(frame: number): AnimationGroup;
  107538. /**
  107539. * Dispose all associated resources
  107540. */
  107541. dispose(): void;
  107542. private _checkAnimationGroupEnded;
  107543. /**
  107544. * Clone the current animation group and returns a copy
  107545. * @param newName defines the name of the new group
  107546. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  107547. * @returns the new aniamtion group
  107548. */
  107549. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  107550. /**
  107551. * Serializes the animationGroup to an object
  107552. * @returns Serialized object
  107553. */
  107554. serialize(): any;
  107555. /**
  107556. * Returns a new AnimationGroup object parsed from the source provided.
  107557. * @param parsedAnimationGroup defines the source
  107558. * @param scene defines the scene that will receive the animationGroup
  107559. * @returns a new AnimationGroup
  107560. */
  107561. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  107562. /**
  107563. * Returns the string "AnimationGroup"
  107564. * @returns "AnimationGroup"
  107565. */
  107566. getClassName(): string;
  107567. /**
  107568. * Creates a detailled string about the object
  107569. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  107570. * @returns a string representing the object
  107571. */
  107572. toString(fullDetails?: boolean): string;
  107573. }
  107574. }
  107575. declare module BABYLON {
  107576. /**
  107577. * Define an interface for all classes that will hold resources
  107578. */
  107579. export interface IDisposable {
  107580. /**
  107581. * Releases all held resources
  107582. */
  107583. dispose(): void;
  107584. }
  107585. /** Interface defining initialization parameters for Scene class */
  107586. export interface SceneOptions {
  107587. /**
  107588. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  107589. * It will improve performance when the number of geometries becomes important.
  107590. */
  107591. useGeometryUniqueIdsMap?: boolean;
  107592. /**
  107593. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  107594. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107595. */
  107596. useMaterialMeshMap?: boolean;
  107597. /**
  107598. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  107599. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107600. */
  107601. useClonedMeshMap?: boolean;
  107602. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  107603. virtual?: boolean;
  107604. }
  107605. /**
  107606. * Represents a scene to be rendered by the engine.
  107607. * @see http://doc.babylonjs.com/features/scene
  107608. */
  107609. export class Scene extends AbstractScene implements IAnimatable {
  107610. /** The fog is deactivated */
  107611. static readonly FOGMODE_NONE: number;
  107612. /** The fog density is following an exponential function */
  107613. static readonly FOGMODE_EXP: number;
  107614. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  107615. static readonly FOGMODE_EXP2: number;
  107616. /** The fog density is following a linear function. */
  107617. static readonly FOGMODE_LINEAR: number;
  107618. /**
  107619. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  107620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107621. */
  107622. static MinDeltaTime: number;
  107623. /**
  107624. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  107625. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107626. */
  107627. static MaxDeltaTime: number;
  107628. /**
  107629. * Factory used to create the default material.
  107630. * @param name The name of the material to create
  107631. * @param scene The scene to create the material for
  107632. * @returns The default material
  107633. */
  107634. static DefaultMaterialFactory(scene: Scene): Material;
  107635. /**
  107636. * Factory used to create the a collision coordinator.
  107637. * @returns The collision coordinator
  107638. */
  107639. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  107640. /** @hidden */
  107641. _inputManager: InputManager;
  107642. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  107643. cameraToUseForPointers: Nullable<Camera>;
  107644. /** @hidden */
  107645. readonly _isScene: boolean;
  107646. /**
  107647. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  107648. */
  107649. autoClear: boolean;
  107650. /**
  107651. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  107652. */
  107653. autoClearDepthAndStencil: boolean;
  107654. /**
  107655. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  107656. */
  107657. clearColor: Color4;
  107658. /**
  107659. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  107660. */
  107661. ambientColor: Color3;
  107662. /**
  107663. * This is use to store the default BRDF lookup for PBR materials in your scene.
  107664. * It should only be one of the following (if not the default embedded one):
  107665. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107666. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  107667. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107668. * The material properties need to be setup according to the type of texture in use.
  107669. */
  107670. environmentBRDFTexture: BaseTexture;
  107671. /** @hidden */
  107672. protected _environmentTexture: Nullable<BaseTexture>;
  107673. /**
  107674. * Texture used in all pbr material as the reflection texture.
  107675. * As in the majority of the scene they are the same (exception for multi room and so on),
  107676. * this is easier to reference from here than from all the materials.
  107677. */
  107678. get environmentTexture(): Nullable<BaseTexture>;
  107679. /**
  107680. * Texture used in all pbr material as the reflection texture.
  107681. * As in the majority of the scene they are the same (exception for multi room and so on),
  107682. * this is easier to set here than in all the materials.
  107683. */
  107684. set environmentTexture(value: Nullable<BaseTexture>);
  107685. /** @hidden */
  107686. protected _environmentIntensity: number;
  107687. /**
  107688. * Intensity of the environment in all pbr material.
  107689. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107690. * As in the majority of the scene they are the same (exception for multi room and so on),
  107691. * this is easier to reference from here than from all the materials.
  107692. */
  107693. get environmentIntensity(): number;
  107694. /**
  107695. * Intensity of the environment in all pbr material.
  107696. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107697. * As in the majority of the scene they are the same (exception for multi room and so on),
  107698. * this is easier to set here than in all the materials.
  107699. */
  107700. set environmentIntensity(value: number);
  107701. /** @hidden */
  107702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107703. /**
  107704. * Default image processing configuration used either in the rendering
  107705. * Forward main pass or through the imageProcessingPostProcess if present.
  107706. * As in the majority of the scene they are the same (exception for multi camera),
  107707. * this is easier to reference from here than from all the materials and post process.
  107708. *
  107709. * No setter as we it is a shared configuration, you can set the values instead.
  107710. */
  107711. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107712. private _forceWireframe;
  107713. /**
  107714. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  107715. */
  107716. set forceWireframe(value: boolean);
  107717. get forceWireframe(): boolean;
  107718. private _skipFrustumClipping;
  107719. /**
  107720. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  107721. */
  107722. set skipFrustumClipping(value: boolean);
  107723. get skipFrustumClipping(): boolean;
  107724. private _forcePointsCloud;
  107725. /**
  107726. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  107727. */
  107728. set forcePointsCloud(value: boolean);
  107729. get forcePointsCloud(): boolean;
  107730. /**
  107731. * Gets or sets the active clipplane 1
  107732. */
  107733. clipPlane: Nullable<Plane>;
  107734. /**
  107735. * Gets or sets the active clipplane 2
  107736. */
  107737. clipPlane2: Nullable<Plane>;
  107738. /**
  107739. * Gets or sets the active clipplane 3
  107740. */
  107741. clipPlane3: Nullable<Plane>;
  107742. /**
  107743. * Gets or sets the active clipplane 4
  107744. */
  107745. clipPlane4: Nullable<Plane>;
  107746. /**
  107747. * Gets or sets the active clipplane 5
  107748. */
  107749. clipPlane5: Nullable<Plane>;
  107750. /**
  107751. * Gets or sets the active clipplane 6
  107752. */
  107753. clipPlane6: Nullable<Plane>;
  107754. /**
  107755. * Gets or sets a boolean indicating if animations are enabled
  107756. */
  107757. animationsEnabled: boolean;
  107758. private _animationPropertiesOverride;
  107759. /**
  107760. * Gets or sets the animation properties override
  107761. */
  107762. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107763. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107764. /**
  107765. * Gets or sets a boolean indicating if a constant deltatime has to be used
  107766. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  107767. */
  107768. useConstantAnimationDeltaTime: boolean;
  107769. /**
  107770. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  107771. * Please note that it requires to run a ray cast through the scene on every frame
  107772. */
  107773. constantlyUpdateMeshUnderPointer: boolean;
  107774. /**
  107775. * Defines the HTML cursor to use when hovering over interactive elements
  107776. */
  107777. hoverCursor: string;
  107778. /**
  107779. * Defines the HTML default cursor to use (empty by default)
  107780. */
  107781. defaultCursor: string;
  107782. /**
  107783. * Defines wether cursors are handled by the scene.
  107784. */
  107785. doNotHandleCursors: boolean;
  107786. /**
  107787. * This is used to call preventDefault() on pointer down
  107788. * in order to block unwanted artifacts like system double clicks
  107789. */
  107790. preventDefaultOnPointerDown: boolean;
  107791. /**
  107792. * This is used to call preventDefault() on pointer up
  107793. * in order to block unwanted artifacts like system double clicks
  107794. */
  107795. preventDefaultOnPointerUp: boolean;
  107796. /**
  107797. * Gets or sets user defined metadata
  107798. */
  107799. metadata: any;
  107800. /**
  107801. * For internal use only. Please do not use.
  107802. */
  107803. reservedDataStore: any;
  107804. /**
  107805. * Gets the name of the plugin used to load this scene (null by default)
  107806. */
  107807. loadingPluginName: string;
  107808. /**
  107809. * Use this array to add regular expressions used to disable offline support for specific urls
  107810. */
  107811. disableOfflineSupportExceptionRules: RegExp[];
  107812. /**
  107813. * An event triggered when the scene is disposed.
  107814. */
  107815. onDisposeObservable: Observable<Scene>;
  107816. private _onDisposeObserver;
  107817. /** Sets a function to be executed when this scene is disposed. */
  107818. set onDispose(callback: () => void);
  107819. /**
  107820. * An event triggered before rendering the scene (right after animations and physics)
  107821. */
  107822. onBeforeRenderObservable: Observable<Scene>;
  107823. private _onBeforeRenderObserver;
  107824. /** Sets a function to be executed before rendering this scene */
  107825. set beforeRender(callback: Nullable<() => void>);
  107826. /**
  107827. * An event triggered after rendering the scene
  107828. */
  107829. onAfterRenderObservable: Observable<Scene>;
  107830. /**
  107831. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  107832. */
  107833. onAfterRenderCameraObservable: Observable<Camera>;
  107834. private _onAfterRenderObserver;
  107835. /** Sets a function to be executed after rendering this scene */
  107836. set afterRender(callback: Nullable<() => void>);
  107837. /**
  107838. * An event triggered before animating the scene
  107839. */
  107840. onBeforeAnimationsObservable: Observable<Scene>;
  107841. /**
  107842. * An event triggered after animations processing
  107843. */
  107844. onAfterAnimationsObservable: Observable<Scene>;
  107845. /**
  107846. * An event triggered before draw calls are ready to be sent
  107847. */
  107848. onBeforeDrawPhaseObservable: Observable<Scene>;
  107849. /**
  107850. * An event triggered after draw calls have been sent
  107851. */
  107852. onAfterDrawPhaseObservable: Observable<Scene>;
  107853. /**
  107854. * An event triggered when the scene is ready
  107855. */
  107856. onReadyObservable: Observable<Scene>;
  107857. /**
  107858. * An event triggered before rendering a camera
  107859. */
  107860. onBeforeCameraRenderObservable: Observable<Camera>;
  107861. private _onBeforeCameraRenderObserver;
  107862. /** Sets a function to be executed before rendering a camera*/
  107863. set beforeCameraRender(callback: () => void);
  107864. /**
  107865. * An event triggered after rendering a camera
  107866. */
  107867. onAfterCameraRenderObservable: Observable<Camera>;
  107868. private _onAfterCameraRenderObserver;
  107869. /** Sets a function to be executed after rendering a camera*/
  107870. set afterCameraRender(callback: () => void);
  107871. /**
  107872. * An event triggered when active meshes evaluation is about to start
  107873. */
  107874. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  107875. /**
  107876. * An event triggered when active meshes evaluation is done
  107877. */
  107878. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  107879. /**
  107880. * An event triggered when particles rendering is about to start
  107881. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107882. */
  107883. onBeforeParticlesRenderingObservable: Observable<Scene>;
  107884. /**
  107885. * An event triggered when particles rendering is done
  107886. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107887. */
  107888. onAfterParticlesRenderingObservable: Observable<Scene>;
  107889. /**
  107890. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  107891. */
  107892. onDataLoadedObservable: Observable<Scene>;
  107893. /**
  107894. * An event triggered when a camera is created
  107895. */
  107896. onNewCameraAddedObservable: Observable<Camera>;
  107897. /**
  107898. * An event triggered when a camera is removed
  107899. */
  107900. onCameraRemovedObservable: Observable<Camera>;
  107901. /**
  107902. * An event triggered when a light is created
  107903. */
  107904. onNewLightAddedObservable: Observable<Light>;
  107905. /**
  107906. * An event triggered when a light is removed
  107907. */
  107908. onLightRemovedObservable: Observable<Light>;
  107909. /**
  107910. * An event triggered when a geometry is created
  107911. */
  107912. onNewGeometryAddedObservable: Observable<Geometry>;
  107913. /**
  107914. * An event triggered when a geometry is removed
  107915. */
  107916. onGeometryRemovedObservable: Observable<Geometry>;
  107917. /**
  107918. * An event triggered when a transform node is created
  107919. */
  107920. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  107921. /**
  107922. * An event triggered when a transform node is removed
  107923. */
  107924. onTransformNodeRemovedObservable: Observable<TransformNode>;
  107925. /**
  107926. * An event triggered when a mesh is created
  107927. */
  107928. onNewMeshAddedObservable: Observable<AbstractMesh>;
  107929. /**
  107930. * An event triggered when a mesh is removed
  107931. */
  107932. onMeshRemovedObservable: Observable<AbstractMesh>;
  107933. /**
  107934. * An event triggered when a skeleton is created
  107935. */
  107936. onNewSkeletonAddedObservable: Observable<Skeleton>;
  107937. /**
  107938. * An event triggered when a skeleton is removed
  107939. */
  107940. onSkeletonRemovedObservable: Observable<Skeleton>;
  107941. /**
  107942. * An event triggered when a material is created
  107943. */
  107944. onNewMaterialAddedObservable: Observable<Material>;
  107945. /**
  107946. * An event triggered when a material is removed
  107947. */
  107948. onMaterialRemovedObservable: Observable<Material>;
  107949. /**
  107950. * An event triggered when a texture is created
  107951. */
  107952. onNewTextureAddedObservable: Observable<BaseTexture>;
  107953. /**
  107954. * An event triggered when a texture is removed
  107955. */
  107956. onTextureRemovedObservable: Observable<BaseTexture>;
  107957. /**
  107958. * An event triggered when render targets are about to be rendered
  107959. * Can happen multiple times per frame.
  107960. */
  107961. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  107962. /**
  107963. * An event triggered when render targets were rendered.
  107964. * Can happen multiple times per frame.
  107965. */
  107966. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  107967. /**
  107968. * An event triggered before calculating deterministic simulation step
  107969. */
  107970. onBeforeStepObservable: Observable<Scene>;
  107971. /**
  107972. * An event triggered after calculating deterministic simulation step
  107973. */
  107974. onAfterStepObservable: Observable<Scene>;
  107975. /**
  107976. * An event triggered when the activeCamera property is updated
  107977. */
  107978. onActiveCameraChanged: Observable<Scene>;
  107979. /**
  107980. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  107981. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107982. * 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)
  107983. */
  107984. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107985. /**
  107986. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  107987. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107988. * 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)
  107989. */
  107990. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107991. /**
  107992. * This Observable will when a mesh has been imported into the scene.
  107993. */
  107994. onMeshImportedObservable: Observable<AbstractMesh>;
  107995. /**
  107996. * This Observable will when an animation file has been imported into the scene.
  107997. */
  107998. onAnimationFileImportedObservable: Observable<Scene>;
  107999. /**
  108000. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108001. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108002. */
  108003. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108004. /** @hidden */
  108005. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108006. /**
  108007. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108008. */
  108009. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108010. /**
  108011. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108012. */
  108013. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108014. /**
  108015. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108016. */
  108017. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108018. /** Callback called when a pointer move is detected */
  108019. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108020. /** Callback called when a pointer down is detected */
  108021. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108022. /** Callback called when a pointer up is detected */
  108023. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108024. /** Callback called when a pointer pick is detected */
  108025. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108026. /**
  108027. * 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).
  108028. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108029. */
  108030. onPrePointerObservable: Observable<PointerInfoPre>;
  108031. /**
  108032. * Observable event triggered each time an input event is received from the rendering canvas
  108033. */
  108034. onPointerObservable: Observable<PointerInfo>;
  108035. /**
  108036. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108037. */
  108038. get unTranslatedPointer(): Vector2;
  108039. /**
  108040. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108041. */
  108042. static get DragMovementThreshold(): number;
  108043. static set DragMovementThreshold(value: number);
  108044. /**
  108045. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108046. */
  108047. static get LongPressDelay(): number;
  108048. static set LongPressDelay(value: number);
  108049. /**
  108050. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108051. */
  108052. static get DoubleClickDelay(): number;
  108053. static set DoubleClickDelay(value: number);
  108054. /** If you need to check double click without raising a single click at first click, enable this flag */
  108055. static get ExclusiveDoubleClickMode(): boolean;
  108056. static set ExclusiveDoubleClickMode(value: boolean);
  108057. /** @hidden */
  108058. _mirroredCameraPosition: Nullable<Vector3>;
  108059. /**
  108060. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108061. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108062. */
  108063. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108064. /**
  108065. * Observable event triggered each time an keyboard event is received from the hosting window
  108066. */
  108067. onKeyboardObservable: Observable<KeyboardInfo>;
  108068. private _useRightHandedSystem;
  108069. /**
  108070. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108071. */
  108072. set useRightHandedSystem(value: boolean);
  108073. get useRightHandedSystem(): boolean;
  108074. private _timeAccumulator;
  108075. private _currentStepId;
  108076. private _currentInternalStep;
  108077. /**
  108078. * Sets the step Id used by deterministic lock step
  108079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108080. * @param newStepId defines the step Id
  108081. */
  108082. setStepId(newStepId: number): void;
  108083. /**
  108084. * Gets the step Id used by deterministic lock step
  108085. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108086. * @returns the step Id
  108087. */
  108088. getStepId(): number;
  108089. /**
  108090. * Gets the internal step used by deterministic lock step
  108091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108092. * @returns the internal step
  108093. */
  108094. getInternalStep(): number;
  108095. private _fogEnabled;
  108096. /**
  108097. * Gets or sets a boolean indicating if fog is enabled on this scene
  108098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108099. * (Default is true)
  108100. */
  108101. set fogEnabled(value: boolean);
  108102. get fogEnabled(): boolean;
  108103. private _fogMode;
  108104. /**
  108105. * Gets or sets the fog mode to use
  108106. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108107. * | mode | value |
  108108. * | --- | --- |
  108109. * | FOGMODE_NONE | 0 |
  108110. * | FOGMODE_EXP | 1 |
  108111. * | FOGMODE_EXP2 | 2 |
  108112. * | FOGMODE_LINEAR | 3 |
  108113. */
  108114. set fogMode(value: number);
  108115. get fogMode(): number;
  108116. /**
  108117. * Gets or sets the fog color to use
  108118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108119. * (Default is Color3(0.2, 0.2, 0.3))
  108120. */
  108121. fogColor: Color3;
  108122. /**
  108123. * Gets or sets the fog density to use
  108124. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108125. * (Default is 0.1)
  108126. */
  108127. fogDensity: number;
  108128. /**
  108129. * Gets or sets the fog start distance to use
  108130. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108131. * (Default is 0)
  108132. */
  108133. fogStart: number;
  108134. /**
  108135. * Gets or sets the fog end distance to use
  108136. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108137. * (Default is 1000)
  108138. */
  108139. fogEnd: number;
  108140. private _shadowsEnabled;
  108141. /**
  108142. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108143. */
  108144. set shadowsEnabled(value: boolean);
  108145. get shadowsEnabled(): boolean;
  108146. private _lightsEnabled;
  108147. /**
  108148. * Gets or sets a boolean indicating if lights are enabled on this scene
  108149. */
  108150. set lightsEnabled(value: boolean);
  108151. get lightsEnabled(): boolean;
  108152. /** All of the active cameras added to this scene. */
  108153. activeCameras: Camera[];
  108154. /** @hidden */
  108155. _activeCamera: Nullable<Camera>;
  108156. /** Gets or sets the current active camera */
  108157. get activeCamera(): Nullable<Camera>;
  108158. set activeCamera(value: Nullable<Camera>);
  108159. private _defaultMaterial;
  108160. /** The default material used on meshes when no material is affected */
  108161. get defaultMaterial(): Material;
  108162. /** The default material used on meshes when no material is affected */
  108163. set defaultMaterial(value: Material);
  108164. private _texturesEnabled;
  108165. /**
  108166. * Gets or sets a boolean indicating if textures are enabled on this scene
  108167. */
  108168. set texturesEnabled(value: boolean);
  108169. get texturesEnabled(): boolean;
  108170. /**
  108171. * Gets or sets a boolean indicating if particles are enabled on this scene
  108172. */
  108173. particlesEnabled: boolean;
  108174. /**
  108175. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108176. */
  108177. spritesEnabled: boolean;
  108178. private _skeletonsEnabled;
  108179. /**
  108180. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108181. */
  108182. set skeletonsEnabled(value: boolean);
  108183. get skeletonsEnabled(): boolean;
  108184. /**
  108185. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108186. */
  108187. lensFlaresEnabled: boolean;
  108188. /**
  108189. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108191. */
  108192. collisionsEnabled: boolean;
  108193. private _collisionCoordinator;
  108194. /** @hidden */
  108195. get collisionCoordinator(): ICollisionCoordinator;
  108196. /**
  108197. * Defines the gravity applied to this scene (used only for collisions)
  108198. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108199. */
  108200. gravity: Vector3;
  108201. /**
  108202. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108203. */
  108204. postProcessesEnabled: boolean;
  108205. /**
  108206. * The list of postprocesses added to the scene
  108207. */
  108208. postProcesses: PostProcess[];
  108209. /**
  108210. * Gets the current postprocess manager
  108211. */
  108212. postProcessManager: PostProcessManager;
  108213. /**
  108214. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108215. */
  108216. renderTargetsEnabled: boolean;
  108217. /**
  108218. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108219. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108220. */
  108221. dumpNextRenderTargets: boolean;
  108222. /**
  108223. * The list of user defined render targets added to the scene
  108224. */
  108225. customRenderTargets: RenderTargetTexture[];
  108226. /**
  108227. * Defines if texture loading must be delayed
  108228. * If true, textures will only be loaded when they need to be rendered
  108229. */
  108230. useDelayedTextureLoading: boolean;
  108231. /**
  108232. * Gets the list of meshes imported to the scene through SceneLoader
  108233. */
  108234. importedMeshesFiles: String[];
  108235. /**
  108236. * Gets or sets a boolean indicating if probes are enabled on this scene
  108237. */
  108238. probesEnabled: boolean;
  108239. /**
  108240. * Gets or sets the current offline provider to use to store scene data
  108241. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108242. */
  108243. offlineProvider: IOfflineProvider;
  108244. /**
  108245. * Gets or sets the action manager associated with the scene
  108246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108247. */
  108248. actionManager: AbstractActionManager;
  108249. private _meshesForIntersections;
  108250. /**
  108251. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108252. */
  108253. proceduralTexturesEnabled: boolean;
  108254. private _engine;
  108255. private _totalVertices;
  108256. /** @hidden */
  108257. _activeIndices: PerfCounter;
  108258. /** @hidden */
  108259. _activeParticles: PerfCounter;
  108260. /** @hidden */
  108261. _activeBones: PerfCounter;
  108262. private _animationRatio;
  108263. /** @hidden */
  108264. _animationTimeLast: number;
  108265. /** @hidden */
  108266. _animationTime: number;
  108267. /**
  108268. * Gets or sets a general scale for animation speed
  108269. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108270. */
  108271. animationTimeScale: number;
  108272. /** @hidden */
  108273. _cachedMaterial: Nullable<Material>;
  108274. /** @hidden */
  108275. _cachedEffect: Nullable<Effect>;
  108276. /** @hidden */
  108277. _cachedVisibility: Nullable<number>;
  108278. private _renderId;
  108279. private _frameId;
  108280. private _executeWhenReadyTimeoutId;
  108281. private _intermediateRendering;
  108282. private _viewUpdateFlag;
  108283. private _projectionUpdateFlag;
  108284. /** @hidden */
  108285. _toBeDisposed: Nullable<IDisposable>[];
  108286. private _activeRequests;
  108287. /** @hidden */
  108288. _pendingData: any[];
  108289. private _isDisposed;
  108290. /**
  108291. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108292. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108293. */
  108294. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108295. private _activeMeshes;
  108296. private _processedMaterials;
  108297. private _renderTargets;
  108298. /** @hidden */
  108299. _activeParticleSystems: SmartArray<IParticleSystem>;
  108300. private _activeSkeletons;
  108301. private _softwareSkinnedMeshes;
  108302. private _renderingManager;
  108303. /** @hidden */
  108304. _activeAnimatables: Animatable[];
  108305. private _transformMatrix;
  108306. private _sceneUbo;
  108307. /** @hidden */
  108308. _viewMatrix: Matrix;
  108309. private _projectionMatrix;
  108310. /** @hidden */
  108311. _forcedViewPosition: Nullable<Vector3>;
  108312. /** @hidden */
  108313. _frustumPlanes: Plane[];
  108314. /**
  108315. * Gets the list of frustum planes (built from the active camera)
  108316. */
  108317. get frustumPlanes(): Plane[];
  108318. /**
  108319. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108320. * This is useful if there are more lights that the maximum simulteanous authorized
  108321. */
  108322. requireLightSorting: boolean;
  108323. /** @hidden */
  108324. readonly useMaterialMeshMap: boolean;
  108325. /** @hidden */
  108326. readonly useClonedMeshMap: boolean;
  108327. private _externalData;
  108328. private _uid;
  108329. /**
  108330. * @hidden
  108331. * Backing store of defined scene components.
  108332. */
  108333. _components: ISceneComponent[];
  108334. /**
  108335. * @hidden
  108336. * Backing store of defined scene components.
  108337. */
  108338. _serializableComponents: ISceneSerializableComponent[];
  108339. /**
  108340. * List of components to register on the next registration step.
  108341. */
  108342. private _transientComponents;
  108343. /**
  108344. * Registers the transient components if needed.
  108345. */
  108346. private _registerTransientComponents;
  108347. /**
  108348. * @hidden
  108349. * Add a component to the scene.
  108350. * Note that the ccomponent could be registered on th next frame if this is called after
  108351. * the register component stage.
  108352. * @param component Defines the component to add to the scene
  108353. */
  108354. _addComponent(component: ISceneComponent): void;
  108355. /**
  108356. * @hidden
  108357. * Gets a component from the scene.
  108358. * @param name defines the name of the component to retrieve
  108359. * @returns the component or null if not present
  108360. */
  108361. _getComponent(name: string): Nullable<ISceneComponent>;
  108362. /**
  108363. * @hidden
  108364. * Defines the actions happening before camera updates.
  108365. */
  108366. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  108367. /**
  108368. * @hidden
  108369. * Defines the actions happening before clear the canvas.
  108370. */
  108371. _beforeClearStage: Stage<SimpleStageAction>;
  108372. /**
  108373. * @hidden
  108374. * Defines the actions when collecting render targets for the frame.
  108375. */
  108376. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108377. /**
  108378. * @hidden
  108379. * Defines the actions happening for one camera in the frame.
  108380. */
  108381. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108382. /**
  108383. * @hidden
  108384. * Defines the actions happening during the per mesh ready checks.
  108385. */
  108386. _isReadyForMeshStage: Stage<MeshStageAction>;
  108387. /**
  108388. * @hidden
  108389. * Defines the actions happening before evaluate active mesh checks.
  108390. */
  108391. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  108392. /**
  108393. * @hidden
  108394. * Defines the actions happening during the evaluate sub mesh checks.
  108395. */
  108396. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  108397. /**
  108398. * @hidden
  108399. * Defines the actions happening during the active mesh stage.
  108400. */
  108401. _activeMeshStage: Stage<ActiveMeshStageAction>;
  108402. /**
  108403. * @hidden
  108404. * Defines the actions happening during the per camera render target step.
  108405. */
  108406. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  108407. /**
  108408. * @hidden
  108409. * Defines the actions happening just before the active camera is drawing.
  108410. */
  108411. _beforeCameraDrawStage: Stage<CameraStageAction>;
  108412. /**
  108413. * @hidden
  108414. * Defines the actions happening just before a render target is drawing.
  108415. */
  108416. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108417. /**
  108418. * @hidden
  108419. * Defines the actions happening just before a rendering group is drawing.
  108420. */
  108421. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108422. /**
  108423. * @hidden
  108424. * Defines the actions happening just before a mesh is drawing.
  108425. */
  108426. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108427. /**
  108428. * @hidden
  108429. * Defines the actions happening just after a mesh has been drawn.
  108430. */
  108431. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108432. /**
  108433. * @hidden
  108434. * Defines the actions happening just after a rendering group has been drawn.
  108435. */
  108436. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108437. /**
  108438. * @hidden
  108439. * Defines the actions happening just after the active camera has been drawn.
  108440. */
  108441. _afterCameraDrawStage: Stage<CameraStageAction>;
  108442. /**
  108443. * @hidden
  108444. * Defines the actions happening just after a render target has been drawn.
  108445. */
  108446. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108447. /**
  108448. * @hidden
  108449. * Defines the actions happening just after rendering all cameras and computing intersections.
  108450. */
  108451. _afterRenderStage: Stage<SimpleStageAction>;
  108452. /**
  108453. * @hidden
  108454. * Defines the actions happening when a pointer move event happens.
  108455. */
  108456. _pointerMoveStage: Stage<PointerMoveStageAction>;
  108457. /**
  108458. * @hidden
  108459. * Defines the actions happening when a pointer down event happens.
  108460. */
  108461. _pointerDownStage: Stage<PointerUpDownStageAction>;
  108462. /**
  108463. * @hidden
  108464. * Defines the actions happening when a pointer up event happens.
  108465. */
  108466. _pointerUpStage: Stage<PointerUpDownStageAction>;
  108467. /**
  108468. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  108469. */
  108470. private geometriesByUniqueId;
  108471. /**
  108472. * Creates a new Scene
  108473. * @param engine defines the engine to use to render this scene
  108474. * @param options defines the scene options
  108475. */
  108476. constructor(engine: Engine, options?: SceneOptions);
  108477. /**
  108478. * Gets a string idenfifying the name of the class
  108479. * @returns "Scene" string
  108480. */
  108481. getClassName(): string;
  108482. private _defaultMeshCandidates;
  108483. /**
  108484. * @hidden
  108485. */
  108486. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108487. private _defaultSubMeshCandidates;
  108488. /**
  108489. * @hidden
  108490. */
  108491. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108492. /**
  108493. * Sets the default candidate providers for the scene.
  108494. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  108495. * and getCollidingSubMeshCandidates to their default function
  108496. */
  108497. setDefaultCandidateProviders(): void;
  108498. /**
  108499. * Gets the mesh that is currently under the pointer
  108500. */
  108501. get meshUnderPointer(): Nullable<AbstractMesh>;
  108502. /**
  108503. * Gets or sets the current on-screen X position of the pointer
  108504. */
  108505. get pointerX(): number;
  108506. set pointerX(value: number);
  108507. /**
  108508. * Gets or sets the current on-screen Y position of the pointer
  108509. */
  108510. get pointerY(): number;
  108511. set pointerY(value: number);
  108512. /**
  108513. * Gets the cached material (ie. the latest rendered one)
  108514. * @returns the cached material
  108515. */
  108516. getCachedMaterial(): Nullable<Material>;
  108517. /**
  108518. * Gets the cached effect (ie. the latest rendered one)
  108519. * @returns the cached effect
  108520. */
  108521. getCachedEffect(): Nullable<Effect>;
  108522. /**
  108523. * Gets the cached visibility state (ie. the latest rendered one)
  108524. * @returns the cached visibility state
  108525. */
  108526. getCachedVisibility(): Nullable<number>;
  108527. /**
  108528. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  108529. * @param material defines the current material
  108530. * @param effect defines the current effect
  108531. * @param visibility defines the current visibility state
  108532. * @returns true if one parameter is not cached
  108533. */
  108534. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  108535. /**
  108536. * Gets the engine associated with the scene
  108537. * @returns an Engine
  108538. */
  108539. getEngine(): Engine;
  108540. /**
  108541. * Gets the total number of vertices rendered per frame
  108542. * @returns the total number of vertices rendered per frame
  108543. */
  108544. getTotalVertices(): number;
  108545. /**
  108546. * Gets the performance counter for total vertices
  108547. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108548. */
  108549. get totalVerticesPerfCounter(): PerfCounter;
  108550. /**
  108551. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  108552. * @returns the total number of active indices rendered per frame
  108553. */
  108554. getActiveIndices(): number;
  108555. /**
  108556. * Gets the performance counter for active indices
  108557. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108558. */
  108559. get totalActiveIndicesPerfCounter(): PerfCounter;
  108560. /**
  108561. * Gets the total number of active particles rendered per frame
  108562. * @returns the total number of active particles rendered per frame
  108563. */
  108564. getActiveParticles(): number;
  108565. /**
  108566. * Gets the performance counter for active particles
  108567. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108568. */
  108569. get activeParticlesPerfCounter(): PerfCounter;
  108570. /**
  108571. * Gets the total number of active bones rendered per frame
  108572. * @returns the total number of active bones rendered per frame
  108573. */
  108574. getActiveBones(): number;
  108575. /**
  108576. * Gets the performance counter for active bones
  108577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108578. */
  108579. get activeBonesPerfCounter(): PerfCounter;
  108580. /**
  108581. * Gets the array of active meshes
  108582. * @returns an array of AbstractMesh
  108583. */
  108584. getActiveMeshes(): SmartArray<AbstractMesh>;
  108585. /**
  108586. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  108587. * @returns a number
  108588. */
  108589. getAnimationRatio(): number;
  108590. /**
  108591. * Gets an unique Id for the current render phase
  108592. * @returns a number
  108593. */
  108594. getRenderId(): number;
  108595. /**
  108596. * Gets an unique Id for the current frame
  108597. * @returns a number
  108598. */
  108599. getFrameId(): number;
  108600. /** Call this function if you want to manually increment the render Id*/
  108601. incrementRenderId(): void;
  108602. private _createUbo;
  108603. /**
  108604. * Use this method to simulate a pointer move on a mesh
  108605. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108606. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108607. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108608. * @returns the current scene
  108609. */
  108610. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108611. /**
  108612. * Use this method to simulate a pointer down on a mesh
  108613. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108614. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108615. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108616. * @returns the current scene
  108617. */
  108618. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108619. /**
  108620. * Use this method to simulate a pointer up on a mesh
  108621. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108622. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108623. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108624. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108625. * @returns the current scene
  108626. */
  108627. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  108628. /**
  108629. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108630. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108631. * @returns true if the pointer was captured
  108632. */
  108633. isPointerCaptured(pointerId?: number): boolean;
  108634. /**
  108635. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108636. * @param attachUp defines if you want to attach events to pointerup
  108637. * @param attachDown defines if you want to attach events to pointerdown
  108638. * @param attachMove defines if you want to attach events to pointermove
  108639. */
  108640. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  108641. /** Detaches all event handlers*/
  108642. detachControl(): void;
  108643. /**
  108644. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  108645. * Delay loaded resources are not taking in account
  108646. * @return true if all required resources are ready
  108647. */
  108648. isReady(): boolean;
  108649. /** Resets all cached information relative to material (including effect and visibility) */
  108650. resetCachedMaterial(): void;
  108651. /**
  108652. * Registers a function to be called before every frame render
  108653. * @param func defines the function to register
  108654. */
  108655. registerBeforeRender(func: () => void): void;
  108656. /**
  108657. * Unregisters a function called before every frame render
  108658. * @param func defines the function to unregister
  108659. */
  108660. unregisterBeforeRender(func: () => void): void;
  108661. /**
  108662. * Registers a function to be called after every frame render
  108663. * @param func defines the function to register
  108664. */
  108665. registerAfterRender(func: () => void): void;
  108666. /**
  108667. * Unregisters a function called after every frame render
  108668. * @param func defines the function to unregister
  108669. */
  108670. unregisterAfterRender(func: () => void): void;
  108671. private _executeOnceBeforeRender;
  108672. /**
  108673. * The provided function will run before render once and will be disposed afterwards.
  108674. * A timeout delay can be provided so that the function will be executed in N ms.
  108675. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  108676. * @param func The function to be executed.
  108677. * @param timeout optional delay in ms
  108678. */
  108679. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  108680. /** @hidden */
  108681. _addPendingData(data: any): void;
  108682. /** @hidden */
  108683. _removePendingData(data: any): void;
  108684. /**
  108685. * Returns the number of items waiting to be loaded
  108686. * @returns the number of items waiting to be loaded
  108687. */
  108688. getWaitingItemsCount(): number;
  108689. /**
  108690. * Returns a boolean indicating if the scene is still loading data
  108691. */
  108692. get isLoading(): boolean;
  108693. /**
  108694. * Registers a function to be executed when the scene is ready
  108695. * @param {Function} func - the function to be executed
  108696. */
  108697. executeWhenReady(func: () => void): void;
  108698. /**
  108699. * Returns a promise that resolves when the scene is ready
  108700. * @returns A promise that resolves when the scene is ready
  108701. */
  108702. whenReadyAsync(): Promise<void>;
  108703. /** @hidden */
  108704. _checkIsReady(): void;
  108705. /**
  108706. * Gets all animatable attached to the scene
  108707. */
  108708. get animatables(): Animatable[];
  108709. /**
  108710. * Resets the last animation time frame.
  108711. * Useful to override when animations start running when loading a scene for the first time.
  108712. */
  108713. resetLastAnimationTimeFrame(): void;
  108714. /**
  108715. * Gets the current view matrix
  108716. * @returns a Matrix
  108717. */
  108718. getViewMatrix(): Matrix;
  108719. /**
  108720. * Gets the current projection matrix
  108721. * @returns a Matrix
  108722. */
  108723. getProjectionMatrix(): Matrix;
  108724. /**
  108725. * Gets the current transform matrix
  108726. * @returns a Matrix made of View * Projection
  108727. */
  108728. getTransformMatrix(): Matrix;
  108729. /**
  108730. * Sets the current transform matrix
  108731. * @param viewL defines the View matrix to use
  108732. * @param projectionL defines the Projection matrix to use
  108733. * @param viewR defines the right View matrix to use (if provided)
  108734. * @param projectionR defines the right Projection matrix to use (if provided)
  108735. */
  108736. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  108737. /**
  108738. * Gets the uniform buffer used to store scene data
  108739. * @returns a UniformBuffer
  108740. */
  108741. getSceneUniformBuffer(): UniformBuffer;
  108742. /**
  108743. * Gets an unique (relatively to the current scene) Id
  108744. * @returns an unique number for the scene
  108745. */
  108746. getUniqueId(): number;
  108747. /**
  108748. * Add a mesh to the list of scene's meshes
  108749. * @param newMesh defines the mesh to add
  108750. * @param recursive if all child meshes should also be added to the scene
  108751. */
  108752. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  108753. /**
  108754. * Remove a mesh for the list of scene's meshes
  108755. * @param toRemove defines the mesh to remove
  108756. * @param recursive if all child meshes should also be removed from the scene
  108757. * @returns the index where the mesh was in the mesh list
  108758. */
  108759. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  108760. /**
  108761. * Add a transform node to the list of scene's transform nodes
  108762. * @param newTransformNode defines the transform node to add
  108763. */
  108764. addTransformNode(newTransformNode: TransformNode): void;
  108765. /**
  108766. * Remove a transform node for the list of scene's transform nodes
  108767. * @param toRemove defines the transform node to remove
  108768. * @returns the index where the transform node was in the transform node list
  108769. */
  108770. removeTransformNode(toRemove: TransformNode): number;
  108771. /**
  108772. * Remove a skeleton for the list of scene's skeletons
  108773. * @param toRemove defines the skeleton to remove
  108774. * @returns the index where the skeleton was in the skeleton list
  108775. */
  108776. removeSkeleton(toRemove: Skeleton): number;
  108777. /**
  108778. * Remove a morph target for the list of scene's morph targets
  108779. * @param toRemove defines the morph target to remove
  108780. * @returns the index where the morph target was in the morph target list
  108781. */
  108782. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  108783. /**
  108784. * Remove a light for the list of scene's lights
  108785. * @param toRemove defines the light to remove
  108786. * @returns the index where the light was in the light list
  108787. */
  108788. removeLight(toRemove: Light): number;
  108789. /**
  108790. * Remove a camera for the list of scene's cameras
  108791. * @param toRemove defines the camera to remove
  108792. * @returns the index where the camera was in the camera list
  108793. */
  108794. removeCamera(toRemove: Camera): number;
  108795. /**
  108796. * Remove a particle system for the list of scene's particle systems
  108797. * @param toRemove defines the particle system to remove
  108798. * @returns the index where the particle system was in the particle system list
  108799. */
  108800. removeParticleSystem(toRemove: IParticleSystem): number;
  108801. /**
  108802. * Remove a animation for the list of scene's animations
  108803. * @param toRemove defines the animation to remove
  108804. * @returns the index where the animation was in the animation list
  108805. */
  108806. removeAnimation(toRemove: Animation): number;
  108807. /**
  108808. * Will stop the animation of the given target
  108809. * @param target - the target
  108810. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  108811. * @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)
  108812. */
  108813. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  108814. /**
  108815. * Removes the given animation group from this scene.
  108816. * @param toRemove The animation group to remove
  108817. * @returns The index of the removed animation group
  108818. */
  108819. removeAnimationGroup(toRemove: AnimationGroup): number;
  108820. /**
  108821. * Removes the given multi-material from this scene.
  108822. * @param toRemove The multi-material to remove
  108823. * @returns The index of the removed multi-material
  108824. */
  108825. removeMultiMaterial(toRemove: MultiMaterial): number;
  108826. /**
  108827. * Removes the given material from this scene.
  108828. * @param toRemove The material to remove
  108829. * @returns The index of the removed material
  108830. */
  108831. removeMaterial(toRemove: Material): number;
  108832. /**
  108833. * Removes the given action manager from this scene.
  108834. * @param toRemove The action manager to remove
  108835. * @returns The index of the removed action manager
  108836. */
  108837. removeActionManager(toRemove: AbstractActionManager): number;
  108838. /**
  108839. * Removes the given texture from this scene.
  108840. * @param toRemove The texture to remove
  108841. * @returns The index of the removed texture
  108842. */
  108843. removeTexture(toRemove: BaseTexture): number;
  108844. /**
  108845. * Adds the given light to this scene
  108846. * @param newLight The light to add
  108847. */
  108848. addLight(newLight: Light): void;
  108849. /**
  108850. * Sorts the list list based on light priorities
  108851. */
  108852. sortLightsByPriority(): void;
  108853. /**
  108854. * Adds the given camera to this scene
  108855. * @param newCamera The camera to add
  108856. */
  108857. addCamera(newCamera: Camera): void;
  108858. /**
  108859. * Adds the given skeleton to this scene
  108860. * @param newSkeleton The skeleton to add
  108861. */
  108862. addSkeleton(newSkeleton: Skeleton): void;
  108863. /**
  108864. * Adds the given particle system to this scene
  108865. * @param newParticleSystem The particle system to add
  108866. */
  108867. addParticleSystem(newParticleSystem: IParticleSystem): void;
  108868. /**
  108869. * Adds the given animation to this scene
  108870. * @param newAnimation The animation to add
  108871. */
  108872. addAnimation(newAnimation: Animation): void;
  108873. /**
  108874. * Adds the given animation group to this scene.
  108875. * @param newAnimationGroup The animation group to add
  108876. */
  108877. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  108878. /**
  108879. * Adds the given multi-material to this scene
  108880. * @param newMultiMaterial The multi-material to add
  108881. */
  108882. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  108883. /**
  108884. * Adds the given material to this scene
  108885. * @param newMaterial The material to add
  108886. */
  108887. addMaterial(newMaterial: Material): void;
  108888. /**
  108889. * Adds the given morph target to this scene
  108890. * @param newMorphTargetManager The morph target to add
  108891. */
  108892. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  108893. /**
  108894. * Adds the given geometry to this scene
  108895. * @param newGeometry The geometry to add
  108896. */
  108897. addGeometry(newGeometry: Geometry): void;
  108898. /**
  108899. * Adds the given action manager to this scene
  108900. * @param newActionManager The action manager to add
  108901. */
  108902. addActionManager(newActionManager: AbstractActionManager): void;
  108903. /**
  108904. * Adds the given texture to this scene.
  108905. * @param newTexture The texture to add
  108906. */
  108907. addTexture(newTexture: BaseTexture): void;
  108908. /**
  108909. * Switch active camera
  108910. * @param newCamera defines the new active camera
  108911. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  108912. */
  108913. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  108914. /**
  108915. * sets the active camera of the scene using its ID
  108916. * @param id defines the camera's ID
  108917. * @return the new active camera or null if none found.
  108918. */
  108919. setActiveCameraByID(id: string): Nullable<Camera>;
  108920. /**
  108921. * sets the active camera of the scene using its name
  108922. * @param name defines the camera's name
  108923. * @returns the new active camera or null if none found.
  108924. */
  108925. setActiveCameraByName(name: string): Nullable<Camera>;
  108926. /**
  108927. * get an animation group using its name
  108928. * @param name defines the material's name
  108929. * @return the animation group or null if none found.
  108930. */
  108931. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  108932. /**
  108933. * Get a material using its unique id
  108934. * @param uniqueId defines the material's unique id
  108935. * @return the material or null if none found.
  108936. */
  108937. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  108938. /**
  108939. * get a material using its id
  108940. * @param id defines the material's ID
  108941. * @return the material or null if none found.
  108942. */
  108943. getMaterialByID(id: string): Nullable<Material>;
  108944. /**
  108945. * Gets a the last added material using a given id
  108946. * @param id defines the material's ID
  108947. * @return the last material with the given id or null if none found.
  108948. */
  108949. getLastMaterialByID(id: string): Nullable<Material>;
  108950. /**
  108951. * Gets a material using its name
  108952. * @param name defines the material's name
  108953. * @return the material or null if none found.
  108954. */
  108955. getMaterialByName(name: string): Nullable<Material>;
  108956. /**
  108957. * Get a texture using its unique id
  108958. * @param uniqueId defines the texture's unique id
  108959. * @return the texture or null if none found.
  108960. */
  108961. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  108962. /**
  108963. * Gets a camera using its id
  108964. * @param id defines the id to look for
  108965. * @returns the camera or null if not found
  108966. */
  108967. getCameraByID(id: string): Nullable<Camera>;
  108968. /**
  108969. * Gets a camera using its unique id
  108970. * @param uniqueId defines the unique id to look for
  108971. * @returns the camera or null if not found
  108972. */
  108973. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  108974. /**
  108975. * Gets a camera using its name
  108976. * @param name defines the camera's name
  108977. * @return the camera or null if none found.
  108978. */
  108979. getCameraByName(name: string): Nullable<Camera>;
  108980. /**
  108981. * Gets a bone using its id
  108982. * @param id defines the bone's id
  108983. * @return the bone or null if not found
  108984. */
  108985. getBoneByID(id: string): Nullable<Bone>;
  108986. /**
  108987. * Gets a bone using its id
  108988. * @param name defines the bone's name
  108989. * @return the bone or null if not found
  108990. */
  108991. getBoneByName(name: string): Nullable<Bone>;
  108992. /**
  108993. * Gets a light node using its name
  108994. * @param name defines the the light's name
  108995. * @return the light or null if none found.
  108996. */
  108997. getLightByName(name: string): Nullable<Light>;
  108998. /**
  108999. * Gets a light node using its id
  109000. * @param id defines the light's id
  109001. * @return the light or null if none found.
  109002. */
  109003. getLightByID(id: string): Nullable<Light>;
  109004. /**
  109005. * Gets a light node using its scene-generated unique ID
  109006. * @param uniqueId defines the light's unique id
  109007. * @return the light or null if none found.
  109008. */
  109009. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109010. /**
  109011. * Gets a particle system by id
  109012. * @param id defines the particle system id
  109013. * @return the corresponding system or null if none found
  109014. */
  109015. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109016. /**
  109017. * Gets a geometry using its ID
  109018. * @param id defines the geometry's id
  109019. * @return the geometry or null if none found.
  109020. */
  109021. getGeometryByID(id: string): Nullable<Geometry>;
  109022. private _getGeometryByUniqueID;
  109023. /**
  109024. * Add a new geometry to this scene
  109025. * @param geometry defines the geometry to be added to the scene.
  109026. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109027. * @return a boolean defining if the geometry was added or not
  109028. */
  109029. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109030. /**
  109031. * Removes an existing geometry
  109032. * @param geometry defines the geometry to be removed from the scene
  109033. * @return a boolean defining if the geometry was removed or not
  109034. */
  109035. removeGeometry(geometry: Geometry): boolean;
  109036. /**
  109037. * Gets the list of geometries attached to the scene
  109038. * @returns an array of Geometry
  109039. */
  109040. getGeometries(): Geometry[];
  109041. /**
  109042. * Gets the first added mesh found of a given ID
  109043. * @param id defines the id to search for
  109044. * @return the mesh found or null if not found at all
  109045. */
  109046. getMeshByID(id: string): Nullable<AbstractMesh>;
  109047. /**
  109048. * Gets a list of meshes using their id
  109049. * @param id defines the id to search for
  109050. * @returns a list of meshes
  109051. */
  109052. getMeshesByID(id: string): Array<AbstractMesh>;
  109053. /**
  109054. * Gets the first added transform node found of a given ID
  109055. * @param id defines the id to search for
  109056. * @return the found transform node or null if not found at all.
  109057. */
  109058. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109059. /**
  109060. * Gets a transform node with its auto-generated unique id
  109061. * @param uniqueId efines the unique id to search for
  109062. * @return the found transform node or null if not found at all.
  109063. */
  109064. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109065. /**
  109066. * Gets a list of transform nodes using their id
  109067. * @param id defines the id to search for
  109068. * @returns a list of transform nodes
  109069. */
  109070. getTransformNodesByID(id: string): Array<TransformNode>;
  109071. /**
  109072. * Gets a mesh with its auto-generated unique id
  109073. * @param uniqueId defines the unique id to search for
  109074. * @return the found mesh or null if not found at all.
  109075. */
  109076. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109077. /**
  109078. * Gets a the last added mesh using a given id
  109079. * @param id defines the id to search for
  109080. * @return the found mesh or null if not found at all.
  109081. */
  109082. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109083. /**
  109084. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109085. * @param id defines the id to search for
  109086. * @return the found node or null if not found at all
  109087. */
  109088. getLastEntryByID(id: string): Nullable<Node>;
  109089. /**
  109090. * Gets a node (Mesh, Camera, Light) using a given id
  109091. * @param id defines the id to search for
  109092. * @return the found node or null if not found at all
  109093. */
  109094. getNodeByID(id: string): Nullable<Node>;
  109095. /**
  109096. * Gets a node (Mesh, Camera, Light) using a given name
  109097. * @param name defines the name to search for
  109098. * @return the found node or null if not found at all.
  109099. */
  109100. getNodeByName(name: string): Nullable<Node>;
  109101. /**
  109102. * Gets a mesh using a given name
  109103. * @param name defines the name to search for
  109104. * @return the found mesh or null if not found at all.
  109105. */
  109106. getMeshByName(name: string): Nullable<AbstractMesh>;
  109107. /**
  109108. * Gets a transform node using a given name
  109109. * @param name defines the name to search for
  109110. * @return the found transform node or null if not found at all.
  109111. */
  109112. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109113. /**
  109114. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109115. * @param id defines the id to search for
  109116. * @return the found skeleton or null if not found at all.
  109117. */
  109118. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109119. /**
  109120. * Gets a skeleton using a given auto generated unique id
  109121. * @param uniqueId defines the unique id to search for
  109122. * @return the found skeleton or null if not found at all.
  109123. */
  109124. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109125. /**
  109126. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109127. * @param id defines the id to search for
  109128. * @return the found skeleton or null if not found at all.
  109129. */
  109130. getSkeletonById(id: string): Nullable<Skeleton>;
  109131. /**
  109132. * Gets a skeleton using a given name
  109133. * @param name defines the name to search for
  109134. * @return the found skeleton or null if not found at all.
  109135. */
  109136. getSkeletonByName(name: string): Nullable<Skeleton>;
  109137. /**
  109138. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109139. * @param id defines the id to search for
  109140. * @return the found morph target manager or null if not found at all.
  109141. */
  109142. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109143. /**
  109144. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109145. * @param id defines the id to search for
  109146. * @return the found morph target or null if not found at all.
  109147. */
  109148. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109149. /**
  109150. * Gets a boolean indicating if the given mesh is active
  109151. * @param mesh defines the mesh to look for
  109152. * @returns true if the mesh is in the active list
  109153. */
  109154. isActiveMesh(mesh: AbstractMesh): boolean;
  109155. /**
  109156. * Return a unique id as a string which can serve as an identifier for the scene
  109157. */
  109158. get uid(): string;
  109159. /**
  109160. * Add an externaly attached data from its key.
  109161. * This method call will fail and return false, if such key already exists.
  109162. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109163. * @param key the unique key that identifies the data
  109164. * @param data the data object to associate to the key for this Engine instance
  109165. * @return true if no such key were already present and the data was added successfully, false otherwise
  109166. */
  109167. addExternalData<T>(key: string, data: T): boolean;
  109168. /**
  109169. * Get an externaly attached data from its key
  109170. * @param key the unique key that identifies the data
  109171. * @return the associated data, if present (can be null), or undefined if not present
  109172. */
  109173. getExternalData<T>(key: string): Nullable<T>;
  109174. /**
  109175. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109176. * @param key the unique key that identifies the data
  109177. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109178. * @return the associated data, can be null if the factory returned null.
  109179. */
  109180. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109181. /**
  109182. * Remove an externaly attached data from the Engine instance
  109183. * @param key the unique key that identifies the data
  109184. * @return true if the data was successfully removed, false if it doesn't exist
  109185. */
  109186. removeExternalData(key: string): boolean;
  109187. private _evaluateSubMesh;
  109188. /**
  109189. * Clear the processed materials smart array preventing retention point in material dispose.
  109190. */
  109191. freeProcessedMaterials(): void;
  109192. private _preventFreeActiveMeshesAndRenderingGroups;
  109193. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109194. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109195. * when disposing several meshes in a row or a hierarchy of meshes.
  109196. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109197. */
  109198. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109199. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109200. /**
  109201. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109202. */
  109203. freeActiveMeshes(): void;
  109204. /**
  109205. * Clear the info related to rendering groups preventing retention points during dispose.
  109206. */
  109207. freeRenderingGroups(): void;
  109208. /** @hidden */
  109209. _isInIntermediateRendering(): boolean;
  109210. /**
  109211. * Lambda returning the list of potentially active meshes.
  109212. */
  109213. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109214. /**
  109215. * Lambda returning the list of potentially active sub meshes.
  109216. */
  109217. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109218. /**
  109219. * Lambda returning the list of potentially intersecting sub meshes.
  109220. */
  109221. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109222. /**
  109223. * Lambda returning the list of potentially colliding sub meshes.
  109224. */
  109225. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109226. private _activeMeshesFrozen;
  109227. private _skipEvaluateActiveMeshesCompletely;
  109228. /**
  109229. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109230. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109231. * @returns the current scene
  109232. */
  109233. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109234. /**
  109235. * Use this function to restart evaluating active meshes on every frame
  109236. * @returns the current scene
  109237. */
  109238. unfreezeActiveMeshes(): Scene;
  109239. private _evaluateActiveMeshes;
  109240. private _activeMesh;
  109241. /**
  109242. * Update the transform matrix to update from the current active camera
  109243. * @param force defines a boolean used to force the update even if cache is up to date
  109244. */
  109245. updateTransformMatrix(force?: boolean): void;
  109246. private _bindFrameBuffer;
  109247. /** @hidden */
  109248. _allowPostProcessClearColor: boolean;
  109249. /** @hidden */
  109250. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109251. private _processSubCameras;
  109252. private _checkIntersections;
  109253. /** @hidden */
  109254. _advancePhysicsEngineStep(step: number): void;
  109255. /**
  109256. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109257. */
  109258. getDeterministicFrameTime: () => number;
  109259. /** @hidden */
  109260. _animate(): void;
  109261. /** Execute all animations (for a frame) */
  109262. animate(): void;
  109263. /**
  109264. * Render the scene
  109265. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109266. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109267. */
  109268. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109269. /**
  109270. * Freeze all materials
  109271. * A frozen material will not be updatable but should be faster to render
  109272. */
  109273. freezeMaterials(): void;
  109274. /**
  109275. * Unfreeze all materials
  109276. * A frozen material will not be updatable but should be faster to render
  109277. */
  109278. unfreezeMaterials(): void;
  109279. /**
  109280. * Releases all held ressources
  109281. */
  109282. dispose(): void;
  109283. /**
  109284. * Gets if the scene is already disposed
  109285. */
  109286. get isDisposed(): boolean;
  109287. /**
  109288. * Call this function to reduce memory footprint of the scene.
  109289. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109290. */
  109291. clearCachedVertexData(): void;
  109292. /**
  109293. * This function will remove the local cached buffer data from texture.
  109294. * It will save memory but will prevent the texture from being rebuilt
  109295. */
  109296. cleanCachedTextureBuffer(): void;
  109297. /**
  109298. * Get the world extend vectors with an optional filter
  109299. *
  109300. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109301. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109302. */
  109303. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109304. min: Vector3;
  109305. max: Vector3;
  109306. };
  109307. /**
  109308. * Creates a ray that can be used to pick in the scene
  109309. * @param x defines the x coordinate of the origin (on-screen)
  109310. * @param y defines the y coordinate of the origin (on-screen)
  109311. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109312. * @param camera defines the camera to use for the picking
  109313. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109314. * @returns a Ray
  109315. */
  109316. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109317. /**
  109318. * Creates a ray that can be used to pick in the scene
  109319. * @param x defines the x coordinate of the origin (on-screen)
  109320. * @param y defines the y coordinate of the origin (on-screen)
  109321. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109322. * @param result defines the ray where to store the picking ray
  109323. * @param camera defines the camera to use for the picking
  109324. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109325. * @returns the current scene
  109326. */
  109327. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109328. /**
  109329. * Creates a ray that can be used to pick in the scene
  109330. * @param x defines the x coordinate of the origin (on-screen)
  109331. * @param y defines the y coordinate of the origin (on-screen)
  109332. * @param camera defines the camera to use for the picking
  109333. * @returns a Ray
  109334. */
  109335. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109336. /**
  109337. * Creates a ray that can be used to pick in the scene
  109338. * @param x defines the x coordinate of the origin (on-screen)
  109339. * @param y defines the y coordinate of the origin (on-screen)
  109340. * @param result defines the ray where to store the picking ray
  109341. * @param camera defines the camera to use for the picking
  109342. * @returns the current scene
  109343. */
  109344. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109345. /** Launch a ray to try to pick a mesh in the scene
  109346. * @param x position on screen
  109347. * @param y position on screen
  109348. * @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
  109349. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109350. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109351. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109352. * @returns a PickingInfo
  109353. */
  109354. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109355. /** Use the given ray to pick a mesh in the scene
  109356. * @param ray The ray to use to pick meshes
  109357. * @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
  109358. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109359. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109360. * @returns a PickingInfo
  109361. */
  109362. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109363. /**
  109364. * Launch a ray to try to pick a mesh in the scene
  109365. * @param x X position on screen
  109366. * @param y Y position on screen
  109367. * @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
  109368. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109369. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109370. * @returns an array of PickingInfo
  109371. */
  109372. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109373. /**
  109374. * Launch a ray to try to pick a mesh in the scene
  109375. * @param ray Ray to use
  109376. * @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
  109377. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109378. * @returns an array of PickingInfo
  109379. */
  109380. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109381. /**
  109382. * Force the value of meshUnderPointer
  109383. * @param mesh defines the mesh to use
  109384. */
  109385. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109386. /**
  109387. * Gets the mesh under the pointer
  109388. * @returns a Mesh or null if no mesh is under the pointer
  109389. */
  109390. getPointerOverMesh(): Nullable<AbstractMesh>;
  109391. /** @hidden */
  109392. _rebuildGeometries(): void;
  109393. /** @hidden */
  109394. _rebuildTextures(): void;
  109395. private _getByTags;
  109396. /**
  109397. * Get a list of meshes by tags
  109398. * @param tagsQuery defines the tags query to use
  109399. * @param forEach defines a predicate used to filter results
  109400. * @returns an array of Mesh
  109401. */
  109402. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  109403. /**
  109404. * Get a list of cameras by tags
  109405. * @param tagsQuery defines the tags query to use
  109406. * @param forEach defines a predicate used to filter results
  109407. * @returns an array of Camera
  109408. */
  109409. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  109410. /**
  109411. * Get a list of lights by tags
  109412. * @param tagsQuery defines the tags query to use
  109413. * @param forEach defines a predicate used to filter results
  109414. * @returns an array of Light
  109415. */
  109416. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  109417. /**
  109418. * Get a list of materials by tags
  109419. * @param tagsQuery defines the tags query to use
  109420. * @param forEach defines a predicate used to filter results
  109421. * @returns an array of Material
  109422. */
  109423. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  109424. /**
  109425. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109426. * This allowed control for front to back rendering or reversly depending of the special needs.
  109427. *
  109428. * @param renderingGroupId The rendering group id corresponding to its index
  109429. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109430. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109431. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109432. */
  109433. 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;
  109434. /**
  109435. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109436. *
  109437. * @param renderingGroupId The rendering group id corresponding to its index
  109438. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109439. * @param depth Automatically clears depth between groups if true and autoClear is true.
  109440. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  109441. */
  109442. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  109443. /**
  109444. * Gets the current auto clear configuration for one rendering group of the rendering
  109445. * manager.
  109446. * @param index the rendering group index to get the information for
  109447. * @returns The auto clear setup for the requested rendering group
  109448. */
  109449. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  109450. private _blockMaterialDirtyMechanism;
  109451. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  109452. get blockMaterialDirtyMechanism(): boolean;
  109453. set blockMaterialDirtyMechanism(value: boolean);
  109454. /**
  109455. * Will flag all materials as dirty to trigger new shader compilation
  109456. * @param flag defines the flag used to specify which material part must be marked as dirty
  109457. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  109458. */
  109459. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109460. /** @hidden */
  109461. _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;
  109462. /** @hidden */
  109463. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109464. /** @hidden */
  109465. _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;
  109466. /** @hidden */
  109467. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  109468. /** @hidden */
  109469. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  109470. /** @hidden */
  109471. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109472. }
  109473. }
  109474. declare module BABYLON {
  109475. /**
  109476. * Set of assets to keep when moving a scene into an asset container.
  109477. */
  109478. export class KeepAssets extends AbstractScene {
  109479. }
  109480. /**
  109481. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  109482. */
  109483. export class InstantiatedEntries {
  109484. /**
  109485. * List of new root nodes (eg. nodes with no parent)
  109486. */
  109487. rootNodes: TransformNode[];
  109488. /**
  109489. * List of new skeletons
  109490. */
  109491. skeletons: Skeleton[];
  109492. /**
  109493. * List of new animation groups
  109494. */
  109495. animationGroups: AnimationGroup[];
  109496. }
  109497. /**
  109498. * Container with a set of assets that can be added or removed from a scene.
  109499. */
  109500. export class AssetContainer extends AbstractScene {
  109501. /**
  109502. * The scene the AssetContainer belongs to.
  109503. */
  109504. scene: Scene;
  109505. /**
  109506. * Instantiates an AssetContainer.
  109507. * @param scene The scene the AssetContainer belongs to.
  109508. */
  109509. constructor(scene: Scene);
  109510. /**
  109511. * Instantiate or clone all meshes and add the new ones to the scene.
  109512. * Skeletons and animation groups will all be cloned
  109513. * @param nameFunction defines an optional function used to get new names for clones
  109514. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  109515. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  109516. */
  109517. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  109518. /**
  109519. * Adds all the assets from the container to the scene.
  109520. */
  109521. addAllToScene(): void;
  109522. /**
  109523. * Removes all the assets in the container from the scene
  109524. */
  109525. removeAllFromScene(): void;
  109526. /**
  109527. * Disposes all the assets in the container
  109528. */
  109529. dispose(): void;
  109530. private _moveAssets;
  109531. /**
  109532. * Removes all the assets contained in the scene and adds them to the container.
  109533. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  109534. */
  109535. moveAllFromScene(keepAssets?: KeepAssets): void;
  109536. /**
  109537. * 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.
  109538. * @returns the root mesh
  109539. */
  109540. createRootMesh(): Mesh;
  109541. /**
  109542. * Merge animations from this asset container into a scene
  109543. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109544. * @param animatables set of animatables to retarget to a node from the scene
  109545. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  109546. */
  109547. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  109548. }
  109549. }
  109550. declare module BABYLON {
  109551. /**
  109552. * Defines how the parser contract is defined.
  109553. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  109554. */
  109555. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  109556. /**
  109557. * Defines how the individual parser contract is defined.
  109558. * These parser can parse an individual asset
  109559. */
  109560. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  109561. /**
  109562. * Base class of the scene acting as a container for the different elements composing a scene.
  109563. * This class is dynamically extended by the different components of the scene increasing
  109564. * flexibility and reducing coupling
  109565. */
  109566. export abstract class AbstractScene {
  109567. /**
  109568. * Stores the list of available parsers in the application.
  109569. */
  109570. private static _BabylonFileParsers;
  109571. /**
  109572. * Stores the list of available individual parsers in the application.
  109573. */
  109574. private static _IndividualBabylonFileParsers;
  109575. /**
  109576. * Adds a parser in the list of available ones
  109577. * @param name Defines the name of the parser
  109578. * @param parser Defines the parser to add
  109579. */
  109580. static AddParser(name: string, parser: BabylonFileParser): void;
  109581. /**
  109582. * Gets a general parser from the list of avaialble ones
  109583. * @param name Defines the name of the parser
  109584. * @returns the requested parser or null
  109585. */
  109586. static GetParser(name: string): Nullable<BabylonFileParser>;
  109587. /**
  109588. * Adds n individual parser in the list of available ones
  109589. * @param name Defines the name of the parser
  109590. * @param parser Defines the parser to add
  109591. */
  109592. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  109593. /**
  109594. * Gets an individual parser from the list of avaialble ones
  109595. * @param name Defines the name of the parser
  109596. * @returns the requested parser or null
  109597. */
  109598. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  109599. /**
  109600. * Parser json data and populate both a scene and its associated container object
  109601. * @param jsonData Defines the data to parse
  109602. * @param scene Defines the scene to parse the data for
  109603. * @param container Defines the container attached to the parsing sequence
  109604. * @param rootUrl Defines the root url of the data
  109605. */
  109606. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  109607. /**
  109608. * Gets the list of root nodes (ie. nodes with no parent)
  109609. */
  109610. rootNodes: Node[];
  109611. /** All of the cameras added to this scene
  109612. * @see http://doc.babylonjs.com/babylon101/cameras
  109613. */
  109614. cameras: Camera[];
  109615. /**
  109616. * All of the lights added to this scene
  109617. * @see http://doc.babylonjs.com/babylon101/lights
  109618. */
  109619. lights: Light[];
  109620. /**
  109621. * All of the (abstract) meshes added to this scene
  109622. */
  109623. meshes: AbstractMesh[];
  109624. /**
  109625. * The list of skeletons added to the scene
  109626. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109627. */
  109628. skeletons: Skeleton[];
  109629. /**
  109630. * All of the particle systems added to this scene
  109631. * @see http://doc.babylonjs.com/babylon101/particles
  109632. */
  109633. particleSystems: IParticleSystem[];
  109634. /**
  109635. * Gets a list of Animations associated with the scene
  109636. */
  109637. animations: Animation[];
  109638. /**
  109639. * All of the animation groups added to this scene
  109640. * @see http://doc.babylonjs.com/how_to/group
  109641. */
  109642. animationGroups: AnimationGroup[];
  109643. /**
  109644. * All of the multi-materials added to this scene
  109645. * @see http://doc.babylonjs.com/how_to/multi_materials
  109646. */
  109647. multiMaterials: MultiMaterial[];
  109648. /**
  109649. * All of the materials added to this scene
  109650. * In the context of a Scene, it is not supposed to be modified manually.
  109651. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  109652. * Note also that the order of the Material within the array is not significant and might change.
  109653. * @see http://doc.babylonjs.com/babylon101/materials
  109654. */
  109655. materials: Material[];
  109656. /**
  109657. * The list of morph target managers added to the scene
  109658. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  109659. */
  109660. morphTargetManagers: MorphTargetManager[];
  109661. /**
  109662. * The list of geometries used in the scene.
  109663. */
  109664. geometries: Geometry[];
  109665. /**
  109666. * All of the tranform nodes added to this scene
  109667. * In the context of a Scene, it is not supposed to be modified manually.
  109668. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  109669. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  109670. * @see http://doc.babylonjs.com/how_to/transformnode
  109671. */
  109672. transformNodes: TransformNode[];
  109673. /**
  109674. * ActionManagers available on the scene.
  109675. */
  109676. actionManagers: AbstractActionManager[];
  109677. /**
  109678. * Textures to keep.
  109679. */
  109680. textures: BaseTexture[];
  109681. /**
  109682. * Environment texture for the scene
  109683. */
  109684. environmentTexture: Nullable<BaseTexture>;
  109685. /**
  109686. * @returns all meshes, lights, cameras, transformNodes and bones
  109687. */
  109688. getNodes(): Array<Node>;
  109689. }
  109690. }
  109691. declare module BABYLON {
  109692. /**
  109693. * Interface used to define options for Sound class
  109694. */
  109695. export interface ISoundOptions {
  109696. /**
  109697. * Does the sound autoplay once loaded.
  109698. */
  109699. autoplay?: boolean;
  109700. /**
  109701. * Does the sound loop after it finishes playing once.
  109702. */
  109703. loop?: boolean;
  109704. /**
  109705. * Sound's volume
  109706. */
  109707. volume?: number;
  109708. /**
  109709. * Is it a spatial sound?
  109710. */
  109711. spatialSound?: boolean;
  109712. /**
  109713. * Maximum distance to hear that sound
  109714. */
  109715. maxDistance?: number;
  109716. /**
  109717. * Uses user defined attenuation function
  109718. */
  109719. useCustomAttenuation?: boolean;
  109720. /**
  109721. * Define the roll off factor of spatial sounds.
  109722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109723. */
  109724. rolloffFactor?: number;
  109725. /**
  109726. * Define the reference distance the sound should be heard perfectly.
  109727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109728. */
  109729. refDistance?: number;
  109730. /**
  109731. * Define the distance attenuation model the sound will follow.
  109732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109733. */
  109734. distanceModel?: string;
  109735. /**
  109736. * Defines the playback speed (1 by default)
  109737. */
  109738. playbackRate?: number;
  109739. /**
  109740. * Defines if the sound is from a streaming source
  109741. */
  109742. streaming?: boolean;
  109743. /**
  109744. * Defines an optional length (in seconds) inside the sound file
  109745. */
  109746. length?: number;
  109747. /**
  109748. * Defines an optional offset (in seconds) inside the sound file
  109749. */
  109750. offset?: number;
  109751. /**
  109752. * If true, URLs will not be required to state the audio file codec to use.
  109753. */
  109754. skipCodecCheck?: boolean;
  109755. }
  109756. /**
  109757. * Defines a sound that can be played in the application.
  109758. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  109759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109760. */
  109761. export class Sound {
  109762. /**
  109763. * The name of the sound in the scene.
  109764. */
  109765. name: string;
  109766. /**
  109767. * Does the sound autoplay once loaded.
  109768. */
  109769. autoplay: boolean;
  109770. /**
  109771. * Does the sound loop after it finishes playing once.
  109772. */
  109773. loop: boolean;
  109774. /**
  109775. * Does the sound use a custom attenuation curve to simulate the falloff
  109776. * happening when the source gets further away from the camera.
  109777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109778. */
  109779. useCustomAttenuation: boolean;
  109780. /**
  109781. * The sound track id this sound belongs to.
  109782. */
  109783. soundTrackId: number;
  109784. /**
  109785. * Is this sound currently played.
  109786. */
  109787. isPlaying: boolean;
  109788. /**
  109789. * Is this sound currently paused.
  109790. */
  109791. isPaused: boolean;
  109792. /**
  109793. * Does this sound enables spatial sound.
  109794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109795. */
  109796. spatialSound: boolean;
  109797. /**
  109798. * Define the reference distance the sound should be heard perfectly.
  109799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109800. */
  109801. refDistance: number;
  109802. /**
  109803. * Define the roll off factor of spatial sounds.
  109804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109805. */
  109806. rolloffFactor: number;
  109807. /**
  109808. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  109809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109810. */
  109811. maxDistance: number;
  109812. /**
  109813. * Define the distance attenuation model the sound will follow.
  109814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109815. */
  109816. distanceModel: string;
  109817. /**
  109818. * @hidden
  109819. * Back Compat
  109820. **/
  109821. onended: () => any;
  109822. /**
  109823. * Observable event when the current playing sound finishes.
  109824. */
  109825. onEndedObservable: Observable<Sound>;
  109826. private _panningModel;
  109827. private _playbackRate;
  109828. private _streaming;
  109829. private _startTime;
  109830. private _startOffset;
  109831. private _position;
  109832. /** @hidden */
  109833. _positionInEmitterSpace: boolean;
  109834. private _localDirection;
  109835. private _volume;
  109836. private _isReadyToPlay;
  109837. private _isDirectional;
  109838. private _readyToPlayCallback;
  109839. private _audioBuffer;
  109840. private _soundSource;
  109841. private _streamingSource;
  109842. private _soundPanner;
  109843. private _soundGain;
  109844. private _inputAudioNode;
  109845. private _outputAudioNode;
  109846. private _coneInnerAngle;
  109847. private _coneOuterAngle;
  109848. private _coneOuterGain;
  109849. private _scene;
  109850. private _connectedTransformNode;
  109851. private _customAttenuationFunction;
  109852. private _registerFunc;
  109853. private _isOutputConnected;
  109854. private _htmlAudioElement;
  109855. private _urlType;
  109856. private _length?;
  109857. private _offset?;
  109858. /** @hidden */
  109859. static _SceneComponentInitialization: (scene: Scene) => void;
  109860. /**
  109861. * Create a sound and attach it to a scene
  109862. * @param name Name of your sound
  109863. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  109864. * @param scene defines the scene the sound belongs to
  109865. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  109866. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  109867. */
  109868. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  109869. /**
  109870. * Release the sound and its associated resources
  109871. */
  109872. dispose(): void;
  109873. /**
  109874. * Gets if the sounds is ready to be played or not.
  109875. * @returns true if ready, otherwise false
  109876. */
  109877. isReady(): boolean;
  109878. private _soundLoaded;
  109879. /**
  109880. * Sets the data of the sound from an audiobuffer
  109881. * @param audioBuffer The audioBuffer containing the data
  109882. */
  109883. setAudioBuffer(audioBuffer: AudioBuffer): void;
  109884. /**
  109885. * Updates the current sounds options such as maxdistance, loop...
  109886. * @param options A JSON object containing values named as the object properties
  109887. */
  109888. updateOptions(options: ISoundOptions): void;
  109889. private _createSpatialParameters;
  109890. private _updateSpatialParameters;
  109891. /**
  109892. * Switch the panning model to HRTF:
  109893. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  109894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109895. */
  109896. switchPanningModelToHRTF(): void;
  109897. /**
  109898. * Switch the panning model to Equal Power:
  109899. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  109900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109901. */
  109902. switchPanningModelToEqualPower(): void;
  109903. private _switchPanningModel;
  109904. /**
  109905. * Connect this sound to a sound track audio node like gain...
  109906. * @param soundTrackAudioNode the sound track audio node to connect to
  109907. */
  109908. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  109909. /**
  109910. * Transform this sound into a directional source
  109911. * @param coneInnerAngle Size of the inner cone in degree
  109912. * @param coneOuterAngle Size of the outer cone in degree
  109913. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  109914. */
  109915. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  109916. /**
  109917. * Gets or sets the inner angle for the directional cone.
  109918. */
  109919. get directionalConeInnerAngle(): number;
  109920. /**
  109921. * Gets or sets the inner angle for the directional cone.
  109922. */
  109923. set directionalConeInnerAngle(value: number);
  109924. /**
  109925. * Gets or sets the outer angle for the directional cone.
  109926. */
  109927. get directionalConeOuterAngle(): number;
  109928. /**
  109929. * Gets or sets the outer angle for the directional cone.
  109930. */
  109931. set directionalConeOuterAngle(value: number);
  109932. /**
  109933. * Sets the position of the emitter if spatial sound is enabled
  109934. * @param newPosition Defines the new posisiton
  109935. */
  109936. setPosition(newPosition: Vector3): void;
  109937. /**
  109938. * Sets the local direction of the emitter if spatial sound is enabled
  109939. * @param newLocalDirection Defines the new local direction
  109940. */
  109941. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  109942. private _updateDirection;
  109943. /** @hidden */
  109944. updateDistanceFromListener(): void;
  109945. /**
  109946. * Sets a new custom attenuation function for the sound.
  109947. * @param callback Defines the function used for the attenuation
  109948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109949. */
  109950. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  109951. /**
  109952. * Play the sound
  109953. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  109954. * @param offset (optional) Start the sound at a specific time in seconds
  109955. * @param length (optional) Sound duration (in seconds)
  109956. */
  109957. play(time?: number, offset?: number, length?: number): void;
  109958. private _onended;
  109959. /**
  109960. * Stop the sound
  109961. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  109962. */
  109963. stop(time?: number): void;
  109964. /**
  109965. * Put the sound in pause
  109966. */
  109967. pause(): void;
  109968. /**
  109969. * Sets a dedicated volume for this sounds
  109970. * @param newVolume Define the new volume of the sound
  109971. * @param time Define time for gradual change to new volume
  109972. */
  109973. setVolume(newVolume: number, time?: number): void;
  109974. /**
  109975. * Set the sound play back rate
  109976. * @param newPlaybackRate Define the playback rate the sound should be played at
  109977. */
  109978. setPlaybackRate(newPlaybackRate: number): void;
  109979. /**
  109980. * Gets the volume of the sound.
  109981. * @returns the volume of the sound
  109982. */
  109983. getVolume(): number;
  109984. /**
  109985. * Attach the sound to a dedicated mesh
  109986. * @param transformNode The transform node to connect the sound with
  109987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109988. */
  109989. attachToMesh(transformNode: TransformNode): void;
  109990. /**
  109991. * Detach the sound from the previously attached mesh
  109992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109993. */
  109994. detachFromMesh(): void;
  109995. private _onRegisterAfterWorldMatrixUpdate;
  109996. /**
  109997. * Clone the current sound in the scene.
  109998. * @returns the new sound clone
  109999. */
  110000. clone(): Nullable<Sound>;
  110001. /**
  110002. * Gets the current underlying audio buffer containing the data
  110003. * @returns the audio buffer
  110004. */
  110005. getAudioBuffer(): Nullable<AudioBuffer>;
  110006. /**
  110007. * Serializes the Sound in a JSON representation
  110008. * @returns the JSON representation of the sound
  110009. */
  110010. serialize(): any;
  110011. /**
  110012. * Parse a JSON representation of a sound to innstantiate in a given scene
  110013. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110014. * @param scene Define the scene the new parsed sound should be created in
  110015. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110016. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110017. * @returns the newly parsed sound
  110018. */
  110019. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110020. }
  110021. }
  110022. declare module BABYLON {
  110023. /**
  110024. * This defines an action helpful to play a defined sound on a triggered action.
  110025. */
  110026. export class PlaySoundAction extends Action {
  110027. private _sound;
  110028. /**
  110029. * Instantiate the action
  110030. * @param triggerOptions defines the trigger options
  110031. * @param sound defines the sound to play
  110032. * @param condition defines the trigger related conditions
  110033. */
  110034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110035. /** @hidden */
  110036. _prepare(): void;
  110037. /**
  110038. * Execute the action and play the sound.
  110039. */
  110040. execute(): void;
  110041. /**
  110042. * Serializes the actions and its related information.
  110043. * @param parent defines the object to serialize in
  110044. * @returns the serialized object
  110045. */
  110046. serialize(parent: any): any;
  110047. }
  110048. /**
  110049. * This defines an action helpful to stop a defined sound on a triggered action.
  110050. */
  110051. export class StopSoundAction extends Action {
  110052. private _sound;
  110053. /**
  110054. * Instantiate the action
  110055. * @param triggerOptions defines the trigger options
  110056. * @param sound defines the sound to stop
  110057. * @param condition defines the trigger related conditions
  110058. */
  110059. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110060. /** @hidden */
  110061. _prepare(): void;
  110062. /**
  110063. * Execute the action and stop the sound.
  110064. */
  110065. execute(): void;
  110066. /**
  110067. * Serializes the actions and its related information.
  110068. * @param parent defines the object to serialize in
  110069. * @returns the serialized object
  110070. */
  110071. serialize(parent: any): any;
  110072. }
  110073. }
  110074. declare module BABYLON {
  110075. /**
  110076. * This defines an action responsible to change the value of a property
  110077. * by interpolating between its current value and the newly set one once triggered.
  110078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110079. */
  110080. export class InterpolateValueAction extends Action {
  110081. /**
  110082. * Defines the path of the property where the value should be interpolated
  110083. */
  110084. propertyPath: string;
  110085. /**
  110086. * Defines the target value at the end of the interpolation.
  110087. */
  110088. value: any;
  110089. /**
  110090. * Defines the time it will take for the property to interpolate to the value.
  110091. */
  110092. duration: number;
  110093. /**
  110094. * Defines if the other scene animations should be stopped when the action has been triggered
  110095. */
  110096. stopOtherAnimations?: boolean;
  110097. /**
  110098. * Defines a callback raised once the interpolation animation has been done.
  110099. */
  110100. onInterpolationDone?: () => void;
  110101. /**
  110102. * Observable triggered once the interpolation animation has been done.
  110103. */
  110104. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110105. private _target;
  110106. private _effectiveTarget;
  110107. private _property;
  110108. /**
  110109. * Instantiate the action
  110110. * @param triggerOptions defines the trigger options
  110111. * @param target defines the object containing the value to interpolate
  110112. * @param propertyPath defines the path to the property in the target object
  110113. * @param value defines the target value at the end of the interpolation
  110114. * @param duration deines the time it will take for the property to interpolate to the value.
  110115. * @param condition defines the trigger related conditions
  110116. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110117. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110118. */
  110119. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110120. /** @hidden */
  110121. _prepare(): void;
  110122. /**
  110123. * Execute the action starts the value interpolation.
  110124. */
  110125. execute(): void;
  110126. /**
  110127. * Serializes the actions and its related information.
  110128. * @param parent defines the object to serialize in
  110129. * @returns the serialized object
  110130. */
  110131. serialize(parent: any): any;
  110132. }
  110133. }
  110134. declare module BABYLON {
  110135. /**
  110136. * Options allowed during the creation of a sound track.
  110137. */
  110138. export interface ISoundTrackOptions {
  110139. /**
  110140. * The volume the sound track should take during creation
  110141. */
  110142. volume?: number;
  110143. /**
  110144. * Define if the sound track is the main sound track of the scene
  110145. */
  110146. mainTrack?: boolean;
  110147. }
  110148. /**
  110149. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110150. * It will be also used in a future release to apply effects on a specific track.
  110151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110152. */
  110153. export class SoundTrack {
  110154. /**
  110155. * The unique identifier of the sound track in the scene.
  110156. */
  110157. id: number;
  110158. /**
  110159. * The list of sounds included in the sound track.
  110160. */
  110161. soundCollection: Array<Sound>;
  110162. private _outputAudioNode;
  110163. private _scene;
  110164. private _connectedAnalyser;
  110165. private _options;
  110166. private _isInitialized;
  110167. /**
  110168. * Creates a new sound track.
  110169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110170. * @param scene Define the scene the sound track belongs to
  110171. * @param options
  110172. */
  110173. constructor(scene: Scene, options?: ISoundTrackOptions);
  110174. private _initializeSoundTrackAudioGraph;
  110175. /**
  110176. * Release the sound track and its associated resources
  110177. */
  110178. dispose(): void;
  110179. /**
  110180. * Adds a sound to this sound track
  110181. * @param sound define the cound to add
  110182. * @ignoreNaming
  110183. */
  110184. AddSound(sound: Sound): void;
  110185. /**
  110186. * Removes a sound to this sound track
  110187. * @param sound define the cound to remove
  110188. * @ignoreNaming
  110189. */
  110190. RemoveSound(sound: Sound): void;
  110191. /**
  110192. * Set a global volume for the full sound track.
  110193. * @param newVolume Define the new volume of the sound track
  110194. */
  110195. setVolume(newVolume: number): void;
  110196. /**
  110197. * Switch the panning model to HRTF:
  110198. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110200. */
  110201. switchPanningModelToHRTF(): void;
  110202. /**
  110203. * Switch the panning model to Equal Power:
  110204. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110206. */
  110207. switchPanningModelToEqualPower(): void;
  110208. /**
  110209. * Connect the sound track to an audio analyser allowing some amazing
  110210. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110212. * @param analyser The analyser to connect to the engine
  110213. */
  110214. connectToAnalyser(analyser: Analyser): void;
  110215. }
  110216. }
  110217. declare module BABYLON {
  110218. interface AbstractScene {
  110219. /**
  110220. * The list of sounds used in the scene.
  110221. */
  110222. sounds: Nullable<Array<Sound>>;
  110223. }
  110224. interface Scene {
  110225. /**
  110226. * @hidden
  110227. * Backing field
  110228. */
  110229. _mainSoundTrack: SoundTrack;
  110230. /**
  110231. * The main sound track played by the scene.
  110232. * It cotains your primary collection of sounds.
  110233. */
  110234. mainSoundTrack: SoundTrack;
  110235. /**
  110236. * The list of sound tracks added to the scene
  110237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110238. */
  110239. soundTracks: Nullable<Array<SoundTrack>>;
  110240. /**
  110241. * Gets a sound using a given name
  110242. * @param name defines the name to search for
  110243. * @return the found sound or null if not found at all.
  110244. */
  110245. getSoundByName(name: string): Nullable<Sound>;
  110246. /**
  110247. * Gets or sets if audio support is enabled
  110248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110249. */
  110250. audioEnabled: boolean;
  110251. /**
  110252. * Gets or sets if audio will be output to headphones
  110253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110254. */
  110255. headphone: boolean;
  110256. /**
  110257. * Gets or sets custom audio listener position provider
  110258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110259. */
  110260. audioListenerPositionProvider: Nullable<() => Vector3>;
  110261. /**
  110262. * Gets or sets a refresh rate when using 3D audio positioning
  110263. */
  110264. audioPositioningRefreshRate: number;
  110265. }
  110266. /**
  110267. * Defines the sound scene component responsible to manage any sounds
  110268. * in a given scene.
  110269. */
  110270. export class AudioSceneComponent implements ISceneSerializableComponent {
  110271. /**
  110272. * The component name helpfull to identify the component in the list of scene components.
  110273. */
  110274. readonly name: string;
  110275. /**
  110276. * The scene the component belongs to.
  110277. */
  110278. scene: Scene;
  110279. private _audioEnabled;
  110280. /**
  110281. * Gets whether audio is enabled or not.
  110282. * Please use related enable/disable method to switch state.
  110283. */
  110284. get audioEnabled(): boolean;
  110285. private _headphone;
  110286. /**
  110287. * Gets whether audio is outputing to headphone or not.
  110288. * Please use the according Switch methods to change output.
  110289. */
  110290. get headphone(): boolean;
  110291. /**
  110292. * Gets or sets a refresh rate when using 3D audio positioning
  110293. */
  110294. audioPositioningRefreshRate: number;
  110295. private _audioListenerPositionProvider;
  110296. /**
  110297. * Gets the current audio listener position provider
  110298. */
  110299. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110300. /**
  110301. * Sets a custom listener position for all sounds in the scene
  110302. * By default, this is the position of the first active camera
  110303. */
  110304. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110305. /**
  110306. * Creates a new instance of the component for the given scene
  110307. * @param scene Defines the scene to register the component in
  110308. */
  110309. constructor(scene: Scene);
  110310. /**
  110311. * Registers the component in a given scene
  110312. */
  110313. register(): void;
  110314. /**
  110315. * Rebuilds the elements related to this component in case of
  110316. * context lost for instance.
  110317. */
  110318. rebuild(): void;
  110319. /**
  110320. * Serializes the component data to the specified json object
  110321. * @param serializationObject The object to serialize to
  110322. */
  110323. serialize(serializationObject: any): void;
  110324. /**
  110325. * Adds all the elements from the container to the scene
  110326. * @param container the container holding the elements
  110327. */
  110328. addFromContainer(container: AbstractScene): void;
  110329. /**
  110330. * Removes all the elements in the container from the scene
  110331. * @param container contains the elements to remove
  110332. * @param dispose if the removed element should be disposed (default: false)
  110333. */
  110334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110335. /**
  110336. * Disposes the component and the associated ressources.
  110337. */
  110338. dispose(): void;
  110339. /**
  110340. * Disables audio in the associated scene.
  110341. */
  110342. disableAudio(): void;
  110343. /**
  110344. * Enables audio in the associated scene.
  110345. */
  110346. enableAudio(): void;
  110347. /**
  110348. * Switch audio to headphone output.
  110349. */
  110350. switchAudioModeForHeadphones(): void;
  110351. /**
  110352. * Switch audio to normal speakers.
  110353. */
  110354. switchAudioModeForNormalSpeakers(): void;
  110355. private _cachedCameraDirection;
  110356. private _cachedCameraPosition;
  110357. private _lastCheck;
  110358. private _afterRender;
  110359. }
  110360. }
  110361. declare module BABYLON {
  110362. /**
  110363. * Wraps one or more Sound objects and selects one with random weight for playback.
  110364. */
  110365. export class WeightedSound {
  110366. /** When true a Sound will be selected and played when the current playing Sound completes. */
  110367. loop: boolean;
  110368. private _coneInnerAngle;
  110369. private _coneOuterAngle;
  110370. private _volume;
  110371. /** A Sound is currently playing. */
  110372. isPlaying: boolean;
  110373. /** A Sound is currently paused. */
  110374. isPaused: boolean;
  110375. private _sounds;
  110376. private _weights;
  110377. private _currentIndex?;
  110378. /**
  110379. * Creates a new WeightedSound from the list of sounds given.
  110380. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  110381. * @param sounds Array of Sounds that will be selected from.
  110382. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  110383. */
  110384. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  110385. /**
  110386. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  110387. */
  110388. get directionalConeInnerAngle(): number;
  110389. /**
  110390. * The size of cone in degress for a directional sound in which there will be no attenuation.
  110391. */
  110392. set directionalConeInnerAngle(value: number);
  110393. /**
  110394. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110395. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110396. */
  110397. get directionalConeOuterAngle(): number;
  110398. /**
  110399. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110400. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110401. */
  110402. set directionalConeOuterAngle(value: number);
  110403. /**
  110404. * Playback volume.
  110405. */
  110406. get volume(): number;
  110407. /**
  110408. * Playback volume.
  110409. */
  110410. set volume(value: number);
  110411. private _onended;
  110412. /**
  110413. * Suspend playback
  110414. */
  110415. pause(): void;
  110416. /**
  110417. * Stop playback
  110418. */
  110419. stop(): void;
  110420. /**
  110421. * Start playback.
  110422. * @param startOffset Position the clip head at a specific time in seconds.
  110423. */
  110424. play(startOffset?: number): void;
  110425. }
  110426. }
  110427. declare module BABYLON {
  110428. /**
  110429. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  110430. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  110431. */
  110432. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  110433. /**
  110434. * Gets the name of the behavior.
  110435. */
  110436. get name(): string;
  110437. /**
  110438. * The easing function used by animations
  110439. */
  110440. static EasingFunction: BackEase;
  110441. /**
  110442. * The easing mode used by animations
  110443. */
  110444. static EasingMode: number;
  110445. /**
  110446. * The duration of the animation, in milliseconds
  110447. */
  110448. transitionDuration: number;
  110449. /**
  110450. * Length of the distance animated by the transition when lower radius is reached
  110451. */
  110452. lowerRadiusTransitionRange: number;
  110453. /**
  110454. * Length of the distance animated by the transition when upper radius is reached
  110455. */
  110456. upperRadiusTransitionRange: number;
  110457. private _autoTransitionRange;
  110458. /**
  110459. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110460. */
  110461. get autoTransitionRange(): boolean;
  110462. /**
  110463. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110464. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  110465. */
  110466. set autoTransitionRange(value: boolean);
  110467. private _attachedCamera;
  110468. private _onAfterCheckInputsObserver;
  110469. private _onMeshTargetChangedObserver;
  110470. /**
  110471. * Initializes the behavior.
  110472. */
  110473. init(): void;
  110474. /**
  110475. * Attaches the behavior to its arc rotate camera.
  110476. * @param camera Defines the camera to attach the behavior to
  110477. */
  110478. attach(camera: ArcRotateCamera): void;
  110479. /**
  110480. * Detaches the behavior from its current arc rotate camera.
  110481. */
  110482. detach(): void;
  110483. private _radiusIsAnimating;
  110484. private _radiusBounceTransition;
  110485. private _animatables;
  110486. private _cachedWheelPrecision;
  110487. /**
  110488. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  110489. * @param radiusLimit The limit to check against.
  110490. * @return Bool to indicate if at limit.
  110491. */
  110492. private _isRadiusAtLimit;
  110493. /**
  110494. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  110495. * @param radiusDelta The delta by which to animate to. Can be negative.
  110496. */
  110497. private _applyBoundRadiusAnimation;
  110498. /**
  110499. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  110500. */
  110501. protected _clearAnimationLocks(): void;
  110502. /**
  110503. * Stops and removes all animations that have been applied to the camera
  110504. */
  110505. stopAllAnimations(): void;
  110506. }
  110507. }
  110508. declare module BABYLON {
  110509. /**
  110510. * 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.
  110511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  110512. */
  110513. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  110514. /**
  110515. * Gets the name of the behavior.
  110516. */
  110517. get name(): string;
  110518. private _mode;
  110519. private _radiusScale;
  110520. private _positionScale;
  110521. private _defaultElevation;
  110522. private _elevationReturnTime;
  110523. private _elevationReturnWaitTime;
  110524. private _zoomStopsAnimation;
  110525. private _framingTime;
  110526. /**
  110527. * The easing function used by animations
  110528. */
  110529. static EasingFunction: ExponentialEase;
  110530. /**
  110531. * The easing mode used by animations
  110532. */
  110533. static EasingMode: number;
  110534. /**
  110535. * Sets the current mode used by the behavior
  110536. */
  110537. set mode(mode: number);
  110538. /**
  110539. * Gets current mode used by the behavior.
  110540. */
  110541. get mode(): number;
  110542. /**
  110543. * Sets the scale applied to the radius (1 by default)
  110544. */
  110545. set radiusScale(radius: number);
  110546. /**
  110547. * Gets the scale applied to the radius
  110548. */
  110549. get radiusScale(): number;
  110550. /**
  110551. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110552. */
  110553. set positionScale(scale: number);
  110554. /**
  110555. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110556. */
  110557. get positionScale(): number;
  110558. /**
  110559. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110560. * behaviour is triggered, in radians.
  110561. */
  110562. set defaultElevation(elevation: number);
  110563. /**
  110564. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110565. * behaviour is triggered, in radians.
  110566. */
  110567. get defaultElevation(): number;
  110568. /**
  110569. * Sets the time (in milliseconds) taken to return to the default beta position.
  110570. * Negative value indicates camera should not return to default.
  110571. */
  110572. set elevationReturnTime(speed: number);
  110573. /**
  110574. * Gets the time (in milliseconds) taken to return to the default beta position.
  110575. * Negative value indicates camera should not return to default.
  110576. */
  110577. get elevationReturnTime(): number;
  110578. /**
  110579. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110580. */
  110581. set elevationReturnWaitTime(time: number);
  110582. /**
  110583. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110584. */
  110585. get elevationReturnWaitTime(): number;
  110586. /**
  110587. * Sets the flag that indicates if user zooming should stop animation.
  110588. */
  110589. set zoomStopsAnimation(flag: boolean);
  110590. /**
  110591. * Gets the flag that indicates if user zooming should stop animation.
  110592. */
  110593. get zoomStopsAnimation(): boolean;
  110594. /**
  110595. * Sets the transition time when framing the mesh, in milliseconds
  110596. */
  110597. set framingTime(time: number);
  110598. /**
  110599. * Gets the transition time when framing the mesh, in milliseconds
  110600. */
  110601. get framingTime(): number;
  110602. /**
  110603. * Define if the behavior should automatically change the configured
  110604. * camera limits and sensibilities.
  110605. */
  110606. autoCorrectCameraLimitsAndSensibility: boolean;
  110607. private _onPrePointerObservableObserver;
  110608. private _onAfterCheckInputsObserver;
  110609. private _onMeshTargetChangedObserver;
  110610. private _attachedCamera;
  110611. private _isPointerDown;
  110612. private _lastInteractionTime;
  110613. /**
  110614. * Initializes the behavior.
  110615. */
  110616. init(): void;
  110617. /**
  110618. * Attaches the behavior to its arc rotate camera.
  110619. * @param camera Defines the camera to attach the behavior to
  110620. */
  110621. attach(camera: ArcRotateCamera): void;
  110622. /**
  110623. * Detaches the behavior from its current arc rotate camera.
  110624. */
  110625. detach(): void;
  110626. private _animatables;
  110627. private _betaIsAnimating;
  110628. private _betaTransition;
  110629. private _radiusTransition;
  110630. private _vectorTransition;
  110631. /**
  110632. * Targets the given mesh and updates zoom level accordingly.
  110633. * @param mesh The mesh to target.
  110634. * @param radius Optional. If a cached radius position already exists, overrides default.
  110635. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110636. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110637. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110638. */
  110639. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110640. /**
  110641. * Targets the given mesh with its children and updates zoom level accordingly.
  110642. * @param mesh The mesh to target.
  110643. * @param radius Optional. If a cached radius position already exists, overrides default.
  110644. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110645. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110646. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110647. */
  110648. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110649. /**
  110650. * Targets the given meshes with their children and updates zoom level accordingly.
  110651. * @param meshes The mesh to target.
  110652. * @param radius Optional. If a cached radius position already exists, overrides default.
  110653. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110654. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110655. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110656. */
  110657. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110658. /**
  110659. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  110660. * @param minimumWorld Determines the smaller position of the bounding box extend
  110661. * @param maximumWorld Determines the bigger position of the bounding box extend
  110662. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110663. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110664. */
  110665. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110666. /**
  110667. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  110668. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  110669. * frustum width.
  110670. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  110671. * to fully enclose the mesh in the viewing frustum.
  110672. */
  110673. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  110674. /**
  110675. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  110676. * is automatically returned to its default position (expected to be above ground plane).
  110677. */
  110678. private _maintainCameraAboveGround;
  110679. /**
  110680. * Returns the frustum slope based on the canvas ratio and camera FOV
  110681. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  110682. */
  110683. private _getFrustumSlope;
  110684. /**
  110685. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  110686. */
  110687. private _clearAnimationLocks;
  110688. /**
  110689. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110690. */
  110691. private _applyUserInteraction;
  110692. /**
  110693. * Stops and removes all animations that have been applied to the camera
  110694. */
  110695. stopAllAnimations(): void;
  110696. /**
  110697. * Gets a value indicating if the user is moving the camera
  110698. */
  110699. get isUserIsMoving(): boolean;
  110700. /**
  110701. * The camera can move all the way towards the mesh.
  110702. */
  110703. static IgnoreBoundsSizeMode: number;
  110704. /**
  110705. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  110706. */
  110707. static FitFrustumSidesMode: number;
  110708. }
  110709. }
  110710. declare module BABYLON {
  110711. /**
  110712. * Base class for Camera Pointer Inputs.
  110713. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  110714. * for example usage.
  110715. */
  110716. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  110717. /**
  110718. * Defines the camera the input is attached to.
  110719. */
  110720. abstract camera: Camera;
  110721. /**
  110722. * Whether keyboard modifier keys are pressed at time of last mouse event.
  110723. */
  110724. protected _altKey: boolean;
  110725. protected _ctrlKey: boolean;
  110726. protected _metaKey: boolean;
  110727. protected _shiftKey: boolean;
  110728. /**
  110729. * Which mouse buttons were pressed at time of last mouse event.
  110730. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  110731. */
  110732. protected _buttonsPressed: number;
  110733. /**
  110734. * Defines the buttons associated with the input to handle camera move.
  110735. */
  110736. buttons: number[];
  110737. /**
  110738. * Attach the input controls to a specific dom element to get the input from.
  110739. * @param element Defines the element the controls should be listened from
  110740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110741. */
  110742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110743. /**
  110744. * Detach the current controls from the specified dom element.
  110745. * @param element Defines the element to stop listening the inputs from
  110746. */
  110747. detachControl(element: Nullable<HTMLElement>): void;
  110748. /**
  110749. * Gets the class name of the current input.
  110750. * @returns the class name
  110751. */
  110752. getClassName(): string;
  110753. /**
  110754. * Get the friendly name associated with the input class.
  110755. * @returns the input friendly name
  110756. */
  110757. getSimpleName(): string;
  110758. /**
  110759. * Called on pointer POINTERDOUBLETAP event.
  110760. * Override this method to provide functionality on POINTERDOUBLETAP event.
  110761. */
  110762. protected onDoubleTap(type: string): void;
  110763. /**
  110764. * Called on pointer POINTERMOVE event if only a single touch is active.
  110765. * Override this method to provide functionality.
  110766. */
  110767. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110768. /**
  110769. * Called on pointer POINTERMOVE event if multiple touches are active.
  110770. * Override this method to provide functionality.
  110771. */
  110772. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110773. /**
  110774. * Called on JS contextmenu event.
  110775. * Override this method to provide functionality.
  110776. */
  110777. protected onContextMenu(evt: PointerEvent): void;
  110778. /**
  110779. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110780. * press.
  110781. * Override this method to provide functionality.
  110782. */
  110783. protected onButtonDown(evt: PointerEvent): void;
  110784. /**
  110785. * Called each time a new POINTERUP event occurs. Ie, for each button
  110786. * release.
  110787. * Override this method to provide functionality.
  110788. */
  110789. protected onButtonUp(evt: PointerEvent): void;
  110790. /**
  110791. * Called when window becomes inactive.
  110792. * Override this method to provide functionality.
  110793. */
  110794. protected onLostFocus(): void;
  110795. private _pointerInput;
  110796. private _observer;
  110797. private _onLostFocus;
  110798. private pointA;
  110799. private pointB;
  110800. }
  110801. }
  110802. declare module BABYLON {
  110803. /**
  110804. * Manage the pointers inputs to control an arc rotate camera.
  110805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110806. */
  110807. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  110808. /**
  110809. * Defines the camera the input is attached to.
  110810. */
  110811. camera: ArcRotateCamera;
  110812. /**
  110813. * Gets the class name of the current input.
  110814. * @returns the class name
  110815. */
  110816. getClassName(): string;
  110817. /**
  110818. * Defines the buttons associated with the input to handle camera move.
  110819. */
  110820. buttons: number[];
  110821. /**
  110822. * Defines the pointer angular sensibility along the X axis or how fast is
  110823. * the camera rotating.
  110824. */
  110825. angularSensibilityX: number;
  110826. /**
  110827. * Defines the pointer angular sensibility along the Y axis or how fast is
  110828. * the camera rotating.
  110829. */
  110830. angularSensibilityY: number;
  110831. /**
  110832. * Defines the pointer pinch precision or how fast is the camera zooming.
  110833. */
  110834. pinchPrecision: number;
  110835. /**
  110836. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110837. * from 0.
  110838. * It defines the percentage of current camera.radius to use as delta when
  110839. * pinch zoom is used.
  110840. */
  110841. pinchDeltaPercentage: number;
  110842. /**
  110843. * Defines the pointer panning sensibility or how fast is the camera moving.
  110844. */
  110845. panningSensibility: number;
  110846. /**
  110847. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  110848. */
  110849. multiTouchPanning: boolean;
  110850. /**
  110851. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  110852. * zoom (pinch) through multitouch.
  110853. */
  110854. multiTouchPanAndZoom: boolean;
  110855. /**
  110856. * Revers pinch action direction.
  110857. */
  110858. pinchInwards: boolean;
  110859. private _isPanClick;
  110860. private _twoFingerActivityCount;
  110861. private _isPinching;
  110862. /**
  110863. * Called on pointer POINTERMOVE event if only a single touch is active.
  110864. */
  110865. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110866. /**
  110867. * Called on pointer POINTERDOUBLETAP event.
  110868. */
  110869. protected onDoubleTap(type: string): void;
  110870. /**
  110871. * Called on pointer POINTERMOVE event if multiple touches are active.
  110872. */
  110873. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110874. /**
  110875. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110876. * press.
  110877. */
  110878. protected onButtonDown(evt: PointerEvent): void;
  110879. /**
  110880. * Called each time a new POINTERUP event occurs. Ie, for each button
  110881. * release.
  110882. */
  110883. protected onButtonUp(evt: PointerEvent): void;
  110884. /**
  110885. * Called when window becomes inactive.
  110886. */
  110887. protected onLostFocus(): void;
  110888. }
  110889. }
  110890. declare module BABYLON {
  110891. /**
  110892. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  110893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110894. */
  110895. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  110896. /**
  110897. * Defines the camera the input is attached to.
  110898. */
  110899. camera: ArcRotateCamera;
  110900. /**
  110901. * Defines the list of key codes associated with the up action (increase alpha)
  110902. */
  110903. keysUp: number[];
  110904. /**
  110905. * Defines the list of key codes associated with the down action (decrease alpha)
  110906. */
  110907. keysDown: number[];
  110908. /**
  110909. * Defines the list of key codes associated with the left action (increase beta)
  110910. */
  110911. keysLeft: number[];
  110912. /**
  110913. * Defines the list of key codes associated with the right action (decrease beta)
  110914. */
  110915. keysRight: number[];
  110916. /**
  110917. * Defines the list of key codes associated with the reset action.
  110918. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  110919. */
  110920. keysReset: number[];
  110921. /**
  110922. * Defines the panning sensibility of the inputs.
  110923. * (How fast is the camera paning)
  110924. */
  110925. panningSensibility: number;
  110926. /**
  110927. * Defines the zooming sensibility of the inputs.
  110928. * (How fast is the camera zooming)
  110929. */
  110930. zoomingSensibility: number;
  110931. /**
  110932. * Defines wether maintaining the alt key down switch the movement mode from
  110933. * orientation to zoom.
  110934. */
  110935. useAltToZoom: boolean;
  110936. /**
  110937. * Rotation speed of the camera
  110938. */
  110939. angularSpeed: number;
  110940. private _keys;
  110941. private _ctrlPressed;
  110942. private _altPressed;
  110943. private _onCanvasBlurObserver;
  110944. private _onKeyboardObserver;
  110945. private _engine;
  110946. private _scene;
  110947. /**
  110948. * Attach the input controls to a specific dom element to get the input from.
  110949. * @param element Defines the element the controls should be listened from
  110950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110951. */
  110952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110953. /**
  110954. * Detach the current controls from the specified dom element.
  110955. * @param element Defines the element to stop listening the inputs from
  110956. */
  110957. detachControl(element: Nullable<HTMLElement>): void;
  110958. /**
  110959. * Update the current camera state depending on the inputs that have been used this frame.
  110960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110961. */
  110962. checkInputs(): void;
  110963. /**
  110964. * Gets the class name of the current intput.
  110965. * @returns the class name
  110966. */
  110967. getClassName(): string;
  110968. /**
  110969. * Get the friendly name associated with the input class.
  110970. * @returns the input friendly name
  110971. */
  110972. getSimpleName(): string;
  110973. }
  110974. }
  110975. declare module BABYLON {
  110976. /**
  110977. * Manage the mouse wheel inputs to control an arc rotate camera.
  110978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110979. */
  110980. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  110981. /**
  110982. * Defines the camera the input is attached to.
  110983. */
  110984. camera: ArcRotateCamera;
  110985. /**
  110986. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  110987. */
  110988. wheelPrecision: number;
  110989. /**
  110990. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110991. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110992. */
  110993. wheelDeltaPercentage: number;
  110994. private _wheel;
  110995. private _observer;
  110996. private computeDeltaFromMouseWheelLegacyEvent;
  110997. /**
  110998. * Attach the input controls to a specific dom element to get the input from.
  110999. * @param element Defines the element the controls should be listened from
  111000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111001. */
  111002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111003. /**
  111004. * Detach the current controls from the specified dom element.
  111005. * @param element Defines the element to stop listening the inputs from
  111006. */
  111007. detachControl(element: Nullable<HTMLElement>): void;
  111008. /**
  111009. * Gets the class name of the current intput.
  111010. * @returns the class name
  111011. */
  111012. getClassName(): string;
  111013. /**
  111014. * Get the friendly name associated with the input class.
  111015. * @returns the input friendly name
  111016. */
  111017. getSimpleName(): string;
  111018. }
  111019. }
  111020. declare module BABYLON {
  111021. /**
  111022. * Default Inputs manager for the ArcRotateCamera.
  111023. * It groups all the default supported inputs for ease of use.
  111024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111025. */
  111026. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111027. /**
  111028. * Instantiates a new ArcRotateCameraInputsManager.
  111029. * @param camera Defines the camera the inputs belong to
  111030. */
  111031. constructor(camera: ArcRotateCamera);
  111032. /**
  111033. * Add mouse wheel input support to the input manager.
  111034. * @returns the current input manager
  111035. */
  111036. addMouseWheel(): ArcRotateCameraInputsManager;
  111037. /**
  111038. * Add pointers input support to the input manager.
  111039. * @returns the current input manager
  111040. */
  111041. addPointers(): ArcRotateCameraInputsManager;
  111042. /**
  111043. * Add keyboard input support to the input manager.
  111044. * @returns the current input manager
  111045. */
  111046. addKeyboard(): ArcRotateCameraInputsManager;
  111047. }
  111048. }
  111049. declare module BABYLON {
  111050. /**
  111051. * This represents an orbital type of camera.
  111052. *
  111053. * 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.
  111054. * 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.
  111055. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111056. */
  111057. export class ArcRotateCamera extends TargetCamera {
  111058. /**
  111059. * Defines the rotation angle of the camera along the longitudinal axis.
  111060. */
  111061. alpha: number;
  111062. /**
  111063. * Defines the rotation angle of the camera along the latitudinal axis.
  111064. */
  111065. beta: number;
  111066. /**
  111067. * Defines the radius of the camera from it s target point.
  111068. */
  111069. radius: number;
  111070. protected _target: Vector3;
  111071. protected _targetHost: Nullable<AbstractMesh>;
  111072. /**
  111073. * Defines the target point of the camera.
  111074. * The camera looks towards it form the radius distance.
  111075. */
  111076. get target(): Vector3;
  111077. set target(value: Vector3);
  111078. /**
  111079. * Define the current local position of the camera in the scene
  111080. */
  111081. get position(): Vector3;
  111082. set position(newPosition: Vector3);
  111083. protected _upVector: Vector3;
  111084. protected _upToYMatrix: Matrix;
  111085. protected _YToUpMatrix: Matrix;
  111086. /**
  111087. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111088. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111089. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111090. */
  111091. set upVector(vec: Vector3);
  111092. get upVector(): Vector3;
  111093. /**
  111094. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111095. */
  111096. setMatUp(): void;
  111097. /**
  111098. * Current inertia value on the longitudinal axis.
  111099. * The bigger this number the longer it will take for the camera to stop.
  111100. */
  111101. inertialAlphaOffset: number;
  111102. /**
  111103. * Current inertia value on the latitudinal axis.
  111104. * The bigger this number the longer it will take for the camera to stop.
  111105. */
  111106. inertialBetaOffset: number;
  111107. /**
  111108. * Current inertia value on the radius axis.
  111109. * The bigger this number the longer it will take for the camera to stop.
  111110. */
  111111. inertialRadiusOffset: number;
  111112. /**
  111113. * Minimum allowed angle on the longitudinal axis.
  111114. * This can help limiting how the Camera is able to move in the scene.
  111115. */
  111116. lowerAlphaLimit: Nullable<number>;
  111117. /**
  111118. * Maximum allowed angle on the longitudinal axis.
  111119. * This can help limiting how the Camera is able to move in the scene.
  111120. */
  111121. upperAlphaLimit: Nullable<number>;
  111122. /**
  111123. * Minimum allowed angle on the latitudinal axis.
  111124. * This can help limiting how the Camera is able to move in the scene.
  111125. */
  111126. lowerBetaLimit: number;
  111127. /**
  111128. * Maximum allowed angle on the latitudinal axis.
  111129. * This can help limiting how the Camera is able to move in the scene.
  111130. */
  111131. upperBetaLimit: number;
  111132. /**
  111133. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111134. * This can help limiting how the Camera is able to move in the scene.
  111135. */
  111136. lowerRadiusLimit: Nullable<number>;
  111137. /**
  111138. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111139. * This can help limiting how the Camera is able to move in the scene.
  111140. */
  111141. upperRadiusLimit: Nullable<number>;
  111142. /**
  111143. * Defines the current inertia value used during panning of the camera along the X axis.
  111144. */
  111145. inertialPanningX: number;
  111146. /**
  111147. * Defines the current inertia value used during panning of the camera along the Y axis.
  111148. */
  111149. inertialPanningY: number;
  111150. /**
  111151. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111152. * Basically if your fingers moves away from more than this distance you will be considered
  111153. * in pinch mode.
  111154. */
  111155. pinchToPanMaxDistance: number;
  111156. /**
  111157. * Defines the maximum distance the camera can pan.
  111158. * This could help keeping the cammera always in your scene.
  111159. */
  111160. panningDistanceLimit: Nullable<number>;
  111161. /**
  111162. * Defines the target of the camera before paning.
  111163. */
  111164. panningOriginTarget: Vector3;
  111165. /**
  111166. * Defines the value of the inertia used during panning.
  111167. * 0 would mean stop inertia and one would mean no decelleration at all.
  111168. */
  111169. panningInertia: number;
  111170. /**
  111171. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111172. */
  111173. get angularSensibilityX(): number;
  111174. set angularSensibilityX(value: number);
  111175. /**
  111176. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111177. */
  111178. get angularSensibilityY(): number;
  111179. set angularSensibilityY(value: number);
  111180. /**
  111181. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111182. */
  111183. get pinchPrecision(): number;
  111184. set pinchPrecision(value: number);
  111185. /**
  111186. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111187. * It will be used instead of pinchDeltaPrecision if different from 0.
  111188. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111189. */
  111190. get pinchDeltaPercentage(): number;
  111191. set pinchDeltaPercentage(value: number);
  111192. /**
  111193. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111194. */
  111195. get panningSensibility(): number;
  111196. set panningSensibility(value: number);
  111197. /**
  111198. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111199. */
  111200. get keysUp(): number[];
  111201. set keysUp(value: number[]);
  111202. /**
  111203. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111204. */
  111205. get keysDown(): number[];
  111206. set keysDown(value: number[]);
  111207. /**
  111208. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111209. */
  111210. get keysLeft(): number[];
  111211. set keysLeft(value: number[]);
  111212. /**
  111213. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111214. */
  111215. get keysRight(): number[];
  111216. set keysRight(value: number[]);
  111217. /**
  111218. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111219. */
  111220. get wheelPrecision(): number;
  111221. set wheelPrecision(value: number);
  111222. /**
  111223. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111224. * It will be used instead of pinchDeltaPrecision if different from 0.
  111225. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111226. */
  111227. get wheelDeltaPercentage(): number;
  111228. set wheelDeltaPercentage(value: number);
  111229. /**
  111230. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111231. */
  111232. zoomOnFactor: number;
  111233. /**
  111234. * Defines a screen offset for the camera position.
  111235. */
  111236. targetScreenOffset: Vector2;
  111237. /**
  111238. * Allows the camera to be completely reversed.
  111239. * If false the camera can not arrive upside down.
  111240. */
  111241. allowUpsideDown: boolean;
  111242. /**
  111243. * Define if double tap/click is used to restore the previously saved state of the camera.
  111244. */
  111245. useInputToRestoreState: boolean;
  111246. /** @hidden */
  111247. _viewMatrix: Matrix;
  111248. /** @hidden */
  111249. _useCtrlForPanning: boolean;
  111250. /** @hidden */
  111251. _panningMouseButton: number;
  111252. /**
  111253. * Defines the input associated to the camera.
  111254. */
  111255. inputs: ArcRotateCameraInputsManager;
  111256. /** @hidden */
  111257. _reset: () => void;
  111258. /**
  111259. * Defines the allowed panning axis.
  111260. */
  111261. panningAxis: Vector3;
  111262. protected _localDirection: Vector3;
  111263. protected _transformedDirection: Vector3;
  111264. private _bouncingBehavior;
  111265. /**
  111266. * Gets the bouncing behavior of the camera if it has been enabled.
  111267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111268. */
  111269. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111270. /**
  111271. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111273. */
  111274. get useBouncingBehavior(): boolean;
  111275. set useBouncingBehavior(value: boolean);
  111276. private _framingBehavior;
  111277. /**
  111278. * Gets the framing behavior of the camera if it has been enabled.
  111279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111280. */
  111281. get framingBehavior(): Nullable<FramingBehavior>;
  111282. /**
  111283. * Defines if the framing behavior of the camera is enabled on the camera.
  111284. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111285. */
  111286. get useFramingBehavior(): boolean;
  111287. set useFramingBehavior(value: boolean);
  111288. private _autoRotationBehavior;
  111289. /**
  111290. * Gets the auto rotation behavior of the camera if it has been enabled.
  111291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111292. */
  111293. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111294. /**
  111295. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111297. */
  111298. get useAutoRotationBehavior(): boolean;
  111299. set useAutoRotationBehavior(value: boolean);
  111300. /**
  111301. * Observable triggered when the mesh target has been changed on the camera.
  111302. */
  111303. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111304. /**
  111305. * Event raised when the camera is colliding with a mesh.
  111306. */
  111307. onCollide: (collidedMesh: AbstractMesh) => void;
  111308. /**
  111309. * Defines whether the camera should check collision with the objects oh the scene.
  111310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111311. */
  111312. checkCollisions: boolean;
  111313. /**
  111314. * Defines the collision radius of the camera.
  111315. * This simulates a sphere around the camera.
  111316. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111317. */
  111318. collisionRadius: Vector3;
  111319. protected _collider: Collider;
  111320. protected _previousPosition: Vector3;
  111321. protected _collisionVelocity: Vector3;
  111322. protected _newPosition: Vector3;
  111323. protected _previousAlpha: number;
  111324. protected _previousBeta: number;
  111325. protected _previousRadius: number;
  111326. protected _collisionTriggered: boolean;
  111327. protected _targetBoundingCenter: Nullable<Vector3>;
  111328. private _computationVector;
  111329. /**
  111330. * Instantiates a new ArcRotateCamera in a given scene
  111331. * @param name Defines the name of the camera
  111332. * @param alpha Defines the camera rotation along the logitudinal axis
  111333. * @param beta Defines the camera rotation along the latitudinal axis
  111334. * @param radius Defines the camera distance from its target
  111335. * @param target Defines the camera target
  111336. * @param scene Defines the scene the camera belongs to
  111337. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111338. */
  111339. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111340. /** @hidden */
  111341. _initCache(): void;
  111342. /** @hidden */
  111343. _updateCache(ignoreParentClass?: boolean): void;
  111344. protected _getTargetPosition(): Vector3;
  111345. private _storedAlpha;
  111346. private _storedBeta;
  111347. private _storedRadius;
  111348. private _storedTarget;
  111349. private _storedTargetScreenOffset;
  111350. /**
  111351. * Stores the current state of the camera (alpha, beta, radius and target)
  111352. * @returns the camera itself
  111353. */
  111354. storeState(): Camera;
  111355. /**
  111356. * @hidden
  111357. * Restored camera state. You must call storeState() first
  111358. */
  111359. _restoreStateValues(): boolean;
  111360. /** @hidden */
  111361. _isSynchronizedViewMatrix(): boolean;
  111362. /**
  111363. * Attached controls to the current camera.
  111364. * @param element Defines the element the controls should be listened from
  111365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111366. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  111367. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  111368. */
  111369. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  111370. /**
  111371. * Detach the current controls from the camera.
  111372. * The camera will stop reacting to inputs.
  111373. * @param element Defines the element to stop listening the inputs from
  111374. */
  111375. detachControl(element: HTMLElement): void;
  111376. /** @hidden */
  111377. _checkInputs(): void;
  111378. protected _checkLimits(): void;
  111379. /**
  111380. * Rebuilds angles (alpha, beta) and radius from the give position and target
  111381. */
  111382. rebuildAnglesAndRadius(): void;
  111383. /**
  111384. * Use a position to define the current camera related information like alpha, beta and radius
  111385. * @param position Defines the position to set the camera at
  111386. */
  111387. setPosition(position: Vector3): void;
  111388. /**
  111389. * Defines the target the camera should look at.
  111390. * This will automatically adapt alpha beta and radius to fit within the new target.
  111391. * @param target Defines the new target as a Vector or a mesh
  111392. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  111393. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  111394. */
  111395. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  111396. /** @hidden */
  111397. _getViewMatrix(): Matrix;
  111398. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  111399. /**
  111400. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  111401. * @param meshes Defines the mesh to zoom on
  111402. * @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)
  111403. */
  111404. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  111405. /**
  111406. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  111407. * The target will be changed but the radius
  111408. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  111409. * @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)
  111410. */
  111411. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  111412. min: Vector3;
  111413. max: Vector3;
  111414. distance: number;
  111415. }, doNotUpdateMaxZ?: boolean): void;
  111416. /**
  111417. * @override
  111418. * Override Camera.createRigCamera
  111419. */
  111420. createRigCamera(name: string, cameraIndex: number): Camera;
  111421. /**
  111422. * @hidden
  111423. * @override
  111424. * Override Camera._updateRigCameras
  111425. */
  111426. _updateRigCameras(): void;
  111427. /**
  111428. * Destroy the camera and release the current resources hold by it.
  111429. */
  111430. dispose(): void;
  111431. /**
  111432. * Gets the current object class name.
  111433. * @return the class name
  111434. */
  111435. getClassName(): string;
  111436. }
  111437. }
  111438. declare module BABYLON {
  111439. /**
  111440. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  111441. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111442. */
  111443. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  111444. /**
  111445. * Gets the name of the behavior.
  111446. */
  111447. get name(): string;
  111448. private _zoomStopsAnimation;
  111449. private _idleRotationSpeed;
  111450. private _idleRotationWaitTime;
  111451. private _idleRotationSpinupTime;
  111452. /**
  111453. * Sets the flag that indicates if user zooming should stop animation.
  111454. */
  111455. set zoomStopsAnimation(flag: boolean);
  111456. /**
  111457. * Gets the flag that indicates if user zooming should stop animation.
  111458. */
  111459. get zoomStopsAnimation(): boolean;
  111460. /**
  111461. * Sets the default speed at which the camera rotates around the model.
  111462. */
  111463. set idleRotationSpeed(speed: number);
  111464. /**
  111465. * Gets the default speed at which the camera rotates around the model.
  111466. */
  111467. get idleRotationSpeed(): number;
  111468. /**
  111469. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  111470. */
  111471. set idleRotationWaitTime(time: number);
  111472. /**
  111473. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  111474. */
  111475. get idleRotationWaitTime(): number;
  111476. /**
  111477. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111478. */
  111479. set idleRotationSpinupTime(time: number);
  111480. /**
  111481. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111482. */
  111483. get idleRotationSpinupTime(): number;
  111484. /**
  111485. * Gets a value indicating if the camera is currently rotating because of this behavior
  111486. */
  111487. get rotationInProgress(): boolean;
  111488. private _onPrePointerObservableObserver;
  111489. private _onAfterCheckInputsObserver;
  111490. private _attachedCamera;
  111491. private _isPointerDown;
  111492. private _lastFrameTime;
  111493. private _lastInteractionTime;
  111494. private _cameraRotationSpeed;
  111495. /**
  111496. * Initializes the behavior.
  111497. */
  111498. init(): void;
  111499. /**
  111500. * Attaches the behavior to its arc rotate camera.
  111501. * @param camera Defines the camera to attach the behavior to
  111502. */
  111503. attach(camera: ArcRotateCamera): void;
  111504. /**
  111505. * Detaches the behavior from its current arc rotate camera.
  111506. */
  111507. detach(): void;
  111508. /**
  111509. * Returns true if user is scrolling.
  111510. * @return true if user is scrolling.
  111511. */
  111512. private _userIsZooming;
  111513. private _lastFrameRadius;
  111514. private _shouldAnimationStopForInteraction;
  111515. /**
  111516. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111517. */
  111518. private _applyUserInteraction;
  111519. private _userIsMoving;
  111520. }
  111521. }
  111522. declare module BABYLON {
  111523. /**
  111524. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  111525. */
  111526. export class AttachToBoxBehavior implements Behavior<Mesh> {
  111527. private ui;
  111528. /**
  111529. * The name of the behavior
  111530. */
  111531. name: string;
  111532. /**
  111533. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  111534. */
  111535. distanceAwayFromFace: number;
  111536. /**
  111537. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  111538. */
  111539. distanceAwayFromBottomOfFace: number;
  111540. private _faceVectors;
  111541. private _target;
  111542. private _scene;
  111543. private _onRenderObserver;
  111544. private _tmpMatrix;
  111545. private _tmpVector;
  111546. /**
  111547. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  111548. * @param ui The transform node that should be attched to the mesh
  111549. */
  111550. constructor(ui: TransformNode);
  111551. /**
  111552. * Initializes the behavior
  111553. */
  111554. init(): void;
  111555. private _closestFace;
  111556. private _zeroVector;
  111557. private _lookAtTmpMatrix;
  111558. private _lookAtToRef;
  111559. /**
  111560. * Attaches the AttachToBoxBehavior to the passed in mesh
  111561. * @param target The mesh that the specified node will be attached to
  111562. */
  111563. attach(target: Mesh): void;
  111564. /**
  111565. * Detaches the behavior from the mesh
  111566. */
  111567. detach(): void;
  111568. }
  111569. }
  111570. declare module BABYLON {
  111571. /**
  111572. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  111573. */
  111574. export class FadeInOutBehavior implements Behavior<Mesh> {
  111575. /**
  111576. * Time in milliseconds to delay before fading in (Default: 0)
  111577. */
  111578. delay: number;
  111579. /**
  111580. * Time in milliseconds for the mesh to fade in (Default: 300)
  111581. */
  111582. fadeInTime: number;
  111583. private _millisecondsPerFrame;
  111584. private _hovered;
  111585. private _hoverValue;
  111586. private _ownerNode;
  111587. /**
  111588. * Instatiates the FadeInOutBehavior
  111589. */
  111590. constructor();
  111591. /**
  111592. * The name of the behavior
  111593. */
  111594. get name(): string;
  111595. /**
  111596. * Initializes the behavior
  111597. */
  111598. init(): void;
  111599. /**
  111600. * Attaches the fade behavior on the passed in mesh
  111601. * @param ownerNode The mesh that will be faded in/out once attached
  111602. */
  111603. attach(ownerNode: Mesh): void;
  111604. /**
  111605. * Detaches the behavior from the mesh
  111606. */
  111607. detach(): void;
  111608. /**
  111609. * Triggers the mesh to begin fading in or out
  111610. * @param value if the object should fade in or out (true to fade in)
  111611. */
  111612. fadeIn(value: boolean): void;
  111613. private _update;
  111614. private _setAllVisibility;
  111615. }
  111616. }
  111617. declare module BABYLON {
  111618. /**
  111619. * Class containing a set of static utilities functions for managing Pivots
  111620. * @hidden
  111621. */
  111622. export class PivotTools {
  111623. private static _PivotCached;
  111624. private static _OldPivotPoint;
  111625. private static _PivotTranslation;
  111626. private static _PivotTmpVector;
  111627. /** @hidden */
  111628. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  111629. /** @hidden */
  111630. static _RestorePivotPoint(mesh: AbstractMesh): void;
  111631. }
  111632. }
  111633. declare module BABYLON {
  111634. /**
  111635. * Class containing static functions to help procedurally build meshes
  111636. */
  111637. export class PlaneBuilder {
  111638. /**
  111639. * Creates a plane mesh
  111640. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  111641. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  111642. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  111643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111646. * @param name defines the name of the mesh
  111647. * @param options defines the options used to create the mesh
  111648. * @param scene defines the hosting scene
  111649. * @returns the plane mesh
  111650. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  111651. */
  111652. static CreatePlane(name: string, options: {
  111653. size?: number;
  111654. width?: number;
  111655. height?: number;
  111656. sideOrientation?: number;
  111657. frontUVs?: Vector4;
  111658. backUVs?: Vector4;
  111659. updatable?: boolean;
  111660. sourcePlane?: Plane;
  111661. }, scene?: Nullable<Scene>): Mesh;
  111662. }
  111663. }
  111664. declare module BABYLON {
  111665. /**
  111666. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  111667. */
  111668. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  111669. private static _AnyMouseID;
  111670. /**
  111671. * Abstract mesh the behavior is set on
  111672. */
  111673. attachedNode: AbstractMesh;
  111674. private _dragPlane;
  111675. private _scene;
  111676. private _pointerObserver;
  111677. private _beforeRenderObserver;
  111678. private static _planeScene;
  111679. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  111680. /**
  111681. * 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)
  111682. */
  111683. maxDragAngle: number;
  111684. /**
  111685. * @hidden
  111686. */
  111687. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  111688. /**
  111689. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111690. */
  111691. currentDraggingPointerID: number;
  111692. /**
  111693. * The last position where the pointer hit the drag plane in world space
  111694. */
  111695. lastDragPosition: Vector3;
  111696. /**
  111697. * If the behavior is currently in a dragging state
  111698. */
  111699. dragging: boolean;
  111700. /**
  111701. * 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)
  111702. */
  111703. dragDeltaRatio: number;
  111704. /**
  111705. * If the drag plane orientation should be updated during the dragging (Default: true)
  111706. */
  111707. updateDragPlane: boolean;
  111708. private _debugMode;
  111709. private _moving;
  111710. /**
  111711. * Fires each time the attached mesh is dragged with the pointer
  111712. * * delta between last drag position and current drag position in world space
  111713. * * dragDistance along the drag axis
  111714. * * dragPlaneNormal normal of the current drag plane used during the drag
  111715. * * dragPlanePoint in world space where the drag intersects the drag plane
  111716. */
  111717. onDragObservable: Observable<{
  111718. delta: Vector3;
  111719. dragPlanePoint: Vector3;
  111720. dragPlaneNormal: Vector3;
  111721. dragDistance: number;
  111722. pointerId: number;
  111723. }>;
  111724. /**
  111725. * Fires each time a drag begins (eg. mouse down on mesh)
  111726. */
  111727. onDragStartObservable: Observable<{
  111728. dragPlanePoint: Vector3;
  111729. pointerId: number;
  111730. }>;
  111731. /**
  111732. * Fires each time a drag ends (eg. mouse release after drag)
  111733. */
  111734. onDragEndObservable: Observable<{
  111735. dragPlanePoint: Vector3;
  111736. pointerId: number;
  111737. }>;
  111738. /**
  111739. * If the attached mesh should be moved when dragged
  111740. */
  111741. moveAttached: boolean;
  111742. /**
  111743. * If the drag behavior will react to drag events (Default: true)
  111744. */
  111745. enabled: boolean;
  111746. /**
  111747. * If pointer events should start and release the drag (Default: true)
  111748. */
  111749. startAndReleaseDragOnPointerEvents: boolean;
  111750. /**
  111751. * If camera controls should be detached during the drag
  111752. */
  111753. detachCameraControls: boolean;
  111754. /**
  111755. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  111756. */
  111757. useObjectOrientationForDragging: boolean;
  111758. private _options;
  111759. /**
  111760. * Gets the options used by the behavior
  111761. */
  111762. get options(): {
  111763. dragAxis?: Vector3;
  111764. dragPlaneNormal?: Vector3;
  111765. };
  111766. /**
  111767. * Sets the options used by the behavior
  111768. */
  111769. set options(options: {
  111770. dragAxis?: Vector3;
  111771. dragPlaneNormal?: Vector3;
  111772. });
  111773. /**
  111774. * Creates a pointer drag behavior that can be attached to a mesh
  111775. * @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)
  111776. */
  111777. constructor(options?: {
  111778. dragAxis?: Vector3;
  111779. dragPlaneNormal?: Vector3;
  111780. });
  111781. /**
  111782. * Predicate to determine if it is valid to move the object to a new position when it is moved
  111783. */
  111784. validateDrag: (targetPosition: Vector3) => boolean;
  111785. /**
  111786. * The name of the behavior
  111787. */
  111788. get name(): string;
  111789. /**
  111790. * Initializes the behavior
  111791. */
  111792. init(): void;
  111793. private _tmpVector;
  111794. private _alternatePickedPoint;
  111795. private _worldDragAxis;
  111796. private _targetPosition;
  111797. private _attachedElement;
  111798. /**
  111799. * Attaches the drag behavior the passed in mesh
  111800. * @param ownerNode The mesh that will be dragged around once attached
  111801. * @param predicate Predicate to use for pick filtering
  111802. */
  111803. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  111804. /**
  111805. * Force relase the drag action by code.
  111806. */
  111807. releaseDrag(): void;
  111808. private _startDragRay;
  111809. private _lastPointerRay;
  111810. /**
  111811. * Simulates the start of a pointer drag event on the behavior
  111812. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  111813. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  111814. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  111815. */
  111816. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  111817. private _startDrag;
  111818. private _dragDelta;
  111819. private _moveDrag;
  111820. private _pickWithRayOnDragPlane;
  111821. private _pointA;
  111822. private _pointB;
  111823. private _pointC;
  111824. private _lineA;
  111825. private _lineB;
  111826. private _localAxis;
  111827. private _lookAt;
  111828. private _updateDragPlanePosition;
  111829. /**
  111830. * Detaches the behavior from the mesh
  111831. */
  111832. detach(): void;
  111833. }
  111834. }
  111835. declare module BABYLON {
  111836. /**
  111837. * A behavior that when attached to a mesh will allow the mesh to be scaled
  111838. */
  111839. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  111840. private _dragBehaviorA;
  111841. private _dragBehaviorB;
  111842. private _startDistance;
  111843. private _initialScale;
  111844. private _targetScale;
  111845. private _ownerNode;
  111846. private _sceneRenderObserver;
  111847. /**
  111848. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  111849. */
  111850. constructor();
  111851. /**
  111852. * The name of the behavior
  111853. */
  111854. get name(): string;
  111855. /**
  111856. * Initializes the behavior
  111857. */
  111858. init(): void;
  111859. private _getCurrentDistance;
  111860. /**
  111861. * Attaches the scale behavior the passed in mesh
  111862. * @param ownerNode The mesh that will be scaled around once attached
  111863. */
  111864. attach(ownerNode: Mesh): void;
  111865. /**
  111866. * Detaches the behavior from the mesh
  111867. */
  111868. detach(): void;
  111869. }
  111870. }
  111871. declare module BABYLON {
  111872. /**
  111873. * 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
  111874. */
  111875. export class SixDofDragBehavior implements Behavior<Mesh> {
  111876. private static _virtualScene;
  111877. private _ownerNode;
  111878. private _sceneRenderObserver;
  111879. private _scene;
  111880. private _targetPosition;
  111881. private _virtualOriginMesh;
  111882. private _virtualDragMesh;
  111883. private _pointerObserver;
  111884. private _moving;
  111885. private _startingOrientation;
  111886. /**
  111887. * 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)
  111888. */
  111889. private zDragFactor;
  111890. /**
  111891. * If the object should rotate to face the drag origin
  111892. */
  111893. rotateDraggedObject: boolean;
  111894. /**
  111895. * If the behavior is currently in a dragging state
  111896. */
  111897. dragging: boolean;
  111898. /**
  111899. * 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)
  111900. */
  111901. dragDeltaRatio: number;
  111902. /**
  111903. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111904. */
  111905. currentDraggingPointerID: number;
  111906. /**
  111907. * If camera controls should be detached during the drag
  111908. */
  111909. detachCameraControls: boolean;
  111910. /**
  111911. * Fires each time a drag starts
  111912. */
  111913. onDragStartObservable: Observable<{}>;
  111914. /**
  111915. * Fires each time a drag ends (eg. mouse release after drag)
  111916. */
  111917. onDragEndObservable: Observable<{}>;
  111918. /**
  111919. * 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
  111920. */
  111921. constructor();
  111922. /**
  111923. * The name of the behavior
  111924. */
  111925. get name(): string;
  111926. /**
  111927. * Initializes the behavior
  111928. */
  111929. init(): void;
  111930. /**
  111931. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  111932. */
  111933. private get _pointerCamera();
  111934. /**
  111935. * Attaches the scale behavior the passed in mesh
  111936. * @param ownerNode The mesh that will be scaled around once attached
  111937. */
  111938. attach(ownerNode: Mesh): void;
  111939. /**
  111940. * Detaches the behavior from the mesh
  111941. */
  111942. detach(): void;
  111943. }
  111944. }
  111945. declare module BABYLON {
  111946. /**
  111947. * Class used to apply inverse kinematics to bones
  111948. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  111949. */
  111950. export class BoneIKController {
  111951. private static _tmpVecs;
  111952. private static _tmpQuat;
  111953. private static _tmpMats;
  111954. /**
  111955. * Gets or sets the target mesh
  111956. */
  111957. targetMesh: AbstractMesh;
  111958. /** Gets or sets the mesh used as pole */
  111959. poleTargetMesh: AbstractMesh;
  111960. /**
  111961. * Gets or sets the bone used as pole
  111962. */
  111963. poleTargetBone: Nullable<Bone>;
  111964. /**
  111965. * Gets or sets the target position
  111966. */
  111967. targetPosition: Vector3;
  111968. /**
  111969. * Gets or sets the pole target position
  111970. */
  111971. poleTargetPosition: Vector3;
  111972. /**
  111973. * Gets or sets the pole target local offset
  111974. */
  111975. poleTargetLocalOffset: Vector3;
  111976. /**
  111977. * Gets or sets the pole angle
  111978. */
  111979. poleAngle: number;
  111980. /**
  111981. * Gets or sets the mesh associated with the controller
  111982. */
  111983. mesh: AbstractMesh;
  111984. /**
  111985. * 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)
  111986. */
  111987. slerpAmount: number;
  111988. private _bone1Quat;
  111989. private _bone1Mat;
  111990. private _bone2Ang;
  111991. private _bone1;
  111992. private _bone2;
  111993. private _bone1Length;
  111994. private _bone2Length;
  111995. private _maxAngle;
  111996. private _maxReach;
  111997. private _rightHandedSystem;
  111998. private _bendAxis;
  111999. private _slerping;
  112000. private _adjustRoll;
  112001. /**
  112002. * Gets or sets maximum allowed angle
  112003. */
  112004. get maxAngle(): number;
  112005. set maxAngle(value: number);
  112006. /**
  112007. * Creates a new BoneIKController
  112008. * @param mesh defines the mesh to control
  112009. * @param bone defines the bone to control
  112010. * @param options defines options to set up the controller
  112011. */
  112012. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112013. targetMesh?: AbstractMesh;
  112014. poleTargetMesh?: AbstractMesh;
  112015. poleTargetBone?: Bone;
  112016. poleTargetLocalOffset?: Vector3;
  112017. poleAngle?: number;
  112018. bendAxis?: Vector3;
  112019. maxAngle?: number;
  112020. slerpAmount?: number;
  112021. });
  112022. private _setMaxAngle;
  112023. /**
  112024. * Force the controller to update the bones
  112025. */
  112026. update(): void;
  112027. }
  112028. }
  112029. declare module BABYLON {
  112030. /**
  112031. * Class used to make a bone look toward a point in space
  112032. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112033. */
  112034. export class BoneLookController {
  112035. private static _tmpVecs;
  112036. private static _tmpQuat;
  112037. private static _tmpMats;
  112038. /**
  112039. * The target Vector3 that the bone will look at
  112040. */
  112041. target: Vector3;
  112042. /**
  112043. * The mesh that the bone is attached to
  112044. */
  112045. mesh: AbstractMesh;
  112046. /**
  112047. * The bone that will be looking to the target
  112048. */
  112049. bone: Bone;
  112050. /**
  112051. * The up axis of the coordinate system that is used when the bone is rotated
  112052. */
  112053. upAxis: Vector3;
  112054. /**
  112055. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112056. */
  112057. upAxisSpace: Space;
  112058. /**
  112059. * Used to make an adjustment to the yaw of the bone
  112060. */
  112061. adjustYaw: number;
  112062. /**
  112063. * Used to make an adjustment to the pitch of the bone
  112064. */
  112065. adjustPitch: number;
  112066. /**
  112067. * Used to make an adjustment to the roll of the bone
  112068. */
  112069. adjustRoll: number;
  112070. /**
  112071. * 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)
  112072. */
  112073. slerpAmount: number;
  112074. private _minYaw;
  112075. private _maxYaw;
  112076. private _minPitch;
  112077. private _maxPitch;
  112078. private _minYawSin;
  112079. private _minYawCos;
  112080. private _maxYawSin;
  112081. private _maxYawCos;
  112082. private _midYawConstraint;
  112083. private _minPitchTan;
  112084. private _maxPitchTan;
  112085. private _boneQuat;
  112086. private _slerping;
  112087. private _transformYawPitch;
  112088. private _transformYawPitchInv;
  112089. private _firstFrameSkipped;
  112090. private _yawRange;
  112091. private _fowardAxis;
  112092. /**
  112093. * Gets or sets the minimum yaw angle that the bone can look to
  112094. */
  112095. get minYaw(): number;
  112096. set minYaw(value: number);
  112097. /**
  112098. * Gets or sets the maximum yaw angle that the bone can look to
  112099. */
  112100. get maxYaw(): number;
  112101. set maxYaw(value: number);
  112102. /**
  112103. * Gets or sets the minimum pitch angle that the bone can look to
  112104. */
  112105. get minPitch(): number;
  112106. set minPitch(value: number);
  112107. /**
  112108. * Gets or sets the maximum pitch angle that the bone can look to
  112109. */
  112110. get maxPitch(): number;
  112111. set maxPitch(value: number);
  112112. /**
  112113. * Create a BoneLookController
  112114. * @param mesh the mesh that the bone belongs to
  112115. * @param bone the bone that will be looking to the target
  112116. * @param target the target Vector3 to look at
  112117. * @param options optional settings:
  112118. * * maxYaw: the maximum angle the bone will yaw to
  112119. * * minYaw: the minimum angle the bone will yaw to
  112120. * * maxPitch: the maximum angle the bone will pitch to
  112121. * * minPitch: the minimum angle the bone will yaw to
  112122. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112123. * * upAxis: the up axis of the coordinate system
  112124. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112125. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112126. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112127. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112128. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112129. * * adjustRoll: used to make an adjustment to the roll of the bone
  112130. **/
  112131. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112132. maxYaw?: number;
  112133. minYaw?: number;
  112134. maxPitch?: number;
  112135. minPitch?: number;
  112136. slerpAmount?: number;
  112137. upAxis?: Vector3;
  112138. upAxisSpace?: Space;
  112139. yawAxis?: Vector3;
  112140. pitchAxis?: Vector3;
  112141. adjustYaw?: number;
  112142. adjustPitch?: number;
  112143. adjustRoll?: number;
  112144. });
  112145. /**
  112146. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112147. */
  112148. update(): void;
  112149. private _getAngleDiff;
  112150. private _getAngleBetween;
  112151. private _isAngleBetween;
  112152. }
  112153. }
  112154. declare module BABYLON {
  112155. /**
  112156. * Manage the gamepad inputs to control an arc rotate camera.
  112157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112158. */
  112159. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112160. /**
  112161. * Defines the camera the input is attached to.
  112162. */
  112163. camera: ArcRotateCamera;
  112164. /**
  112165. * Defines the gamepad the input is gathering event from.
  112166. */
  112167. gamepad: Nullable<Gamepad>;
  112168. /**
  112169. * Defines the gamepad rotation sensiblity.
  112170. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112171. */
  112172. gamepadRotationSensibility: number;
  112173. /**
  112174. * Defines the gamepad move sensiblity.
  112175. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112176. */
  112177. gamepadMoveSensibility: number;
  112178. private _yAxisScale;
  112179. /**
  112180. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112181. */
  112182. get invertYAxis(): boolean;
  112183. set invertYAxis(value: boolean);
  112184. private _onGamepadConnectedObserver;
  112185. private _onGamepadDisconnectedObserver;
  112186. /**
  112187. * Attach the input controls to a specific dom element to get the input from.
  112188. * @param element Defines the element the controls should be listened from
  112189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112190. */
  112191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112192. /**
  112193. * Detach the current controls from the specified dom element.
  112194. * @param element Defines the element to stop listening the inputs from
  112195. */
  112196. detachControl(element: Nullable<HTMLElement>): void;
  112197. /**
  112198. * Update the current camera state depending on the inputs that have been used this frame.
  112199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112200. */
  112201. checkInputs(): void;
  112202. /**
  112203. * Gets the class name of the current intput.
  112204. * @returns the class name
  112205. */
  112206. getClassName(): string;
  112207. /**
  112208. * Get the friendly name associated with the input class.
  112209. * @returns the input friendly name
  112210. */
  112211. getSimpleName(): string;
  112212. }
  112213. }
  112214. declare module BABYLON {
  112215. interface ArcRotateCameraInputsManager {
  112216. /**
  112217. * Add orientation input support to the input manager.
  112218. * @returns the current input manager
  112219. */
  112220. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112221. }
  112222. /**
  112223. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112225. */
  112226. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112227. /**
  112228. * Defines the camera the input is attached to.
  112229. */
  112230. camera: ArcRotateCamera;
  112231. /**
  112232. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112233. */
  112234. alphaCorrection: number;
  112235. /**
  112236. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112237. */
  112238. gammaCorrection: number;
  112239. private _alpha;
  112240. private _gamma;
  112241. private _dirty;
  112242. private _deviceOrientationHandler;
  112243. /**
  112244. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112245. */
  112246. constructor();
  112247. /**
  112248. * Attach the input controls to a specific dom element to get the input from.
  112249. * @param element Defines the element the controls should be listened from
  112250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112251. */
  112252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112253. /** @hidden */
  112254. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112255. /**
  112256. * Update the current camera state depending on the inputs that have been used this frame.
  112257. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112258. */
  112259. checkInputs(): void;
  112260. /**
  112261. * Detach the current controls from the specified dom element.
  112262. * @param element Defines the element to stop listening the inputs from
  112263. */
  112264. detachControl(element: Nullable<HTMLElement>): void;
  112265. /**
  112266. * Gets the class name of the current intput.
  112267. * @returns the class name
  112268. */
  112269. getClassName(): string;
  112270. /**
  112271. * Get the friendly name associated with the input class.
  112272. * @returns the input friendly name
  112273. */
  112274. getSimpleName(): string;
  112275. }
  112276. }
  112277. declare module BABYLON {
  112278. /**
  112279. * Listen to mouse events to control the camera.
  112280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112281. */
  112282. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112283. /**
  112284. * Defines the camera the input is attached to.
  112285. */
  112286. camera: FlyCamera;
  112287. /**
  112288. * Defines if touch is enabled. (Default is true.)
  112289. */
  112290. touchEnabled: boolean;
  112291. /**
  112292. * Defines the buttons associated with the input to handle camera rotation.
  112293. */
  112294. buttons: number[];
  112295. /**
  112296. * Assign buttons for Yaw control.
  112297. */
  112298. buttonsYaw: number[];
  112299. /**
  112300. * Assign buttons for Pitch control.
  112301. */
  112302. buttonsPitch: number[];
  112303. /**
  112304. * Assign buttons for Roll control.
  112305. */
  112306. buttonsRoll: number[];
  112307. /**
  112308. * Detect if any button is being pressed while mouse is moved.
  112309. * -1 = Mouse locked.
  112310. * 0 = Left button.
  112311. * 1 = Middle Button.
  112312. * 2 = Right Button.
  112313. */
  112314. activeButton: number;
  112315. /**
  112316. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112317. * Higher values reduce its sensitivity.
  112318. */
  112319. angularSensibility: number;
  112320. private _mousemoveCallback;
  112321. private _observer;
  112322. private _rollObserver;
  112323. private previousPosition;
  112324. private noPreventDefault;
  112325. private element;
  112326. /**
  112327. * Listen to mouse events to control the camera.
  112328. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112330. */
  112331. constructor(touchEnabled?: boolean);
  112332. /**
  112333. * Attach the mouse control to the HTML DOM element.
  112334. * @param element Defines the element that listens to the input events.
  112335. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112336. */
  112337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112338. /**
  112339. * Detach the current controls from the specified dom element.
  112340. * @param element Defines the element to stop listening the inputs from
  112341. */
  112342. detachControl(element: Nullable<HTMLElement>): void;
  112343. /**
  112344. * Gets the class name of the current input.
  112345. * @returns the class name.
  112346. */
  112347. getClassName(): string;
  112348. /**
  112349. * Get the friendly name associated with the input class.
  112350. * @returns the input's friendly name.
  112351. */
  112352. getSimpleName(): string;
  112353. private _pointerInput;
  112354. private _onMouseMove;
  112355. /**
  112356. * Rotate camera by mouse offset.
  112357. */
  112358. private rotateCamera;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /**
  112363. * Default Inputs manager for the FlyCamera.
  112364. * It groups all the default supported inputs for ease of use.
  112365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112366. */
  112367. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  112368. /**
  112369. * Instantiates a new FlyCameraInputsManager.
  112370. * @param camera Defines the camera the inputs belong to.
  112371. */
  112372. constructor(camera: FlyCamera);
  112373. /**
  112374. * Add keyboard input support to the input manager.
  112375. * @returns the new FlyCameraKeyboardMoveInput().
  112376. */
  112377. addKeyboard(): FlyCameraInputsManager;
  112378. /**
  112379. * Add mouse input support to the input manager.
  112380. * @param touchEnabled Enable touch screen support.
  112381. * @returns the new FlyCameraMouseInput().
  112382. */
  112383. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  112384. }
  112385. }
  112386. declare module BABYLON {
  112387. /**
  112388. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112389. * such as in a 3D Space Shooter or a Flight Simulator.
  112390. */
  112391. export class FlyCamera extends TargetCamera {
  112392. /**
  112393. * Define the collision ellipsoid of the camera.
  112394. * This is helpful for simulating a camera body, like a player's body.
  112395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112396. */
  112397. ellipsoid: Vector3;
  112398. /**
  112399. * Define an offset for the position of the ellipsoid around the camera.
  112400. * This can be helpful if the camera is attached away from the player's body center,
  112401. * such as at its head.
  112402. */
  112403. ellipsoidOffset: Vector3;
  112404. /**
  112405. * Enable or disable collisions of the camera with the rest of the scene objects.
  112406. */
  112407. checkCollisions: boolean;
  112408. /**
  112409. * Enable or disable gravity on the camera.
  112410. */
  112411. applyGravity: boolean;
  112412. /**
  112413. * Define the current direction the camera is moving to.
  112414. */
  112415. cameraDirection: Vector3;
  112416. /**
  112417. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  112418. * This overrides and empties cameraRotation.
  112419. */
  112420. rotationQuaternion: Quaternion;
  112421. /**
  112422. * Track Roll to maintain the wanted Rolling when looking around.
  112423. */
  112424. _trackRoll: number;
  112425. /**
  112426. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  112427. */
  112428. rollCorrect: number;
  112429. /**
  112430. * Mimic a banked turn, Rolling the camera when Yawing.
  112431. * It's recommended to use rollCorrect = 10 for faster banking correction.
  112432. */
  112433. bankedTurn: boolean;
  112434. /**
  112435. * Limit in radians for how much Roll banking will add. (Default: 90°)
  112436. */
  112437. bankedTurnLimit: number;
  112438. /**
  112439. * Value of 0 disables the banked Roll.
  112440. * Value of 1 is equal to the Yaw angle in radians.
  112441. */
  112442. bankedTurnMultiplier: number;
  112443. /**
  112444. * The inputs manager loads all the input sources, such as keyboard and mouse.
  112445. */
  112446. inputs: FlyCameraInputsManager;
  112447. /**
  112448. * Gets the input sensibility for mouse input.
  112449. * Higher values reduce sensitivity.
  112450. */
  112451. get angularSensibility(): number;
  112452. /**
  112453. * Sets the input sensibility for a mouse input.
  112454. * Higher values reduce sensitivity.
  112455. */
  112456. set angularSensibility(value: number);
  112457. /**
  112458. * Get the keys for camera movement forward.
  112459. */
  112460. get keysForward(): number[];
  112461. /**
  112462. * Set the keys for camera movement forward.
  112463. */
  112464. set keysForward(value: number[]);
  112465. /**
  112466. * Get the keys for camera movement backward.
  112467. */
  112468. get keysBackward(): number[];
  112469. set keysBackward(value: number[]);
  112470. /**
  112471. * Get the keys for camera movement up.
  112472. */
  112473. get keysUp(): number[];
  112474. /**
  112475. * Set the keys for camera movement up.
  112476. */
  112477. set keysUp(value: number[]);
  112478. /**
  112479. * Get the keys for camera movement down.
  112480. */
  112481. get keysDown(): number[];
  112482. /**
  112483. * Set the keys for camera movement down.
  112484. */
  112485. set keysDown(value: number[]);
  112486. /**
  112487. * Get the keys for camera movement left.
  112488. */
  112489. get keysLeft(): number[];
  112490. /**
  112491. * Set the keys for camera movement left.
  112492. */
  112493. set keysLeft(value: number[]);
  112494. /**
  112495. * Set the keys for camera movement right.
  112496. */
  112497. get keysRight(): number[];
  112498. /**
  112499. * Set the keys for camera movement right.
  112500. */
  112501. set keysRight(value: number[]);
  112502. /**
  112503. * Event raised when the camera collides with a mesh in the scene.
  112504. */
  112505. onCollide: (collidedMesh: AbstractMesh) => void;
  112506. private _collider;
  112507. private _needMoveForGravity;
  112508. private _oldPosition;
  112509. private _diffPosition;
  112510. private _newPosition;
  112511. /** @hidden */
  112512. _localDirection: Vector3;
  112513. /** @hidden */
  112514. _transformedDirection: Vector3;
  112515. /**
  112516. * Instantiates a FlyCamera.
  112517. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112518. * such as in a 3D Space Shooter or a Flight Simulator.
  112519. * @param name Define the name of the camera in the scene.
  112520. * @param position Define the starting position of the camera in the scene.
  112521. * @param scene Define the scene the camera belongs to.
  112522. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  112523. */
  112524. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112525. /**
  112526. * Attach a control to the HTML DOM element.
  112527. * @param element Defines the element that listens to the input events.
  112528. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  112529. */
  112530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112531. /**
  112532. * Detach a control from the HTML DOM element.
  112533. * The camera will stop reacting to that input.
  112534. * @param element Defines the element that listens to the input events.
  112535. */
  112536. detachControl(element: HTMLElement): void;
  112537. private _collisionMask;
  112538. /**
  112539. * Get the mask that the camera ignores in collision events.
  112540. */
  112541. get collisionMask(): number;
  112542. /**
  112543. * Set the mask that the camera ignores in collision events.
  112544. */
  112545. set collisionMask(mask: number);
  112546. /** @hidden */
  112547. _collideWithWorld(displacement: Vector3): void;
  112548. /** @hidden */
  112549. private _onCollisionPositionChange;
  112550. /** @hidden */
  112551. _checkInputs(): void;
  112552. /** @hidden */
  112553. _decideIfNeedsToMove(): boolean;
  112554. /** @hidden */
  112555. _updatePosition(): void;
  112556. /**
  112557. * Restore the Roll to its target value at the rate specified.
  112558. * @param rate - Higher means slower restoring.
  112559. * @hidden
  112560. */
  112561. restoreRoll(rate: number): void;
  112562. /**
  112563. * Destroy the camera and release the current resources held by it.
  112564. */
  112565. dispose(): void;
  112566. /**
  112567. * Get the current object class name.
  112568. * @returns the class name.
  112569. */
  112570. getClassName(): string;
  112571. }
  112572. }
  112573. declare module BABYLON {
  112574. /**
  112575. * Listen to keyboard events to control the camera.
  112576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112577. */
  112578. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  112579. /**
  112580. * Defines the camera the input is attached to.
  112581. */
  112582. camera: FlyCamera;
  112583. /**
  112584. * The list of keyboard keys used to control the forward move of the camera.
  112585. */
  112586. keysForward: number[];
  112587. /**
  112588. * The list of keyboard keys used to control the backward move of the camera.
  112589. */
  112590. keysBackward: number[];
  112591. /**
  112592. * The list of keyboard keys used to control the forward move of the camera.
  112593. */
  112594. keysUp: number[];
  112595. /**
  112596. * The list of keyboard keys used to control the backward move of the camera.
  112597. */
  112598. keysDown: number[];
  112599. /**
  112600. * The list of keyboard keys used to control the right strafe move of the camera.
  112601. */
  112602. keysRight: number[];
  112603. /**
  112604. * The list of keyboard keys used to control the left strafe move of the camera.
  112605. */
  112606. keysLeft: number[];
  112607. private _keys;
  112608. private _onCanvasBlurObserver;
  112609. private _onKeyboardObserver;
  112610. private _engine;
  112611. private _scene;
  112612. /**
  112613. * Attach the input controls to a specific dom element to get the input from.
  112614. * @param element Defines the element the controls should be listened from
  112615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112616. */
  112617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112618. /**
  112619. * Detach the current controls from the specified dom element.
  112620. * @param element Defines the element to stop listening the inputs from
  112621. */
  112622. detachControl(element: Nullable<HTMLElement>): void;
  112623. /**
  112624. * Gets the class name of the current intput.
  112625. * @returns the class name
  112626. */
  112627. getClassName(): string;
  112628. /** @hidden */
  112629. _onLostFocus(e: FocusEvent): void;
  112630. /**
  112631. * Get the friendly name associated with the input class.
  112632. * @returns the input friendly name
  112633. */
  112634. getSimpleName(): string;
  112635. /**
  112636. * Update the current camera state depending on the inputs that have been used this frame.
  112637. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112638. */
  112639. checkInputs(): void;
  112640. }
  112641. }
  112642. declare module BABYLON {
  112643. /**
  112644. * Manage the mouse wheel inputs to control a follow camera.
  112645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112646. */
  112647. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  112648. /**
  112649. * Defines the camera the input is attached to.
  112650. */
  112651. camera: FollowCamera;
  112652. /**
  112653. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  112654. */
  112655. axisControlRadius: boolean;
  112656. /**
  112657. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  112658. */
  112659. axisControlHeight: boolean;
  112660. /**
  112661. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  112662. */
  112663. axisControlRotation: boolean;
  112664. /**
  112665. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  112666. * relation to mouseWheel events.
  112667. */
  112668. wheelPrecision: number;
  112669. /**
  112670. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112671. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112672. */
  112673. wheelDeltaPercentage: number;
  112674. private _wheel;
  112675. private _observer;
  112676. /**
  112677. * Attach the input controls to a specific dom element to get the input from.
  112678. * @param element Defines the element the controls should be listened from
  112679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112680. */
  112681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112682. /**
  112683. * Detach the current controls from the specified dom element.
  112684. * @param element Defines the element to stop listening the inputs from
  112685. */
  112686. detachControl(element: Nullable<HTMLElement>): void;
  112687. /**
  112688. * Gets the class name of the current intput.
  112689. * @returns the class name
  112690. */
  112691. getClassName(): string;
  112692. /**
  112693. * Get the friendly name associated with the input class.
  112694. * @returns the input friendly name
  112695. */
  112696. getSimpleName(): string;
  112697. }
  112698. }
  112699. declare module BABYLON {
  112700. /**
  112701. * Manage the pointers inputs to control an follow camera.
  112702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112703. */
  112704. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  112705. /**
  112706. * Defines the camera the input is attached to.
  112707. */
  112708. camera: FollowCamera;
  112709. /**
  112710. * Gets the class name of the current input.
  112711. * @returns the class name
  112712. */
  112713. getClassName(): string;
  112714. /**
  112715. * Defines the pointer angular sensibility along the X axis or how fast is
  112716. * the camera rotating.
  112717. * A negative number will reverse the axis direction.
  112718. */
  112719. angularSensibilityX: number;
  112720. /**
  112721. * Defines the pointer angular sensibility along the Y axis or how fast is
  112722. * the camera rotating.
  112723. * A negative number will reverse the axis direction.
  112724. */
  112725. angularSensibilityY: number;
  112726. /**
  112727. * Defines the pointer pinch precision or how fast is the camera zooming.
  112728. * A negative number will reverse the axis direction.
  112729. */
  112730. pinchPrecision: number;
  112731. /**
  112732. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112733. * from 0.
  112734. * It defines the percentage of current camera.radius to use as delta when
  112735. * pinch zoom is used.
  112736. */
  112737. pinchDeltaPercentage: number;
  112738. /**
  112739. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  112740. */
  112741. axisXControlRadius: boolean;
  112742. /**
  112743. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  112744. */
  112745. axisXControlHeight: boolean;
  112746. /**
  112747. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  112748. */
  112749. axisXControlRotation: boolean;
  112750. /**
  112751. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  112752. */
  112753. axisYControlRadius: boolean;
  112754. /**
  112755. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  112756. */
  112757. axisYControlHeight: boolean;
  112758. /**
  112759. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  112760. */
  112761. axisYControlRotation: boolean;
  112762. /**
  112763. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  112764. */
  112765. axisPinchControlRadius: boolean;
  112766. /**
  112767. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  112768. */
  112769. axisPinchControlHeight: boolean;
  112770. /**
  112771. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  112772. */
  112773. axisPinchControlRotation: boolean;
  112774. /**
  112775. * Log error messages if basic misconfiguration has occurred.
  112776. */
  112777. warningEnable: boolean;
  112778. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112779. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112780. private _warningCounter;
  112781. private _warning;
  112782. }
  112783. }
  112784. declare module BABYLON {
  112785. /**
  112786. * Default Inputs manager for the FollowCamera.
  112787. * It groups all the default supported inputs for ease of use.
  112788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112789. */
  112790. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  112791. /**
  112792. * Instantiates a new FollowCameraInputsManager.
  112793. * @param camera Defines the camera the inputs belong to
  112794. */
  112795. constructor(camera: FollowCamera);
  112796. /**
  112797. * Add keyboard input support to the input manager.
  112798. * @returns the current input manager
  112799. */
  112800. addKeyboard(): FollowCameraInputsManager;
  112801. /**
  112802. * Add mouse wheel input support to the input manager.
  112803. * @returns the current input manager
  112804. */
  112805. addMouseWheel(): FollowCameraInputsManager;
  112806. /**
  112807. * Add pointers input support to the input manager.
  112808. * @returns the current input manager
  112809. */
  112810. addPointers(): FollowCameraInputsManager;
  112811. /**
  112812. * Add orientation input support to the input manager.
  112813. * @returns the current input manager
  112814. */
  112815. addVRDeviceOrientation(): FollowCameraInputsManager;
  112816. }
  112817. }
  112818. declare module BABYLON {
  112819. /**
  112820. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  112821. * an arc rotate version arcFollowCamera are available.
  112822. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112823. */
  112824. export class FollowCamera extends TargetCamera {
  112825. /**
  112826. * Distance the follow camera should follow an object at
  112827. */
  112828. radius: number;
  112829. /**
  112830. * Minimum allowed distance of the camera to the axis of rotation
  112831. * (The camera can not get closer).
  112832. * This can help limiting how the Camera is able to move in the scene.
  112833. */
  112834. lowerRadiusLimit: Nullable<number>;
  112835. /**
  112836. * Maximum allowed distance of the camera to the axis of rotation
  112837. * (The camera can not get further).
  112838. * This can help limiting how the Camera is able to move in the scene.
  112839. */
  112840. upperRadiusLimit: Nullable<number>;
  112841. /**
  112842. * Define a rotation offset between the camera and the object it follows
  112843. */
  112844. rotationOffset: number;
  112845. /**
  112846. * Minimum allowed angle to camera position relative to target object.
  112847. * This can help limiting how the Camera is able to move in the scene.
  112848. */
  112849. lowerRotationOffsetLimit: Nullable<number>;
  112850. /**
  112851. * Maximum allowed angle to camera position relative to target object.
  112852. * This can help limiting how the Camera is able to move in the scene.
  112853. */
  112854. upperRotationOffsetLimit: Nullable<number>;
  112855. /**
  112856. * Define a height offset between the camera and the object it follows.
  112857. * It can help following an object from the top (like a car chaing a plane)
  112858. */
  112859. heightOffset: number;
  112860. /**
  112861. * Minimum allowed height of camera position relative to target object.
  112862. * This can help limiting how the Camera is able to move in the scene.
  112863. */
  112864. lowerHeightOffsetLimit: Nullable<number>;
  112865. /**
  112866. * Maximum allowed height of camera position relative to target object.
  112867. * This can help limiting how the Camera is able to move in the scene.
  112868. */
  112869. upperHeightOffsetLimit: Nullable<number>;
  112870. /**
  112871. * Define how fast the camera can accelerate to follow it s target.
  112872. */
  112873. cameraAcceleration: number;
  112874. /**
  112875. * Define the speed limit of the camera following an object.
  112876. */
  112877. maxCameraSpeed: number;
  112878. /**
  112879. * Define the target of the camera.
  112880. */
  112881. lockedTarget: Nullable<AbstractMesh>;
  112882. /**
  112883. * Defines the input associated with the camera.
  112884. */
  112885. inputs: FollowCameraInputsManager;
  112886. /**
  112887. * Instantiates the follow camera.
  112888. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112889. * @param name Define the name of the camera in the scene
  112890. * @param position Define the position of the camera
  112891. * @param scene Define the scene the camera belong to
  112892. * @param lockedTarget Define the target of the camera
  112893. */
  112894. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  112895. private _follow;
  112896. /**
  112897. * Attached controls to the current camera.
  112898. * @param element Defines the element the controls should be listened from
  112899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112900. */
  112901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112902. /**
  112903. * Detach the current controls from the camera.
  112904. * The camera will stop reacting to inputs.
  112905. * @param element Defines the element to stop listening the inputs from
  112906. */
  112907. detachControl(element: HTMLElement): void;
  112908. /** @hidden */
  112909. _checkInputs(): void;
  112910. private _checkLimits;
  112911. /**
  112912. * Gets the camera class name.
  112913. * @returns the class name
  112914. */
  112915. getClassName(): string;
  112916. }
  112917. /**
  112918. * Arc Rotate version of the follow camera.
  112919. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  112920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112921. */
  112922. export class ArcFollowCamera extends TargetCamera {
  112923. /** The longitudinal angle of the camera */
  112924. alpha: number;
  112925. /** The latitudinal angle of the camera */
  112926. beta: number;
  112927. /** The radius of the camera from its target */
  112928. radius: number;
  112929. /** Define the camera target (the messh it should follow) */
  112930. target: Nullable<AbstractMesh>;
  112931. private _cartesianCoordinates;
  112932. /**
  112933. * Instantiates a new ArcFollowCamera
  112934. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112935. * @param name Define the name of the camera
  112936. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  112937. * @param beta Define the rotation angle of the camera around the elevation axis
  112938. * @param radius Define the radius of the camera from its target point
  112939. * @param target Define the target of the camera
  112940. * @param scene Define the scene the camera belongs to
  112941. */
  112942. constructor(name: string,
  112943. /** The longitudinal angle of the camera */
  112944. alpha: number,
  112945. /** The latitudinal angle of the camera */
  112946. beta: number,
  112947. /** The radius of the camera from its target */
  112948. radius: number,
  112949. /** Define the camera target (the messh it should follow) */
  112950. target: Nullable<AbstractMesh>, scene: Scene);
  112951. private _follow;
  112952. /** @hidden */
  112953. _checkInputs(): void;
  112954. /**
  112955. * Returns the class name of the object.
  112956. * It is mostly used internally for serialization purposes.
  112957. */
  112958. getClassName(): string;
  112959. }
  112960. }
  112961. declare module BABYLON {
  112962. /**
  112963. * Manage the keyboard inputs to control the movement of a follow camera.
  112964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112965. */
  112966. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  112967. /**
  112968. * Defines the camera the input is attached to.
  112969. */
  112970. camera: FollowCamera;
  112971. /**
  112972. * Defines the list of key codes associated with the up action (increase heightOffset)
  112973. */
  112974. keysHeightOffsetIncr: number[];
  112975. /**
  112976. * Defines the list of key codes associated with the down action (decrease heightOffset)
  112977. */
  112978. keysHeightOffsetDecr: number[];
  112979. /**
  112980. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  112981. */
  112982. keysHeightOffsetModifierAlt: boolean;
  112983. /**
  112984. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  112985. */
  112986. keysHeightOffsetModifierCtrl: boolean;
  112987. /**
  112988. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  112989. */
  112990. keysHeightOffsetModifierShift: boolean;
  112991. /**
  112992. * Defines the list of key codes associated with the left action (increase rotationOffset)
  112993. */
  112994. keysRotationOffsetIncr: number[];
  112995. /**
  112996. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  112997. */
  112998. keysRotationOffsetDecr: number[];
  112999. /**
  113000. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113001. */
  113002. keysRotationOffsetModifierAlt: boolean;
  113003. /**
  113004. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113005. */
  113006. keysRotationOffsetModifierCtrl: boolean;
  113007. /**
  113008. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113009. */
  113010. keysRotationOffsetModifierShift: boolean;
  113011. /**
  113012. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113013. */
  113014. keysRadiusIncr: number[];
  113015. /**
  113016. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113017. */
  113018. keysRadiusDecr: number[];
  113019. /**
  113020. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113021. */
  113022. keysRadiusModifierAlt: boolean;
  113023. /**
  113024. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113025. */
  113026. keysRadiusModifierCtrl: boolean;
  113027. /**
  113028. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113029. */
  113030. keysRadiusModifierShift: boolean;
  113031. /**
  113032. * Defines the rate of change of heightOffset.
  113033. */
  113034. heightSensibility: number;
  113035. /**
  113036. * Defines the rate of change of rotationOffset.
  113037. */
  113038. rotationSensibility: number;
  113039. /**
  113040. * Defines the rate of change of radius.
  113041. */
  113042. radiusSensibility: number;
  113043. private _keys;
  113044. private _ctrlPressed;
  113045. private _altPressed;
  113046. private _shiftPressed;
  113047. private _onCanvasBlurObserver;
  113048. private _onKeyboardObserver;
  113049. private _engine;
  113050. private _scene;
  113051. /**
  113052. * Attach the input controls to a specific dom element to get the input from.
  113053. * @param element Defines the element the controls should be listened from
  113054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113055. */
  113056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113057. /**
  113058. * Detach the current controls from the specified dom element.
  113059. * @param element Defines the element to stop listening the inputs from
  113060. */
  113061. detachControl(element: Nullable<HTMLElement>): void;
  113062. /**
  113063. * Update the current camera state depending on the inputs that have been used this frame.
  113064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113065. */
  113066. checkInputs(): void;
  113067. /**
  113068. * Gets the class name of the current input.
  113069. * @returns the class name
  113070. */
  113071. getClassName(): string;
  113072. /**
  113073. * Get the friendly name associated with the input class.
  113074. * @returns the input friendly name
  113075. */
  113076. getSimpleName(): string;
  113077. /**
  113078. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113079. * allow modification of the heightOffset value.
  113080. */
  113081. private _modifierHeightOffset;
  113082. /**
  113083. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113084. * allow modification of the rotationOffset value.
  113085. */
  113086. private _modifierRotationOffset;
  113087. /**
  113088. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113089. * allow modification of the radius value.
  113090. */
  113091. private _modifierRadius;
  113092. }
  113093. }
  113094. declare module BABYLON {
  113095. interface FreeCameraInputsManager {
  113096. /**
  113097. * @hidden
  113098. */
  113099. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113100. /**
  113101. * Add orientation input support to the input manager.
  113102. * @returns the current input manager
  113103. */
  113104. addDeviceOrientation(): FreeCameraInputsManager;
  113105. }
  113106. /**
  113107. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113108. * Screen rotation is taken into account.
  113109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113110. */
  113111. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113112. private _camera;
  113113. private _screenOrientationAngle;
  113114. private _constantTranform;
  113115. private _screenQuaternion;
  113116. private _alpha;
  113117. private _beta;
  113118. private _gamma;
  113119. /**
  113120. * Can be used to detect if a device orientation sensor is available on a device
  113121. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113122. * @returns a promise that will resolve on orientation change
  113123. */
  113124. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113125. /**
  113126. * @hidden
  113127. */
  113128. _onDeviceOrientationChangedObservable: Observable<void>;
  113129. /**
  113130. * Instantiates a new input
  113131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113132. */
  113133. constructor();
  113134. /**
  113135. * Define the camera controlled by the input.
  113136. */
  113137. get camera(): FreeCamera;
  113138. set camera(camera: FreeCamera);
  113139. /**
  113140. * Attach the input controls to a specific dom element to get the input from.
  113141. * @param element Defines the element the controls should be listened from
  113142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113143. */
  113144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113145. private _orientationChanged;
  113146. private _deviceOrientation;
  113147. /**
  113148. * Detach the current controls from the specified dom element.
  113149. * @param element Defines the element to stop listening the inputs from
  113150. */
  113151. detachControl(element: Nullable<HTMLElement>): void;
  113152. /**
  113153. * Update the current camera state depending on the inputs that have been used this frame.
  113154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113155. */
  113156. checkInputs(): void;
  113157. /**
  113158. * Gets the class name of the current intput.
  113159. * @returns the class name
  113160. */
  113161. getClassName(): string;
  113162. /**
  113163. * Get the friendly name associated with the input class.
  113164. * @returns the input friendly name
  113165. */
  113166. getSimpleName(): string;
  113167. }
  113168. }
  113169. declare module BABYLON {
  113170. /**
  113171. * Manage the gamepad inputs to control a free camera.
  113172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113173. */
  113174. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113175. /**
  113176. * Define the camera the input is attached to.
  113177. */
  113178. camera: FreeCamera;
  113179. /**
  113180. * Define the Gamepad controlling the input
  113181. */
  113182. gamepad: Nullable<Gamepad>;
  113183. /**
  113184. * Defines the gamepad rotation sensiblity.
  113185. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113186. */
  113187. gamepadAngularSensibility: number;
  113188. /**
  113189. * Defines the gamepad move sensiblity.
  113190. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113191. */
  113192. gamepadMoveSensibility: number;
  113193. private _yAxisScale;
  113194. /**
  113195. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113196. */
  113197. get invertYAxis(): boolean;
  113198. set invertYAxis(value: boolean);
  113199. private _onGamepadConnectedObserver;
  113200. private _onGamepadDisconnectedObserver;
  113201. private _cameraTransform;
  113202. private _deltaTransform;
  113203. private _vector3;
  113204. private _vector2;
  113205. /**
  113206. * Attach the input controls to a specific dom element to get the input from.
  113207. * @param element Defines the element the controls should be listened from
  113208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113209. */
  113210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113211. /**
  113212. * Detach the current controls from the specified dom element.
  113213. * @param element Defines the element to stop listening the inputs from
  113214. */
  113215. detachControl(element: Nullable<HTMLElement>): void;
  113216. /**
  113217. * Update the current camera state depending on the inputs that have been used this frame.
  113218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113219. */
  113220. checkInputs(): void;
  113221. /**
  113222. * Gets the class name of the current intput.
  113223. * @returns the class name
  113224. */
  113225. getClassName(): string;
  113226. /**
  113227. * Get the friendly name associated with the input class.
  113228. * @returns the input friendly name
  113229. */
  113230. getSimpleName(): string;
  113231. }
  113232. }
  113233. declare module BABYLON {
  113234. /**
  113235. * Defines the potential axis of a Joystick
  113236. */
  113237. export enum JoystickAxis {
  113238. /** X axis */
  113239. X = 0,
  113240. /** Y axis */
  113241. Y = 1,
  113242. /** Z axis */
  113243. Z = 2
  113244. }
  113245. /**
  113246. * Class used to define virtual joystick (used in touch mode)
  113247. */
  113248. export class VirtualJoystick {
  113249. /**
  113250. * Gets or sets a boolean indicating that left and right values must be inverted
  113251. */
  113252. reverseLeftRight: boolean;
  113253. /**
  113254. * Gets or sets a boolean indicating that up and down values must be inverted
  113255. */
  113256. reverseUpDown: boolean;
  113257. /**
  113258. * Gets the offset value for the position (ie. the change of the position value)
  113259. */
  113260. deltaPosition: Vector3;
  113261. /**
  113262. * Gets a boolean indicating if the virtual joystick was pressed
  113263. */
  113264. pressed: boolean;
  113265. /**
  113266. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113267. */
  113268. static Canvas: Nullable<HTMLCanvasElement>;
  113269. private static _globalJoystickIndex;
  113270. private static vjCanvasContext;
  113271. private static vjCanvasWidth;
  113272. private static vjCanvasHeight;
  113273. private static halfWidth;
  113274. private _action;
  113275. private _axisTargetedByLeftAndRight;
  113276. private _axisTargetedByUpAndDown;
  113277. private _joystickSensibility;
  113278. private _inversedSensibility;
  113279. private _joystickPointerID;
  113280. private _joystickColor;
  113281. private _joystickPointerPos;
  113282. private _joystickPreviousPointerPos;
  113283. private _joystickPointerStartPos;
  113284. private _deltaJoystickVector;
  113285. private _leftJoystick;
  113286. private _touches;
  113287. private _onPointerDownHandlerRef;
  113288. private _onPointerMoveHandlerRef;
  113289. private _onPointerUpHandlerRef;
  113290. private _onResize;
  113291. /**
  113292. * Creates a new virtual joystick
  113293. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113294. */
  113295. constructor(leftJoystick?: boolean);
  113296. /**
  113297. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113298. * @param newJoystickSensibility defines the new sensibility
  113299. */
  113300. setJoystickSensibility(newJoystickSensibility: number): void;
  113301. private _onPointerDown;
  113302. private _onPointerMove;
  113303. private _onPointerUp;
  113304. /**
  113305. * Change the color of the virtual joystick
  113306. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113307. */
  113308. setJoystickColor(newColor: string): void;
  113309. /**
  113310. * Defines a callback to call when the joystick is touched
  113311. * @param action defines the callback
  113312. */
  113313. setActionOnTouch(action: () => any): void;
  113314. /**
  113315. * Defines which axis you'd like to control for left & right
  113316. * @param axis defines the axis to use
  113317. */
  113318. setAxisForLeftRight(axis: JoystickAxis): void;
  113319. /**
  113320. * Defines which axis you'd like to control for up & down
  113321. * @param axis defines the axis to use
  113322. */
  113323. setAxisForUpDown(axis: JoystickAxis): void;
  113324. private _drawVirtualJoystick;
  113325. /**
  113326. * Release internal HTML canvas
  113327. */
  113328. releaseCanvas(): void;
  113329. }
  113330. }
  113331. declare module BABYLON {
  113332. interface FreeCameraInputsManager {
  113333. /**
  113334. * Add virtual joystick input support to the input manager.
  113335. * @returns the current input manager
  113336. */
  113337. addVirtualJoystick(): FreeCameraInputsManager;
  113338. }
  113339. /**
  113340. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113342. */
  113343. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113344. /**
  113345. * Defines the camera the input is attached to.
  113346. */
  113347. camera: FreeCamera;
  113348. private _leftjoystick;
  113349. private _rightjoystick;
  113350. /**
  113351. * Gets the left stick of the virtual joystick.
  113352. * @returns The virtual Joystick
  113353. */
  113354. getLeftJoystick(): VirtualJoystick;
  113355. /**
  113356. * Gets the right stick of the virtual joystick.
  113357. * @returns The virtual Joystick
  113358. */
  113359. getRightJoystick(): VirtualJoystick;
  113360. /**
  113361. * Update the current camera state depending on the inputs that have been used this frame.
  113362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113363. */
  113364. checkInputs(): void;
  113365. /**
  113366. * Attach the input controls to a specific dom element to get the input from.
  113367. * @param element Defines the element the controls should be listened from
  113368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113369. */
  113370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113371. /**
  113372. * Detach the current controls from the specified dom element.
  113373. * @param element Defines the element to stop listening the inputs from
  113374. */
  113375. detachControl(element: Nullable<HTMLElement>): void;
  113376. /**
  113377. * Gets the class name of the current intput.
  113378. * @returns the class name
  113379. */
  113380. getClassName(): string;
  113381. /**
  113382. * Get the friendly name associated with the input class.
  113383. * @returns the input friendly name
  113384. */
  113385. getSimpleName(): string;
  113386. }
  113387. }
  113388. declare module BABYLON {
  113389. /**
  113390. * This represents a FPS type of camera controlled by touch.
  113391. * This is like a universal camera minus the Gamepad controls.
  113392. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113393. */
  113394. export class TouchCamera extends FreeCamera {
  113395. /**
  113396. * Defines the touch sensibility for rotation.
  113397. * The higher the faster.
  113398. */
  113399. get touchAngularSensibility(): number;
  113400. set touchAngularSensibility(value: number);
  113401. /**
  113402. * Defines the touch sensibility for move.
  113403. * The higher the faster.
  113404. */
  113405. get touchMoveSensibility(): number;
  113406. set touchMoveSensibility(value: number);
  113407. /**
  113408. * Instantiates a new touch camera.
  113409. * This represents a FPS type of camera controlled by touch.
  113410. * This is like a universal camera minus the Gamepad controls.
  113411. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113412. * @param name Define the name of the camera in the scene
  113413. * @param position Define the start position of the camera in the scene
  113414. * @param scene Define the scene the camera belongs to
  113415. */
  113416. constructor(name: string, position: Vector3, scene: Scene);
  113417. /**
  113418. * Gets the current object class name.
  113419. * @return the class name
  113420. */
  113421. getClassName(): string;
  113422. /** @hidden */
  113423. _setupInputs(): void;
  113424. }
  113425. }
  113426. declare module BABYLON {
  113427. /**
  113428. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  113429. * being tilted forward or back and left or right.
  113430. */
  113431. export class DeviceOrientationCamera extends FreeCamera {
  113432. private _initialQuaternion;
  113433. private _quaternionCache;
  113434. private _tmpDragQuaternion;
  113435. private _disablePointerInputWhenUsingDeviceOrientation;
  113436. /**
  113437. * Creates a new device orientation camera
  113438. * @param name The name of the camera
  113439. * @param position The start position camera
  113440. * @param scene The scene the camera belongs to
  113441. */
  113442. constructor(name: string, position: Vector3, scene: Scene);
  113443. /**
  113444. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  113445. */
  113446. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  113447. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  113448. private _dragFactor;
  113449. /**
  113450. * Enabled turning on the y axis when the orientation sensor is active
  113451. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  113452. */
  113453. enableHorizontalDragging(dragFactor?: number): void;
  113454. /**
  113455. * Gets the current instance class name ("DeviceOrientationCamera").
  113456. * This helps avoiding instanceof at run time.
  113457. * @returns the class name
  113458. */
  113459. getClassName(): string;
  113460. /**
  113461. * @hidden
  113462. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  113463. */
  113464. _checkInputs(): void;
  113465. /**
  113466. * Reset the camera to its default orientation on the specified axis only.
  113467. * @param axis The axis to reset
  113468. */
  113469. resetToCurrentRotation(axis?: Axis): void;
  113470. }
  113471. }
  113472. declare module BABYLON {
  113473. /**
  113474. * Defines supported buttons for XBox360 compatible gamepads
  113475. */
  113476. export enum Xbox360Button {
  113477. /** A */
  113478. A = 0,
  113479. /** B */
  113480. B = 1,
  113481. /** X */
  113482. X = 2,
  113483. /** Y */
  113484. Y = 3,
  113485. /** Start */
  113486. Start = 4,
  113487. /** Back */
  113488. Back = 5,
  113489. /** Left button */
  113490. LB = 6,
  113491. /** Right button */
  113492. RB = 7,
  113493. /** Left stick */
  113494. LeftStick = 8,
  113495. /** Right stick */
  113496. RightStick = 9
  113497. }
  113498. /** Defines values for XBox360 DPad */
  113499. export enum Xbox360Dpad {
  113500. /** Up */
  113501. Up = 0,
  113502. /** Down */
  113503. Down = 1,
  113504. /** Left */
  113505. Left = 2,
  113506. /** Right */
  113507. Right = 3
  113508. }
  113509. /**
  113510. * Defines a XBox360 gamepad
  113511. */
  113512. export class Xbox360Pad extends Gamepad {
  113513. private _leftTrigger;
  113514. private _rightTrigger;
  113515. private _onlefttriggerchanged;
  113516. private _onrighttriggerchanged;
  113517. private _onbuttondown;
  113518. private _onbuttonup;
  113519. private _ondpaddown;
  113520. private _ondpadup;
  113521. /** Observable raised when a button is pressed */
  113522. onButtonDownObservable: Observable<Xbox360Button>;
  113523. /** Observable raised when a button is released */
  113524. onButtonUpObservable: Observable<Xbox360Button>;
  113525. /** Observable raised when a pad is pressed */
  113526. onPadDownObservable: Observable<Xbox360Dpad>;
  113527. /** Observable raised when a pad is released */
  113528. onPadUpObservable: Observable<Xbox360Dpad>;
  113529. private _buttonA;
  113530. private _buttonB;
  113531. private _buttonX;
  113532. private _buttonY;
  113533. private _buttonBack;
  113534. private _buttonStart;
  113535. private _buttonLB;
  113536. private _buttonRB;
  113537. private _buttonLeftStick;
  113538. private _buttonRightStick;
  113539. private _dPadUp;
  113540. private _dPadDown;
  113541. private _dPadLeft;
  113542. private _dPadRight;
  113543. private _isXboxOnePad;
  113544. /**
  113545. * Creates a new XBox360 gamepad object
  113546. * @param id defines the id of this gamepad
  113547. * @param index defines its index
  113548. * @param gamepad defines the internal HTML gamepad object
  113549. * @param xboxOne defines if it is a XBox One gamepad
  113550. */
  113551. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  113552. /**
  113553. * Defines the callback to call when left trigger is pressed
  113554. * @param callback defines the callback to use
  113555. */
  113556. onlefttriggerchanged(callback: (value: number) => void): void;
  113557. /**
  113558. * Defines the callback to call when right trigger is pressed
  113559. * @param callback defines the callback to use
  113560. */
  113561. onrighttriggerchanged(callback: (value: number) => void): void;
  113562. /**
  113563. * Gets the left trigger value
  113564. */
  113565. get leftTrigger(): number;
  113566. /**
  113567. * Sets the left trigger value
  113568. */
  113569. set leftTrigger(newValue: number);
  113570. /**
  113571. * Gets the right trigger value
  113572. */
  113573. get rightTrigger(): number;
  113574. /**
  113575. * Sets the right trigger value
  113576. */
  113577. set rightTrigger(newValue: number);
  113578. /**
  113579. * Defines the callback to call when a button is pressed
  113580. * @param callback defines the callback to use
  113581. */
  113582. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  113583. /**
  113584. * Defines the callback to call when a button is released
  113585. * @param callback defines the callback to use
  113586. */
  113587. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  113588. /**
  113589. * Defines the callback to call when a pad is pressed
  113590. * @param callback defines the callback to use
  113591. */
  113592. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  113593. /**
  113594. * Defines the callback to call when a pad is released
  113595. * @param callback defines the callback to use
  113596. */
  113597. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  113598. private _setButtonValue;
  113599. private _setDPadValue;
  113600. /**
  113601. * Gets the value of the `A` button
  113602. */
  113603. get buttonA(): number;
  113604. /**
  113605. * Sets the value of the `A` button
  113606. */
  113607. set buttonA(value: number);
  113608. /**
  113609. * Gets the value of the `B` button
  113610. */
  113611. get buttonB(): number;
  113612. /**
  113613. * Sets the value of the `B` button
  113614. */
  113615. set buttonB(value: number);
  113616. /**
  113617. * Gets the value of the `X` button
  113618. */
  113619. get buttonX(): number;
  113620. /**
  113621. * Sets the value of the `X` button
  113622. */
  113623. set buttonX(value: number);
  113624. /**
  113625. * Gets the value of the `Y` button
  113626. */
  113627. get buttonY(): number;
  113628. /**
  113629. * Sets the value of the `Y` button
  113630. */
  113631. set buttonY(value: number);
  113632. /**
  113633. * Gets the value of the `Start` button
  113634. */
  113635. get buttonStart(): number;
  113636. /**
  113637. * Sets the value of the `Start` button
  113638. */
  113639. set buttonStart(value: number);
  113640. /**
  113641. * Gets the value of the `Back` button
  113642. */
  113643. get buttonBack(): number;
  113644. /**
  113645. * Sets the value of the `Back` button
  113646. */
  113647. set buttonBack(value: number);
  113648. /**
  113649. * Gets the value of the `Left` button
  113650. */
  113651. get buttonLB(): number;
  113652. /**
  113653. * Sets the value of the `Left` button
  113654. */
  113655. set buttonLB(value: number);
  113656. /**
  113657. * Gets the value of the `Right` button
  113658. */
  113659. get buttonRB(): number;
  113660. /**
  113661. * Sets the value of the `Right` button
  113662. */
  113663. set buttonRB(value: number);
  113664. /**
  113665. * Gets the value of the Left joystick
  113666. */
  113667. get buttonLeftStick(): number;
  113668. /**
  113669. * Sets the value of the Left joystick
  113670. */
  113671. set buttonLeftStick(value: number);
  113672. /**
  113673. * Gets the value of the Right joystick
  113674. */
  113675. get buttonRightStick(): number;
  113676. /**
  113677. * Sets the value of the Right joystick
  113678. */
  113679. set buttonRightStick(value: number);
  113680. /**
  113681. * Gets the value of D-pad up
  113682. */
  113683. get dPadUp(): number;
  113684. /**
  113685. * Sets the value of D-pad up
  113686. */
  113687. set dPadUp(value: number);
  113688. /**
  113689. * Gets the value of D-pad down
  113690. */
  113691. get dPadDown(): number;
  113692. /**
  113693. * Sets the value of D-pad down
  113694. */
  113695. set dPadDown(value: number);
  113696. /**
  113697. * Gets the value of D-pad left
  113698. */
  113699. get dPadLeft(): number;
  113700. /**
  113701. * Sets the value of D-pad left
  113702. */
  113703. set dPadLeft(value: number);
  113704. /**
  113705. * Gets the value of D-pad right
  113706. */
  113707. get dPadRight(): number;
  113708. /**
  113709. * Sets the value of D-pad right
  113710. */
  113711. set dPadRight(value: number);
  113712. /**
  113713. * Force the gamepad to synchronize with device values
  113714. */
  113715. update(): void;
  113716. /**
  113717. * Disposes the gamepad
  113718. */
  113719. dispose(): void;
  113720. }
  113721. }
  113722. declare module BABYLON {
  113723. /**
  113724. * Defines supported buttons for DualShock compatible gamepads
  113725. */
  113726. export enum DualShockButton {
  113727. /** Cross */
  113728. Cross = 0,
  113729. /** Circle */
  113730. Circle = 1,
  113731. /** Square */
  113732. Square = 2,
  113733. /** Triangle */
  113734. Triangle = 3,
  113735. /** Options */
  113736. Options = 4,
  113737. /** Share */
  113738. Share = 5,
  113739. /** L1 */
  113740. L1 = 6,
  113741. /** R1 */
  113742. R1 = 7,
  113743. /** Left stick */
  113744. LeftStick = 8,
  113745. /** Right stick */
  113746. RightStick = 9
  113747. }
  113748. /** Defines values for DualShock DPad */
  113749. export enum DualShockDpad {
  113750. /** Up */
  113751. Up = 0,
  113752. /** Down */
  113753. Down = 1,
  113754. /** Left */
  113755. Left = 2,
  113756. /** Right */
  113757. Right = 3
  113758. }
  113759. /**
  113760. * Defines a DualShock gamepad
  113761. */
  113762. export class DualShockPad extends Gamepad {
  113763. private _leftTrigger;
  113764. private _rightTrigger;
  113765. private _onlefttriggerchanged;
  113766. private _onrighttriggerchanged;
  113767. private _onbuttondown;
  113768. private _onbuttonup;
  113769. private _ondpaddown;
  113770. private _ondpadup;
  113771. /** Observable raised when a button is pressed */
  113772. onButtonDownObservable: Observable<DualShockButton>;
  113773. /** Observable raised when a button is released */
  113774. onButtonUpObservable: Observable<DualShockButton>;
  113775. /** Observable raised when a pad is pressed */
  113776. onPadDownObservable: Observable<DualShockDpad>;
  113777. /** Observable raised when a pad is released */
  113778. onPadUpObservable: Observable<DualShockDpad>;
  113779. private _buttonCross;
  113780. private _buttonCircle;
  113781. private _buttonSquare;
  113782. private _buttonTriangle;
  113783. private _buttonShare;
  113784. private _buttonOptions;
  113785. private _buttonL1;
  113786. private _buttonR1;
  113787. private _buttonLeftStick;
  113788. private _buttonRightStick;
  113789. private _dPadUp;
  113790. private _dPadDown;
  113791. private _dPadLeft;
  113792. private _dPadRight;
  113793. /**
  113794. * Creates a new DualShock gamepad object
  113795. * @param id defines the id of this gamepad
  113796. * @param index defines its index
  113797. * @param gamepad defines the internal HTML gamepad object
  113798. */
  113799. constructor(id: string, index: number, gamepad: any);
  113800. /**
  113801. * Defines the callback to call when left trigger is pressed
  113802. * @param callback defines the callback to use
  113803. */
  113804. onlefttriggerchanged(callback: (value: number) => void): void;
  113805. /**
  113806. * Defines the callback to call when right trigger is pressed
  113807. * @param callback defines the callback to use
  113808. */
  113809. onrighttriggerchanged(callback: (value: number) => void): void;
  113810. /**
  113811. * Gets the left trigger value
  113812. */
  113813. get leftTrigger(): number;
  113814. /**
  113815. * Sets the left trigger value
  113816. */
  113817. set leftTrigger(newValue: number);
  113818. /**
  113819. * Gets the right trigger value
  113820. */
  113821. get rightTrigger(): number;
  113822. /**
  113823. * Sets the right trigger value
  113824. */
  113825. set rightTrigger(newValue: number);
  113826. /**
  113827. * Defines the callback to call when a button is pressed
  113828. * @param callback defines the callback to use
  113829. */
  113830. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  113831. /**
  113832. * Defines the callback to call when a button is released
  113833. * @param callback defines the callback to use
  113834. */
  113835. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  113836. /**
  113837. * Defines the callback to call when a pad is pressed
  113838. * @param callback defines the callback to use
  113839. */
  113840. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  113841. /**
  113842. * Defines the callback to call when a pad is released
  113843. * @param callback defines the callback to use
  113844. */
  113845. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  113846. private _setButtonValue;
  113847. private _setDPadValue;
  113848. /**
  113849. * Gets the value of the `Cross` button
  113850. */
  113851. get buttonCross(): number;
  113852. /**
  113853. * Sets the value of the `Cross` button
  113854. */
  113855. set buttonCross(value: number);
  113856. /**
  113857. * Gets the value of the `Circle` button
  113858. */
  113859. get buttonCircle(): number;
  113860. /**
  113861. * Sets the value of the `Circle` button
  113862. */
  113863. set buttonCircle(value: number);
  113864. /**
  113865. * Gets the value of the `Square` button
  113866. */
  113867. get buttonSquare(): number;
  113868. /**
  113869. * Sets the value of the `Square` button
  113870. */
  113871. set buttonSquare(value: number);
  113872. /**
  113873. * Gets the value of the `Triangle` button
  113874. */
  113875. get buttonTriangle(): number;
  113876. /**
  113877. * Sets the value of the `Triangle` button
  113878. */
  113879. set buttonTriangle(value: number);
  113880. /**
  113881. * Gets the value of the `Options` button
  113882. */
  113883. get buttonOptions(): number;
  113884. /**
  113885. * Sets the value of the `Options` button
  113886. */
  113887. set buttonOptions(value: number);
  113888. /**
  113889. * Gets the value of the `Share` button
  113890. */
  113891. get buttonShare(): number;
  113892. /**
  113893. * Sets the value of the `Share` button
  113894. */
  113895. set buttonShare(value: number);
  113896. /**
  113897. * Gets the value of the `L1` button
  113898. */
  113899. get buttonL1(): number;
  113900. /**
  113901. * Sets the value of the `L1` button
  113902. */
  113903. set buttonL1(value: number);
  113904. /**
  113905. * Gets the value of the `R1` button
  113906. */
  113907. get buttonR1(): number;
  113908. /**
  113909. * Sets the value of the `R1` button
  113910. */
  113911. set buttonR1(value: number);
  113912. /**
  113913. * Gets the value of the Left joystick
  113914. */
  113915. get buttonLeftStick(): number;
  113916. /**
  113917. * Sets the value of the Left joystick
  113918. */
  113919. set buttonLeftStick(value: number);
  113920. /**
  113921. * Gets the value of the Right joystick
  113922. */
  113923. get buttonRightStick(): number;
  113924. /**
  113925. * Sets the value of the Right joystick
  113926. */
  113927. set buttonRightStick(value: number);
  113928. /**
  113929. * Gets the value of D-pad up
  113930. */
  113931. get dPadUp(): number;
  113932. /**
  113933. * Sets the value of D-pad up
  113934. */
  113935. set dPadUp(value: number);
  113936. /**
  113937. * Gets the value of D-pad down
  113938. */
  113939. get dPadDown(): number;
  113940. /**
  113941. * Sets the value of D-pad down
  113942. */
  113943. set dPadDown(value: number);
  113944. /**
  113945. * Gets the value of D-pad left
  113946. */
  113947. get dPadLeft(): number;
  113948. /**
  113949. * Sets the value of D-pad left
  113950. */
  113951. set dPadLeft(value: number);
  113952. /**
  113953. * Gets the value of D-pad right
  113954. */
  113955. get dPadRight(): number;
  113956. /**
  113957. * Sets the value of D-pad right
  113958. */
  113959. set dPadRight(value: number);
  113960. /**
  113961. * Force the gamepad to synchronize with device values
  113962. */
  113963. update(): void;
  113964. /**
  113965. * Disposes the gamepad
  113966. */
  113967. dispose(): void;
  113968. }
  113969. }
  113970. declare module BABYLON {
  113971. /**
  113972. * Manager for handling gamepads
  113973. */
  113974. export class GamepadManager {
  113975. private _scene?;
  113976. private _babylonGamepads;
  113977. private _oneGamepadConnected;
  113978. /** @hidden */
  113979. _isMonitoring: boolean;
  113980. private _gamepadEventSupported;
  113981. private _gamepadSupport?;
  113982. /**
  113983. * observable to be triggered when the gamepad controller has been connected
  113984. */
  113985. onGamepadConnectedObservable: Observable<Gamepad>;
  113986. /**
  113987. * observable to be triggered when the gamepad controller has been disconnected
  113988. */
  113989. onGamepadDisconnectedObservable: Observable<Gamepad>;
  113990. private _onGamepadConnectedEvent;
  113991. private _onGamepadDisconnectedEvent;
  113992. /**
  113993. * Initializes the gamepad manager
  113994. * @param _scene BabylonJS scene
  113995. */
  113996. constructor(_scene?: Scene | undefined);
  113997. /**
  113998. * The gamepads in the game pad manager
  113999. */
  114000. get gamepads(): Gamepad[];
  114001. /**
  114002. * Get the gamepad controllers based on type
  114003. * @param type The type of gamepad controller
  114004. * @returns Nullable gamepad
  114005. */
  114006. getGamepadByType(type?: number): Nullable<Gamepad>;
  114007. /**
  114008. * Disposes the gamepad manager
  114009. */
  114010. dispose(): void;
  114011. private _addNewGamepad;
  114012. private _startMonitoringGamepads;
  114013. private _stopMonitoringGamepads;
  114014. /** @hidden */
  114015. _checkGamepadsStatus(): void;
  114016. private _updateGamepadObjects;
  114017. }
  114018. }
  114019. declare module BABYLON {
  114020. interface Scene {
  114021. /** @hidden */
  114022. _gamepadManager: Nullable<GamepadManager>;
  114023. /**
  114024. * Gets the gamepad manager associated with the scene
  114025. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114026. */
  114027. gamepadManager: GamepadManager;
  114028. }
  114029. /**
  114030. * Interface representing a free camera inputs manager
  114031. */
  114032. interface FreeCameraInputsManager {
  114033. /**
  114034. * Adds gamepad input support to the FreeCameraInputsManager.
  114035. * @returns the FreeCameraInputsManager
  114036. */
  114037. addGamepad(): FreeCameraInputsManager;
  114038. }
  114039. /**
  114040. * Interface representing an arc rotate camera inputs manager
  114041. */
  114042. interface ArcRotateCameraInputsManager {
  114043. /**
  114044. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114045. * @returns the camera inputs manager
  114046. */
  114047. addGamepad(): ArcRotateCameraInputsManager;
  114048. }
  114049. /**
  114050. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114051. */
  114052. export class GamepadSystemSceneComponent implements ISceneComponent {
  114053. /**
  114054. * The component name helpfull to identify the component in the list of scene components.
  114055. */
  114056. readonly name: string;
  114057. /**
  114058. * The scene the component belongs to.
  114059. */
  114060. scene: Scene;
  114061. /**
  114062. * Creates a new instance of the component for the given scene
  114063. * @param scene Defines the scene to register the component in
  114064. */
  114065. constructor(scene: Scene);
  114066. /**
  114067. * Registers the component in a given scene
  114068. */
  114069. register(): void;
  114070. /**
  114071. * Rebuilds the elements related to this component in case of
  114072. * context lost for instance.
  114073. */
  114074. rebuild(): void;
  114075. /**
  114076. * Disposes the component and the associated ressources
  114077. */
  114078. dispose(): void;
  114079. private _beforeCameraUpdate;
  114080. }
  114081. }
  114082. declare module BABYLON {
  114083. /**
  114084. * 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,
  114085. * which still works and will still be found in many Playgrounds.
  114086. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114087. */
  114088. export class UniversalCamera extends TouchCamera {
  114089. /**
  114090. * Defines the gamepad rotation sensiblity.
  114091. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114092. */
  114093. get gamepadAngularSensibility(): number;
  114094. set gamepadAngularSensibility(value: number);
  114095. /**
  114096. * Defines the gamepad move sensiblity.
  114097. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114098. */
  114099. get gamepadMoveSensibility(): number;
  114100. set gamepadMoveSensibility(value: number);
  114101. /**
  114102. * 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,
  114103. * which still works and will still be found in many Playgrounds.
  114104. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114105. * @param name Define the name of the camera in the scene
  114106. * @param position Define the start position of the camera in the scene
  114107. * @param scene Define the scene the camera belongs to
  114108. */
  114109. constructor(name: string, position: Vector3, scene: Scene);
  114110. /**
  114111. * Gets the current object class name.
  114112. * @return the class name
  114113. */
  114114. getClassName(): string;
  114115. }
  114116. }
  114117. declare module BABYLON {
  114118. /**
  114119. * This represents a FPS type of camera. This is only here for back compat purpose.
  114120. * Please use the UniversalCamera instead as both are identical.
  114121. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114122. */
  114123. export class GamepadCamera extends UniversalCamera {
  114124. /**
  114125. * Instantiates a new Gamepad Camera
  114126. * This represents a FPS type of camera. This is only here for back compat purpose.
  114127. * Please use the UniversalCamera instead as both are identical.
  114128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114129. * @param name Define the name of the camera in the scene
  114130. * @param position Define the start position of the camera in the scene
  114131. * @param scene Define the scene the camera belongs to
  114132. */
  114133. constructor(name: string, position: Vector3, scene: Scene);
  114134. /**
  114135. * Gets the current object class name.
  114136. * @return the class name
  114137. */
  114138. getClassName(): string;
  114139. }
  114140. }
  114141. declare module BABYLON {
  114142. /** @hidden */
  114143. export var passPixelShader: {
  114144. name: string;
  114145. shader: string;
  114146. };
  114147. }
  114148. declare module BABYLON {
  114149. /** @hidden */
  114150. export var passCubePixelShader: {
  114151. name: string;
  114152. shader: string;
  114153. };
  114154. }
  114155. declare module BABYLON {
  114156. /**
  114157. * PassPostProcess which produces an output the same as it's input
  114158. */
  114159. export class PassPostProcess extends PostProcess {
  114160. /**
  114161. * Creates the PassPostProcess
  114162. * @param name The name of the effect.
  114163. * @param options The required width/height ratio to downsize to before computing the render pass.
  114164. * @param camera The camera to apply the render pass to.
  114165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114166. * @param engine The engine which the post process will be applied. (default: current engine)
  114167. * @param reusable If the post process can be reused on the same frame. (default: false)
  114168. * @param textureType The type of texture to be used when performing the post processing.
  114169. * @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)
  114170. */
  114171. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114172. }
  114173. /**
  114174. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114175. */
  114176. export class PassCubePostProcess extends PostProcess {
  114177. private _face;
  114178. /**
  114179. * Gets or sets the cube face to display.
  114180. * * 0 is +X
  114181. * * 1 is -X
  114182. * * 2 is +Y
  114183. * * 3 is -Y
  114184. * * 4 is +Z
  114185. * * 5 is -Z
  114186. */
  114187. get face(): number;
  114188. set face(value: number);
  114189. /**
  114190. * Creates the PassCubePostProcess
  114191. * @param name The name of the effect.
  114192. * @param options The required width/height ratio to downsize to before computing the render pass.
  114193. * @param camera The camera to apply the render pass to.
  114194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114195. * @param engine The engine which the post process will be applied. (default: current engine)
  114196. * @param reusable If the post process can be reused on the same frame. (default: false)
  114197. * @param textureType The type of texture to be used when performing the post processing.
  114198. * @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)
  114199. */
  114200. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114201. }
  114202. }
  114203. declare module BABYLON {
  114204. /** @hidden */
  114205. export var anaglyphPixelShader: {
  114206. name: string;
  114207. shader: string;
  114208. };
  114209. }
  114210. declare module BABYLON {
  114211. /**
  114212. * Postprocess used to generate anaglyphic rendering
  114213. */
  114214. export class AnaglyphPostProcess extends PostProcess {
  114215. private _passedProcess;
  114216. /**
  114217. * Creates a new AnaglyphPostProcess
  114218. * @param name defines postprocess name
  114219. * @param options defines creation options or target ratio scale
  114220. * @param rigCameras defines cameras using this postprocess
  114221. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114222. * @param engine defines hosting engine
  114223. * @param reusable defines if the postprocess will be reused multiple times per frame
  114224. */
  114225. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114226. }
  114227. }
  114228. declare module BABYLON {
  114229. /**
  114230. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114231. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114232. */
  114233. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114234. /**
  114235. * Creates a new AnaglyphArcRotateCamera
  114236. * @param name defines camera name
  114237. * @param alpha defines alpha angle (in radians)
  114238. * @param beta defines beta angle (in radians)
  114239. * @param radius defines radius
  114240. * @param target defines camera target
  114241. * @param interaxialDistance defines distance between each color axis
  114242. * @param scene defines the hosting scene
  114243. */
  114244. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114245. /**
  114246. * Gets camera class name
  114247. * @returns AnaglyphArcRotateCamera
  114248. */
  114249. getClassName(): string;
  114250. }
  114251. }
  114252. declare module BABYLON {
  114253. /**
  114254. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114255. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114256. */
  114257. export class AnaglyphFreeCamera extends FreeCamera {
  114258. /**
  114259. * Creates a new AnaglyphFreeCamera
  114260. * @param name defines camera name
  114261. * @param position defines initial position
  114262. * @param interaxialDistance defines distance between each color axis
  114263. * @param scene defines the hosting scene
  114264. */
  114265. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114266. /**
  114267. * Gets camera class name
  114268. * @returns AnaglyphFreeCamera
  114269. */
  114270. getClassName(): string;
  114271. }
  114272. }
  114273. declare module BABYLON {
  114274. /**
  114275. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114276. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114277. */
  114278. export class AnaglyphGamepadCamera extends GamepadCamera {
  114279. /**
  114280. * Creates a new AnaglyphGamepadCamera
  114281. * @param name defines camera name
  114282. * @param position defines initial position
  114283. * @param interaxialDistance defines distance between each color axis
  114284. * @param scene defines the hosting scene
  114285. */
  114286. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114287. /**
  114288. * Gets camera class name
  114289. * @returns AnaglyphGamepadCamera
  114290. */
  114291. getClassName(): string;
  114292. }
  114293. }
  114294. declare module BABYLON {
  114295. /**
  114296. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114297. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114298. */
  114299. export class AnaglyphUniversalCamera extends UniversalCamera {
  114300. /**
  114301. * Creates a new AnaglyphUniversalCamera
  114302. * @param name defines camera name
  114303. * @param position defines initial position
  114304. * @param interaxialDistance defines distance between each color axis
  114305. * @param scene defines the hosting scene
  114306. */
  114307. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114308. /**
  114309. * Gets camera class name
  114310. * @returns AnaglyphUniversalCamera
  114311. */
  114312. getClassName(): string;
  114313. }
  114314. }
  114315. declare module BABYLON {
  114316. /** @hidden */
  114317. export var stereoscopicInterlacePixelShader: {
  114318. name: string;
  114319. shader: string;
  114320. };
  114321. }
  114322. declare module BABYLON {
  114323. /**
  114324. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114325. */
  114326. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114327. private _stepSize;
  114328. private _passedProcess;
  114329. /**
  114330. * Initializes a StereoscopicInterlacePostProcessI
  114331. * @param name The name of the effect.
  114332. * @param rigCameras The rig cameras to be appled to the post process
  114333. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114334. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114336. * @param engine The engine which the post process will be applied. (default: current engine)
  114337. * @param reusable If the post process can be reused on the same frame. (default: false)
  114338. */
  114339. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114340. }
  114341. /**
  114342. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114343. */
  114344. export class StereoscopicInterlacePostProcess extends PostProcess {
  114345. private _stepSize;
  114346. private _passedProcess;
  114347. /**
  114348. * Initializes a StereoscopicInterlacePostProcess
  114349. * @param name The name of the effect.
  114350. * @param rigCameras The rig cameras to be appled to the post process
  114351. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  114352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114353. * @param engine The engine which the post process will be applied. (default: current engine)
  114354. * @param reusable If the post process can be reused on the same frame. (default: false)
  114355. */
  114356. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114357. }
  114358. }
  114359. declare module BABYLON {
  114360. /**
  114361. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  114362. * @see http://doc.babylonjs.com/features/cameras
  114363. */
  114364. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  114365. /**
  114366. * Creates a new StereoscopicArcRotateCamera
  114367. * @param name defines camera name
  114368. * @param alpha defines alpha angle (in radians)
  114369. * @param beta defines beta angle (in radians)
  114370. * @param radius defines radius
  114371. * @param target defines camera target
  114372. * @param interaxialDistance defines distance between each color axis
  114373. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114374. * @param scene defines the hosting scene
  114375. */
  114376. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114377. /**
  114378. * Gets camera class name
  114379. * @returns StereoscopicArcRotateCamera
  114380. */
  114381. getClassName(): string;
  114382. }
  114383. }
  114384. declare module BABYLON {
  114385. /**
  114386. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  114387. * @see http://doc.babylonjs.com/features/cameras
  114388. */
  114389. export class StereoscopicFreeCamera extends FreeCamera {
  114390. /**
  114391. * Creates a new StereoscopicFreeCamera
  114392. * @param name defines camera name
  114393. * @param position defines initial position
  114394. * @param interaxialDistance defines distance between each color axis
  114395. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114396. * @param scene defines the hosting scene
  114397. */
  114398. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114399. /**
  114400. * Gets camera class name
  114401. * @returns StereoscopicFreeCamera
  114402. */
  114403. getClassName(): string;
  114404. }
  114405. }
  114406. declare module BABYLON {
  114407. /**
  114408. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  114409. * @see http://doc.babylonjs.com/features/cameras
  114410. */
  114411. export class StereoscopicGamepadCamera extends GamepadCamera {
  114412. /**
  114413. * Creates a new StereoscopicGamepadCamera
  114414. * @param name defines camera name
  114415. * @param position defines initial position
  114416. * @param interaxialDistance defines distance between each color axis
  114417. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114418. * @param scene defines the hosting scene
  114419. */
  114420. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114421. /**
  114422. * Gets camera class name
  114423. * @returns StereoscopicGamepadCamera
  114424. */
  114425. getClassName(): string;
  114426. }
  114427. }
  114428. declare module BABYLON {
  114429. /**
  114430. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  114431. * @see http://doc.babylonjs.com/features/cameras
  114432. */
  114433. export class StereoscopicUniversalCamera extends UniversalCamera {
  114434. /**
  114435. * Creates a new StereoscopicUniversalCamera
  114436. * @param name defines camera name
  114437. * @param position defines initial position
  114438. * @param interaxialDistance defines distance between each color axis
  114439. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114440. * @param scene defines the hosting scene
  114441. */
  114442. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114443. /**
  114444. * Gets camera class name
  114445. * @returns StereoscopicUniversalCamera
  114446. */
  114447. getClassName(): string;
  114448. }
  114449. }
  114450. declare module BABYLON {
  114451. /**
  114452. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  114453. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114454. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114455. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114456. */
  114457. export class VirtualJoysticksCamera extends FreeCamera {
  114458. /**
  114459. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  114460. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114461. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114462. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114463. * @param name Define the name of the camera in the scene
  114464. * @param position Define the start position of the camera in the scene
  114465. * @param scene Define the scene the camera belongs to
  114466. */
  114467. constructor(name: string, position: Vector3, scene: Scene);
  114468. /**
  114469. * Gets the current object class name.
  114470. * @return the class name
  114471. */
  114472. getClassName(): string;
  114473. }
  114474. }
  114475. declare module BABYLON {
  114476. /**
  114477. * This represents all the required metrics to create a VR camera.
  114478. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  114479. */
  114480. export class VRCameraMetrics {
  114481. /**
  114482. * Define the horizontal resolution off the screen.
  114483. */
  114484. hResolution: number;
  114485. /**
  114486. * Define the vertical resolution off the screen.
  114487. */
  114488. vResolution: number;
  114489. /**
  114490. * Define the horizontal screen size.
  114491. */
  114492. hScreenSize: number;
  114493. /**
  114494. * Define the vertical screen size.
  114495. */
  114496. vScreenSize: number;
  114497. /**
  114498. * Define the vertical screen center position.
  114499. */
  114500. vScreenCenter: number;
  114501. /**
  114502. * Define the distance of the eyes to the screen.
  114503. */
  114504. eyeToScreenDistance: number;
  114505. /**
  114506. * Define the distance between both lenses
  114507. */
  114508. lensSeparationDistance: number;
  114509. /**
  114510. * Define the distance between both viewer's eyes.
  114511. */
  114512. interpupillaryDistance: number;
  114513. /**
  114514. * Define the distortion factor of the VR postprocess.
  114515. * Please, touch with care.
  114516. */
  114517. distortionK: number[];
  114518. /**
  114519. * Define the chromatic aberration correction factors for the VR post process.
  114520. */
  114521. chromaAbCorrection: number[];
  114522. /**
  114523. * Define the scale factor of the post process.
  114524. * The smaller the better but the slower.
  114525. */
  114526. postProcessScaleFactor: number;
  114527. /**
  114528. * Define an offset for the lens center.
  114529. */
  114530. lensCenterOffset: number;
  114531. /**
  114532. * Define if the current vr camera should compensate the distortion of the lense or not.
  114533. */
  114534. compensateDistortion: boolean;
  114535. /**
  114536. * Defines if multiview should be enabled when rendering (Default: false)
  114537. */
  114538. multiviewEnabled: boolean;
  114539. /**
  114540. * Gets the rendering aspect ratio based on the provided resolutions.
  114541. */
  114542. get aspectRatio(): number;
  114543. /**
  114544. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  114545. */
  114546. get aspectRatioFov(): number;
  114547. /**
  114548. * @hidden
  114549. */
  114550. get leftHMatrix(): Matrix;
  114551. /**
  114552. * @hidden
  114553. */
  114554. get rightHMatrix(): Matrix;
  114555. /**
  114556. * @hidden
  114557. */
  114558. get leftPreViewMatrix(): Matrix;
  114559. /**
  114560. * @hidden
  114561. */
  114562. get rightPreViewMatrix(): Matrix;
  114563. /**
  114564. * Get the default VRMetrics based on the most generic setup.
  114565. * @returns the default vr metrics
  114566. */
  114567. static GetDefault(): VRCameraMetrics;
  114568. }
  114569. }
  114570. declare module BABYLON {
  114571. /** @hidden */
  114572. export var vrDistortionCorrectionPixelShader: {
  114573. name: string;
  114574. shader: string;
  114575. };
  114576. }
  114577. declare module BABYLON {
  114578. /**
  114579. * VRDistortionCorrectionPostProcess used for mobile VR
  114580. */
  114581. export class VRDistortionCorrectionPostProcess extends PostProcess {
  114582. private _isRightEye;
  114583. private _distortionFactors;
  114584. private _postProcessScaleFactor;
  114585. private _lensCenterOffset;
  114586. private _scaleIn;
  114587. private _scaleFactor;
  114588. private _lensCenter;
  114589. /**
  114590. * Initializes the VRDistortionCorrectionPostProcess
  114591. * @param name The name of the effect.
  114592. * @param camera The camera to apply the render pass to.
  114593. * @param isRightEye If this is for the right eye distortion
  114594. * @param vrMetrics All the required metrics for the VR camera
  114595. */
  114596. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  114597. }
  114598. }
  114599. declare module BABYLON {
  114600. /**
  114601. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  114602. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114603. */
  114604. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  114605. /**
  114606. * Creates a new VRDeviceOrientationArcRotateCamera
  114607. * @param name defines camera name
  114608. * @param alpha defines the camera rotation along the logitudinal axis
  114609. * @param beta defines the camera rotation along the latitudinal axis
  114610. * @param radius defines the camera distance from its target
  114611. * @param target defines the camera target
  114612. * @param scene defines the scene the camera belongs to
  114613. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114614. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114615. */
  114616. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114617. /**
  114618. * Gets camera class name
  114619. * @returns VRDeviceOrientationArcRotateCamera
  114620. */
  114621. getClassName(): string;
  114622. }
  114623. }
  114624. declare module BABYLON {
  114625. /**
  114626. * Camera used to simulate VR rendering (based on FreeCamera)
  114627. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114628. */
  114629. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  114630. /**
  114631. * Creates a new VRDeviceOrientationFreeCamera
  114632. * @param name defines camera name
  114633. * @param position defines the start position of the camera
  114634. * @param scene defines the scene the camera belongs to
  114635. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114636. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114637. */
  114638. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114639. /**
  114640. * Gets camera class name
  114641. * @returns VRDeviceOrientationFreeCamera
  114642. */
  114643. getClassName(): string;
  114644. }
  114645. }
  114646. declare module BABYLON {
  114647. /**
  114648. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  114649. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114650. */
  114651. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  114652. /**
  114653. * Creates a new VRDeviceOrientationGamepadCamera
  114654. * @param name defines camera name
  114655. * @param position defines the start position of the camera
  114656. * @param scene defines the scene the camera belongs to
  114657. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114658. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114659. */
  114660. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114661. /**
  114662. * Gets camera class name
  114663. * @returns VRDeviceOrientationGamepadCamera
  114664. */
  114665. getClassName(): string;
  114666. }
  114667. }
  114668. declare module BABYLON {
  114669. /** @hidden */
  114670. export var imageProcessingPixelShader: {
  114671. name: string;
  114672. shader: string;
  114673. };
  114674. }
  114675. declare module BABYLON {
  114676. /**
  114677. * ImageProcessingPostProcess
  114678. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  114679. */
  114680. export class ImageProcessingPostProcess extends PostProcess {
  114681. /**
  114682. * Default configuration related to image processing available in the PBR Material.
  114683. */
  114684. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114685. /**
  114686. * Gets the image processing configuration used either in this material.
  114687. */
  114688. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  114689. /**
  114690. * Sets the Default image processing configuration used either in the this material.
  114691. *
  114692. * If sets to null, the scene one is in use.
  114693. */
  114694. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  114695. /**
  114696. * Keep track of the image processing observer to allow dispose and replace.
  114697. */
  114698. private _imageProcessingObserver;
  114699. /**
  114700. * Attaches a new image processing configuration to the PBR Material.
  114701. * @param configuration
  114702. */
  114703. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  114704. /**
  114705. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114706. */
  114707. get colorCurves(): Nullable<ColorCurves>;
  114708. /**
  114709. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114710. */
  114711. set colorCurves(value: Nullable<ColorCurves>);
  114712. /**
  114713. * Gets wether the color curves effect is enabled.
  114714. */
  114715. get colorCurvesEnabled(): boolean;
  114716. /**
  114717. * Sets wether the color curves effect is enabled.
  114718. */
  114719. set colorCurvesEnabled(value: boolean);
  114720. /**
  114721. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114722. */
  114723. get colorGradingTexture(): Nullable<BaseTexture>;
  114724. /**
  114725. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114726. */
  114727. set colorGradingTexture(value: Nullable<BaseTexture>);
  114728. /**
  114729. * Gets wether the color grading effect is enabled.
  114730. */
  114731. get colorGradingEnabled(): boolean;
  114732. /**
  114733. * Gets wether the color grading effect is enabled.
  114734. */
  114735. set colorGradingEnabled(value: boolean);
  114736. /**
  114737. * Gets exposure used in the effect.
  114738. */
  114739. get exposure(): number;
  114740. /**
  114741. * Sets exposure used in the effect.
  114742. */
  114743. set exposure(value: number);
  114744. /**
  114745. * Gets wether tonemapping is enabled or not.
  114746. */
  114747. get toneMappingEnabled(): boolean;
  114748. /**
  114749. * Sets wether tonemapping is enabled or not
  114750. */
  114751. set toneMappingEnabled(value: boolean);
  114752. /**
  114753. * Gets the type of tone mapping effect.
  114754. */
  114755. get toneMappingType(): number;
  114756. /**
  114757. * Sets the type of tone mapping effect.
  114758. */
  114759. set toneMappingType(value: number);
  114760. /**
  114761. * Gets contrast used in the effect.
  114762. */
  114763. get contrast(): number;
  114764. /**
  114765. * Sets contrast used in the effect.
  114766. */
  114767. set contrast(value: number);
  114768. /**
  114769. * Gets Vignette stretch size.
  114770. */
  114771. get vignetteStretch(): number;
  114772. /**
  114773. * Sets Vignette stretch size.
  114774. */
  114775. set vignetteStretch(value: number);
  114776. /**
  114777. * Gets Vignette centre X Offset.
  114778. */
  114779. get vignetteCentreX(): number;
  114780. /**
  114781. * Sets Vignette centre X Offset.
  114782. */
  114783. set vignetteCentreX(value: number);
  114784. /**
  114785. * Gets Vignette centre Y Offset.
  114786. */
  114787. get vignetteCentreY(): number;
  114788. /**
  114789. * Sets Vignette centre Y Offset.
  114790. */
  114791. set vignetteCentreY(value: number);
  114792. /**
  114793. * Gets Vignette weight or intensity of the vignette effect.
  114794. */
  114795. get vignetteWeight(): number;
  114796. /**
  114797. * Sets Vignette weight or intensity of the vignette effect.
  114798. */
  114799. set vignetteWeight(value: number);
  114800. /**
  114801. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114802. * if vignetteEnabled is set to true.
  114803. */
  114804. get vignetteColor(): Color4;
  114805. /**
  114806. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114807. * if vignetteEnabled is set to true.
  114808. */
  114809. set vignetteColor(value: Color4);
  114810. /**
  114811. * Gets Camera field of view used by the Vignette effect.
  114812. */
  114813. get vignetteCameraFov(): number;
  114814. /**
  114815. * Sets Camera field of view used by the Vignette effect.
  114816. */
  114817. set vignetteCameraFov(value: number);
  114818. /**
  114819. * Gets the vignette blend mode allowing different kind of effect.
  114820. */
  114821. get vignetteBlendMode(): number;
  114822. /**
  114823. * Sets the vignette blend mode allowing different kind of effect.
  114824. */
  114825. set vignetteBlendMode(value: number);
  114826. /**
  114827. * Gets wether the vignette effect is enabled.
  114828. */
  114829. get vignetteEnabled(): boolean;
  114830. /**
  114831. * Sets wether the vignette effect is enabled.
  114832. */
  114833. set vignetteEnabled(value: boolean);
  114834. private _fromLinearSpace;
  114835. /**
  114836. * Gets wether the input of the processing is in Gamma or Linear Space.
  114837. */
  114838. get fromLinearSpace(): boolean;
  114839. /**
  114840. * Sets wether the input of the processing is in Gamma or Linear Space.
  114841. */
  114842. set fromLinearSpace(value: boolean);
  114843. /**
  114844. * Defines cache preventing GC.
  114845. */
  114846. private _defines;
  114847. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  114848. /**
  114849. * "ImageProcessingPostProcess"
  114850. * @returns "ImageProcessingPostProcess"
  114851. */
  114852. getClassName(): string;
  114853. protected _updateParameters(): void;
  114854. dispose(camera?: Camera): void;
  114855. }
  114856. }
  114857. declare module BABYLON {
  114858. /**
  114859. * Class containing static functions to help procedurally build meshes
  114860. */
  114861. export class GroundBuilder {
  114862. /**
  114863. * Creates a ground mesh
  114864. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  114865. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  114866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114867. * @param name defines the name of the mesh
  114868. * @param options defines the options used to create the mesh
  114869. * @param scene defines the hosting scene
  114870. * @returns the ground mesh
  114871. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  114872. */
  114873. static CreateGround(name: string, options: {
  114874. width?: number;
  114875. height?: number;
  114876. subdivisions?: number;
  114877. subdivisionsX?: number;
  114878. subdivisionsY?: number;
  114879. updatable?: boolean;
  114880. }, scene: any): Mesh;
  114881. /**
  114882. * Creates a tiled ground mesh
  114883. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  114884. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  114885. * * 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
  114886. * * 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
  114887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114888. * @param name defines the name of the mesh
  114889. * @param options defines the options used to create the mesh
  114890. * @param scene defines the hosting scene
  114891. * @returns the tiled ground mesh
  114892. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  114893. */
  114894. static CreateTiledGround(name: string, options: {
  114895. xmin: number;
  114896. zmin: number;
  114897. xmax: number;
  114898. zmax: number;
  114899. subdivisions?: {
  114900. w: number;
  114901. h: number;
  114902. };
  114903. precision?: {
  114904. w: number;
  114905. h: number;
  114906. };
  114907. updatable?: boolean;
  114908. }, scene?: Nullable<Scene>): Mesh;
  114909. /**
  114910. * Creates a ground mesh from a height map
  114911. * * The parameter `url` sets the URL of the height map image resource.
  114912. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  114913. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  114914. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  114915. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  114916. * * 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.
  114917. * * 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).
  114918. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114920. * @param name defines the name of the mesh
  114921. * @param url defines the url to the height map
  114922. * @param options defines the options used to create the mesh
  114923. * @param scene defines the hosting scene
  114924. * @returns the ground mesh
  114925. * @see https://doc.babylonjs.com/babylon101/height_map
  114926. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  114927. */
  114928. static CreateGroundFromHeightMap(name: string, url: string, options: {
  114929. width?: number;
  114930. height?: number;
  114931. subdivisions?: number;
  114932. minHeight?: number;
  114933. maxHeight?: number;
  114934. colorFilter?: Color3;
  114935. alphaFilter?: number;
  114936. updatable?: boolean;
  114937. onReady?: (mesh: GroundMesh) => void;
  114938. }, scene?: Nullable<Scene>): GroundMesh;
  114939. }
  114940. }
  114941. declare module BABYLON {
  114942. /**
  114943. * Class containing static functions to help procedurally build meshes
  114944. */
  114945. export class TorusBuilder {
  114946. /**
  114947. * Creates a torus mesh
  114948. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114949. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114950. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114954. * @param name defines the name of the mesh
  114955. * @param options defines the options used to create the mesh
  114956. * @param scene defines the hosting scene
  114957. * @returns the torus mesh
  114958. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  114959. */
  114960. static CreateTorus(name: string, options: {
  114961. diameter?: number;
  114962. thickness?: number;
  114963. tessellation?: number;
  114964. updatable?: boolean;
  114965. sideOrientation?: number;
  114966. frontUVs?: Vector4;
  114967. backUVs?: Vector4;
  114968. }, scene: any): Mesh;
  114969. }
  114970. }
  114971. declare module BABYLON {
  114972. /**
  114973. * Class containing static functions to help procedurally build meshes
  114974. */
  114975. export class CylinderBuilder {
  114976. /**
  114977. * Creates a cylinder or a cone mesh
  114978. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114979. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114980. * * 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.
  114981. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114982. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114983. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114984. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114985. * * 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).
  114986. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114987. * * 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).
  114988. * * 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
  114989. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114990. * * 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
  114991. * * 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.
  114992. * * If `enclose` is false, a ring surface is one element.
  114993. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114994. * * 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
  114995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114998. * @param name defines the name of the mesh
  114999. * @param options defines the options used to create the mesh
  115000. * @param scene defines the hosting scene
  115001. * @returns the cylinder mesh
  115002. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115003. */
  115004. static CreateCylinder(name: string, options: {
  115005. height?: number;
  115006. diameterTop?: number;
  115007. diameterBottom?: number;
  115008. diameter?: number;
  115009. tessellation?: number;
  115010. subdivisions?: number;
  115011. arc?: number;
  115012. faceColors?: Color4[];
  115013. faceUV?: Vector4[];
  115014. updatable?: boolean;
  115015. hasRings?: boolean;
  115016. enclose?: boolean;
  115017. cap?: number;
  115018. sideOrientation?: number;
  115019. frontUVs?: Vector4;
  115020. backUVs?: Vector4;
  115021. }, scene: any): Mesh;
  115022. }
  115023. }
  115024. declare module BABYLON {
  115025. /**
  115026. * States of the webXR experience
  115027. */
  115028. export enum WebXRState {
  115029. /**
  115030. * Transitioning to being in XR mode
  115031. */
  115032. ENTERING_XR = 0,
  115033. /**
  115034. * Transitioning to non XR mode
  115035. */
  115036. EXITING_XR = 1,
  115037. /**
  115038. * In XR mode and presenting
  115039. */
  115040. IN_XR = 2,
  115041. /**
  115042. * Not entered XR mode
  115043. */
  115044. NOT_IN_XR = 3
  115045. }
  115046. /**
  115047. * Abstraction of the XR render target
  115048. */
  115049. export interface WebXRRenderTarget extends IDisposable {
  115050. /**
  115051. * xrpresent context of the canvas which can be used to display/mirror xr content
  115052. */
  115053. canvasContext: WebGLRenderingContext;
  115054. /**
  115055. * xr layer for the canvas
  115056. */
  115057. xrLayer: Nullable<XRWebGLLayer>;
  115058. /**
  115059. * Initializes the xr layer for the session
  115060. * @param xrSession xr session
  115061. * @returns a promise that will resolve once the XR Layer has been created
  115062. */
  115063. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115064. }
  115065. }
  115066. declare module BABYLON {
  115067. /**
  115068. * COnfiguration object for WebXR output canvas
  115069. */
  115070. export class WebXRManagedOutputCanvasOptions {
  115071. /**
  115072. * Options for this XR Layer output
  115073. */
  115074. canvasOptions?: XRWebGLLayerOptions;
  115075. /**
  115076. * CSS styling for a newly created canvas (if not provided)
  115077. */
  115078. newCanvasCssStyle?: string;
  115079. /**
  115080. * An optional canvas in case you wish to create it yourself and provide it here.
  115081. * If not provided, a new canvas will be created
  115082. */
  115083. canvasElement?: HTMLCanvasElement;
  115084. /**
  115085. * Get the default values of the configuration object
  115086. * @returns default values of this configuration object
  115087. */
  115088. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115089. }
  115090. /**
  115091. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115092. */
  115093. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115094. private _options;
  115095. private _engine;
  115096. private _canvas;
  115097. /**
  115098. * Rendering context of the canvas which can be used to display/mirror xr content
  115099. */
  115100. canvasContext: WebGLRenderingContext;
  115101. /**
  115102. * xr layer for the canvas
  115103. */
  115104. xrLayer: Nullable<XRWebGLLayer>;
  115105. /**
  115106. * Initializes the xr layer for the session
  115107. * @param xrSession xr session
  115108. * @returns a promise that will resolve once the XR Layer has been created
  115109. */
  115110. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115111. /**
  115112. * Initializes the canvas to be added/removed upon entering/exiting xr
  115113. * @param _xrSessionManager The XR Session manager
  115114. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115115. */
  115116. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115117. /**
  115118. * Disposes of the object
  115119. */
  115120. dispose(): void;
  115121. private _setManagedOutputCanvas;
  115122. private _addCanvas;
  115123. private _removeCanvas;
  115124. }
  115125. }
  115126. declare module BABYLON {
  115127. /**
  115128. * Manages an XRSession to work with Babylon's engine
  115129. * @see https://doc.babylonjs.com/how_to/webxr
  115130. */
  115131. export class WebXRSessionManager implements IDisposable {
  115132. /** The scene which the session should be created for */
  115133. scene: Scene;
  115134. /**
  115135. * Fires every time a new xrFrame arrives which can be used to update the camera
  115136. */
  115137. onXRFrameObservable: Observable<XRFrame>;
  115138. /**
  115139. * Fires when the xr session is ended either by the device or manually done
  115140. */
  115141. onXRSessionEnded: Observable<any>;
  115142. /**
  115143. * Fires when the xr session is ended either by the device or manually done
  115144. */
  115145. onXRSessionInit: Observable<XRSession>;
  115146. /**
  115147. * Fires when the reference space changed
  115148. */
  115149. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115150. /**
  115151. * Underlying xr session
  115152. */
  115153. session: XRSession;
  115154. /**
  115155. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115156. * or get the offset the player is currently at.
  115157. */
  115158. viewerReferenceSpace: XRReferenceSpace;
  115159. private _referenceSpace;
  115160. /**
  115161. * The current reference space used in this session. This reference space can constantly change!
  115162. * It is mainly used to offset the camera's position.
  115163. */
  115164. get referenceSpace(): XRReferenceSpace;
  115165. /**
  115166. * Set a new reference space and triggers the observable
  115167. */
  115168. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115169. /**
  115170. * The base reference space from which the session started. good if you want to reset your
  115171. * reference space
  115172. */
  115173. baseReferenceSpace: XRReferenceSpace;
  115174. /**
  115175. * Used just in case of a failure to initialize an immersive session.
  115176. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115177. */
  115178. defaultHeightCompensation: number;
  115179. /**
  115180. * Current XR frame
  115181. */
  115182. currentFrame: Nullable<XRFrame>;
  115183. /** WebXR timestamp updated every frame */
  115184. currentTimestamp: number;
  115185. private _xrNavigator;
  115186. private baseLayer;
  115187. private _rttProvider;
  115188. private _sessionEnded;
  115189. /**
  115190. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115191. * @param scene The scene which the session should be created for
  115192. */
  115193. constructor(
  115194. /** The scene which the session should be created for */
  115195. scene: Scene);
  115196. /**
  115197. * Initializes the manager
  115198. * After initialization enterXR can be called to start an XR session
  115199. * @returns Promise which resolves after it is initialized
  115200. */
  115201. initializeAsync(): Promise<void>;
  115202. /**
  115203. * Initializes an xr session
  115204. * @param xrSessionMode mode to initialize
  115205. * @param xrSessionInit defines optional and required values to pass to the session builder
  115206. * @returns a promise which will resolve once the session has been initialized
  115207. */
  115208. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115209. /**
  115210. * Sets the reference space on the xr session
  115211. * @param referenceSpace space to set
  115212. * @returns a promise that will resolve once the reference space has been set
  115213. */
  115214. setReferenceSpaceAsync(referenceSpace?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115215. /**
  115216. * Resets the reference space to the one started the session
  115217. */
  115218. resetReferenceSpace(): void;
  115219. /**
  115220. * Updates the render state of the session
  115221. * @param state state to set
  115222. * @returns a promise that resolves once the render state has been updated
  115223. */
  115224. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115225. /**
  115226. * Starts rendering to the xr layer
  115227. */
  115228. runXRRenderLoop(): void;
  115229. /**
  115230. * Gets the correct render target texture to be rendered this frame for this eye
  115231. * @param eye the eye for which to get the render target
  115232. * @returns the render target for the specified eye
  115233. */
  115234. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115235. /**
  115236. * Stops the xrSession and restores the renderloop
  115237. * @returns Promise which resolves after it exits XR
  115238. */
  115239. exitXRAsync(): Promise<void>;
  115240. /**
  115241. * Checks if a session would be supported for the creation options specified
  115242. * @param sessionMode session mode to check if supported eg. immersive-vr
  115243. * @returns true if supported
  115244. */
  115245. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115246. /**
  115247. * Creates a WebXRRenderTarget object for the XR session
  115248. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115249. * @param options optional options to provide when creating a new render target
  115250. * @returns a WebXR render target to which the session can render
  115251. */
  115252. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115253. /**
  115254. * @hidden
  115255. * Converts the render layer of xrSession to a render target
  115256. * @param session session to create render target for
  115257. * @param scene scene the new render target should be created for
  115258. * @param baseLayer the webgl layer to create the render target for
  115259. */
  115260. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115261. /**
  115262. * Disposes of the session manager
  115263. */
  115264. dispose(): void;
  115265. /**
  115266. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115267. * @param sessionMode defines the session to test
  115268. * @returns a promise with boolean as final value
  115269. */
  115270. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115271. }
  115272. }
  115273. declare module BABYLON {
  115274. /**
  115275. * WebXR Camera which holds the views for the xrSession
  115276. * @see https://doc.babylonjs.com/how_to/webxr
  115277. */
  115278. export class WebXRCamera extends FreeCamera {
  115279. private _xrSessionManager;
  115280. /**
  115281. * Is the camera in debug mode. Used when using an emulator
  115282. */
  115283. debugMode: boolean;
  115284. private _firstFrame;
  115285. private _referencedPosition;
  115286. private _referenceQuaternion;
  115287. private _xrInvPositionCache;
  115288. private _xrInvQuaternionCache;
  115289. /**
  115290. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115291. * @param name the name of the camera
  115292. * @param scene the scene to add the camera to
  115293. */
  115294. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115295. private _updateNumberOfRigCameras;
  115296. /**
  115297. * Sets this camera's transformation based on a non-vr camera
  115298. * @param otherCamera the non-vr camera to copy the transformation from
  115299. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115300. */
  115301. setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace?: boolean): void;
  115302. /** @hidden */
  115303. _updateForDualEyeDebugging(): void;
  115304. private _updateReferenceSpace;
  115305. private _updateReferenceSpaceOffset;
  115306. private _updateFromXRSession;
  115307. }
  115308. }
  115309. declare module BABYLON {
  115310. /**
  115311. * Defining the interface required for a (webxr) feature
  115312. */
  115313. export interface IWebXRFeature extends IDisposable {
  115314. /**
  115315. * Is this feature attached
  115316. */
  115317. attached: boolean;
  115318. /**
  115319. * Attach the feature to the session
  115320. * Will usually be called by the features manager
  115321. *
  115322. * @returns true if successful.
  115323. */
  115324. attach(): boolean;
  115325. /**
  115326. * Detach the feature from the session
  115327. * Will usually be called by the features manager
  115328. *
  115329. * @returns true if successful.
  115330. */
  115331. detach(): boolean;
  115332. }
  115333. /**
  115334. * Defining the constructor of a feature. Used to register the modules.
  115335. */
  115336. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  115337. /**
  115338. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  115339. * It is mainly used in AR sessions.
  115340. *
  115341. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  115342. */
  115343. export class WebXRFeaturesManager implements IDisposable {
  115344. private _xrSessionManager;
  115345. private static readonly _AvailableFeatures;
  115346. /**
  115347. * Used to register a module. After calling this function a developer can use this feature in the scene.
  115348. * Mainly used internally.
  115349. *
  115350. * @param featureName the name of the feature to register
  115351. * @param constructorFunction the function used to construct the module
  115352. * @param version the (babylon) version of the module
  115353. * @param stable is that a stable version of this module
  115354. */
  115355. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  115356. /**
  115357. * Returns a constructor of a specific feature.
  115358. *
  115359. * @param featureName the name of the feature to construct
  115360. * @param version the version of the feature to load
  115361. * @param xrSessionManager the xrSessionManager. Used to construct the module
  115362. * @param options optional options provided to the module.
  115363. * @returns a function that, when called, will return a new instance of this feature
  115364. */
  115365. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  115366. /**
  115367. * Return the latest unstable version of this feature
  115368. * @param featureName the name of the feature to search
  115369. * @returns the version number. if not found will return -1
  115370. */
  115371. static GetLatestVersionOfFeature(featureName: string): number;
  115372. /**
  115373. * Return the latest stable version of this feature
  115374. * @param featureName the name of the feature to search
  115375. * @returns the version number. if not found will return -1
  115376. */
  115377. static GetStableVersionOfFeature(featureName: string): number;
  115378. /**
  115379. * Can be used to return the list of features currently registered
  115380. *
  115381. * @returns an Array of available features
  115382. */
  115383. static GetAvailableFeatures(): string[];
  115384. /**
  115385. * Gets the versions available for a specific feature
  115386. * @param featureName the name of the feature
  115387. * @returns an array with the available versions
  115388. */
  115389. static GetAvailableVersions(featureName: string): string[];
  115390. private _features;
  115391. /**
  115392. * constructs a new features manages.
  115393. *
  115394. * @param _xrSessionManager an instance of WebXRSessionManager
  115395. */
  115396. constructor(_xrSessionManager: WebXRSessionManager);
  115397. /**
  115398. * 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.
  115399. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  115400. *
  115401. * @param featureName the name of the feature to load or the class of the feature
  115402. * @param version optional version to load. if not provided the latest version will be enabled
  115403. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  115404. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  115405. * @returns a new constructed feature or throws an error if feature not found.
  115406. */
  115407. enableFeature(featureName: string | {
  115408. Name: string;
  115409. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  115410. /**
  115411. * Used to disable an already-enabled feature
  115412. * The feature will be disposed and will be recreated once enabled.
  115413. * @param featureName the feature to disable
  115414. * @returns true if disable was successful
  115415. */
  115416. disableFeature(featureName: string | {
  115417. Name: string;
  115418. }): boolean;
  115419. /**
  115420. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  115421. * Can be used during a session to start a feature
  115422. * @param featureName the name of feature to attach
  115423. */
  115424. attachFeature(featureName: string): void;
  115425. /**
  115426. * Can be used inside a session or when the session ends to detach a specific feature
  115427. * @param featureName the name of the feature to detach
  115428. */
  115429. detachFeature(featureName: string): void;
  115430. /**
  115431. * Get the list of enabled features
  115432. * @returns an array of enabled features
  115433. */
  115434. getEnabledFeatures(): string[];
  115435. /**
  115436. * get the implementation of an enabled feature.
  115437. * @param featureName the name of the feature to load
  115438. * @returns the feature class, if found
  115439. */
  115440. getEnabledFeature(featureName: string): IWebXRFeature;
  115441. /**
  115442. * dispose this features manager
  115443. */
  115444. dispose(): void;
  115445. }
  115446. }
  115447. declare module BABYLON {
  115448. /**
  115449. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  115450. * @see https://doc.babylonjs.com/how_to/webxr
  115451. */
  115452. export class WebXRExperienceHelper implements IDisposable {
  115453. private scene;
  115454. /**
  115455. * Camera used to render xr content
  115456. */
  115457. camera: WebXRCamera;
  115458. /**
  115459. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  115460. */
  115461. state: WebXRState;
  115462. private _setState;
  115463. /**
  115464. * Fires when the state of the experience helper has changed
  115465. */
  115466. onStateChangedObservable: Observable<WebXRState>;
  115467. /**
  115468. * Observers registered here will be triggered after the camera's initial transformation is set
  115469. * This can be used to set a different ground level or an extra rotation.
  115470. *
  115471. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  115472. * to the position set after this observable is done executing.
  115473. */
  115474. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  115475. /** Session manager used to keep track of xr session */
  115476. sessionManager: WebXRSessionManager;
  115477. /** A features manager for this xr session */
  115478. featuresManager: WebXRFeaturesManager;
  115479. private _nonVRCamera;
  115480. private _originalSceneAutoClear;
  115481. private _supported;
  115482. /**
  115483. * Creates the experience helper
  115484. * @param scene the scene to attach the experience helper to
  115485. * @returns a promise for the experience helper
  115486. */
  115487. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  115488. /**
  115489. * Creates a WebXRExperienceHelper
  115490. * @param scene The scene the helper should be created in
  115491. */
  115492. private constructor();
  115493. /**
  115494. * Exits XR mode and returns the scene to its original state
  115495. * @returns promise that resolves after xr mode has exited
  115496. */
  115497. exitXRAsync(): Promise<void>;
  115498. /**
  115499. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  115500. * @param sessionMode options for the XR session
  115501. * @param referenceSpaceType frame of reference of the XR session
  115502. * @param renderTarget the output canvas that will be used to enter XR mode
  115503. * @returns promise that resolves after xr mode has entered
  115504. */
  115505. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  115506. /**
  115507. * Disposes of the experience helper
  115508. */
  115509. dispose(): void;
  115510. private _nonXRToXRCamera;
  115511. }
  115512. }
  115513. declare module BABYLON {
  115514. /**
  115515. * X-Y values for axes in WebXR
  115516. */
  115517. export interface IWebXRMotionControllerAxesValue {
  115518. /**
  115519. * The value of the x axis
  115520. */
  115521. x: number;
  115522. /**
  115523. * The value of the y-axis
  115524. */
  115525. y: number;
  115526. }
  115527. /**
  115528. * changed / previous values for the values of this component
  115529. */
  115530. export interface IWebXRMotionControllerComponentChangesValues<T> {
  115531. /**
  115532. * current (this frame) value
  115533. */
  115534. current: T;
  115535. /**
  115536. * previous (last change) value
  115537. */
  115538. previous: T;
  115539. }
  115540. /**
  115541. * Represents changes in the component between current frame and last values recorded
  115542. */
  115543. export interface IWebXRMotionControllerComponentChanges {
  115544. /**
  115545. * will be populated with previous and current values if touched changed
  115546. */
  115547. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115548. /**
  115549. * will be populated with previous and current values if pressed changed
  115550. */
  115551. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115552. /**
  115553. * will be populated with previous and current values if value changed
  115554. */
  115555. value?: IWebXRMotionControllerComponentChangesValues<number>;
  115556. /**
  115557. * will be populated with previous and current values if axes changed
  115558. */
  115559. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  115560. }
  115561. /**
  115562. * This class represents a single component (for example button or thumbstick) of a motion controller
  115563. */
  115564. export class WebXRControllerComponent implements IDisposable {
  115565. /**
  115566. * the id of this component
  115567. */
  115568. id: string;
  115569. /**
  115570. * the type of the component
  115571. */
  115572. type: MotionControllerComponentType;
  115573. private _buttonIndex;
  115574. private _axesIndices;
  115575. /**
  115576. * Thumbstick component type
  115577. */
  115578. static THUMBSTICK: string;
  115579. /**
  115580. * Touchpad component type
  115581. */
  115582. static TOUCHPAD: string;
  115583. /**
  115584. * trigger component type
  115585. */
  115586. static TRIGGER: string;
  115587. /**
  115588. * squeeze component type
  115589. */
  115590. static SQUEEZE: string;
  115591. /**
  115592. * Observers registered here will be triggered when the state of a button changes
  115593. * State change is either pressed / touched / value
  115594. */
  115595. onButtonStateChanged: Observable<WebXRControllerComponent>;
  115596. /**
  115597. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  115598. * the axes data changes
  115599. */
  115600. onAxisValueChanged: Observable<{
  115601. x: number;
  115602. y: number;
  115603. }>;
  115604. private _currentValue;
  115605. private _touched;
  115606. private _pressed;
  115607. private _axes;
  115608. private _changes;
  115609. /**
  115610. * Creates a new component for a motion controller.
  115611. * It is created by the motion controller itself
  115612. *
  115613. * @param id the id of this component
  115614. * @param type the type of the component
  115615. * @param _buttonIndex index in the buttons array of the gamepad
  115616. * @param _axesIndices indices of the values in the axes array of the gamepad
  115617. */
  115618. constructor(
  115619. /**
  115620. * the id of this component
  115621. */
  115622. id: string,
  115623. /**
  115624. * the type of the component
  115625. */
  115626. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  115627. /**
  115628. * Get the current value of this component
  115629. */
  115630. get value(): number;
  115631. /**
  115632. * is the button currently pressed
  115633. */
  115634. get pressed(): boolean;
  115635. /**
  115636. * is the button currently touched
  115637. */
  115638. get touched(): boolean;
  115639. /**
  115640. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  115641. */
  115642. get axes(): IWebXRMotionControllerAxesValue;
  115643. /**
  115644. * Get the changes. Elements will be populated only if they changed with their previous and current value
  115645. */
  115646. get changes(): IWebXRMotionControllerComponentChanges;
  115647. /**
  115648. * Is this component a button (hence - pressable)
  115649. * @returns true if can be pressed
  115650. */
  115651. isButton(): boolean;
  115652. /**
  115653. * Are there axes correlating to this component
  115654. * @return true is axes data is available
  115655. */
  115656. isAxes(): boolean;
  115657. /**
  115658. * update this component using the gamepad object it is in. Called on every frame
  115659. * @param nativeController the native gamepad controller object
  115660. */
  115661. update(nativeController: IMinimalMotionControllerObject): void;
  115662. /**
  115663. * Dispose this component
  115664. */
  115665. dispose(): void;
  115666. }
  115667. }
  115668. declare module BABYLON {
  115669. /**
  115670. * Class used to represent data loading progression
  115671. */
  115672. export class SceneLoaderProgressEvent {
  115673. /** defines if data length to load can be evaluated */
  115674. readonly lengthComputable: boolean;
  115675. /** defines the loaded data length */
  115676. readonly loaded: number;
  115677. /** defines the data length to load */
  115678. readonly total: number;
  115679. /**
  115680. * Create a new progress event
  115681. * @param lengthComputable defines if data length to load can be evaluated
  115682. * @param loaded defines the loaded data length
  115683. * @param total defines the data length to load
  115684. */
  115685. constructor(
  115686. /** defines if data length to load can be evaluated */
  115687. lengthComputable: boolean,
  115688. /** defines the loaded data length */
  115689. loaded: number,
  115690. /** defines the data length to load */
  115691. total: number);
  115692. /**
  115693. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  115694. * @param event defines the source event
  115695. * @returns a new SceneLoaderProgressEvent
  115696. */
  115697. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  115698. }
  115699. /**
  115700. * Interface used by SceneLoader plugins to define supported file extensions
  115701. */
  115702. export interface ISceneLoaderPluginExtensions {
  115703. /**
  115704. * Defines the list of supported extensions
  115705. */
  115706. [extension: string]: {
  115707. isBinary: boolean;
  115708. };
  115709. }
  115710. /**
  115711. * Interface used by SceneLoader plugin factory
  115712. */
  115713. export interface ISceneLoaderPluginFactory {
  115714. /**
  115715. * Defines the name of the factory
  115716. */
  115717. name: string;
  115718. /**
  115719. * Function called to create a new plugin
  115720. * @return the new plugin
  115721. */
  115722. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  115723. /**
  115724. * The callback that returns true if the data can be directly loaded.
  115725. * @param data string containing the file data
  115726. * @returns if the data can be loaded directly
  115727. */
  115728. canDirectLoad?(data: string): boolean;
  115729. }
  115730. /**
  115731. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  115732. */
  115733. export interface ISceneLoaderPluginBase {
  115734. /**
  115735. * The friendly name of this plugin.
  115736. */
  115737. name: string;
  115738. /**
  115739. * The file extensions supported by this plugin.
  115740. */
  115741. extensions: string | ISceneLoaderPluginExtensions;
  115742. /**
  115743. * The callback called when loading from a url.
  115744. * @param scene scene loading this url
  115745. * @param url url to load
  115746. * @param onSuccess callback called when the file successfully loads
  115747. * @param onProgress callback called while file is loading (if the server supports this mode)
  115748. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115749. * @param onError callback called when the file fails to load
  115750. * @returns a file request object
  115751. */
  115752. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115753. /**
  115754. * The callback called when loading from a file object.
  115755. * @param scene scene loading this file
  115756. * @param file defines the file to load
  115757. * @param onSuccess defines the callback to call when data is loaded
  115758. * @param onProgress defines the callback to call during loading process
  115759. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115760. * @param onError defines the callback to call when an error occurs
  115761. * @returns a file request object
  115762. */
  115763. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115764. /**
  115765. * The callback that returns true if the data can be directly loaded.
  115766. * @param data string containing the file data
  115767. * @returns if the data can be loaded directly
  115768. */
  115769. canDirectLoad?(data: string): boolean;
  115770. /**
  115771. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  115772. * @param scene scene loading this data
  115773. * @param data string containing the data
  115774. * @returns data to pass to the plugin
  115775. */
  115776. directLoad?(scene: Scene, data: string): any;
  115777. /**
  115778. * The callback that allows custom handling of the root url based on the response url.
  115779. * @param rootUrl the original root url
  115780. * @param responseURL the response url if available
  115781. * @returns the new root url
  115782. */
  115783. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  115784. }
  115785. /**
  115786. * Interface used to define a SceneLoader plugin
  115787. */
  115788. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  115789. /**
  115790. * Import meshes into a scene.
  115791. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115792. * @param scene The scene to import into
  115793. * @param data The data to import
  115794. * @param rootUrl The root url for scene and resources
  115795. * @param meshes The meshes array to import into
  115796. * @param particleSystems The particle systems array to import into
  115797. * @param skeletons The skeletons array to import into
  115798. * @param onError The callback when import fails
  115799. * @returns True if successful or false otherwise
  115800. */
  115801. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  115802. /**
  115803. * Load into a scene.
  115804. * @param scene The scene to load into
  115805. * @param data The data to import
  115806. * @param rootUrl The root url for scene and resources
  115807. * @param onError The callback when import fails
  115808. * @returns True if successful or false otherwise
  115809. */
  115810. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  115811. /**
  115812. * Load into an asset container.
  115813. * @param scene The scene to load into
  115814. * @param data The data to import
  115815. * @param rootUrl The root url for scene and resources
  115816. * @param onError The callback when import fails
  115817. * @returns The loaded asset container
  115818. */
  115819. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  115820. }
  115821. /**
  115822. * Interface used to define an async SceneLoader plugin
  115823. */
  115824. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  115825. /**
  115826. * Import meshes into a scene.
  115827. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115828. * @param scene The scene to import into
  115829. * @param data The data to import
  115830. * @param rootUrl The root url for scene and resources
  115831. * @param onProgress The callback when the load progresses
  115832. * @param fileName Defines the name of the file to load
  115833. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  115834. */
  115835. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  115836. meshes: AbstractMesh[];
  115837. particleSystems: IParticleSystem[];
  115838. skeletons: Skeleton[];
  115839. animationGroups: AnimationGroup[];
  115840. }>;
  115841. /**
  115842. * Load into a scene.
  115843. * @param scene The scene to load into
  115844. * @param data The data to import
  115845. * @param rootUrl The root url for scene and resources
  115846. * @param onProgress The callback when the load progresses
  115847. * @param fileName Defines the name of the file to load
  115848. * @returns Nothing
  115849. */
  115850. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  115851. /**
  115852. * Load into an asset container.
  115853. * @param scene The scene to load into
  115854. * @param data The data to import
  115855. * @param rootUrl The root url for scene and resources
  115856. * @param onProgress The callback when the load progresses
  115857. * @param fileName Defines the name of the file to load
  115858. * @returns The loaded asset container
  115859. */
  115860. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  115861. }
  115862. /**
  115863. * Mode that determines how to handle old animation groups before loading new ones.
  115864. */
  115865. export enum SceneLoaderAnimationGroupLoadingMode {
  115866. /**
  115867. * Reset all old animations to initial state then dispose them.
  115868. */
  115869. Clean = 0,
  115870. /**
  115871. * Stop all old animations.
  115872. */
  115873. Stop = 1,
  115874. /**
  115875. * Restart old animations from first frame.
  115876. */
  115877. Sync = 2,
  115878. /**
  115879. * Old animations remains untouched.
  115880. */
  115881. NoSync = 3
  115882. }
  115883. /**
  115884. * Class used to load scene from various file formats using registered plugins
  115885. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  115886. */
  115887. export class SceneLoader {
  115888. /**
  115889. * No logging while loading
  115890. */
  115891. static readonly NO_LOGGING: number;
  115892. /**
  115893. * Minimal logging while loading
  115894. */
  115895. static readonly MINIMAL_LOGGING: number;
  115896. /**
  115897. * Summary logging while loading
  115898. */
  115899. static readonly SUMMARY_LOGGING: number;
  115900. /**
  115901. * Detailled logging while loading
  115902. */
  115903. static readonly DETAILED_LOGGING: number;
  115904. /**
  115905. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  115906. */
  115907. static get ForceFullSceneLoadingForIncremental(): boolean;
  115908. static set ForceFullSceneLoadingForIncremental(value: boolean);
  115909. /**
  115910. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  115911. */
  115912. static get ShowLoadingScreen(): boolean;
  115913. static set ShowLoadingScreen(value: boolean);
  115914. /**
  115915. * Defines the current logging level (while loading the scene)
  115916. * @ignorenaming
  115917. */
  115918. static get loggingLevel(): number;
  115919. static set loggingLevel(value: number);
  115920. /**
  115921. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  115922. */
  115923. static get CleanBoneMatrixWeights(): boolean;
  115924. static set CleanBoneMatrixWeights(value: boolean);
  115925. /**
  115926. * Event raised when a plugin is used to load a scene
  115927. */
  115928. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  115929. private static _registeredPlugins;
  115930. private static _getDefaultPlugin;
  115931. private static _getPluginForExtension;
  115932. private static _getPluginForDirectLoad;
  115933. private static _getPluginForFilename;
  115934. private static _getDirectLoad;
  115935. private static _loadData;
  115936. private static _getFileInfo;
  115937. /**
  115938. * Gets a plugin that can load the given extension
  115939. * @param extension defines the extension to load
  115940. * @returns a plugin or null if none works
  115941. */
  115942. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  115943. /**
  115944. * Gets a boolean indicating that the given extension can be loaded
  115945. * @param extension defines the extension to load
  115946. * @returns true if the extension is supported
  115947. */
  115948. static IsPluginForExtensionAvailable(extension: string): boolean;
  115949. /**
  115950. * Adds a new plugin to the list of registered plugins
  115951. * @param plugin defines the plugin to add
  115952. */
  115953. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  115954. /**
  115955. * Import meshes into a scene
  115956. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115957. * @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)
  115958. * @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)
  115959. * @param scene the instance of BABYLON.Scene to append to
  115960. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  115961. * @param onProgress a callback with a progress event for each file being loaded
  115962. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115963. * @param pluginExtension the extension used to determine the plugin
  115964. * @returns The loaded plugin
  115965. */
  115966. 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>;
  115967. /**
  115968. * Import meshes into a scene
  115969. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115970. * @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)
  115971. * @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)
  115972. * @param scene the instance of BABYLON.Scene to append to
  115973. * @param onProgress a callback with a progress event for each file being loaded
  115974. * @param pluginExtension the extension used to determine the plugin
  115975. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  115976. */
  115977. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  115978. meshes: AbstractMesh[];
  115979. particleSystems: IParticleSystem[];
  115980. skeletons: Skeleton[];
  115981. animationGroups: AnimationGroup[];
  115982. }>;
  115983. /**
  115984. * Load a scene
  115985. * @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)
  115986. * @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)
  115987. * @param engine is the instance of BABYLON.Engine to use to create the scene
  115988. * @param onSuccess a callback with the scene when import succeeds
  115989. * @param onProgress a callback with a progress event for each file being loaded
  115990. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115991. * @param pluginExtension the extension used to determine the plugin
  115992. * @returns The loaded plugin
  115993. */
  115994. 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>;
  115995. /**
  115996. * Load a scene
  115997. * @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)
  115998. * @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)
  115999. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116000. * @param onProgress a callback with a progress event for each file being loaded
  116001. * @param pluginExtension the extension used to determine the plugin
  116002. * @returns The loaded scene
  116003. */
  116004. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116005. /**
  116006. * Append a scene
  116007. * @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)
  116008. * @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)
  116009. * @param scene is the instance of BABYLON.Scene to append to
  116010. * @param onSuccess a callback with the scene when import succeeds
  116011. * @param onProgress a callback with a progress event for each file being loaded
  116012. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116013. * @param pluginExtension the extension used to determine the plugin
  116014. * @returns The loaded plugin
  116015. */
  116016. 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>;
  116017. /**
  116018. * Append a scene
  116019. * @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)
  116020. * @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)
  116021. * @param scene is the instance of BABYLON.Scene to append to
  116022. * @param onProgress a callback with a progress event for each file being loaded
  116023. * @param pluginExtension the extension used to determine the plugin
  116024. * @returns The given scene
  116025. */
  116026. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116027. /**
  116028. * Load a scene into an asset container
  116029. * @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)
  116030. * @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)
  116031. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116032. * @param onSuccess a callback with the scene when import succeeds
  116033. * @param onProgress a callback with a progress event for each file being loaded
  116034. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116035. * @param pluginExtension the extension used to determine the plugin
  116036. * @returns The loaded plugin
  116037. */
  116038. 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>;
  116039. /**
  116040. * Load a scene into an asset container
  116041. * @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)
  116042. * @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)
  116043. * @param scene is the instance of Scene to append to
  116044. * @param onProgress a callback with a progress event for each file being loaded
  116045. * @param pluginExtension the extension used to determine the plugin
  116046. * @returns The loaded asset container
  116047. */
  116048. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116049. /**
  116050. * Import animations from a file into a scene
  116051. * @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)
  116052. * @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)
  116053. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116054. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116055. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116056. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116057. * @param onSuccess a callback with the scene when import succeeds
  116058. * @param onProgress a callback with a progress event for each file being loaded
  116059. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116060. */
  116061. 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;
  116062. /**
  116063. * Import animations from a file into a scene
  116064. * @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)
  116065. * @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)
  116066. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116067. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116068. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116069. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116070. * @param onSuccess a callback with the scene when import succeeds
  116071. * @param onProgress a callback with a progress event for each file being loaded
  116072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116073. * @returns the updated scene with imported animations
  116074. */
  116075. 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>;
  116076. }
  116077. }
  116078. declare module BABYLON {
  116079. /**
  116080. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116081. */
  116082. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  116083. /**
  116084. * The type of components available in motion controllers.
  116085. * This is not the name of the component.
  116086. */
  116087. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116088. /**
  116089. * The schema of motion controller layout.
  116090. * No object will be initialized using this interface
  116091. * This is used just to define the profile.
  116092. */
  116093. export interface IMotionControllerLayout {
  116094. /**
  116095. * Defines the main button component id
  116096. */
  116097. selectComponentId: string;
  116098. /**
  116099. * Available components (unsorted)
  116100. */
  116101. components: {
  116102. /**
  116103. * A map of component Ids
  116104. */
  116105. [componentId: string]: {
  116106. /**
  116107. * The type of input the component outputs
  116108. */
  116109. type: MotionControllerComponentType;
  116110. };
  116111. };
  116112. /**
  116113. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  116114. */
  116115. gamepad?: {
  116116. /**
  116117. * Is the mapping based on the xr-standard defined here:
  116118. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  116119. */
  116120. mapping: "" | "xr-standard";
  116121. /**
  116122. * The buttons available in this input in the right order
  116123. * index of this button will be the index in the gamepadObject.buttons array
  116124. * correlates to the componentId in components
  116125. */
  116126. buttons: Array<string | null>;
  116127. /**
  116128. * Definition of the axes of the gamepad input, sorted
  116129. * Correlates to componentIds in the components map
  116130. */
  116131. axes: Array<{
  116132. /**
  116133. * The component id that the axis correlates to
  116134. */
  116135. componentId: string;
  116136. /**
  116137. * X or Y Axis
  116138. */
  116139. axis: "x-axis" | "y-axis";
  116140. } | null>;
  116141. };
  116142. }
  116143. /**
  116144. * A definition for the layout map in the input profile
  116145. */
  116146. export interface IMotionControllerLayoutMap {
  116147. /**
  116148. * Layouts with handness type as a key
  116149. */
  116150. [handness: string]: IMotionControllerLayout;
  116151. }
  116152. /**
  116153. * The XR Input profile schema
  116154. * Profiles can be found here:
  116155. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116156. */
  116157. export interface IMotionControllerProfile {
  116158. /**
  116159. * The id of this profile
  116160. * correlates to the profile(s) in the xrInput.profiles array
  116161. */
  116162. profileId: string;
  116163. /**
  116164. * fallback profiles for this profileId
  116165. */
  116166. fallbackProfileIds: string[];
  116167. /**
  116168. * The layout map, with handness as key
  116169. */
  116170. layouts: IMotionControllerLayoutMap;
  116171. }
  116172. /**
  116173. * A helper-interface for the 3 meshes needed for controller button animation
  116174. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116175. */
  116176. export interface IMotionControllerButtonMeshMap {
  116177. /**
  116178. * The mesh that will be changed when value changes
  116179. */
  116180. valueMesh: AbstractMesh;
  116181. /**
  116182. * the mesh that defines the pressed value mesh position.
  116183. * This is used to find the max-position of this button
  116184. */
  116185. pressedMesh: AbstractMesh;
  116186. /**
  116187. * the mesh that defines the unpressed value mesh position.
  116188. * This is used to find the min (or initial) position of this button
  116189. */
  116190. unpressedMesh: AbstractMesh;
  116191. }
  116192. /**
  116193. * A helper-interface for the 3 meshes needed for controller axis animation.
  116194. * This will be expanded when touchpad animations are fully supported
  116195. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116196. */
  116197. export interface IMotionControllerAxisMeshMap {
  116198. /**
  116199. * The mesh that will be changed when axis value changes
  116200. */
  116201. valueMesh: AbstractMesh;
  116202. /**
  116203. * the mesh that defines the minimum value mesh position.
  116204. */
  116205. minMesh: AbstractMesh;
  116206. /**
  116207. * the mesh that defines the maximum value mesh position.
  116208. */
  116209. maxMesh: AbstractMesh;
  116210. }
  116211. /**
  116212. * The elements needed for change-detection of the gamepad objects in motion controllers
  116213. */
  116214. export interface IMinimalMotionControllerObject {
  116215. /**
  116216. * An array of available buttons
  116217. */
  116218. buttons: Array<{
  116219. /**
  116220. * Value of the button/trigger
  116221. */
  116222. value: number;
  116223. /**
  116224. * If the button/trigger is currently touched
  116225. */
  116226. touched: boolean;
  116227. /**
  116228. * If the button/trigger is currently pressed
  116229. */
  116230. pressed: boolean;
  116231. }>;
  116232. /**
  116233. * Available axes of this controller
  116234. */
  116235. axes: number[];
  116236. }
  116237. /**
  116238. * An Abstract Motion controller
  116239. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116240. * Each component has an observable to check for changes in value and state
  116241. */
  116242. export abstract class WebXRAbstractMotionController implements IDisposable {
  116243. protected scene: Scene;
  116244. protected layout: IMotionControllerLayout;
  116245. /**
  116246. * The gamepad object correlating to this controller
  116247. */
  116248. gamepadObject: IMinimalMotionControllerObject;
  116249. /**
  116250. * handness (left/right/none) of this controller
  116251. */
  116252. handness: MotionControllerHandness;
  116253. /**
  116254. * Component type map
  116255. */
  116256. static ComponentType: {
  116257. TRIGGER: string;
  116258. SQUEEZE: string;
  116259. TOUCHPAD: string;
  116260. THUMBSTICK: string;
  116261. BUTTON: string;
  116262. };
  116263. /**
  116264. * The profile id of this motion controller
  116265. */
  116266. abstract profileId: string;
  116267. /**
  116268. * A map of components (WebXRControllerComponent) in this motion controller
  116269. * Components have a ComponentType and can also have both button and axis definitions
  116270. */
  116271. readonly components: {
  116272. [id: string]: WebXRControllerComponent;
  116273. };
  116274. /**
  116275. * Observers registered here will be triggered when the model of this controller is done loading
  116276. */
  116277. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  116278. /**
  116279. * The root mesh of the model. It is null if the model was not yet initialized
  116280. */
  116281. rootMesh: Nullable<AbstractMesh>;
  116282. private _modelReady;
  116283. /**
  116284. * constructs a new abstract motion controller
  116285. * @param scene the scene to which the model of the controller will be added
  116286. * @param layout The profile layout to load
  116287. * @param gamepadObject The gamepad object correlating to this controller
  116288. * @param handness handness (left/right/none) of this controller
  116289. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  116290. */
  116291. constructor(scene: Scene, layout: IMotionControllerLayout,
  116292. /**
  116293. * The gamepad object correlating to this controller
  116294. */
  116295. gamepadObject: IMinimalMotionControllerObject,
  116296. /**
  116297. * handness (left/right/none) of this controller
  116298. */
  116299. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  116300. private _initComponent;
  116301. /**
  116302. * Update this model using the current XRFrame
  116303. * @param xrFrame the current xr frame to use and update the model
  116304. */
  116305. updateFromXRFrame(xrFrame: XRFrame): void;
  116306. /**
  116307. * Get the list of components available in this motion controller
  116308. * @returns an array of strings correlating to available components
  116309. */
  116310. getComponentTypes(): string[];
  116311. /**
  116312. * Get the main (Select) component of this controller as defined in the layout
  116313. * @returns the main component of this controller
  116314. */
  116315. getMainComponent(): WebXRControllerComponent;
  116316. /**
  116317. * get a component based an its component id as defined in layout.components
  116318. * @param id the id of the component
  116319. * @returns the component correlates to the id or undefined if not found
  116320. */
  116321. getComponent(id: string): WebXRControllerComponent;
  116322. /**
  116323. * Loads the model correlating to this controller
  116324. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  116325. * @returns A promise fulfilled with the result of the model loading
  116326. */
  116327. loadModel(): Promise<boolean>;
  116328. /**
  116329. * Update the model itself with the current frame data
  116330. * @param xrFrame the frame to use for updating the model mesh
  116331. */
  116332. protected updateModel(xrFrame: XRFrame): void;
  116333. /**
  116334. * Moves the axis on the controller mesh based on its current state
  116335. * @param axis the index of the axis
  116336. * @param axisValue the value of the axis which determines the meshes new position
  116337. * @hidden
  116338. */
  116339. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  116340. /**
  116341. * Moves the buttons on the controller mesh based on their current state
  116342. * @param buttonName the name of the button to move
  116343. * @param buttonValue the value of the button which determines the buttons new position
  116344. */
  116345. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  116346. private _getGenericFilenameAndPath;
  116347. private _getGenericParentMesh;
  116348. /**
  116349. * Get the filename and path for this controller's model
  116350. * @returns a map of filename and path
  116351. */
  116352. protected abstract _getFilenameAndPath(): {
  116353. filename: string;
  116354. path: string;
  116355. };
  116356. /**
  116357. * This function will be called after the model was successfully loaded and can be used
  116358. * for mesh transformations before it is available for the user
  116359. * @param meshes the loaded meshes
  116360. */
  116361. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  116362. /**
  116363. * Set the root mesh for this controller. Important for the WebXR controller class
  116364. * @param meshes the loaded meshes
  116365. */
  116366. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  116367. /**
  116368. * A function executed each frame that updates the mesh (if needed)
  116369. * @param xrFrame the current xrFrame
  116370. */
  116371. protected abstract _updateModel(xrFrame: XRFrame): void;
  116372. /**
  116373. * This function is called before the mesh is loaded. It checks for loading constraints.
  116374. * For example, this function can check if the GLB loader is available
  116375. * If this function returns false, the generic controller will be loaded instead
  116376. * @returns Is the client ready to load the mesh
  116377. */
  116378. protected abstract _getModelLoadingConstraints(): boolean;
  116379. /**
  116380. * Dispose this controller, the model mesh and all its components
  116381. */
  116382. dispose(): void;
  116383. }
  116384. }
  116385. declare module BABYLON {
  116386. /**
  116387. * A generic trigger-only motion controller for WebXR
  116388. */
  116389. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  116390. /**
  116391. * Static version of the profile id of this controller
  116392. */
  116393. static ProfileId: string;
  116394. profileId: string;
  116395. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116396. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  116397. protected _updateModel(): void;
  116398. protected _getFilenameAndPath(): {
  116399. filename: string;
  116400. path: string;
  116401. };
  116402. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116403. protected _getModelLoadingConstraints(): boolean;
  116404. }
  116405. }
  116406. declare module BABYLON {
  116407. /**
  116408. * A construction function type to create a new controller based on an xrInput object
  116409. */
  116410. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  116411. /**
  116412. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  116413. *
  116414. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  116415. * it should be replaced with auto-loaded controllers.
  116416. *
  116417. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  116418. */
  116419. export class WebXRMotionControllerManager {
  116420. private static _AvailableControllers;
  116421. private static _Fallbacks;
  116422. /**
  116423. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  116424. *
  116425. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  116426. *
  116427. * @param type the profile type to register
  116428. * @param constructFunction the function to be called when loading this profile
  116429. */
  116430. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  116431. /**
  116432. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  116433. * The order of search:
  116434. *
  116435. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  116436. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  116437. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  116438. * 4) return the generic trigger controller if none were found
  116439. *
  116440. * @param xrInput the xrInput to which a new controller is initialized
  116441. * @param scene the scene to which the model will be added
  116442. * @param forceProfile force a certain profile for this controller
  116443. * @return the motion controller class for this profile id or the generic standard class if none was found
  116444. */
  116445. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  116446. /**
  116447. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  116448. * @param profileId the profile to which a fallback needs to be found
  116449. * @return an array with corresponding fallback profiles
  116450. */
  116451. static FindFallbackWithProfileId(profileId: string): string[];
  116452. /**
  116453. * Register a fallback to a specific profile.
  116454. * @param profileId the profileId that will receive the fallbacks
  116455. * @param fallbacks A list of fallback profiles
  116456. */
  116457. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  116458. /**
  116459. * Register the default fallbacks.
  116460. * This function is called automatically when this file is imported.
  116461. */
  116462. static DefaultFallbacks(): void;
  116463. }
  116464. }
  116465. declare module BABYLON {
  116466. /**
  116467. * Configuration options for the WebXR controller creation
  116468. */
  116469. export interface IWebXRControllerOptions {
  116470. /**
  116471. * Force a specific controller type for this controller.
  116472. * This can be used when creating your own profile or when testing different controllers
  116473. */
  116474. forceControllerProfile?: string;
  116475. }
  116476. /**
  116477. * Represents an XR controller
  116478. */
  116479. export class WebXRController {
  116480. private _scene;
  116481. /** The underlying input source for the controller */
  116482. inputSource: XRInputSource;
  116483. private _options;
  116484. /**
  116485. * 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
  116486. */
  116487. grip?: AbstractMesh;
  116488. /**
  116489. * Pointer which can be used to select objects or attach a visible laser to
  116490. */
  116491. pointer: AbstractMesh;
  116492. /**
  116493. * If available, this is the gamepad object related to this controller.
  116494. * Using this object it is possible to get click events and trackpad changes of the
  116495. * webxr controller that is currently being used.
  116496. */
  116497. motionController?: WebXRAbstractMotionController;
  116498. /**
  116499. * Event that fires when the controller is removed/disposed
  116500. */
  116501. onDisposeObservable: Observable<{}>;
  116502. private _tmpQuaternion;
  116503. private _tmpVector;
  116504. private _uniqueId;
  116505. /**
  116506. * Creates the controller
  116507. * @see https://doc.babylonjs.com/how_to/webxr
  116508. * @param _scene the scene which the controller should be associated to
  116509. * @param inputSource the underlying input source for the controller
  116510. * @param _options options for this controller creation
  116511. */
  116512. constructor(_scene: Scene,
  116513. /** The underlying input source for the controller */
  116514. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  116515. /**
  116516. * Get this controllers unique id
  116517. */
  116518. get uniqueId(): string;
  116519. /**
  116520. * Updates the controller pose based on the given XRFrame
  116521. * @param xrFrame xr frame to update the pose with
  116522. * @param referenceSpace reference space to use
  116523. */
  116524. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  116525. /**
  116526. * Gets a world space ray coming from the controller
  116527. * @param result the resulting ray
  116528. */
  116529. getWorldPointerRayToRef(result: Ray): void;
  116530. /**
  116531. * Disposes of the object
  116532. */
  116533. dispose(): void;
  116534. }
  116535. }
  116536. declare module BABYLON {
  116537. /**
  116538. * The schema for initialization options of the XR Input class
  116539. */
  116540. export interface IWebXRInputOptions {
  116541. /**
  116542. * If set to true no model will be automatically loaded
  116543. */
  116544. doNotLoadControllerMeshes?: boolean;
  116545. /**
  116546. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  116547. * If not found, the xr input profile data will be used.
  116548. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  116549. */
  116550. forceInputProfile?: string;
  116551. }
  116552. /**
  116553. * XR input used to track XR inputs such as controllers/rays
  116554. */
  116555. export class WebXRInput implements IDisposable {
  116556. /**
  116557. * the xr session manager for this session
  116558. */
  116559. xrSessionManager: WebXRSessionManager;
  116560. /**
  116561. * the WebXR camera for this session. Mainly used for teleportation
  116562. */
  116563. xrCamera: WebXRCamera;
  116564. private readonly options;
  116565. /**
  116566. * XR controllers being tracked
  116567. */
  116568. controllers: Array<WebXRController>;
  116569. private _frameObserver;
  116570. private _sessionEndedObserver;
  116571. private _sessionInitObserver;
  116572. /**
  116573. * Event when a controller has been connected/added
  116574. */
  116575. onControllerAddedObservable: Observable<WebXRController>;
  116576. /**
  116577. * Event when a controller has been removed/disconnected
  116578. */
  116579. onControllerRemovedObservable: Observable<WebXRController>;
  116580. /**
  116581. * Initializes the WebXRInput
  116582. * @param xrSessionManager the xr session manager for this session
  116583. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  116584. * @param options = initialization options for this xr input
  116585. */
  116586. constructor(
  116587. /**
  116588. * the xr session manager for this session
  116589. */
  116590. xrSessionManager: WebXRSessionManager,
  116591. /**
  116592. * the WebXR camera for this session. Mainly used for teleportation
  116593. */
  116594. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  116595. private _onInputSourcesChange;
  116596. private _addAndRemoveControllers;
  116597. /**
  116598. * Disposes of the object
  116599. */
  116600. dispose(): void;
  116601. }
  116602. }
  116603. declare module BABYLON {
  116604. /**
  116605. * This is the base class for all WebXR features.
  116606. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  116607. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  116608. */
  116609. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  116610. protected _xrSessionManager: WebXRSessionManager;
  116611. /**
  116612. * Construct a new (abstract) webxr feature
  116613. * @param _xrSessionManager the xr session manager for this feature
  116614. */
  116615. constructor(_xrSessionManager: WebXRSessionManager);
  116616. private _attached;
  116617. private _removeOnDetach;
  116618. /**
  116619. * Is this feature attached
  116620. */
  116621. get attached(): boolean;
  116622. /**
  116623. * attach this feature
  116624. *
  116625. * @returns true if successful, false is failed or already attached
  116626. */
  116627. attach(): boolean;
  116628. /**
  116629. * detach this feature.
  116630. *
  116631. * @returns true if successful, false if failed or already detached
  116632. */
  116633. detach(): boolean;
  116634. /**
  116635. * Dispose this feature and all of the resources attached
  116636. */
  116637. dispose(): void;
  116638. /**
  116639. * Code in this function will be executed on each xrFrame received from the browser.
  116640. * This function will not execute after the feature is detached.
  116641. * @param _xrFrame the current frame
  116642. */
  116643. protected _onXRFrame(_xrFrame: XRFrame): void;
  116644. /**
  116645. * This is used to register callbacks that will automatically be removed when detach is called.
  116646. * @param observable the observable to which the observer will be attached
  116647. * @param callback the callback to register
  116648. */
  116649. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  116650. }
  116651. }
  116652. declare module BABYLON {
  116653. /**
  116654. * Options interface for the pointer selection module
  116655. */
  116656. export interface IWebXRControllerPointerSelectionOptions {
  116657. /**
  116658. * the xr input to use with this pointer selection
  116659. */
  116660. xrInput: WebXRInput;
  116661. /**
  116662. * Different button type to use instead of the main component
  116663. */
  116664. overrideButtonId?: string;
  116665. /**
  116666. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  116667. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  116668. * 3000 means 3 seconds between pointing at something and selecting it
  116669. */
  116670. timeToSelect?: number;
  116671. /**
  116672. * 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)
  116673. * If not disabled, the last picked point will be used to execute a pointer up event
  116674. * If disabled, pointer up event will be triggered right after the pointer down event.
  116675. * Used in screen and gaze target ray mode only
  116676. */
  116677. disablePointerUpOnTouchOut: boolean;
  116678. /**
  116679. * For gaze mode (time to select instead of press)
  116680. */
  116681. forceGazeMode: boolean;
  116682. /**
  116683. * 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
  116684. * to start a new countdown to the pointer down event.
  116685. * Defaults to 1.
  116686. */
  116687. gazeModePointerMovedFactor?: number;
  116688. }
  116689. /**
  116690. * A module that will enable pointer selection for motion controllers of XR Input Sources
  116691. */
  116692. export class WebXRControllerPointerSelection extends WebXRAbstractFeature implements IWebXRFeature {
  116693. private readonly _options;
  116694. /**
  116695. * The module's name
  116696. */
  116697. static readonly Name: string;
  116698. /**
  116699. * The (Babylon) version of this module.
  116700. * This is an integer representing the implementation version.
  116701. * This number does not correspond to the webxr specs version
  116702. */
  116703. static readonly Version: number;
  116704. /**
  116705. * This color will be set to the laser pointer when selection is triggered
  116706. */
  116707. laserPointerPickedColor: Color3;
  116708. /**
  116709. * This color will be applied to the selection ring when selection is triggered
  116710. */
  116711. selectionMeshPickedColor: Color3;
  116712. /**
  116713. * default color of the selection ring
  116714. */
  116715. selectionMeshDefaultColor: Color3;
  116716. /**
  116717. * Default color of the laser pointer
  116718. */
  116719. lasterPointerDefaultColor: Color3;
  116720. /**
  116721. * Should the laser pointer be displayed
  116722. */
  116723. displayLaserPointer: boolean;
  116724. /**
  116725. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  116726. */
  116727. displaySelectionMesh: boolean;
  116728. private static _idCounter;
  116729. private _tmpRay;
  116730. private _controllers;
  116731. private _scene;
  116732. /**
  116733. * constructs a new background remover module
  116734. * @param _xrSessionManager the session manager for this module
  116735. * @param _options read-only options to be used in this module
  116736. */
  116737. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  116738. /**
  116739. * attach this feature
  116740. * Will usually be called by the features manager
  116741. *
  116742. * @returns true if successful.
  116743. */
  116744. attach(): boolean;
  116745. /**
  116746. * detach this feature.
  116747. * Will usually be called by the features manager
  116748. *
  116749. * @returns true if successful.
  116750. */
  116751. detach(): boolean;
  116752. /**
  116753. * Get the xr controller that correlates to the pointer id in the pointer event
  116754. *
  116755. * @param id the pointer id to search for
  116756. * @returns the controller that correlates to this id or null if not found
  116757. */
  116758. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  116759. protected _onXRFrame(_xrFrame: XRFrame): void;
  116760. private _attachController;
  116761. private _attachScreenRayMode;
  116762. private _attachGazeMode;
  116763. private _tmpVectorForPickCompare;
  116764. private _pickingMoved;
  116765. private _attachTrackedPointerRayMode;
  116766. private _detachController;
  116767. private _generateNewMeshPair;
  116768. private _convertNormalToDirectionOfRay;
  116769. private _updatePointerDistance;
  116770. }
  116771. }
  116772. declare module BABYLON {
  116773. /**
  116774. * Button which can be used to enter a different mode of XR
  116775. */
  116776. export class WebXREnterExitUIButton {
  116777. /** button element */
  116778. element: HTMLElement;
  116779. /** XR initialization options for the button */
  116780. sessionMode: XRSessionMode;
  116781. /** Reference space type */
  116782. referenceSpaceType: XRReferenceSpaceType;
  116783. /**
  116784. * Creates a WebXREnterExitUIButton
  116785. * @param element button element
  116786. * @param sessionMode XR initialization session mode
  116787. * @param referenceSpaceType the type of reference space to be used
  116788. */
  116789. constructor(
  116790. /** button element */
  116791. element: HTMLElement,
  116792. /** XR initialization options for the button */
  116793. sessionMode: XRSessionMode,
  116794. /** Reference space type */
  116795. referenceSpaceType: XRReferenceSpaceType);
  116796. /**
  116797. * Overwritable function which can be used to update the button's visuals when the state changes
  116798. * @param activeButton the current active button in the UI
  116799. */
  116800. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  116801. }
  116802. /**
  116803. * Options to create the webXR UI
  116804. */
  116805. export class WebXREnterExitUIOptions {
  116806. /**
  116807. * Context to enter xr with
  116808. */
  116809. renderTarget?: Nullable<WebXRRenderTarget>;
  116810. /**
  116811. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  116812. */
  116813. customButtons?: Array<WebXREnterExitUIButton>;
  116814. /**
  116815. * A session mode to use when creating the default button.
  116816. * Default is immersive-vr
  116817. */
  116818. sessionMode?: XRSessionMode;
  116819. /**
  116820. * A reference space type to use when creating the default button.
  116821. * Default is local-floor
  116822. */
  116823. referenceSpaceType?: XRReferenceSpaceType;
  116824. }
  116825. /**
  116826. * UI to allow the user to enter/exit XR mode
  116827. */
  116828. export class WebXREnterExitUI implements IDisposable {
  116829. private scene;
  116830. /** version of the options passed to this UI */
  116831. options: WebXREnterExitUIOptions;
  116832. private _overlay;
  116833. private _buttons;
  116834. private _activeButton;
  116835. /**
  116836. * Fired every time the active button is changed.
  116837. *
  116838. * When xr is entered via a button that launches xr that button will be the callback parameter
  116839. *
  116840. * When exiting xr the callback parameter will be null)
  116841. */
  116842. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  116843. /**
  116844. * Creates UI to allow the user to enter/exit XR mode
  116845. * @param scene the scene to add the ui to
  116846. * @param helper the xr experience helper to enter/exit xr with
  116847. * @param options options to configure the UI
  116848. * @returns the created ui
  116849. */
  116850. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  116851. /**
  116852. *
  116853. * @param scene babylon scene object to use
  116854. * @param options (read-only) version of the options passed to this UI
  116855. */
  116856. private constructor();
  116857. private _updateButtons;
  116858. /**
  116859. * Disposes of the object
  116860. */
  116861. dispose(): void;
  116862. }
  116863. }
  116864. declare module BABYLON {
  116865. /**
  116866. * Class containing static functions to help procedurally build meshes
  116867. */
  116868. export class LinesBuilder {
  116869. /**
  116870. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116871. * * 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
  116872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116873. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116874. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116875. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116877. * * 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
  116878. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116881. * @param name defines the name of the new line system
  116882. * @param options defines the options used to create the line system
  116883. * @param scene defines the hosting scene
  116884. * @returns a new line system mesh
  116885. */
  116886. static CreateLineSystem(name: string, options: {
  116887. lines: Vector3[][];
  116888. updatable?: boolean;
  116889. instance?: Nullable<LinesMesh>;
  116890. colors?: Nullable<Color4[][]>;
  116891. useVertexAlpha?: boolean;
  116892. }, scene: Nullable<Scene>): LinesMesh;
  116893. /**
  116894. * Creates a line mesh
  116895. * 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
  116896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116897. * * The parameter `points` is an array successive Vector3
  116898. * * 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
  116899. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116900. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116901. * * When updating an instance, remember that only point positions can change, not the number of points
  116902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116904. * @param name defines the name of the new line system
  116905. * @param options defines the options used to create the line system
  116906. * @param scene defines the hosting scene
  116907. * @returns a new line mesh
  116908. */
  116909. static CreateLines(name: string, options: {
  116910. points: Vector3[];
  116911. updatable?: boolean;
  116912. instance?: Nullable<LinesMesh>;
  116913. colors?: Color4[];
  116914. useVertexAlpha?: boolean;
  116915. }, scene?: Nullable<Scene>): LinesMesh;
  116916. /**
  116917. * Creates a dashed line mesh
  116918. * * 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
  116919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116920. * * The parameter `points` is an array successive Vector3
  116921. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116922. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116923. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116924. * * 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
  116925. * * When updating an instance, remember that only point positions can change, not the number of points
  116926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116927. * @param name defines the name of the mesh
  116928. * @param options defines the options used to create the mesh
  116929. * @param scene defines the hosting scene
  116930. * @returns the dashed line mesh
  116931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116932. */
  116933. static CreateDashedLines(name: string, options: {
  116934. points: Vector3[];
  116935. dashSize?: number;
  116936. gapSize?: number;
  116937. dashNb?: number;
  116938. updatable?: boolean;
  116939. instance?: LinesMesh;
  116940. }, scene?: Nullable<Scene>): LinesMesh;
  116941. }
  116942. }
  116943. declare module BABYLON {
  116944. /**
  116945. * The options container for the teleportation module
  116946. */
  116947. export interface IWebXRTeleportationOptions {
  116948. /**
  116949. * Babylon XR Input class for controller
  116950. */
  116951. xrInput: WebXRInput;
  116952. /**
  116953. * A list of meshes to use as floor meshes.
  116954. * Meshes can be added and removed after initializing the feature using the
  116955. * addFloorMesh and removeFloorMesh functions
  116956. * If empty, rotation will still work
  116957. */
  116958. floorMeshes?: AbstractMesh[];
  116959. /**
  116960. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  116961. * If you want to support rotation, make sure your mesh has a direction indicator.
  116962. *
  116963. * When left untouched, the default mesh will be initialized.
  116964. */
  116965. teleportationTargetMesh?: AbstractMesh;
  116966. /**
  116967. * Values to configure the default target mesh
  116968. */
  116969. defaultTargetMeshOptions?: {
  116970. /**
  116971. * Fill color of the teleportation area
  116972. */
  116973. teleportationFillColor?: string;
  116974. /**
  116975. * Border color for the teleportation area
  116976. */
  116977. teleportationBorderColor?: string;
  116978. /**
  116979. * Override the default material of the torus and arrow
  116980. */
  116981. torusArrowMaterial?: Material;
  116982. /**
  116983. * Disable the mesh's animation sequence
  116984. */
  116985. disableAnimation?: boolean;
  116986. };
  116987. /**
  116988. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  116989. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  116990. */
  116991. useMainComponentOnly?: boolean;
  116992. /**
  116993. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  116994. */
  116995. timeToTeleport?: number;
  116996. }
  116997. /**
  116998. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  116999. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  117000. * the input of the attached controllers.
  117001. */
  117002. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature implements IWebXRFeature {
  117003. private _options;
  117004. /**
  117005. * The module's name
  117006. */
  117007. static readonly Name: string;
  117008. /**
  117009. * The (Babylon) version of this module.
  117010. * This is an integer representing the implementation version.
  117011. * This number does not correspond to the webxr specs version
  117012. */
  117013. static readonly Version: number;
  117014. /**
  117015. * Is rotation enabled when moving forward?
  117016. * Disabling this feature will prevent the user from deciding the direction when teleporting
  117017. */
  117018. rotationEnabled: boolean;
  117019. /**
  117020. * Should the module support parabolic ray on top of direct ray
  117021. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  117022. * Very helpful when moving between floors / different heights
  117023. */
  117024. parabolicRayEnabled: boolean;
  117025. /**
  117026. * The distance from the user to the inspection point in the direction of the controller
  117027. * A higher number will allow the user to move further
  117028. * defaults to 5 (meters, in xr units)
  117029. */
  117030. parabolicCheckRadius: number;
  117031. /**
  117032. * How much rotation should be applied when rotating right and left
  117033. */
  117034. rotationAngle: number;
  117035. /**
  117036. * Distance to travel when moving backwards
  117037. */
  117038. backwardsTeleportationDistance: number;
  117039. /**
  117040. * Add a new mesh to the floor meshes array
  117041. * @param mesh the mesh to use as floor mesh
  117042. */
  117043. addFloorMesh(mesh: AbstractMesh): void;
  117044. /**
  117045. * Remove a mesh from the floor meshes array
  117046. * @param mesh the mesh to remove
  117047. */
  117048. removeFloorMesh(mesh: AbstractMesh): void;
  117049. /**
  117050. * Remove a mesh from the floor meshes array using its name
  117051. * @param name the mesh name to remove
  117052. */
  117053. removeFloorMeshByName(name: string): void;
  117054. private _tmpRay;
  117055. private _tmpVector;
  117056. private _floorMeshes;
  117057. private _controllers;
  117058. /**
  117059. * constructs a new anchor system
  117060. * @param _xrSessionManager an instance of WebXRSessionManager
  117061. * @param _options configuration object for this feature
  117062. */
  117063. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  117064. private _selectionFeature;
  117065. /**
  117066. * This function sets a selection feature that will be disabled when
  117067. * the forward ray is shown and will be reattached when hidden.
  117068. * This is used to remove the selection rays when moving.
  117069. * @param selectionFeature the feature to disable when forward movement is enabled
  117070. */
  117071. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  117072. attach(): boolean;
  117073. detach(): boolean;
  117074. dispose(): void;
  117075. protected _onXRFrame(_xrFrame: XRFrame): void;
  117076. private _currentTeleportationControllerId;
  117077. private _attachController;
  117078. private _teleportForward;
  117079. private _detachController;
  117080. private createDefaultTargetMesh;
  117081. private setTargetMeshVisibility;
  117082. private setTargetMeshPosition;
  117083. private _quadraticBezierCurve;
  117084. private showParabolicPath;
  117085. }
  117086. }
  117087. declare module BABYLON {
  117088. /**
  117089. * Options for the default xr helper
  117090. */
  117091. export class WebXRDefaultExperienceOptions {
  117092. /**
  117093. * Floor meshes that will be used for teleporting
  117094. */
  117095. floorMeshes?: Array<AbstractMesh>;
  117096. /**
  117097. * Enable or disable default UI to enter XR
  117098. */
  117099. disableDefaultUI?: boolean;
  117100. /**
  117101. * optional configuration for the output canvas
  117102. */
  117103. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  117104. /**
  117105. * optional UI options. This can be used among other to change session mode and reference space type
  117106. */
  117107. uiOptions?: WebXREnterExitUIOptions;
  117108. /**
  117109. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  117110. */
  117111. inputOptions?: IWebXRInputOptions;
  117112. /**
  117113. * Should teleportation not initialize. defaults to false.
  117114. */
  117115. disableTeleportation?: boolean;
  117116. }
  117117. /**
  117118. * Default experience which provides a similar setup to the previous webVRExperience
  117119. */
  117120. export class WebXRDefaultExperience {
  117121. /**
  117122. * Base experience
  117123. */
  117124. baseExperience: WebXRExperienceHelper;
  117125. /**
  117126. * Input experience extension
  117127. */
  117128. input: WebXRInput;
  117129. /**
  117130. * Enables laser pointer and selection
  117131. */
  117132. pointerSelection: WebXRControllerPointerSelection;
  117133. /**
  117134. * Enables teleportation
  117135. */
  117136. teleportation: WebXRMotionControllerTeleportation;
  117137. /**
  117138. * Enables ui for entering/exiting xr
  117139. */
  117140. enterExitUI: WebXREnterExitUI;
  117141. /**
  117142. * Default target xr should render to
  117143. */
  117144. renderTarget: WebXRRenderTarget;
  117145. /**
  117146. * Creates the default xr experience
  117147. * @param scene scene
  117148. * @param options options for basic configuration
  117149. * @returns resulting WebXRDefaultExperience
  117150. */
  117151. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117152. private constructor();
  117153. /**
  117154. * DIsposes of the experience helper
  117155. */
  117156. dispose(): void;
  117157. }
  117158. }
  117159. declare module BABYLON {
  117160. /**
  117161. * Options to modify the vr teleportation behavior.
  117162. */
  117163. export interface VRTeleportationOptions {
  117164. /**
  117165. * The name of the mesh which should be used as the teleportation floor. (default: null)
  117166. */
  117167. floorMeshName?: string;
  117168. /**
  117169. * A list of meshes to be used as the teleportation floor. (default: empty)
  117170. */
  117171. floorMeshes?: Mesh[];
  117172. /**
  117173. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  117174. */
  117175. teleportationMode?: number;
  117176. /**
  117177. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  117178. */
  117179. teleportationTime?: number;
  117180. /**
  117181. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  117182. */
  117183. teleportationSpeed?: number;
  117184. /**
  117185. * The easing function used in the animation or null for Linear. (default CircleEase)
  117186. */
  117187. easingFunction?: EasingFunction;
  117188. }
  117189. /**
  117190. * Options to modify the vr experience helper's behavior.
  117191. */
  117192. export interface VRExperienceHelperOptions extends WebVROptions {
  117193. /**
  117194. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  117195. */
  117196. createDeviceOrientationCamera?: boolean;
  117197. /**
  117198. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  117199. */
  117200. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  117201. /**
  117202. * Uses the main button on the controller to toggle the laser casted. (default: true)
  117203. */
  117204. laserToggle?: boolean;
  117205. /**
  117206. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  117207. */
  117208. floorMeshes?: Mesh[];
  117209. /**
  117210. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  117211. */
  117212. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  117213. /**
  117214. * Defines if WebXR should be used instead of WebVR (if available)
  117215. */
  117216. useXR?: boolean;
  117217. }
  117218. /**
  117219. * Event containing information after VR has been entered
  117220. */
  117221. export class OnAfterEnteringVRObservableEvent {
  117222. /**
  117223. * If entering vr was successful
  117224. */
  117225. success: boolean;
  117226. }
  117227. /**
  117228. * Helps to quickly add VR support to an existing scene.
  117229. * See http://doc.babylonjs.com/how_to/webvr_helper
  117230. */
  117231. export class VRExperienceHelper {
  117232. /** Options to modify the vr experience helper's behavior. */
  117233. webVROptions: VRExperienceHelperOptions;
  117234. private _scene;
  117235. private _position;
  117236. private _btnVR;
  117237. private _btnVRDisplayed;
  117238. private _webVRsupported;
  117239. private _webVRready;
  117240. private _webVRrequesting;
  117241. private _webVRpresenting;
  117242. private _hasEnteredVR;
  117243. private _fullscreenVRpresenting;
  117244. private _inputElement;
  117245. private _webVRCamera;
  117246. private _vrDeviceOrientationCamera;
  117247. private _deviceOrientationCamera;
  117248. private _existingCamera;
  117249. private _onKeyDown;
  117250. private _onVrDisplayPresentChange;
  117251. private _onVRDisplayChanged;
  117252. private _onVRRequestPresentStart;
  117253. private _onVRRequestPresentComplete;
  117254. /**
  117255. * 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)
  117256. */
  117257. enableGazeEvenWhenNoPointerLock: boolean;
  117258. /**
  117259. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  117260. */
  117261. exitVROnDoubleTap: boolean;
  117262. /**
  117263. * Observable raised right before entering VR.
  117264. */
  117265. onEnteringVRObservable: Observable<VRExperienceHelper>;
  117266. /**
  117267. * Observable raised when entering VR has completed.
  117268. */
  117269. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  117270. /**
  117271. * Observable raised when exiting VR.
  117272. */
  117273. onExitingVRObservable: Observable<VRExperienceHelper>;
  117274. /**
  117275. * Observable raised when controller mesh is loaded.
  117276. */
  117277. onControllerMeshLoadedObservable: Observable<WebVRController>;
  117278. /** Return this.onEnteringVRObservable
  117279. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  117280. */
  117281. get onEnteringVR(): Observable<VRExperienceHelper>;
  117282. /** Return this.onExitingVRObservable
  117283. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  117284. */
  117285. get onExitingVR(): Observable<VRExperienceHelper>;
  117286. /** Return this.onControllerMeshLoadedObservable
  117287. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  117288. */
  117289. get onControllerMeshLoaded(): Observable<WebVRController>;
  117290. private _rayLength;
  117291. private _useCustomVRButton;
  117292. private _teleportationRequested;
  117293. private _teleportActive;
  117294. private _floorMeshName;
  117295. private _floorMeshesCollection;
  117296. private _teleportationMode;
  117297. private _teleportationTime;
  117298. private _teleportationSpeed;
  117299. private _teleportationEasing;
  117300. private _rotationAllowed;
  117301. private _teleportBackwardsVector;
  117302. private _teleportationTarget;
  117303. private _isDefaultTeleportationTarget;
  117304. private _postProcessMove;
  117305. private _teleportationFillColor;
  117306. private _teleportationBorderColor;
  117307. private _rotationAngle;
  117308. private _haloCenter;
  117309. private _cameraGazer;
  117310. private _padSensibilityUp;
  117311. private _padSensibilityDown;
  117312. private _leftController;
  117313. private _rightController;
  117314. private _gazeColor;
  117315. private _laserColor;
  117316. private _pickedLaserColor;
  117317. private _pickedGazeColor;
  117318. /**
  117319. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  117320. */
  117321. onNewMeshSelected: Observable<AbstractMesh>;
  117322. /**
  117323. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  117324. * This observable will provide the mesh and the controller used to select the mesh
  117325. */
  117326. onMeshSelectedWithController: Observable<{
  117327. mesh: AbstractMesh;
  117328. controller: WebVRController;
  117329. }>;
  117330. /**
  117331. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  117332. */
  117333. onNewMeshPicked: Observable<PickingInfo>;
  117334. private _circleEase;
  117335. /**
  117336. * Observable raised before camera teleportation
  117337. */
  117338. onBeforeCameraTeleport: Observable<Vector3>;
  117339. /**
  117340. * Observable raised after camera teleportation
  117341. */
  117342. onAfterCameraTeleport: Observable<Vector3>;
  117343. /**
  117344. * Observable raised when current selected mesh gets unselected
  117345. */
  117346. onSelectedMeshUnselected: Observable<AbstractMesh>;
  117347. private _raySelectionPredicate;
  117348. /**
  117349. * To be optionaly changed by user to define custom ray selection
  117350. */
  117351. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  117352. /**
  117353. * To be optionaly changed by user to define custom selection logic (after ray selection)
  117354. */
  117355. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117356. /**
  117357. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  117358. */
  117359. teleportationEnabled: boolean;
  117360. private _defaultHeight;
  117361. private _teleportationInitialized;
  117362. private _interactionsEnabled;
  117363. private _interactionsRequested;
  117364. private _displayGaze;
  117365. private _displayLaserPointer;
  117366. /**
  117367. * The mesh used to display where the user is going to teleport.
  117368. */
  117369. get teleportationTarget(): Mesh;
  117370. /**
  117371. * Sets the mesh to be used to display where the user is going to teleport.
  117372. */
  117373. set teleportationTarget(value: Mesh);
  117374. /**
  117375. * 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
  117376. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  117377. * See http://doc.babylonjs.com/resources/baking_transformations
  117378. */
  117379. get gazeTrackerMesh(): Mesh;
  117380. set gazeTrackerMesh(value: Mesh);
  117381. /**
  117382. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  117383. */
  117384. updateGazeTrackerScale: boolean;
  117385. /**
  117386. * If the gaze trackers color should be updated when selecting meshes
  117387. */
  117388. updateGazeTrackerColor: boolean;
  117389. /**
  117390. * If the controller laser color should be updated when selecting meshes
  117391. */
  117392. updateControllerLaserColor: boolean;
  117393. /**
  117394. * The gaze tracking mesh corresponding to the left controller
  117395. */
  117396. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  117397. /**
  117398. * The gaze tracking mesh corresponding to the right controller
  117399. */
  117400. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  117401. /**
  117402. * If the ray of the gaze should be displayed.
  117403. */
  117404. get displayGaze(): boolean;
  117405. /**
  117406. * Sets if the ray of the gaze should be displayed.
  117407. */
  117408. set displayGaze(value: boolean);
  117409. /**
  117410. * If the ray of the LaserPointer should be displayed.
  117411. */
  117412. get displayLaserPointer(): boolean;
  117413. /**
  117414. * Sets if the ray of the LaserPointer should be displayed.
  117415. */
  117416. set displayLaserPointer(value: boolean);
  117417. /**
  117418. * The deviceOrientationCamera used as the camera when not in VR.
  117419. */
  117420. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  117421. /**
  117422. * Based on the current WebVR support, returns the current VR camera used.
  117423. */
  117424. get currentVRCamera(): Nullable<Camera>;
  117425. /**
  117426. * The webVRCamera which is used when in VR.
  117427. */
  117428. get webVRCamera(): WebVRFreeCamera;
  117429. /**
  117430. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  117431. */
  117432. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  117433. /**
  117434. * The html button that is used to trigger entering into VR.
  117435. */
  117436. get vrButton(): Nullable<HTMLButtonElement>;
  117437. private get _teleportationRequestInitiated();
  117438. /**
  117439. * Defines wether or not Pointer lock should be requested when switching to
  117440. * full screen.
  117441. */
  117442. requestPointerLockOnFullScreen: boolean;
  117443. /**
  117444. * If asking to force XR, this will be populated with the default xr experience
  117445. */
  117446. xr: WebXRDefaultExperience;
  117447. /**
  117448. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  117449. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  117450. */
  117451. xrTestDone: boolean;
  117452. /**
  117453. * Instantiates a VRExperienceHelper.
  117454. * Helps to quickly add VR support to an existing scene.
  117455. * @param scene The scene the VRExperienceHelper belongs to.
  117456. * @param webVROptions Options to modify the vr experience helper's behavior.
  117457. */
  117458. constructor(scene: Scene,
  117459. /** Options to modify the vr experience helper's behavior. */
  117460. webVROptions?: VRExperienceHelperOptions);
  117461. private completeVRInit;
  117462. private _onDefaultMeshLoaded;
  117463. private _onResize;
  117464. private _onFullscreenChange;
  117465. /**
  117466. * Gets a value indicating if we are currently in VR mode.
  117467. */
  117468. get isInVRMode(): boolean;
  117469. private onVrDisplayPresentChange;
  117470. private onVRDisplayChanged;
  117471. private moveButtonToBottomRight;
  117472. private displayVRButton;
  117473. private updateButtonVisibility;
  117474. private _cachedAngularSensibility;
  117475. /**
  117476. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  117477. * Otherwise, will use the fullscreen API.
  117478. */
  117479. enterVR(): void;
  117480. /**
  117481. * Attempt to exit VR, or fullscreen.
  117482. */
  117483. exitVR(): void;
  117484. /**
  117485. * The position of the vr experience helper.
  117486. */
  117487. get position(): Vector3;
  117488. /**
  117489. * Sets the position of the vr experience helper.
  117490. */
  117491. set position(value: Vector3);
  117492. /**
  117493. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  117494. */
  117495. enableInteractions(): void;
  117496. private get _noControllerIsActive();
  117497. private beforeRender;
  117498. private _isTeleportationFloor;
  117499. /**
  117500. * Adds a floor mesh to be used for teleportation.
  117501. * @param floorMesh the mesh to be used for teleportation.
  117502. */
  117503. addFloorMesh(floorMesh: Mesh): void;
  117504. /**
  117505. * Removes a floor mesh from being used for teleportation.
  117506. * @param floorMesh the mesh to be removed.
  117507. */
  117508. removeFloorMesh(floorMesh: Mesh): void;
  117509. /**
  117510. * Enables interactions and teleportation using the VR controllers and gaze.
  117511. * @param vrTeleportationOptions options to modify teleportation behavior.
  117512. */
  117513. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  117514. private _onNewGamepadConnected;
  117515. private _tryEnableInteractionOnController;
  117516. private _onNewGamepadDisconnected;
  117517. private _enableInteractionOnController;
  117518. private _checkTeleportWithRay;
  117519. private _checkRotate;
  117520. private _checkTeleportBackwards;
  117521. private _enableTeleportationOnController;
  117522. private _createTeleportationCircles;
  117523. private _displayTeleportationTarget;
  117524. private _hideTeleportationTarget;
  117525. private _rotateCamera;
  117526. private _moveTeleportationSelectorTo;
  117527. private _workingVector;
  117528. private _workingQuaternion;
  117529. private _workingMatrix;
  117530. /**
  117531. * Time Constant Teleportation Mode
  117532. */
  117533. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  117534. /**
  117535. * Speed Constant Teleportation Mode
  117536. */
  117537. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  117538. /**
  117539. * Teleports the users feet to the desired location
  117540. * @param location The location where the user's feet should be placed
  117541. */
  117542. teleportCamera(location: Vector3): void;
  117543. private _convertNormalToDirectionOfRay;
  117544. private _castRayAndSelectObject;
  117545. private _notifySelectedMeshUnselected;
  117546. /**
  117547. * Permanently set new colors for the laser pointer
  117548. * @param color the new laser color
  117549. * @param pickedColor the new laser color when picked mesh detected
  117550. */
  117551. setLaserColor(color: Color3, pickedColor?: Color3): void;
  117552. /**
  117553. * Permanently set new colors for the gaze pointer
  117554. * @param color the new gaze color
  117555. * @param pickedColor the new gaze color when picked mesh detected
  117556. */
  117557. setGazeColor(color: Color3, pickedColor?: Color3): void;
  117558. /**
  117559. * Sets the color of the laser ray from the vr controllers.
  117560. * @param color new color for the ray.
  117561. */
  117562. changeLaserColor(color: Color3): void;
  117563. /**
  117564. * Sets the color of the ray from the vr headsets gaze.
  117565. * @param color new color for the ray.
  117566. */
  117567. changeGazeColor(color: Color3): void;
  117568. /**
  117569. * Exits VR and disposes of the vr experience helper
  117570. */
  117571. dispose(): void;
  117572. /**
  117573. * Gets the name of the VRExperienceHelper class
  117574. * @returns "VRExperienceHelper"
  117575. */
  117576. getClassName(): string;
  117577. }
  117578. }
  117579. declare module BABYLON {
  117580. /**
  117581. * Options used for hit testing
  117582. */
  117583. export interface IWebXRHitTestOptions {
  117584. /**
  117585. * Only test when user interacted with the scene. Default - hit test every frame
  117586. */
  117587. testOnPointerDownOnly?: boolean;
  117588. /**
  117589. * The node to use to transform the local results to world coordinates
  117590. */
  117591. worldParentNode?: TransformNode;
  117592. }
  117593. /**
  117594. * Interface defining the babylon result of raycasting/hit-test
  117595. */
  117596. export interface IWebXRHitResult {
  117597. /**
  117598. * The native hit test result
  117599. */
  117600. xrHitResult: XRHitResult;
  117601. /**
  117602. * Transformation matrix that can be applied to a node that will put it in the hit point location
  117603. */
  117604. transformationMatrix: Matrix;
  117605. }
  117606. /**
  117607. * The currently-working hit-test module.
  117608. * Hit test (or raycasting) is used to interact with the real world.
  117609. * For further information read here - https://github.com/immersive-web/hit-test
  117610. */
  117611. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRFeature {
  117612. /**
  117613. * options to use when constructing this feature
  117614. */
  117615. readonly options: IWebXRHitTestOptions;
  117616. /**
  117617. * The module's name
  117618. */
  117619. static readonly Name: string;
  117620. /**
  117621. * The (Babylon) version of this module.
  117622. * This is an integer representing the implementation version.
  117623. * This number does not correspond to the webxr specs version
  117624. */
  117625. static readonly Version: number;
  117626. /**
  117627. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  117628. * @param event the (select) event to use to select with
  117629. * @param referenceSpace the reference space to use for this hit test
  117630. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117631. */
  117632. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  117633. /**
  117634. * execute a hit test with an XR Ray
  117635. *
  117636. * @param xrSession a native xrSession that will execute this hit test
  117637. * @param xrRay the ray (position and direction) to use for raycasting
  117638. * @param referenceSpace native XR reference space to use for the hit-test
  117639. * @param filter filter function that will filter the results
  117640. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117641. */
  117642. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  117643. /**
  117644. * Triggered when new babylon (transformed) hit test results are available
  117645. */
  117646. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  117647. private _onSelectEnabled;
  117648. /**
  117649. * Creates a new instance of the (legacy version) hit test feature
  117650. * @param _xrSessionManager an instance of WebXRSessionManager
  117651. * @param options options to use when constructing this feature
  117652. */
  117653. constructor(_xrSessionManager: WebXRSessionManager,
  117654. /**
  117655. * options to use when constructing this feature
  117656. */
  117657. options?: IWebXRHitTestOptions);
  117658. /**
  117659. * Populated with the last native XR Hit Results
  117660. */
  117661. lastNativeXRHitResults: XRHitResult[];
  117662. /**
  117663. * attach this feature
  117664. * Will usually be called by the features manager
  117665. *
  117666. * @returns true if successful.
  117667. */
  117668. attach(): boolean;
  117669. /**
  117670. * detach this feature.
  117671. * Will usually be called by the features manager
  117672. *
  117673. * @returns true if successful.
  117674. */
  117675. detach(): boolean;
  117676. private _onHitTestResults;
  117677. private _origin;
  117678. private _direction;
  117679. private _mat;
  117680. protected _onXRFrame(frame: XRFrame): void;
  117681. private _onSelect;
  117682. /**
  117683. * Dispose this feature and all of the resources attached
  117684. */
  117685. dispose(): void;
  117686. }
  117687. }
  117688. declare module BABYLON {
  117689. /**
  117690. * Options used in the plane detector module
  117691. */
  117692. export interface IWebXRPlaneDetectorOptions {
  117693. /**
  117694. * The node to use to transform the local results to world coordinates
  117695. */
  117696. worldParentNode?: TransformNode;
  117697. }
  117698. /**
  117699. * A babylon interface for a webxr plane.
  117700. * A Plane is actually a polygon, built from N points in space
  117701. */
  117702. export interface IWebXRPlane {
  117703. /**
  117704. * a babylon-assigned ID for this polygon
  117705. */
  117706. id: number;
  117707. /**
  117708. * the native xr-plane object
  117709. */
  117710. xrPlane: XRPlane;
  117711. /**
  117712. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  117713. */
  117714. polygonDefinition: Array<Vector3>;
  117715. /**
  117716. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  117717. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  117718. */
  117719. transformationMatrix: Matrix;
  117720. }
  117721. /**
  117722. * The plane detector is used to detect planes in the real world when in AR
  117723. * For more information see https://github.com/immersive-web/real-world-geometry/
  117724. */
  117725. export class WebXRPlaneDetector extends WebXRAbstractFeature implements IWebXRFeature {
  117726. private _options;
  117727. /**
  117728. * The module's name
  117729. */
  117730. static readonly Name: string;
  117731. /**
  117732. * The (Babylon) version of this module.
  117733. * This is an integer representing the implementation version.
  117734. * This number does not correspond to the webxr specs version
  117735. */
  117736. static readonly Version: number;
  117737. /**
  117738. * Observers registered here will be executed when a new plane was added to the session
  117739. */
  117740. onPlaneAddedObservable: Observable<IWebXRPlane>;
  117741. /**
  117742. * Observers registered here will be executed when a plane is no longer detected in the session
  117743. */
  117744. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  117745. /**
  117746. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  117747. * This can execute N times every frame
  117748. */
  117749. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  117750. private _enabled;
  117751. private _detectedPlanes;
  117752. private _lastFrameDetected;
  117753. /**
  117754. * construct a new Plane Detector
  117755. * @param _xrSessionManager an instance of xr Session manager
  117756. * @param _options configuration to use when constructing this feature
  117757. */
  117758. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  117759. protected _onXRFrame(frame: XRFrame): void;
  117760. /**
  117761. * Dispose this feature and all of the resources attached
  117762. */
  117763. dispose(): void;
  117764. private _updatePlaneWithXRPlane;
  117765. /**
  117766. * avoiding using Array.find for global support.
  117767. * @param xrPlane the plane to find in the array
  117768. */
  117769. private findIndexInPlaneArray;
  117770. }
  117771. }
  117772. declare module BABYLON {
  117773. /**
  117774. * Configuration options of the anchor system
  117775. */
  117776. export interface IWebXRAnchorSystemOptions {
  117777. /**
  117778. * a node that will be used to convert local to world coordinates
  117779. */
  117780. worldParentNode?: TransformNode;
  117781. /**
  117782. * should the anchor system use plane detection.
  117783. * If set to true, the plane-detection feature should be set using setPlaneDetector
  117784. */
  117785. usePlaneDetection?: boolean;
  117786. /**
  117787. * Should a new anchor be added every time a select event is triggered
  117788. */
  117789. addAnchorOnSelect?: boolean;
  117790. }
  117791. /**
  117792. * A babylon container for an XR Anchor
  117793. */
  117794. export interface IWebXRAnchor {
  117795. /**
  117796. * A babylon-assigned ID for this anchor
  117797. */
  117798. id: number;
  117799. /**
  117800. * The native anchor object
  117801. */
  117802. xrAnchor: XRAnchor;
  117803. /**
  117804. * Transformation matrix to apply to an object attached to this anchor
  117805. */
  117806. transformationMatrix: Matrix;
  117807. }
  117808. /**
  117809. * An implementation of the anchor system of WebXR.
  117810. * Note that the current documented implementation is not available in any browser. Future implementations
  117811. * will use the frame to create an anchor and not the session or a detected plane
  117812. * For further information see https://github.com/immersive-web/anchors/
  117813. */
  117814. export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFeature {
  117815. private _options;
  117816. /**
  117817. * The module's name
  117818. */
  117819. static readonly Name: string;
  117820. /**
  117821. * The (Babylon) version of this module.
  117822. * This is an integer representing the implementation version.
  117823. * This number does not correspond to the webxr specs version
  117824. */
  117825. static readonly Version: number;
  117826. /**
  117827. * Observers registered here will be executed when a new anchor was added to the session
  117828. */
  117829. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  117830. /**
  117831. * Observers registered here will be executed when an existing anchor updates
  117832. * This can execute N times every frame
  117833. */
  117834. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  117835. /**
  117836. * Observers registered here will be executed when an anchor was removed from the session
  117837. */
  117838. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  117839. private _planeDetector;
  117840. private _hitTestModule;
  117841. private _enabled;
  117842. private _trackedAnchors;
  117843. private _lastFrameDetected;
  117844. /**
  117845. * constructs a new anchor system
  117846. * @param _xrSessionManager an instance of WebXRSessionManager
  117847. * @param _options configuration object for this feature
  117848. */
  117849. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  117850. /**
  117851. * set the plane detector to use in order to create anchors from frames
  117852. * @param planeDetector the plane-detector module to use
  117853. * @param enable enable plane-anchors. default is true
  117854. */
  117855. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  117856. /**
  117857. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  117858. * @param hitTestModule the hit-test module to use.
  117859. */
  117860. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  117861. /**
  117862. * attach this feature
  117863. * Will usually be called by the features manager
  117864. *
  117865. * @returns true if successful.
  117866. */
  117867. attach(): boolean;
  117868. /**
  117869. * detach this feature.
  117870. * Will usually be called by the features manager
  117871. *
  117872. * @returns true if successful.
  117873. */
  117874. detach(): boolean;
  117875. /**
  117876. * Dispose this feature and all of the resources attached
  117877. */
  117878. dispose(): void;
  117879. protected _onXRFrame(frame: XRFrame): void;
  117880. private _onSelect;
  117881. /**
  117882. * Add anchor at a specific XR point.
  117883. *
  117884. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  117885. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  117886. * @returns a promise the fulfills when the anchor was created
  117887. */
  117888. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  117889. private _updateAnchorWithXRFrame;
  117890. /**
  117891. * avoiding using Array.find for global support.
  117892. * @param xrAnchor the plane to find in the array
  117893. */
  117894. private _findIndexInAnchorArray;
  117895. }
  117896. }
  117897. declare module BABYLON {
  117898. /**
  117899. * Options interface for the background remover plugin
  117900. */
  117901. export interface IWebXRBackgroundRemoverOptions {
  117902. /**
  117903. * don't disable the environment helper
  117904. */
  117905. ignoreEnvironmentHelper?: boolean;
  117906. /**
  117907. * flags to configure the removal of the environment helper.
  117908. * If not set, the entire background will be removed. If set, flags should be set as well.
  117909. */
  117910. environmentHelperRemovalFlags?: {
  117911. /**
  117912. * Should the skybox be removed (default false)
  117913. */
  117914. skyBox?: boolean;
  117915. /**
  117916. * Should the ground be removed (default false)
  117917. */
  117918. ground?: boolean;
  117919. };
  117920. /**
  117921. * Further background meshes to disable when entering AR
  117922. */
  117923. backgroundMeshes?: AbstractMesh[];
  117924. }
  117925. /**
  117926. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  117927. */
  117928. export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWebXRFeature {
  117929. /**
  117930. * read-only options to be used in this module
  117931. */
  117932. readonly options: IWebXRBackgroundRemoverOptions;
  117933. /**
  117934. * The module's name
  117935. */
  117936. static readonly Name: string;
  117937. /**
  117938. * The (Babylon) version of this module.
  117939. * This is an integer representing the implementation version.
  117940. * This number does not correspond to the webxr specs version
  117941. */
  117942. static readonly Version: number;
  117943. /**
  117944. * registered observers will be triggered when the background state changes
  117945. */
  117946. onBackgroundStateChangedObservable: Observable<boolean>;
  117947. /**
  117948. * constructs a new background remover module
  117949. * @param _xrSessionManager the session manager for this module
  117950. * @param options read-only options to be used in this module
  117951. */
  117952. constructor(_xrSessionManager: WebXRSessionManager,
  117953. /**
  117954. * read-only options to be used in this module
  117955. */
  117956. options?: IWebXRBackgroundRemoverOptions);
  117957. /**
  117958. * attach this feature
  117959. * Will usually be called by the features manager
  117960. *
  117961. * @returns true if successful.
  117962. */
  117963. attach(): boolean;
  117964. /**
  117965. * detach this feature.
  117966. * Will usually be called by the features manager
  117967. *
  117968. * @returns true if successful.
  117969. */
  117970. detach(): boolean;
  117971. private _setBackgroundState;
  117972. /**
  117973. * Dispose this feature and all of the resources attached
  117974. */
  117975. dispose(): void;
  117976. }
  117977. }
  117978. declare module BABYLON {
  117979. /**
  117980. * The motion controller class for all microsoft mixed reality controllers
  117981. */
  117982. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  117983. /**
  117984. * The base url used to load the left and right controller models
  117985. */
  117986. static MODEL_BASE_URL: string;
  117987. /**
  117988. * The name of the left controller model file
  117989. */
  117990. static MODEL_LEFT_FILENAME: string;
  117991. /**
  117992. * The name of the right controller model file
  117993. */
  117994. static MODEL_RIGHT_FILENAME: string;
  117995. profileId: string;
  117996. protected readonly _mapping: {
  117997. defaultButton: {
  117998. "valueNodeName": string;
  117999. "unpressedNodeName": string;
  118000. "pressedNodeName": string;
  118001. };
  118002. defaultAxis: {
  118003. "valueNodeName": string;
  118004. "minNodeName": string;
  118005. "maxNodeName": string;
  118006. };
  118007. buttons: {
  118008. "xr-standard-trigger": {
  118009. "rootNodeName": string;
  118010. "componentProperty": string;
  118011. "states": string[];
  118012. };
  118013. "xr-standard-squeeze": {
  118014. "rootNodeName": string;
  118015. "componentProperty": string;
  118016. "states": string[];
  118017. };
  118018. "xr-standard-touchpad": {
  118019. "rootNodeName": string;
  118020. "labelAnchorNodeName": string;
  118021. "touchPointNodeName": string;
  118022. };
  118023. "xr-standard-thumbstick": {
  118024. "rootNodeName": string;
  118025. "componentProperty": string;
  118026. "states": string[];
  118027. };
  118028. };
  118029. axes: {
  118030. "xr-standard-touchpad": {
  118031. "x-axis": {
  118032. "rootNodeName": string;
  118033. };
  118034. "y-axis": {
  118035. "rootNodeName": string;
  118036. };
  118037. };
  118038. "xr-standard-thumbstick": {
  118039. "x-axis": {
  118040. "rootNodeName": string;
  118041. };
  118042. "y-axis": {
  118043. "rootNodeName": string;
  118044. };
  118045. };
  118046. };
  118047. };
  118048. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118049. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118050. private _getChildByName;
  118051. private _getImmediateChildByName;
  118052. protected _getFilenameAndPath(): {
  118053. filename: string;
  118054. path: string;
  118055. };
  118056. protected _updateModel(): void;
  118057. protected _getModelLoadingConstraints(): boolean;
  118058. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118059. }
  118060. }
  118061. declare module BABYLON {
  118062. /**
  118063. * The motion controller class for oculus touch (quest, rift).
  118064. * This class supports legacy mapping as well the standard xr mapping
  118065. */
  118066. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  118067. private _forceLegacyControllers;
  118068. /**
  118069. * The base url used to load the left and right controller models
  118070. */
  118071. static MODEL_BASE_URL: string;
  118072. /**
  118073. * The name of the left controller model file
  118074. */
  118075. static MODEL_LEFT_FILENAME: string;
  118076. /**
  118077. * The name of the right controller model file
  118078. */
  118079. static MODEL_RIGHT_FILENAME: string;
  118080. /**
  118081. * Base Url for the Quest controller model.
  118082. */
  118083. static QUEST_MODEL_BASE_URL: string;
  118084. profileId: string;
  118085. private _modelRootNode;
  118086. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  118087. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118088. protected _getFilenameAndPath(): {
  118089. filename: string;
  118090. path: string;
  118091. };
  118092. /**
  118093. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  118094. * between the touch and touch 2.
  118095. */
  118096. private _isQuest;
  118097. protected _updateModel(): void;
  118098. protected _getModelLoadingConstraints(): boolean;
  118099. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118100. }
  118101. }
  118102. declare module BABYLON {
  118103. /**
  118104. * The motion controller class for the standard HTC-Vive controllers
  118105. */
  118106. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  118107. /**
  118108. * The base url used to load the left and right controller models
  118109. */
  118110. static MODEL_BASE_URL: string;
  118111. /**
  118112. * File name for the controller model.
  118113. */
  118114. static MODEL_FILENAME: string;
  118115. profileId: string;
  118116. private _modelRootNode;
  118117. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  118118. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118119. protected _getFilenameAndPath(): {
  118120. filename: string;
  118121. path: string;
  118122. };
  118123. protected _updateModel(): void;
  118124. protected _getModelLoadingConstraints(): boolean;
  118125. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118126. }
  118127. }
  118128. declare module BABYLON {
  118129. /**
  118130. * Contains an array of blocks representing the octree
  118131. */
  118132. export interface IOctreeContainer<T> {
  118133. /**
  118134. * Blocks within the octree
  118135. */
  118136. blocks: Array<OctreeBlock<T>>;
  118137. }
  118138. /**
  118139. * Class used to store a cell in an octree
  118140. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118141. */
  118142. export class OctreeBlock<T> {
  118143. /**
  118144. * Gets the content of the current block
  118145. */
  118146. entries: T[];
  118147. /**
  118148. * Gets the list of block children
  118149. */
  118150. blocks: Array<OctreeBlock<T>>;
  118151. private _depth;
  118152. private _maxDepth;
  118153. private _capacity;
  118154. private _minPoint;
  118155. private _maxPoint;
  118156. private _boundingVectors;
  118157. private _creationFunc;
  118158. /**
  118159. * Creates a new block
  118160. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118161. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118162. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118163. * @param depth defines the current depth of this block in the octree
  118164. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118165. * @param creationFunc defines a callback to call when an element is added to the block
  118166. */
  118167. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118168. /**
  118169. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118170. */
  118171. get capacity(): number;
  118172. /**
  118173. * Gets the minimum vector (in world space) of the block's bounding box
  118174. */
  118175. get minPoint(): Vector3;
  118176. /**
  118177. * Gets the maximum vector (in world space) of the block's bounding box
  118178. */
  118179. get maxPoint(): Vector3;
  118180. /**
  118181. * Add a new element to this block
  118182. * @param entry defines the element to add
  118183. */
  118184. addEntry(entry: T): void;
  118185. /**
  118186. * Remove an element from this block
  118187. * @param entry defines the element to remove
  118188. */
  118189. removeEntry(entry: T): void;
  118190. /**
  118191. * Add an array of elements to this block
  118192. * @param entries defines the array of elements to add
  118193. */
  118194. addEntries(entries: T[]): void;
  118195. /**
  118196. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118197. * @param frustumPlanes defines the frustum planes to test
  118198. * @param selection defines the array to store current content if selection is positive
  118199. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118200. */
  118201. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118202. /**
  118203. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118204. * @param sphereCenter defines the bounding sphere center
  118205. * @param sphereRadius defines the bounding sphere radius
  118206. * @param selection defines the array to store current content if selection is positive
  118207. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118208. */
  118209. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118210. /**
  118211. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118212. * @param ray defines the ray to test with
  118213. * @param selection defines the array to store current content if selection is positive
  118214. */
  118215. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118216. /**
  118217. * Subdivide the content into child blocks (this block will then be empty)
  118218. */
  118219. createInnerBlocks(): void;
  118220. /**
  118221. * @hidden
  118222. */
  118223. 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;
  118224. }
  118225. }
  118226. declare module BABYLON {
  118227. /**
  118228. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118230. */
  118231. export class Octree<T> {
  118232. /** 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.) */
  118233. maxDepth: number;
  118234. /**
  118235. * Blocks within the octree containing objects
  118236. */
  118237. blocks: Array<OctreeBlock<T>>;
  118238. /**
  118239. * Content stored in the octree
  118240. */
  118241. dynamicContent: T[];
  118242. private _maxBlockCapacity;
  118243. private _selectionContent;
  118244. private _creationFunc;
  118245. /**
  118246. * Creates a octree
  118247. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118248. * @param creationFunc function to be used to instatiate the octree
  118249. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118250. * @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.)
  118251. */
  118252. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118253. /** 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.) */
  118254. maxDepth?: number);
  118255. /**
  118256. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118257. * @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);
  118258. * @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);
  118259. * @param entries meshes to be added to the octree blocks
  118260. */
  118261. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118262. /**
  118263. * Adds a mesh to the octree
  118264. * @param entry Mesh to add to the octree
  118265. */
  118266. addMesh(entry: T): void;
  118267. /**
  118268. * Remove an element from the octree
  118269. * @param entry defines the element to remove
  118270. */
  118271. removeMesh(entry: T): void;
  118272. /**
  118273. * Selects an array of meshes within the frustum
  118274. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118275. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118276. * @returns array of meshes within the frustum
  118277. */
  118278. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118279. /**
  118280. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118281. * @param sphereCenter defines the bounding sphere center
  118282. * @param sphereRadius defines the bounding sphere radius
  118283. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118284. * @returns an array of objects that intersect the sphere
  118285. */
  118286. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118287. /**
  118288. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118289. * @param ray defines the ray to test with
  118290. * @returns array of intersected objects
  118291. */
  118292. intersectsRay(ray: Ray): SmartArray<T>;
  118293. /**
  118294. * Adds a mesh into the octree block if it intersects the block
  118295. */
  118296. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118297. /**
  118298. * Adds a submesh into the octree block if it intersects the block
  118299. */
  118300. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118301. }
  118302. }
  118303. declare module BABYLON {
  118304. interface Scene {
  118305. /**
  118306. * @hidden
  118307. * Backing Filed
  118308. */
  118309. _selectionOctree: Octree<AbstractMesh>;
  118310. /**
  118311. * Gets the octree used to boost mesh selection (picking)
  118312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118313. */
  118314. selectionOctree: Octree<AbstractMesh>;
  118315. /**
  118316. * Creates or updates the octree used to boost selection (picking)
  118317. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118318. * @param maxCapacity defines the maximum capacity per leaf
  118319. * @param maxDepth defines the maximum depth of the octree
  118320. * @returns an octree of AbstractMesh
  118321. */
  118322. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118323. }
  118324. interface AbstractMesh {
  118325. /**
  118326. * @hidden
  118327. * Backing Field
  118328. */
  118329. _submeshesOctree: Octree<SubMesh>;
  118330. /**
  118331. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118332. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118333. * @param maxCapacity defines the maximum size of each block (64 by default)
  118334. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118335. * @returns the new octree
  118336. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118338. */
  118339. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118340. }
  118341. /**
  118342. * Defines the octree scene component responsible to manage any octrees
  118343. * in a given scene.
  118344. */
  118345. export class OctreeSceneComponent {
  118346. /**
  118347. * The component name help to identify the component in the list of scene components.
  118348. */
  118349. readonly name: string;
  118350. /**
  118351. * The scene the component belongs to.
  118352. */
  118353. scene: Scene;
  118354. /**
  118355. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118356. */
  118357. readonly checksIsEnabled: boolean;
  118358. /**
  118359. * Creates a new instance of the component for the given scene
  118360. * @param scene Defines the scene to register the component in
  118361. */
  118362. constructor(scene: Scene);
  118363. /**
  118364. * Registers the component in a given scene
  118365. */
  118366. register(): void;
  118367. /**
  118368. * Return the list of active meshes
  118369. * @returns the list of active meshes
  118370. */
  118371. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118372. /**
  118373. * Return the list of active sub meshes
  118374. * @param mesh The mesh to get the candidates sub meshes from
  118375. * @returns the list of active sub meshes
  118376. */
  118377. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118378. private _tempRay;
  118379. /**
  118380. * Return the list of sub meshes intersecting with a given local ray
  118381. * @param mesh defines the mesh to find the submesh for
  118382. * @param localRay defines the ray in local space
  118383. * @returns the list of intersecting sub meshes
  118384. */
  118385. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118386. /**
  118387. * Return the list of sub meshes colliding with a collider
  118388. * @param mesh defines the mesh to find the submesh for
  118389. * @param collider defines the collider to evaluate the collision against
  118390. * @returns the list of colliding sub meshes
  118391. */
  118392. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118393. /**
  118394. * Rebuilds the elements related to this component in case of
  118395. * context lost for instance.
  118396. */
  118397. rebuild(): void;
  118398. /**
  118399. * Disposes the component and the associated ressources.
  118400. */
  118401. dispose(): void;
  118402. }
  118403. }
  118404. declare module BABYLON {
  118405. /**
  118406. * Renders a layer on top of an existing scene
  118407. */
  118408. export class UtilityLayerRenderer implements IDisposable {
  118409. /** the original scene that will be rendered on top of */
  118410. originalScene: Scene;
  118411. private _pointerCaptures;
  118412. private _lastPointerEvents;
  118413. private static _DefaultUtilityLayer;
  118414. private static _DefaultKeepDepthUtilityLayer;
  118415. private _sharedGizmoLight;
  118416. private _renderCamera;
  118417. /**
  118418. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118419. * @returns the camera that is used when rendering the utility layer
  118420. */
  118421. getRenderCamera(): Nullable<Camera>;
  118422. /**
  118423. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118424. * @param cam the camera that should be used when rendering the utility layer
  118425. */
  118426. setRenderCamera(cam: Nullable<Camera>): void;
  118427. /**
  118428. * @hidden
  118429. * Light which used by gizmos to get light shading
  118430. */
  118431. _getSharedGizmoLight(): HemisphericLight;
  118432. /**
  118433. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118434. */
  118435. pickUtilitySceneFirst: boolean;
  118436. /**
  118437. * 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)
  118438. */
  118439. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118440. /**
  118441. * 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)
  118442. */
  118443. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118444. /**
  118445. * The scene that is rendered on top of the original scene
  118446. */
  118447. utilityLayerScene: Scene;
  118448. /**
  118449. * If the utility layer should automatically be rendered on top of existing scene
  118450. */
  118451. shouldRender: boolean;
  118452. /**
  118453. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118454. */
  118455. onlyCheckPointerDownEvents: boolean;
  118456. /**
  118457. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118458. */
  118459. processAllEvents: boolean;
  118460. /**
  118461. * Observable raised when the pointer move from the utility layer scene to the main scene
  118462. */
  118463. onPointerOutObservable: Observable<number>;
  118464. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118465. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118466. private _afterRenderObserver;
  118467. private _sceneDisposeObserver;
  118468. private _originalPointerObserver;
  118469. /**
  118470. * Instantiates a UtilityLayerRenderer
  118471. * @param originalScene the original scene that will be rendered on top of
  118472. * @param handleEvents boolean indicating if the utility layer should handle events
  118473. */
  118474. constructor(
  118475. /** the original scene that will be rendered on top of */
  118476. originalScene: Scene, handleEvents?: boolean);
  118477. private _notifyObservers;
  118478. /**
  118479. * Renders the utility layers scene on top of the original scene
  118480. */
  118481. render(): void;
  118482. /**
  118483. * Disposes of the renderer
  118484. */
  118485. dispose(): void;
  118486. private _updateCamera;
  118487. }
  118488. }
  118489. declare module BABYLON {
  118490. /**
  118491. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118492. */
  118493. export class Gizmo implements IDisposable {
  118494. /** The utility layer the gizmo will be added to */
  118495. gizmoLayer: UtilityLayerRenderer;
  118496. /**
  118497. * The root mesh of the gizmo
  118498. */
  118499. _rootMesh: Mesh;
  118500. private _attachedMesh;
  118501. /**
  118502. * Ratio for the scale of the gizmo (Default: 1)
  118503. */
  118504. scaleRatio: number;
  118505. /**
  118506. * If a custom mesh has been set (Default: false)
  118507. */
  118508. protected _customMeshSet: boolean;
  118509. /**
  118510. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118511. * * When set, interactions will be enabled
  118512. */
  118513. get attachedMesh(): Nullable<AbstractMesh>;
  118514. set attachedMesh(value: Nullable<AbstractMesh>);
  118515. /**
  118516. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118517. * @param mesh The mesh to replace the default mesh of the gizmo
  118518. */
  118519. setCustomMesh(mesh: Mesh): void;
  118520. /**
  118521. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118522. */
  118523. updateGizmoRotationToMatchAttachedMesh: boolean;
  118524. /**
  118525. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118526. */
  118527. updateGizmoPositionToMatchAttachedMesh: boolean;
  118528. /**
  118529. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118530. */
  118531. updateScale: boolean;
  118532. protected _interactionsEnabled: boolean;
  118533. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118534. private _beforeRenderObserver;
  118535. private _tempVector;
  118536. /**
  118537. * Creates a gizmo
  118538. * @param gizmoLayer The utility layer the gizmo will be added to
  118539. */
  118540. constructor(
  118541. /** The utility layer the gizmo will be added to */
  118542. gizmoLayer?: UtilityLayerRenderer);
  118543. /**
  118544. * Updates the gizmo to match the attached mesh's position/rotation
  118545. */
  118546. protected _update(): void;
  118547. /**
  118548. * Disposes of the gizmo
  118549. */
  118550. dispose(): void;
  118551. }
  118552. }
  118553. declare module BABYLON {
  118554. /**
  118555. * Single plane drag gizmo
  118556. */
  118557. export class PlaneDragGizmo extends Gizmo {
  118558. /**
  118559. * Drag behavior responsible for the gizmos dragging interactions
  118560. */
  118561. dragBehavior: PointerDragBehavior;
  118562. private _pointerObserver;
  118563. /**
  118564. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118565. */
  118566. snapDistance: number;
  118567. /**
  118568. * Event that fires each time the gizmo snaps to a new location.
  118569. * * snapDistance is the the change in distance
  118570. */
  118571. onSnapObservable: Observable<{
  118572. snapDistance: number;
  118573. }>;
  118574. private _plane;
  118575. private _coloredMaterial;
  118576. private _hoverMaterial;
  118577. private _isEnabled;
  118578. private _parent;
  118579. /** @hidden */
  118580. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  118581. /** @hidden */
  118582. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118583. /**
  118584. * Creates a PlaneDragGizmo
  118585. * @param gizmoLayer The utility layer the gizmo will be added to
  118586. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  118587. * @param color The color of the gizmo
  118588. */
  118589. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118590. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118591. /**
  118592. * If the gizmo is enabled
  118593. */
  118594. set isEnabled(value: boolean);
  118595. get isEnabled(): boolean;
  118596. /**
  118597. * Disposes of the gizmo
  118598. */
  118599. dispose(): void;
  118600. }
  118601. }
  118602. declare module BABYLON {
  118603. /**
  118604. * Gizmo that enables dragging a mesh along 3 axis
  118605. */
  118606. export class PositionGizmo extends Gizmo {
  118607. /**
  118608. * Internal gizmo used for interactions on the x axis
  118609. */
  118610. xGizmo: AxisDragGizmo;
  118611. /**
  118612. * Internal gizmo used for interactions on the y axis
  118613. */
  118614. yGizmo: AxisDragGizmo;
  118615. /**
  118616. * Internal gizmo used for interactions on the z axis
  118617. */
  118618. zGizmo: AxisDragGizmo;
  118619. /**
  118620. * Internal gizmo used for interactions on the yz plane
  118621. */
  118622. xPlaneGizmo: PlaneDragGizmo;
  118623. /**
  118624. * Internal gizmo used for interactions on the xz plane
  118625. */
  118626. yPlaneGizmo: PlaneDragGizmo;
  118627. /**
  118628. * Internal gizmo used for interactions on the xy plane
  118629. */
  118630. zPlaneGizmo: PlaneDragGizmo;
  118631. /**
  118632. * private variables
  118633. */
  118634. private _meshAttached;
  118635. private _updateGizmoRotationToMatchAttachedMesh;
  118636. private _snapDistance;
  118637. private _scaleRatio;
  118638. /** Fires an event when any of it's sub gizmos are dragged */
  118639. onDragStartObservable: Observable<unknown>;
  118640. /** Fires an event when any of it's sub gizmos are released from dragging */
  118641. onDragEndObservable: Observable<unknown>;
  118642. /**
  118643. * If set to true, planar drag is enabled
  118644. */
  118645. private _planarGizmoEnabled;
  118646. get attachedMesh(): Nullable<AbstractMesh>;
  118647. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118648. /**
  118649. * Creates a PositionGizmo
  118650. * @param gizmoLayer The utility layer the gizmo will be added to
  118651. */
  118652. constructor(gizmoLayer?: UtilityLayerRenderer);
  118653. /**
  118654. * If the planar drag gizmo is enabled
  118655. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  118656. */
  118657. set planarGizmoEnabled(value: boolean);
  118658. get planarGizmoEnabled(): boolean;
  118659. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118660. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118661. /**
  118662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118663. */
  118664. set snapDistance(value: number);
  118665. get snapDistance(): number;
  118666. /**
  118667. * Ratio for the scale of the gizmo (Default: 1)
  118668. */
  118669. set scaleRatio(value: number);
  118670. get scaleRatio(): number;
  118671. /**
  118672. * Disposes of the gizmo
  118673. */
  118674. dispose(): void;
  118675. /**
  118676. * CustomMeshes are not supported by this gizmo
  118677. * @param mesh The mesh to replace the default mesh of the gizmo
  118678. */
  118679. setCustomMesh(mesh: Mesh): void;
  118680. }
  118681. }
  118682. declare module BABYLON {
  118683. /**
  118684. * Single axis drag gizmo
  118685. */
  118686. export class AxisDragGizmo extends Gizmo {
  118687. /**
  118688. * Drag behavior responsible for the gizmos dragging interactions
  118689. */
  118690. dragBehavior: PointerDragBehavior;
  118691. private _pointerObserver;
  118692. /**
  118693. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118694. */
  118695. snapDistance: number;
  118696. /**
  118697. * Event that fires each time the gizmo snaps to a new location.
  118698. * * snapDistance is the the change in distance
  118699. */
  118700. onSnapObservable: Observable<{
  118701. snapDistance: number;
  118702. }>;
  118703. private _isEnabled;
  118704. private _parent;
  118705. private _arrow;
  118706. private _coloredMaterial;
  118707. private _hoverMaterial;
  118708. /** @hidden */
  118709. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  118710. /** @hidden */
  118711. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118712. /**
  118713. * Creates an AxisDragGizmo
  118714. * @param gizmoLayer The utility layer the gizmo will be added to
  118715. * @param dragAxis The axis which the gizmo will be able to drag on
  118716. * @param color The color of the gizmo
  118717. */
  118718. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118719. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118720. /**
  118721. * If the gizmo is enabled
  118722. */
  118723. set isEnabled(value: boolean);
  118724. get isEnabled(): boolean;
  118725. /**
  118726. * Disposes of the gizmo
  118727. */
  118728. dispose(): void;
  118729. }
  118730. }
  118731. declare module BABYLON.Debug {
  118732. /**
  118733. * The Axes viewer will show 3 axes in a specific point in space
  118734. */
  118735. export class AxesViewer {
  118736. private _xAxis;
  118737. private _yAxis;
  118738. private _zAxis;
  118739. private _scaleLinesFactor;
  118740. private _instanced;
  118741. /**
  118742. * Gets the hosting scene
  118743. */
  118744. scene: Scene;
  118745. /**
  118746. * Gets or sets a number used to scale line length
  118747. */
  118748. scaleLines: number;
  118749. /** Gets the node hierarchy used to render x-axis */
  118750. get xAxis(): TransformNode;
  118751. /** Gets the node hierarchy used to render y-axis */
  118752. get yAxis(): TransformNode;
  118753. /** Gets the node hierarchy used to render z-axis */
  118754. get zAxis(): TransformNode;
  118755. /**
  118756. * Creates a new AxesViewer
  118757. * @param scene defines the hosting scene
  118758. * @param scaleLines defines a number used to scale line length (1 by default)
  118759. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  118760. * @param xAxis defines the node hierarchy used to render the x-axis
  118761. * @param yAxis defines the node hierarchy used to render the y-axis
  118762. * @param zAxis defines the node hierarchy used to render the z-axis
  118763. */
  118764. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  118765. /**
  118766. * Force the viewer to update
  118767. * @param position defines the position of the viewer
  118768. * @param xaxis defines the x axis of the viewer
  118769. * @param yaxis defines the y axis of the viewer
  118770. * @param zaxis defines the z axis of the viewer
  118771. */
  118772. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  118773. /**
  118774. * Creates an instance of this axes viewer.
  118775. * @returns a new axes viewer with instanced meshes
  118776. */
  118777. createInstance(): AxesViewer;
  118778. /** Releases resources */
  118779. dispose(): void;
  118780. private static _SetRenderingGroupId;
  118781. }
  118782. }
  118783. declare module BABYLON.Debug {
  118784. /**
  118785. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  118786. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  118787. */
  118788. export class BoneAxesViewer extends AxesViewer {
  118789. /**
  118790. * Gets or sets the target mesh where to display the axes viewer
  118791. */
  118792. mesh: Nullable<Mesh>;
  118793. /**
  118794. * Gets or sets the target bone where to display the axes viewer
  118795. */
  118796. bone: Nullable<Bone>;
  118797. /** Gets current position */
  118798. pos: Vector3;
  118799. /** Gets direction of X axis */
  118800. xaxis: Vector3;
  118801. /** Gets direction of Y axis */
  118802. yaxis: Vector3;
  118803. /** Gets direction of Z axis */
  118804. zaxis: Vector3;
  118805. /**
  118806. * Creates a new BoneAxesViewer
  118807. * @param scene defines the hosting scene
  118808. * @param bone defines the target bone
  118809. * @param mesh defines the target mesh
  118810. * @param scaleLines defines a scaling factor for line length (1 by default)
  118811. */
  118812. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  118813. /**
  118814. * Force the viewer to update
  118815. */
  118816. update(): void;
  118817. /** Releases resources */
  118818. dispose(): void;
  118819. }
  118820. }
  118821. declare module BABYLON {
  118822. /**
  118823. * Interface used to define scene explorer extensibility option
  118824. */
  118825. export interface IExplorerExtensibilityOption {
  118826. /**
  118827. * Define the option label
  118828. */
  118829. label: string;
  118830. /**
  118831. * Defines the action to execute on click
  118832. */
  118833. action: (entity: any) => void;
  118834. }
  118835. /**
  118836. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  118837. */
  118838. export interface IExplorerExtensibilityGroup {
  118839. /**
  118840. * Defines a predicate to test if a given type mut be extended
  118841. */
  118842. predicate: (entity: any) => boolean;
  118843. /**
  118844. * Gets the list of options added to a type
  118845. */
  118846. entries: IExplorerExtensibilityOption[];
  118847. }
  118848. /**
  118849. * Interface used to define the options to use to create the Inspector
  118850. */
  118851. export interface IInspectorOptions {
  118852. /**
  118853. * Display in overlay mode (default: false)
  118854. */
  118855. overlay?: boolean;
  118856. /**
  118857. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  118858. */
  118859. globalRoot?: HTMLElement;
  118860. /**
  118861. * Display the Scene explorer
  118862. */
  118863. showExplorer?: boolean;
  118864. /**
  118865. * Display the property inspector
  118866. */
  118867. showInspector?: boolean;
  118868. /**
  118869. * Display in embed mode (both panes on the right)
  118870. */
  118871. embedMode?: boolean;
  118872. /**
  118873. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  118874. */
  118875. handleResize?: boolean;
  118876. /**
  118877. * Allow the panes to popup (default: true)
  118878. */
  118879. enablePopup?: boolean;
  118880. /**
  118881. * Allow the panes to be closed by users (default: true)
  118882. */
  118883. enableClose?: boolean;
  118884. /**
  118885. * Optional list of extensibility entries
  118886. */
  118887. explorerExtensibility?: IExplorerExtensibilityGroup[];
  118888. /**
  118889. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  118890. */
  118891. inspectorURL?: string;
  118892. /**
  118893. * Optional initial tab (default to DebugLayerTab.Properties)
  118894. */
  118895. initialTab?: DebugLayerTab;
  118896. }
  118897. interface Scene {
  118898. /**
  118899. * @hidden
  118900. * Backing field
  118901. */
  118902. _debugLayer: DebugLayer;
  118903. /**
  118904. * Gets the debug layer (aka Inspector) associated with the scene
  118905. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118906. */
  118907. debugLayer: DebugLayer;
  118908. }
  118909. /**
  118910. * Enum of inspector action tab
  118911. */
  118912. export enum DebugLayerTab {
  118913. /**
  118914. * Properties tag (default)
  118915. */
  118916. Properties = 0,
  118917. /**
  118918. * Debug tab
  118919. */
  118920. Debug = 1,
  118921. /**
  118922. * Statistics tab
  118923. */
  118924. Statistics = 2,
  118925. /**
  118926. * Tools tab
  118927. */
  118928. Tools = 3,
  118929. /**
  118930. * Settings tab
  118931. */
  118932. Settings = 4
  118933. }
  118934. /**
  118935. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118936. * what is happening in your scene
  118937. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118938. */
  118939. export class DebugLayer {
  118940. /**
  118941. * Define the url to get the inspector script from.
  118942. * By default it uses the babylonjs CDN.
  118943. * @ignoreNaming
  118944. */
  118945. static InspectorURL: string;
  118946. private _scene;
  118947. private BJSINSPECTOR;
  118948. private _onPropertyChangedObservable?;
  118949. /**
  118950. * Observable triggered when a property is changed through the inspector.
  118951. */
  118952. get onPropertyChangedObservable(): any;
  118953. /**
  118954. * Instantiates a new debug layer.
  118955. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118956. * what is happening in your scene
  118957. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118958. * @param scene Defines the scene to inspect
  118959. */
  118960. constructor(scene: Scene);
  118961. /** Creates the inspector window. */
  118962. private _createInspector;
  118963. /**
  118964. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  118965. * @param entity defines the entity to select
  118966. * @param lineContainerTitle defines the specific block to highlight
  118967. */
  118968. select(entity: any, lineContainerTitle?: string): void;
  118969. /** Get the inspector from bundle or global */
  118970. private _getGlobalInspector;
  118971. /**
  118972. * Get if the inspector is visible or not.
  118973. * @returns true if visible otherwise, false
  118974. */
  118975. isVisible(): boolean;
  118976. /**
  118977. * Hide the inspector and close its window.
  118978. */
  118979. hide(): void;
  118980. /**
  118981. * Launch the debugLayer.
  118982. * @param config Define the configuration of the inspector
  118983. * @return a promise fulfilled when the debug layer is visible
  118984. */
  118985. show(config?: IInspectorOptions): Promise<DebugLayer>;
  118986. }
  118987. }
  118988. declare module BABYLON {
  118989. /**
  118990. * Class containing static functions to help procedurally build meshes
  118991. */
  118992. export class BoxBuilder {
  118993. /**
  118994. * Creates a box mesh
  118995. * * The parameter `size` sets the size (float) of each box side (default 1)
  118996. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118997. * * 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)
  118998. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119002. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119003. * @param name defines the name of the mesh
  119004. * @param options defines the options used to create the mesh
  119005. * @param scene defines the hosting scene
  119006. * @returns the box mesh
  119007. */
  119008. static CreateBox(name: string, options: {
  119009. size?: number;
  119010. width?: number;
  119011. height?: number;
  119012. depth?: number;
  119013. faceUV?: Vector4[];
  119014. faceColors?: Color4[];
  119015. sideOrientation?: number;
  119016. frontUVs?: Vector4;
  119017. backUVs?: Vector4;
  119018. wrap?: boolean;
  119019. topBaseAt?: number;
  119020. bottomBaseAt?: number;
  119021. updatable?: boolean;
  119022. }, scene?: Nullable<Scene>): Mesh;
  119023. }
  119024. }
  119025. declare module BABYLON {
  119026. /**
  119027. * Class containing static functions to help procedurally build meshes
  119028. */
  119029. export class SphereBuilder {
  119030. /**
  119031. * Creates a sphere mesh
  119032. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  119033. * * 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`)
  119034. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  119035. * * 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
  119036. * * 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)
  119037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119040. * @param name defines the name of the mesh
  119041. * @param options defines the options used to create the mesh
  119042. * @param scene defines the hosting scene
  119043. * @returns the sphere mesh
  119044. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119045. */
  119046. static CreateSphere(name: string, options: {
  119047. segments?: number;
  119048. diameter?: number;
  119049. diameterX?: number;
  119050. diameterY?: number;
  119051. diameterZ?: number;
  119052. arc?: number;
  119053. slice?: number;
  119054. sideOrientation?: number;
  119055. frontUVs?: Vector4;
  119056. backUVs?: Vector4;
  119057. updatable?: boolean;
  119058. }, scene?: Nullable<Scene>): Mesh;
  119059. }
  119060. }
  119061. declare module BABYLON.Debug {
  119062. /**
  119063. * Used to show the physics impostor around the specific mesh
  119064. */
  119065. export class PhysicsViewer {
  119066. /** @hidden */
  119067. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119068. /** @hidden */
  119069. protected _meshes: Array<Nullable<AbstractMesh>>;
  119070. /** @hidden */
  119071. protected _scene: Nullable<Scene>;
  119072. /** @hidden */
  119073. protected _numMeshes: number;
  119074. /** @hidden */
  119075. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119076. private _renderFunction;
  119077. private _utilityLayer;
  119078. private _debugBoxMesh;
  119079. private _debugSphereMesh;
  119080. private _debugCylinderMesh;
  119081. private _debugMaterial;
  119082. private _debugMeshMeshes;
  119083. /**
  119084. * Creates a new PhysicsViewer
  119085. * @param scene defines the hosting scene
  119086. */
  119087. constructor(scene: Scene);
  119088. /** @hidden */
  119089. protected _updateDebugMeshes(): void;
  119090. /**
  119091. * Renders a specified physic impostor
  119092. * @param impostor defines the impostor to render
  119093. * @param targetMesh defines the mesh represented by the impostor
  119094. * @returns the new debug mesh used to render the impostor
  119095. */
  119096. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119097. /**
  119098. * Hides a specified physic impostor
  119099. * @param impostor defines the impostor to hide
  119100. */
  119101. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119102. private _getDebugMaterial;
  119103. private _getDebugBoxMesh;
  119104. private _getDebugSphereMesh;
  119105. private _getDebugCylinderMesh;
  119106. private _getDebugMeshMesh;
  119107. private _getDebugMesh;
  119108. /** Releases all resources */
  119109. dispose(): void;
  119110. }
  119111. }
  119112. declare module BABYLON {
  119113. /**
  119114. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119115. * in order to better appreciate the issue one might have.
  119116. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119117. */
  119118. export class RayHelper {
  119119. /**
  119120. * Defines the ray we are currently tryin to visualize.
  119121. */
  119122. ray: Nullable<Ray>;
  119123. private _renderPoints;
  119124. private _renderLine;
  119125. private _renderFunction;
  119126. private _scene;
  119127. private _updateToMeshFunction;
  119128. private _attachedToMesh;
  119129. private _meshSpaceDirection;
  119130. private _meshSpaceOrigin;
  119131. /**
  119132. * Helper function to create a colored helper in a scene in one line.
  119133. * @param ray Defines the ray we are currently tryin to visualize
  119134. * @param scene Defines the scene the ray is used in
  119135. * @param color Defines the color we want to see the ray in
  119136. * @returns The newly created ray helper.
  119137. */
  119138. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119139. /**
  119140. * Instantiate a new ray helper.
  119141. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119142. * in order to better appreciate the issue one might have.
  119143. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119144. * @param ray Defines the ray we are currently tryin to visualize
  119145. */
  119146. constructor(ray: Ray);
  119147. /**
  119148. * Shows the ray we are willing to debug.
  119149. * @param scene Defines the scene the ray needs to be rendered in
  119150. * @param color Defines the color the ray needs to be rendered in
  119151. */
  119152. show(scene: Scene, color?: Color3): void;
  119153. /**
  119154. * Hides the ray we are debugging.
  119155. */
  119156. hide(): void;
  119157. private _render;
  119158. /**
  119159. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119160. * @param mesh Defines the mesh we want the helper attached to
  119161. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119162. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119163. * @param length Defines the length of the ray
  119164. */
  119165. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119166. /**
  119167. * Detach the ray helper from the mesh it has previously been attached to.
  119168. */
  119169. detachFromMesh(): void;
  119170. private _updateToMesh;
  119171. /**
  119172. * Dispose the helper and release its associated resources.
  119173. */
  119174. dispose(): void;
  119175. }
  119176. }
  119177. declare module BABYLON.Debug {
  119178. /**
  119179. * Class used to render a debug view of a given skeleton
  119180. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119181. */
  119182. export class SkeletonViewer {
  119183. /** defines the skeleton to render */
  119184. skeleton: Skeleton;
  119185. /** defines the mesh attached to the skeleton */
  119186. mesh: AbstractMesh;
  119187. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119188. autoUpdateBonesMatrices: boolean;
  119189. /** defines the rendering group id to use with the viewer */
  119190. renderingGroupId: number;
  119191. /** Gets or sets the color used to render the skeleton */
  119192. color: Color3;
  119193. private _scene;
  119194. private _debugLines;
  119195. private _debugMesh;
  119196. private _isEnabled;
  119197. private _renderFunction;
  119198. private _utilityLayer;
  119199. /**
  119200. * Returns the mesh used to render the bones
  119201. */
  119202. get debugMesh(): Nullable<LinesMesh>;
  119203. /**
  119204. * Creates a new SkeletonViewer
  119205. * @param skeleton defines the skeleton to render
  119206. * @param mesh defines the mesh attached to the skeleton
  119207. * @param scene defines the hosting scene
  119208. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119209. * @param renderingGroupId defines the rendering group id to use with the viewer
  119210. */
  119211. constructor(
  119212. /** defines the skeleton to render */
  119213. skeleton: Skeleton,
  119214. /** defines the mesh attached to the skeleton */
  119215. mesh: AbstractMesh, scene: Scene,
  119216. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119217. autoUpdateBonesMatrices?: boolean,
  119218. /** defines the rendering group id to use with the viewer */
  119219. renderingGroupId?: number);
  119220. /** Gets or sets a boolean indicating if the viewer is enabled */
  119221. set isEnabled(value: boolean);
  119222. get isEnabled(): boolean;
  119223. private _getBonePosition;
  119224. private _getLinesForBonesWithLength;
  119225. private _getLinesForBonesNoLength;
  119226. /** Update the viewer to sync with current skeleton state */
  119227. update(): void;
  119228. /** Release associated resources */
  119229. dispose(): void;
  119230. }
  119231. }
  119232. declare module BABYLON {
  119233. /**
  119234. * Options to create the null engine
  119235. */
  119236. export class NullEngineOptions {
  119237. /**
  119238. * Render width (Default: 512)
  119239. */
  119240. renderWidth: number;
  119241. /**
  119242. * Render height (Default: 256)
  119243. */
  119244. renderHeight: number;
  119245. /**
  119246. * Texture size (Default: 512)
  119247. */
  119248. textureSize: number;
  119249. /**
  119250. * If delta time between frames should be constant
  119251. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119252. */
  119253. deterministicLockstep: boolean;
  119254. /**
  119255. * Maximum about of steps between frames (Default: 4)
  119256. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119257. */
  119258. lockstepMaxSteps: number;
  119259. }
  119260. /**
  119261. * The null engine class provides support for headless version of babylon.js.
  119262. * This can be used in server side scenario or for testing purposes
  119263. */
  119264. export class NullEngine extends Engine {
  119265. private _options;
  119266. /**
  119267. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119268. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119269. * @returns true if engine is in deterministic lock step mode
  119270. */
  119271. isDeterministicLockStep(): boolean;
  119272. /**
  119273. * Gets the max steps when engine is running in deterministic lock step
  119274. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119275. * @returns the max steps
  119276. */
  119277. getLockstepMaxSteps(): number;
  119278. /**
  119279. * Gets the current hardware scaling level.
  119280. * By default the hardware scaling level is computed from the window device ratio.
  119281. * 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.
  119282. * @returns a number indicating the current hardware scaling level
  119283. */
  119284. getHardwareScalingLevel(): number;
  119285. constructor(options?: NullEngineOptions);
  119286. /**
  119287. * Creates a vertex buffer
  119288. * @param vertices the data for the vertex buffer
  119289. * @returns the new WebGL static buffer
  119290. */
  119291. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119292. /**
  119293. * Creates a new index buffer
  119294. * @param indices defines the content of the index buffer
  119295. * @param updatable defines if the index buffer must be updatable
  119296. * @returns a new webGL buffer
  119297. */
  119298. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119299. /**
  119300. * Clear the current render buffer or the current render target (if any is set up)
  119301. * @param color defines the color to use
  119302. * @param backBuffer defines if the back buffer must be cleared
  119303. * @param depth defines if the depth buffer must be cleared
  119304. * @param stencil defines if the stencil buffer must be cleared
  119305. */
  119306. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119307. /**
  119308. * Gets the current render width
  119309. * @param useScreen defines if screen size must be used (or the current render target if any)
  119310. * @returns a number defining the current render width
  119311. */
  119312. getRenderWidth(useScreen?: boolean): number;
  119313. /**
  119314. * Gets the current render height
  119315. * @param useScreen defines if screen size must be used (or the current render target if any)
  119316. * @returns a number defining the current render height
  119317. */
  119318. getRenderHeight(useScreen?: boolean): number;
  119319. /**
  119320. * Set the WebGL's viewport
  119321. * @param viewport defines the viewport element to be used
  119322. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119323. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119324. */
  119325. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119326. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119327. /**
  119328. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119329. * @param pipelineContext defines the pipeline context to use
  119330. * @param uniformsNames defines the list of uniform names
  119331. * @returns an array of webGL uniform locations
  119332. */
  119333. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119334. /**
  119335. * Gets the lsit of active attributes for a given webGL program
  119336. * @param pipelineContext defines the pipeline context to use
  119337. * @param attributesNames defines the list of attribute names to get
  119338. * @returns an array of indices indicating the offset of each attribute
  119339. */
  119340. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119341. /**
  119342. * Binds an effect to the webGL context
  119343. * @param effect defines the effect to bind
  119344. */
  119345. bindSamplers(effect: Effect): void;
  119346. /**
  119347. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119348. * @param effect defines the effect to activate
  119349. */
  119350. enableEffect(effect: Effect): void;
  119351. /**
  119352. * Set various states to the webGL context
  119353. * @param culling defines backface culling state
  119354. * @param zOffset defines the value to apply to zOffset (0 by default)
  119355. * @param force defines if states must be applied even if cache is up to date
  119356. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119357. */
  119358. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119359. /**
  119360. * Set the value of an uniform to an array of int32
  119361. * @param uniform defines the webGL uniform location where to store the value
  119362. * @param array defines the array of int32 to store
  119363. */
  119364. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119365. /**
  119366. * Set the value of an uniform to an array of int32 (stored as vec2)
  119367. * @param uniform defines the webGL uniform location where to store the value
  119368. * @param array defines the array of int32 to store
  119369. */
  119370. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119371. /**
  119372. * Set the value of an uniform to an array of int32 (stored as vec3)
  119373. * @param uniform defines the webGL uniform location where to store the value
  119374. * @param array defines the array of int32 to store
  119375. */
  119376. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119377. /**
  119378. * Set the value of an uniform to an array of int32 (stored as vec4)
  119379. * @param uniform defines the webGL uniform location where to store the value
  119380. * @param array defines the array of int32 to store
  119381. */
  119382. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119383. /**
  119384. * Set the value of an uniform to an array of float32
  119385. * @param uniform defines the webGL uniform location where to store the value
  119386. * @param array defines the array of float32 to store
  119387. */
  119388. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119389. /**
  119390. * Set the value of an uniform to an array of float32 (stored as vec2)
  119391. * @param uniform defines the webGL uniform location where to store the value
  119392. * @param array defines the array of float32 to store
  119393. */
  119394. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119395. /**
  119396. * Set the value of an uniform to an array of float32 (stored as vec3)
  119397. * @param uniform defines the webGL uniform location where to store the value
  119398. * @param array defines the array of float32 to store
  119399. */
  119400. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119401. /**
  119402. * Set the value of an uniform to an array of float32 (stored as vec4)
  119403. * @param uniform defines the webGL uniform location where to store the value
  119404. * @param array defines the array of float32 to store
  119405. */
  119406. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119407. /**
  119408. * Set the value of an uniform to an array of number
  119409. * @param uniform defines the webGL uniform location where to store the value
  119410. * @param array defines the array of number to store
  119411. */
  119412. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119413. /**
  119414. * Set the value of an uniform to an array of number (stored as vec2)
  119415. * @param uniform defines the webGL uniform location where to store the value
  119416. * @param array defines the array of number to store
  119417. */
  119418. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119419. /**
  119420. * Set the value of an uniform to an array of number (stored as vec3)
  119421. * @param uniform defines the webGL uniform location where to store the value
  119422. * @param array defines the array of number to store
  119423. */
  119424. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119425. /**
  119426. * Set the value of an uniform to an array of number (stored as vec4)
  119427. * @param uniform defines the webGL uniform location where to store the value
  119428. * @param array defines the array of number to store
  119429. */
  119430. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119431. /**
  119432. * Set the value of an uniform to an array of float32 (stored as matrices)
  119433. * @param uniform defines the webGL uniform location where to store the value
  119434. * @param matrices defines the array of float32 to store
  119435. */
  119436. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119437. /**
  119438. * Set the value of an uniform to a matrix (3x3)
  119439. * @param uniform defines the webGL uniform location where to store the value
  119440. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119441. */
  119442. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119443. /**
  119444. * Set the value of an uniform to a matrix (2x2)
  119445. * @param uniform defines the webGL uniform location where to store the value
  119446. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119447. */
  119448. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119449. /**
  119450. * Set the value of an uniform to a number (float)
  119451. * @param uniform defines the webGL uniform location where to store the value
  119452. * @param value defines the float number to store
  119453. */
  119454. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119455. /**
  119456. * Set the value of an uniform to a vec2
  119457. * @param uniform defines the webGL uniform location where to store the value
  119458. * @param x defines the 1st component of the value
  119459. * @param y defines the 2nd component of the value
  119460. */
  119461. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119462. /**
  119463. * Set the value of an uniform to a vec3
  119464. * @param uniform defines the webGL uniform location where to store the value
  119465. * @param x defines the 1st component of the value
  119466. * @param y defines the 2nd component of the value
  119467. * @param z defines the 3rd component of the value
  119468. */
  119469. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119470. /**
  119471. * Set the value of an uniform to a boolean
  119472. * @param uniform defines the webGL uniform location where to store the value
  119473. * @param bool defines the boolean to store
  119474. */
  119475. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119476. /**
  119477. * Set the value of an uniform to a vec4
  119478. * @param uniform defines the webGL uniform location where to store the value
  119479. * @param x defines the 1st component of the value
  119480. * @param y defines the 2nd component of the value
  119481. * @param z defines the 3rd component of the value
  119482. * @param w defines the 4th component of the value
  119483. */
  119484. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119485. /**
  119486. * Sets the current alpha mode
  119487. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119488. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119489. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119490. */
  119491. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119492. /**
  119493. * Bind webGl buffers directly to the webGL context
  119494. * @param vertexBuffers defines the vertex buffer to bind
  119495. * @param indexBuffer defines the index buffer to bind
  119496. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119497. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119498. * @param effect defines the effect associated with the vertex buffer
  119499. */
  119500. bindBuffers(vertexBuffers: {
  119501. [key: string]: VertexBuffer;
  119502. }, indexBuffer: DataBuffer, effect: Effect): void;
  119503. /**
  119504. * Force the entire cache to be cleared
  119505. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119506. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119507. */
  119508. wipeCaches(bruteForce?: boolean): void;
  119509. /**
  119510. * Send a draw order
  119511. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119512. * @param indexStart defines the starting index
  119513. * @param indexCount defines the number of index to draw
  119514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119515. */
  119516. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119517. /**
  119518. * Draw a list of indexed primitives
  119519. * @param fillMode defines the primitive to use
  119520. * @param indexStart defines the starting index
  119521. * @param indexCount defines the number of index to draw
  119522. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119523. */
  119524. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119525. /**
  119526. * Draw a list of unindexed primitives
  119527. * @param fillMode defines the primitive to use
  119528. * @param verticesStart defines the index of first vertex to draw
  119529. * @param verticesCount defines the count of vertices to draw
  119530. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119531. */
  119532. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119533. /** @hidden */
  119534. _createTexture(): WebGLTexture;
  119535. /** @hidden */
  119536. _releaseTexture(texture: InternalTexture): void;
  119537. /**
  119538. * Usually called from Texture.ts.
  119539. * Passed information to create a WebGLTexture
  119540. * @param urlArg defines a value which contains one of the following:
  119541. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119542. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119543. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119544. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119545. * @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)
  119546. * @param scene needed for loading to the correct scene
  119547. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119548. * @param onLoad optional callback to be called upon successful completion
  119549. * @param onError optional callback to be called upon failure
  119550. * @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
  119551. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119552. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119553. * @param forcedExtension defines the extension to use to pick the right loader
  119554. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119556. */
  119557. 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;
  119558. /**
  119559. * Creates a new render target texture
  119560. * @param size defines the size of the texture
  119561. * @param options defines the options used to create the texture
  119562. * @returns a new render target texture stored in an InternalTexture
  119563. */
  119564. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119565. /**
  119566. * Update the sampling mode of a given texture
  119567. * @param samplingMode defines the required sampling mode
  119568. * @param texture defines the texture to update
  119569. */
  119570. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119571. /**
  119572. * Binds the frame buffer to the specified texture.
  119573. * @param texture The texture to render to or null for the default canvas
  119574. * @param faceIndex The face of the texture to render to in case of cube texture
  119575. * @param requiredWidth The width of the target to render to
  119576. * @param requiredHeight The height of the target to render to
  119577. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119578. * @param lodLevel defines le lod level to bind to the frame buffer
  119579. */
  119580. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119581. /**
  119582. * Unbind the current render target texture from the webGL context
  119583. * @param texture defines the render target texture to unbind
  119584. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119585. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119586. */
  119587. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119588. /**
  119589. * Creates a dynamic vertex buffer
  119590. * @param vertices the data for the dynamic vertex buffer
  119591. * @returns the new WebGL dynamic buffer
  119592. */
  119593. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119594. /**
  119595. * Update the content of a dynamic texture
  119596. * @param texture defines the texture to update
  119597. * @param canvas defines the canvas containing the source
  119598. * @param invertY defines if data must be stored with Y axis inverted
  119599. * @param premulAlpha defines if alpha is stored as premultiplied
  119600. * @param format defines the format of the data
  119601. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119602. */
  119603. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119604. /**
  119605. * Gets a boolean indicating if all created effects are ready
  119606. * @returns true if all effects are ready
  119607. */
  119608. areAllEffectsReady(): boolean;
  119609. /**
  119610. * @hidden
  119611. * Get the current error code of the webGL context
  119612. * @returns the error code
  119613. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119614. */
  119615. getError(): number;
  119616. /** @hidden */
  119617. _getUnpackAlignement(): number;
  119618. /** @hidden */
  119619. _unpackFlipY(value: boolean): void;
  119620. /**
  119621. * Update a dynamic index buffer
  119622. * @param indexBuffer defines the target index buffer
  119623. * @param indices defines the data to update
  119624. * @param offset defines the offset in the target index buffer where update should start
  119625. */
  119626. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  119627. /**
  119628. * Updates a dynamic vertex buffer.
  119629. * @param vertexBuffer the vertex buffer to update
  119630. * @param vertices the data used to update the vertex buffer
  119631. * @param byteOffset the byte offset of the data (optional)
  119632. * @param byteLength the byte length of the data (optional)
  119633. */
  119634. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  119635. /** @hidden */
  119636. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  119637. /** @hidden */
  119638. _bindTexture(channel: number, texture: InternalTexture): void;
  119639. protected _deleteBuffer(buffer: WebGLBuffer): void;
  119640. /**
  119641. * 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
  119642. */
  119643. releaseEffects(): void;
  119644. displayLoadingUI(): void;
  119645. hideLoadingUI(): void;
  119646. /** @hidden */
  119647. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119648. /** @hidden */
  119649. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119650. /** @hidden */
  119651. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119652. /** @hidden */
  119653. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  119654. }
  119655. }
  119656. declare module BABYLON {
  119657. /** @hidden */
  119658. export class _OcclusionDataStorage {
  119659. /** @hidden */
  119660. occlusionInternalRetryCounter: number;
  119661. /** @hidden */
  119662. isOcclusionQueryInProgress: boolean;
  119663. /** @hidden */
  119664. isOccluded: boolean;
  119665. /** @hidden */
  119666. occlusionRetryCount: number;
  119667. /** @hidden */
  119668. occlusionType: number;
  119669. /** @hidden */
  119670. occlusionQueryAlgorithmType: number;
  119671. }
  119672. interface Engine {
  119673. /**
  119674. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  119675. * @return the new query
  119676. */
  119677. createQuery(): WebGLQuery;
  119678. /**
  119679. * Delete and release a webGL query
  119680. * @param query defines the query to delete
  119681. * @return the current engine
  119682. */
  119683. deleteQuery(query: WebGLQuery): Engine;
  119684. /**
  119685. * Check if a given query has resolved and got its value
  119686. * @param query defines the query to check
  119687. * @returns true if the query got its value
  119688. */
  119689. isQueryResultAvailable(query: WebGLQuery): boolean;
  119690. /**
  119691. * Gets the value of a given query
  119692. * @param query defines the query to check
  119693. * @returns the value of the query
  119694. */
  119695. getQueryResult(query: WebGLQuery): number;
  119696. /**
  119697. * Initiates an occlusion query
  119698. * @param algorithmType defines the algorithm to use
  119699. * @param query defines the query to use
  119700. * @returns the current engine
  119701. * @see http://doc.babylonjs.com/features/occlusionquery
  119702. */
  119703. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  119704. /**
  119705. * Ends an occlusion query
  119706. * @see http://doc.babylonjs.com/features/occlusionquery
  119707. * @param algorithmType defines the algorithm to use
  119708. * @returns the current engine
  119709. */
  119710. endOcclusionQuery(algorithmType: number): Engine;
  119711. /**
  119712. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  119713. * Please note that only one query can be issued at a time
  119714. * @returns a time token used to track the time span
  119715. */
  119716. startTimeQuery(): Nullable<_TimeToken>;
  119717. /**
  119718. * Ends a time query
  119719. * @param token defines the token used to measure the time span
  119720. * @returns the time spent (in ns)
  119721. */
  119722. endTimeQuery(token: _TimeToken): int;
  119723. /** @hidden */
  119724. _currentNonTimestampToken: Nullable<_TimeToken>;
  119725. /** @hidden */
  119726. _createTimeQuery(): WebGLQuery;
  119727. /** @hidden */
  119728. _deleteTimeQuery(query: WebGLQuery): void;
  119729. /** @hidden */
  119730. _getGlAlgorithmType(algorithmType: number): number;
  119731. /** @hidden */
  119732. _getTimeQueryResult(query: WebGLQuery): any;
  119733. /** @hidden */
  119734. _getTimeQueryAvailability(query: WebGLQuery): any;
  119735. }
  119736. interface AbstractMesh {
  119737. /**
  119738. * Backing filed
  119739. * @hidden
  119740. */
  119741. __occlusionDataStorage: _OcclusionDataStorage;
  119742. /**
  119743. * Access property
  119744. * @hidden
  119745. */
  119746. _occlusionDataStorage: _OcclusionDataStorage;
  119747. /**
  119748. * 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.
  119749. * The default value is -1 which means don't break the query and wait till the result
  119750. * @see http://doc.babylonjs.com/features/occlusionquery
  119751. */
  119752. occlusionRetryCount: number;
  119753. /**
  119754. * 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:
  119755. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  119756. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  119757. * * 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.
  119758. * @see http://doc.babylonjs.com/features/occlusionquery
  119759. */
  119760. occlusionType: number;
  119761. /**
  119762. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  119763. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  119764. * * 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.
  119765. * @see http://doc.babylonjs.com/features/occlusionquery
  119766. */
  119767. occlusionQueryAlgorithmType: number;
  119768. /**
  119769. * 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
  119770. * @see http://doc.babylonjs.com/features/occlusionquery
  119771. */
  119772. isOccluded: boolean;
  119773. /**
  119774. * Flag to check the progress status of the query
  119775. * @see http://doc.babylonjs.com/features/occlusionquery
  119776. */
  119777. isOcclusionQueryInProgress: boolean;
  119778. }
  119779. }
  119780. declare module BABYLON {
  119781. /** @hidden */
  119782. export var _forceTransformFeedbackToBundle: boolean;
  119783. interface Engine {
  119784. /**
  119785. * Creates a webGL transform feedback object
  119786. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  119787. * @returns the webGL transform feedback object
  119788. */
  119789. createTransformFeedback(): WebGLTransformFeedback;
  119790. /**
  119791. * Delete a webGL transform feedback object
  119792. * @param value defines the webGL transform feedback object to delete
  119793. */
  119794. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  119795. /**
  119796. * Bind a webGL transform feedback object to the webgl context
  119797. * @param value defines the webGL transform feedback object to bind
  119798. */
  119799. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  119800. /**
  119801. * Begins a transform feedback operation
  119802. * @param usePoints defines if points or triangles must be used
  119803. */
  119804. beginTransformFeedback(usePoints: boolean): void;
  119805. /**
  119806. * Ends a transform feedback operation
  119807. */
  119808. endTransformFeedback(): void;
  119809. /**
  119810. * Specify the varyings to use with transform feedback
  119811. * @param program defines the associated webGL program
  119812. * @param value defines the list of strings representing the varying names
  119813. */
  119814. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  119815. /**
  119816. * Bind a webGL buffer for a transform feedback operation
  119817. * @param value defines the webGL buffer to bind
  119818. */
  119819. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  119820. }
  119821. }
  119822. declare module BABYLON {
  119823. /**
  119824. * Creation options of the multi render target texture.
  119825. */
  119826. export interface IMultiRenderTargetOptions {
  119827. /**
  119828. * Define if the texture needs to create mip maps after render.
  119829. */
  119830. generateMipMaps?: boolean;
  119831. /**
  119832. * Define the types of all the draw buffers we want to create
  119833. */
  119834. types?: number[];
  119835. /**
  119836. * Define the sampling modes of all the draw buffers we want to create
  119837. */
  119838. samplingModes?: number[];
  119839. /**
  119840. * Define if a depth buffer is required
  119841. */
  119842. generateDepthBuffer?: boolean;
  119843. /**
  119844. * Define if a stencil buffer is required
  119845. */
  119846. generateStencilBuffer?: boolean;
  119847. /**
  119848. * Define if a depth texture is required instead of a depth buffer
  119849. */
  119850. generateDepthTexture?: boolean;
  119851. /**
  119852. * Define the number of desired draw buffers
  119853. */
  119854. textureCount?: number;
  119855. /**
  119856. * Define if aspect ratio should be adapted to the texture or stay the scene one
  119857. */
  119858. doNotChangeAspectRatio?: boolean;
  119859. /**
  119860. * Define the default type of the buffers we are creating
  119861. */
  119862. defaultType?: number;
  119863. }
  119864. /**
  119865. * A multi render target, like a render target provides the ability to render to a texture.
  119866. * Unlike the render target, it can render to several draw buffers in one draw.
  119867. * This is specially interesting in deferred rendering or for any effects requiring more than
  119868. * just one color from a single pass.
  119869. */
  119870. export class MultiRenderTarget extends RenderTargetTexture {
  119871. private _internalTextures;
  119872. private _textures;
  119873. private _multiRenderTargetOptions;
  119874. /**
  119875. * Get if draw buffers are currently supported by the used hardware and browser.
  119876. */
  119877. get isSupported(): boolean;
  119878. /**
  119879. * Get the list of textures generated by the multi render target.
  119880. */
  119881. get textures(): Texture[];
  119882. /**
  119883. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  119884. */
  119885. get depthTexture(): Texture;
  119886. /**
  119887. * Set the wrapping mode on U of all the textures we are rendering to.
  119888. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119889. */
  119890. set wrapU(wrap: number);
  119891. /**
  119892. * Set the wrapping mode on V of all the textures we are rendering to.
  119893. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119894. */
  119895. set wrapV(wrap: number);
  119896. /**
  119897. * Instantiate a new multi render target texture.
  119898. * A multi render target, like a render target provides the ability to render to a texture.
  119899. * Unlike the render target, it can render to several draw buffers in one draw.
  119900. * This is specially interesting in deferred rendering or for any effects requiring more than
  119901. * just one color from a single pass.
  119902. * @param name Define the name of the texture
  119903. * @param size Define the size of the buffers to render to
  119904. * @param count Define the number of target we are rendering into
  119905. * @param scene Define the scene the texture belongs to
  119906. * @param options Define the options used to create the multi render target
  119907. */
  119908. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  119909. /** @hidden */
  119910. _rebuild(): void;
  119911. private _createInternalTextures;
  119912. private _createTextures;
  119913. /**
  119914. * Define the number of samples used if MSAA is enabled.
  119915. */
  119916. get samples(): number;
  119917. set samples(value: number);
  119918. /**
  119919. * Resize all the textures in the multi render target.
  119920. * Be carrefull as it will recreate all the data in the new texture.
  119921. * @param size Define the new size
  119922. */
  119923. resize(size: any): void;
  119924. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119925. /**
  119926. * Dispose the render targets and their associated resources
  119927. */
  119928. dispose(): void;
  119929. /**
  119930. * Release all the underlying texture used as draw buffers.
  119931. */
  119932. releaseInternalTextures(): void;
  119933. }
  119934. }
  119935. declare module BABYLON {
  119936. interface ThinEngine {
  119937. /**
  119938. * Unbind a list of render target textures from the webGL context
  119939. * This is used only when drawBuffer extension or webGL2 are active
  119940. * @param textures defines the render target textures to unbind
  119941. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119942. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119943. */
  119944. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  119945. /**
  119946. * Create a multi render target texture
  119947. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  119948. * @param size defines the size of the texture
  119949. * @param options defines the creation options
  119950. * @returns the cube texture as an InternalTexture
  119951. */
  119952. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  119953. /**
  119954. * Update the sample count for a given multiple render target texture
  119955. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  119956. * @param textures defines the textures to update
  119957. * @param samples defines the sample count to set
  119958. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  119959. */
  119960. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  119961. }
  119962. }
  119963. declare module BABYLON {
  119964. /**
  119965. * Class used to define an additional view for the engine
  119966. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119967. */
  119968. export class EngineView {
  119969. /** Defines the canvas where to render the view */
  119970. target: HTMLCanvasElement;
  119971. /** Defines an optional camera used to render the view (will use active camera else) */
  119972. camera?: Camera;
  119973. }
  119974. interface Engine {
  119975. /**
  119976. * Gets or sets the HTML element to use for attaching events
  119977. */
  119978. inputElement: Nullable<HTMLElement>;
  119979. /**
  119980. * Gets the current engine view
  119981. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119982. */
  119983. activeView: Nullable<EngineView>;
  119984. /** Gets or sets the list of views */
  119985. views: EngineView[];
  119986. /**
  119987. * Register a new child canvas
  119988. * @param canvas defines the canvas to register
  119989. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  119990. * @returns the associated view
  119991. */
  119992. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  119993. /**
  119994. * Remove a registered child canvas
  119995. * @param canvas defines the canvas to remove
  119996. * @returns the current engine
  119997. */
  119998. unRegisterView(canvas: HTMLCanvasElement): Engine;
  119999. }
  120000. }
  120001. declare module BABYLON {
  120002. /**
  120003. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120004. */
  120005. export interface CubeMapInfo {
  120006. /**
  120007. * The pixel array for the front face.
  120008. * This is stored in format, left to right, up to down format.
  120009. */
  120010. front: Nullable<ArrayBufferView>;
  120011. /**
  120012. * The pixel array for the back face.
  120013. * This is stored in format, left to right, up to down format.
  120014. */
  120015. back: Nullable<ArrayBufferView>;
  120016. /**
  120017. * The pixel array for the left face.
  120018. * This is stored in format, left to right, up to down format.
  120019. */
  120020. left: Nullable<ArrayBufferView>;
  120021. /**
  120022. * The pixel array for the right face.
  120023. * This is stored in format, left to right, up to down format.
  120024. */
  120025. right: Nullable<ArrayBufferView>;
  120026. /**
  120027. * The pixel array for the up face.
  120028. * This is stored in format, left to right, up to down format.
  120029. */
  120030. up: Nullable<ArrayBufferView>;
  120031. /**
  120032. * The pixel array for the down face.
  120033. * This is stored in format, left to right, up to down format.
  120034. */
  120035. down: Nullable<ArrayBufferView>;
  120036. /**
  120037. * The size of the cubemap stored.
  120038. *
  120039. * Each faces will be size * size pixels.
  120040. */
  120041. size: number;
  120042. /**
  120043. * The format of the texture.
  120044. *
  120045. * RGBA, RGB.
  120046. */
  120047. format: number;
  120048. /**
  120049. * The type of the texture data.
  120050. *
  120051. * UNSIGNED_INT, FLOAT.
  120052. */
  120053. type: number;
  120054. /**
  120055. * Specifies whether the texture is in gamma space.
  120056. */
  120057. gammaSpace: boolean;
  120058. }
  120059. /**
  120060. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120061. */
  120062. export class PanoramaToCubeMapTools {
  120063. private static FACE_FRONT;
  120064. private static FACE_BACK;
  120065. private static FACE_RIGHT;
  120066. private static FACE_LEFT;
  120067. private static FACE_DOWN;
  120068. private static FACE_UP;
  120069. /**
  120070. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120071. *
  120072. * @param float32Array The source data.
  120073. * @param inputWidth The width of the input panorama.
  120074. * @param inputHeight The height of the input panorama.
  120075. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120076. * @return The cubemap data
  120077. */
  120078. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120079. private static CreateCubemapTexture;
  120080. private static CalcProjectionSpherical;
  120081. }
  120082. }
  120083. declare module BABYLON {
  120084. /**
  120085. * Helper class dealing with the extraction of spherical polynomial dataArray
  120086. * from a cube map.
  120087. */
  120088. export class CubeMapToSphericalPolynomialTools {
  120089. private static FileFaces;
  120090. /**
  120091. * Converts a texture to the according Spherical Polynomial data.
  120092. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120093. *
  120094. * @param texture The texture to extract the information from.
  120095. * @return The Spherical Polynomial data.
  120096. */
  120097. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120098. /**
  120099. * Converts a cubemap to the according Spherical Polynomial data.
  120100. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120101. *
  120102. * @param cubeInfo The Cube map to extract the information from.
  120103. * @return The Spherical Polynomial data.
  120104. */
  120105. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120106. }
  120107. }
  120108. declare module BABYLON {
  120109. interface BaseTexture {
  120110. /**
  120111. * Get the polynomial representation of the texture data.
  120112. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120113. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120114. */
  120115. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120116. }
  120117. }
  120118. declare module BABYLON {
  120119. /** @hidden */
  120120. export var rgbdEncodePixelShader: {
  120121. name: string;
  120122. shader: string;
  120123. };
  120124. }
  120125. declare module BABYLON {
  120126. /** @hidden */
  120127. export var rgbdDecodePixelShader: {
  120128. name: string;
  120129. shader: string;
  120130. };
  120131. }
  120132. declare module BABYLON {
  120133. /**
  120134. * Raw texture data and descriptor sufficient for WebGL texture upload
  120135. */
  120136. export interface EnvironmentTextureInfo {
  120137. /**
  120138. * Version of the environment map
  120139. */
  120140. version: number;
  120141. /**
  120142. * Width of image
  120143. */
  120144. width: number;
  120145. /**
  120146. * Irradiance information stored in the file.
  120147. */
  120148. irradiance: any;
  120149. /**
  120150. * Specular information stored in the file.
  120151. */
  120152. specular: any;
  120153. }
  120154. /**
  120155. * Defines One Image in the file. It requires only the position in the file
  120156. * as well as the length.
  120157. */
  120158. interface BufferImageData {
  120159. /**
  120160. * Length of the image data.
  120161. */
  120162. length: number;
  120163. /**
  120164. * Position of the data from the null terminator delimiting the end of the JSON.
  120165. */
  120166. position: number;
  120167. }
  120168. /**
  120169. * Defines the specular data enclosed in the file.
  120170. * This corresponds to the version 1 of the data.
  120171. */
  120172. export interface EnvironmentTextureSpecularInfoV1 {
  120173. /**
  120174. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120175. */
  120176. specularDataPosition?: number;
  120177. /**
  120178. * This contains all the images data needed to reconstruct the cubemap.
  120179. */
  120180. mipmaps: Array<BufferImageData>;
  120181. /**
  120182. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120183. */
  120184. lodGenerationScale: number;
  120185. }
  120186. /**
  120187. * Sets of helpers addressing the serialization and deserialization of environment texture
  120188. * stored in a BabylonJS env file.
  120189. * Those files are usually stored as .env files.
  120190. */
  120191. export class EnvironmentTextureTools {
  120192. /**
  120193. * Magic number identifying the env file.
  120194. */
  120195. private static _MagicBytes;
  120196. /**
  120197. * Gets the environment info from an env file.
  120198. * @param data The array buffer containing the .env bytes.
  120199. * @returns the environment file info (the json header) if successfully parsed.
  120200. */
  120201. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  120202. /**
  120203. * Creates an environment texture from a loaded cube texture.
  120204. * @param texture defines the cube texture to convert in env file
  120205. * @return a promise containing the environment data if succesfull.
  120206. */
  120207. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120208. /**
  120209. * Creates a JSON representation of the spherical data.
  120210. * @param texture defines the texture containing the polynomials
  120211. * @return the JSON representation of the spherical info
  120212. */
  120213. private static _CreateEnvTextureIrradiance;
  120214. /**
  120215. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120216. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  120217. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120218. * @return the views described by info providing access to the underlying buffer
  120219. */
  120220. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120221. /**
  120222. * Uploads the texture info contained in the env file to the GPU.
  120223. * @param texture defines the internal texture to upload to
  120224. * @param arrayBuffer defines the buffer cotaining the data to load
  120225. * @param info defines the texture info retrieved through the GetEnvInfo method
  120226. * @returns a promise
  120227. */
  120228. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  120229. private static _OnImageReadyAsync;
  120230. /**
  120231. * Uploads the levels of image data to the GPU.
  120232. * @param texture defines the internal texture to upload to
  120233. * @param imageData defines the array buffer views of image data [mipmap][face]
  120234. * @returns a promise
  120235. */
  120236. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120237. /**
  120238. * Uploads spherical polynomials information to the texture.
  120239. * @param texture defines the texture we are trying to upload the information to
  120240. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120241. */
  120242. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120243. /** @hidden */
  120244. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120245. }
  120246. }
  120247. declare module BABYLON {
  120248. /**
  120249. * Contains position and normal vectors for a vertex
  120250. */
  120251. export class PositionNormalVertex {
  120252. /** the position of the vertex (defaut: 0,0,0) */
  120253. position: Vector3;
  120254. /** the normal of the vertex (defaut: 0,1,0) */
  120255. normal: Vector3;
  120256. /**
  120257. * Creates a PositionNormalVertex
  120258. * @param position the position of the vertex (defaut: 0,0,0)
  120259. * @param normal the normal of the vertex (defaut: 0,1,0)
  120260. */
  120261. constructor(
  120262. /** the position of the vertex (defaut: 0,0,0) */
  120263. position?: Vector3,
  120264. /** the normal of the vertex (defaut: 0,1,0) */
  120265. normal?: Vector3);
  120266. /**
  120267. * Clones the PositionNormalVertex
  120268. * @returns the cloned PositionNormalVertex
  120269. */
  120270. clone(): PositionNormalVertex;
  120271. }
  120272. /**
  120273. * Contains position, normal and uv vectors for a vertex
  120274. */
  120275. export class PositionNormalTextureVertex {
  120276. /** the position of the vertex (defaut: 0,0,0) */
  120277. position: Vector3;
  120278. /** the normal of the vertex (defaut: 0,1,0) */
  120279. normal: Vector3;
  120280. /** the uv of the vertex (default: 0,0) */
  120281. uv: Vector2;
  120282. /**
  120283. * Creates a PositionNormalTextureVertex
  120284. * @param position the position of the vertex (defaut: 0,0,0)
  120285. * @param normal the normal of the vertex (defaut: 0,1,0)
  120286. * @param uv the uv of the vertex (default: 0,0)
  120287. */
  120288. constructor(
  120289. /** the position of the vertex (defaut: 0,0,0) */
  120290. position?: Vector3,
  120291. /** the normal of the vertex (defaut: 0,1,0) */
  120292. normal?: Vector3,
  120293. /** the uv of the vertex (default: 0,0) */
  120294. uv?: Vector2);
  120295. /**
  120296. * Clones the PositionNormalTextureVertex
  120297. * @returns the cloned PositionNormalTextureVertex
  120298. */
  120299. clone(): PositionNormalTextureVertex;
  120300. }
  120301. }
  120302. declare module BABYLON {
  120303. /** @hidden */
  120304. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120305. private _genericAttributeLocation;
  120306. private _varyingLocationCount;
  120307. private _varyingLocationMap;
  120308. private _replacements;
  120309. private _textureCount;
  120310. private _uniforms;
  120311. lineProcessor(line: string): string;
  120312. attributeProcessor(attribute: string): string;
  120313. varyingProcessor(varying: string, isFragment: boolean): string;
  120314. uniformProcessor(uniform: string): string;
  120315. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120316. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120317. }
  120318. }
  120319. declare module BABYLON {
  120320. /**
  120321. * Container for accessors for natively-stored mesh data buffers.
  120322. */
  120323. class NativeDataBuffer extends DataBuffer {
  120324. /**
  120325. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120326. */
  120327. nativeIndexBuffer?: any;
  120328. /**
  120329. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120330. */
  120331. nativeVertexBuffer?: any;
  120332. }
  120333. /** @hidden */
  120334. class NativeTexture extends InternalTexture {
  120335. getInternalTexture(): InternalTexture;
  120336. getViewCount(): number;
  120337. }
  120338. /** @hidden */
  120339. export class NativeEngine extends Engine {
  120340. private readonly _native;
  120341. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120342. private readonly INVALID_HANDLE;
  120343. getHardwareScalingLevel(): number;
  120344. constructor();
  120345. /**
  120346. * Can be used to override the current requestAnimationFrame requester.
  120347. * @hidden
  120348. */
  120349. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120350. /**
  120351. * Override default engine behavior.
  120352. * @param color
  120353. * @param backBuffer
  120354. * @param depth
  120355. * @param stencil
  120356. */
  120357. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120358. /**
  120359. * Gets host document
  120360. * @returns the host document object
  120361. */
  120362. getHostDocument(): Nullable<Document>;
  120363. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120364. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120365. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120366. recordVertexArrayObject(vertexBuffers: {
  120367. [key: string]: VertexBuffer;
  120368. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120369. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120370. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120371. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120372. /**
  120373. * Draw a list of indexed primitives
  120374. * @param fillMode defines the primitive to use
  120375. * @param indexStart defines the starting index
  120376. * @param indexCount defines the number of index to draw
  120377. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120378. */
  120379. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120380. /**
  120381. * Draw a list of unindexed primitives
  120382. * @param fillMode defines the primitive to use
  120383. * @param verticesStart defines the index of first vertex to draw
  120384. * @param verticesCount defines the count of vertices to draw
  120385. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120386. */
  120387. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120388. createPipelineContext(): IPipelineContext;
  120389. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120390. /** @hidden */
  120391. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120392. /** @hidden */
  120393. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120394. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120395. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120396. protected _setProgram(program: WebGLProgram): void;
  120397. _releaseEffect(effect: Effect): void;
  120398. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120399. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120400. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120401. bindSamplers(effect: Effect): void;
  120402. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120403. getRenderWidth(useScreen?: boolean): number;
  120404. getRenderHeight(useScreen?: boolean): number;
  120405. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120406. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120407. /**
  120408. * Set the z offset to apply to current rendering
  120409. * @param value defines the offset to apply
  120410. */
  120411. setZOffset(value: number): void;
  120412. /**
  120413. * Gets the current value of the zOffset
  120414. * @returns the current zOffset state
  120415. */
  120416. getZOffset(): number;
  120417. /**
  120418. * Enable or disable depth buffering
  120419. * @param enable defines the state to set
  120420. */
  120421. setDepthBuffer(enable: boolean): void;
  120422. /**
  120423. * Gets a boolean indicating if depth writing is enabled
  120424. * @returns the current depth writing state
  120425. */
  120426. getDepthWrite(): boolean;
  120427. /**
  120428. * Enable or disable depth writing
  120429. * @param enable defines the state to set
  120430. */
  120431. setDepthWrite(enable: boolean): void;
  120432. /**
  120433. * Enable or disable color writing
  120434. * @param enable defines the state to set
  120435. */
  120436. setColorWrite(enable: boolean): void;
  120437. /**
  120438. * Gets a boolean indicating if color writing is enabled
  120439. * @returns the current color writing state
  120440. */
  120441. getColorWrite(): boolean;
  120442. /**
  120443. * Sets alpha constants used by some alpha blending modes
  120444. * @param r defines the red component
  120445. * @param g defines the green component
  120446. * @param b defines the blue component
  120447. * @param a defines the alpha component
  120448. */
  120449. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120450. /**
  120451. * Sets the current alpha mode
  120452. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120453. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120454. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120455. */
  120456. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120457. /**
  120458. * Gets the current alpha mode
  120459. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120460. * @returns the current alpha mode
  120461. */
  120462. getAlphaMode(): number;
  120463. setInt(uniform: WebGLUniformLocation, int: number): void;
  120464. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120465. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120466. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120467. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120468. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120469. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120470. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120471. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120472. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120473. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120474. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120475. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120476. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120477. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120478. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120479. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120480. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120481. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120482. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120483. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120484. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120485. wipeCaches(bruteForce?: boolean): void;
  120486. _createTexture(): WebGLTexture;
  120487. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120488. /**
  120489. * Usually called from BABYLON.Texture.ts.
  120490. * Passed information to create a WebGLTexture
  120491. * @param urlArg defines a value which contains one of the following:
  120492. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120493. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120494. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120496. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120497. * @param scene needed for loading to the correct scene
  120498. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120499. * @param onLoad optional callback to be called upon successful completion
  120500. * @param onError optional callback to be called upon failure
  120501. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120502. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120503. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120504. * @param forcedExtension defines the extension to use to pick the right loader
  120505. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120506. */
  120507. 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;
  120508. /**
  120509. * Creates a cube texture
  120510. * @param rootUrl defines the url where the files to load is located
  120511. * @param scene defines the current scene
  120512. * @param files defines the list of files to load (1 per face)
  120513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120514. * @param onLoad defines an optional callback raised when the texture is loaded
  120515. * @param onError defines an optional callback raised if there is an issue to load the texture
  120516. * @param format defines the format of the data
  120517. * @param forcedExtension defines the extension to use to pick the right loader
  120518. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120519. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120520. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120521. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120522. * @returns the cube texture as an InternalTexture
  120523. */
  120524. 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;
  120525. private _getSamplingFilter;
  120526. private static _GetNativeTextureFormat;
  120527. createRenderTargetTexture(size: number | {
  120528. width: number;
  120529. height: number;
  120530. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120531. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120532. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120533. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120534. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120535. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120536. /**
  120537. * Updates a dynamic vertex buffer.
  120538. * @param vertexBuffer the vertex buffer to update
  120539. * @param data the data used to update the vertex buffer
  120540. * @param byteOffset the byte offset of the data (optional)
  120541. * @param byteLength the byte length of the data (optional)
  120542. */
  120543. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120544. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120545. private _updateAnisotropicLevel;
  120546. private _getAddressMode;
  120547. /** @hidden */
  120548. _bindTexture(channel: number, texture: InternalTexture): void;
  120549. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120550. releaseEffects(): void;
  120551. /** @hidden */
  120552. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120553. /** @hidden */
  120554. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120555. /** @hidden */
  120556. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120557. /** @hidden */
  120558. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120559. }
  120560. }
  120561. declare module BABYLON {
  120562. /**
  120563. * Gather the list of clipboard event types as constants.
  120564. */
  120565. export class ClipboardEventTypes {
  120566. /**
  120567. * The clipboard event is fired when a copy command is active (pressed).
  120568. */
  120569. static readonly COPY: number;
  120570. /**
  120571. * The clipboard event is fired when a cut command is active (pressed).
  120572. */
  120573. static readonly CUT: number;
  120574. /**
  120575. * The clipboard event is fired when a paste command is active (pressed).
  120576. */
  120577. static readonly PASTE: number;
  120578. }
  120579. /**
  120580. * This class is used to store clipboard related info for the onClipboardObservable event.
  120581. */
  120582. export class ClipboardInfo {
  120583. /**
  120584. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120585. */
  120586. type: number;
  120587. /**
  120588. * Defines the related dom event
  120589. */
  120590. event: ClipboardEvent;
  120591. /**
  120592. *Creates an instance of ClipboardInfo.
  120593. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120594. * @param event Defines the related dom event
  120595. */
  120596. constructor(
  120597. /**
  120598. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120599. */
  120600. type: number,
  120601. /**
  120602. * Defines the related dom event
  120603. */
  120604. event: ClipboardEvent);
  120605. /**
  120606. * Get the clipboard event's type from the keycode.
  120607. * @param keyCode Defines the keyCode for the current keyboard event.
  120608. * @return {number}
  120609. */
  120610. static GetTypeFromCharacter(keyCode: number): number;
  120611. }
  120612. }
  120613. declare module BABYLON {
  120614. /**
  120615. * Google Daydream controller
  120616. */
  120617. export class DaydreamController extends WebVRController {
  120618. /**
  120619. * Base Url for the controller model.
  120620. */
  120621. static MODEL_BASE_URL: string;
  120622. /**
  120623. * File name for the controller model.
  120624. */
  120625. static MODEL_FILENAME: string;
  120626. /**
  120627. * Gamepad Id prefix used to identify Daydream Controller.
  120628. */
  120629. static readonly GAMEPAD_ID_PREFIX: string;
  120630. /**
  120631. * Creates a new DaydreamController from a gamepad
  120632. * @param vrGamepad the gamepad that the controller should be created from
  120633. */
  120634. constructor(vrGamepad: any);
  120635. /**
  120636. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120637. * @param scene scene in which to add meshes
  120638. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120639. */
  120640. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120641. /**
  120642. * Called once for each button that changed state since the last frame
  120643. * @param buttonIdx Which button index changed
  120644. * @param state New state of the button
  120645. * @param changes Which properties on the state changed since last frame
  120646. */
  120647. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120648. }
  120649. }
  120650. declare module BABYLON {
  120651. /**
  120652. * Gear VR Controller
  120653. */
  120654. export class GearVRController extends WebVRController {
  120655. /**
  120656. * Base Url for the controller model.
  120657. */
  120658. static MODEL_BASE_URL: string;
  120659. /**
  120660. * File name for the controller model.
  120661. */
  120662. static MODEL_FILENAME: string;
  120663. /**
  120664. * Gamepad Id prefix used to identify this controller.
  120665. */
  120666. static readonly GAMEPAD_ID_PREFIX: string;
  120667. private readonly _buttonIndexToObservableNameMap;
  120668. /**
  120669. * Creates a new GearVRController from a gamepad
  120670. * @param vrGamepad the gamepad that the controller should be created from
  120671. */
  120672. constructor(vrGamepad: any);
  120673. /**
  120674. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120675. * @param scene scene in which to add meshes
  120676. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120677. */
  120678. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120679. /**
  120680. * Called once for each button that changed state since the last frame
  120681. * @param buttonIdx Which button index changed
  120682. * @param state New state of the button
  120683. * @param changes Which properties on the state changed since last frame
  120684. */
  120685. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120686. }
  120687. }
  120688. declare module BABYLON {
  120689. /**
  120690. * Generic Controller
  120691. */
  120692. export class GenericController extends WebVRController {
  120693. /**
  120694. * Base Url for the controller model.
  120695. */
  120696. static readonly MODEL_BASE_URL: string;
  120697. /**
  120698. * File name for the controller model.
  120699. */
  120700. static readonly MODEL_FILENAME: string;
  120701. /**
  120702. * Creates a new GenericController from a gamepad
  120703. * @param vrGamepad the gamepad that the controller should be created from
  120704. */
  120705. constructor(vrGamepad: any);
  120706. /**
  120707. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120708. * @param scene scene in which to add meshes
  120709. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120710. */
  120711. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120712. /**
  120713. * Called once for each button that changed state since the last frame
  120714. * @param buttonIdx Which button index changed
  120715. * @param state New state of the button
  120716. * @param changes Which properties on the state changed since last frame
  120717. */
  120718. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120719. }
  120720. }
  120721. declare module BABYLON {
  120722. /**
  120723. * Oculus Touch Controller
  120724. */
  120725. export class OculusTouchController extends WebVRController {
  120726. /**
  120727. * Base Url for the controller model.
  120728. */
  120729. static MODEL_BASE_URL: string;
  120730. /**
  120731. * File name for the left controller model.
  120732. */
  120733. static MODEL_LEFT_FILENAME: string;
  120734. /**
  120735. * File name for the right controller model.
  120736. */
  120737. static MODEL_RIGHT_FILENAME: string;
  120738. /**
  120739. * Base Url for the Quest controller model.
  120740. */
  120741. static QUEST_MODEL_BASE_URL: string;
  120742. /**
  120743. * @hidden
  120744. * If the controllers are running on a device that needs the updated Quest controller models
  120745. */
  120746. static _IsQuest: boolean;
  120747. /**
  120748. * Fired when the secondary trigger on this controller is modified
  120749. */
  120750. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  120751. /**
  120752. * Fired when the thumb rest on this controller is modified
  120753. */
  120754. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  120755. /**
  120756. * Creates a new OculusTouchController from a gamepad
  120757. * @param vrGamepad the gamepad that the controller should be created from
  120758. */
  120759. constructor(vrGamepad: any);
  120760. /**
  120761. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120762. * @param scene scene in which to add meshes
  120763. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120764. */
  120765. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120766. /**
  120767. * Fired when the A button on this controller is modified
  120768. */
  120769. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120770. /**
  120771. * Fired when the B button on this controller is modified
  120772. */
  120773. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120774. /**
  120775. * Fired when the X button on this controller is modified
  120776. */
  120777. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120778. /**
  120779. * Fired when the Y button on this controller is modified
  120780. */
  120781. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120782. /**
  120783. * Called once for each button that changed state since the last frame
  120784. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  120785. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  120786. * 2) secondary trigger (same)
  120787. * 3) A (right) X (left), touch, pressed = value
  120788. * 4) B / Y
  120789. * 5) thumb rest
  120790. * @param buttonIdx Which button index changed
  120791. * @param state New state of the button
  120792. * @param changes Which properties on the state changed since last frame
  120793. */
  120794. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120795. }
  120796. }
  120797. declare module BABYLON {
  120798. /**
  120799. * Vive Controller
  120800. */
  120801. export class ViveController extends WebVRController {
  120802. /**
  120803. * Base Url for the controller model.
  120804. */
  120805. static MODEL_BASE_URL: string;
  120806. /**
  120807. * File name for the controller model.
  120808. */
  120809. static MODEL_FILENAME: string;
  120810. /**
  120811. * Creates a new ViveController from a gamepad
  120812. * @param vrGamepad the gamepad that the controller should be created from
  120813. */
  120814. constructor(vrGamepad: any);
  120815. /**
  120816. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120817. * @param scene scene in which to add meshes
  120818. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120819. */
  120820. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120821. /**
  120822. * Fired when the left button on this controller is modified
  120823. */
  120824. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120825. /**
  120826. * Fired when the right button on this controller is modified
  120827. */
  120828. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120829. /**
  120830. * Fired when the menu button on this controller is modified
  120831. */
  120832. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120833. /**
  120834. * Called once for each button that changed state since the last frame
  120835. * Vive mapping:
  120836. * 0: touchpad
  120837. * 1: trigger
  120838. * 2: left AND right buttons
  120839. * 3: menu button
  120840. * @param buttonIdx Which button index changed
  120841. * @param state New state of the button
  120842. * @param changes Which properties on the state changed since last frame
  120843. */
  120844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120845. }
  120846. }
  120847. declare module BABYLON {
  120848. /**
  120849. * Defines the WindowsMotionController object that the state of the windows motion controller
  120850. */
  120851. export class WindowsMotionController extends WebVRController {
  120852. /**
  120853. * The base url used to load the left and right controller models
  120854. */
  120855. static MODEL_BASE_URL: string;
  120856. /**
  120857. * The name of the left controller model file
  120858. */
  120859. static MODEL_LEFT_FILENAME: string;
  120860. /**
  120861. * The name of the right controller model file
  120862. */
  120863. static MODEL_RIGHT_FILENAME: string;
  120864. /**
  120865. * The controller name prefix for this controller type
  120866. */
  120867. static readonly GAMEPAD_ID_PREFIX: string;
  120868. /**
  120869. * The controller id pattern for this controller type
  120870. */
  120871. private static readonly GAMEPAD_ID_PATTERN;
  120872. private _loadedMeshInfo;
  120873. protected readonly _mapping: {
  120874. buttons: string[];
  120875. buttonMeshNames: {
  120876. 'trigger': string;
  120877. 'menu': string;
  120878. 'grip': string;
  120879. 'thumbstick': string;
  120880. 'trackpad': string;
  120881. };
  120882. buttonObservableNames: {
  120883. 'trigger': string;
  120884. 'menu': string;
  120885. 'grip': string;
  120886. 'thumbstick': string;
  120887. 'trackpad': string;
  120888. };
  120889. axisMeshNames: string[];
  120890. pointingPoseMeshName: string;
  120891. };
  120892. /**
  120893. * Fired when the trackpad on this controller is clicked
  120894. */
  120895. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120896. /**
  120897. * Fired when the trackpad on this controller is modified
  120898. */
  120899. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120900. /**
  120901. * The current x and y values of this controller's trackpad
  120902. */
  120903. trackpad: StickValues;
  120904. /**
  120905. * Creates a new WindowsMotionController from a gamepad
  120906. * @param vrGamepad the gamepad that the controller should be created from
  120907. */
  120908. constructor(vrGamepad: any);
  120909. /**
  120910. * Fired when the trigger on this controller is modified
  120911. */
  120912. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120913. /**
  120914. * Fired when the menu button on this controller is modified
  120915. */
  120916. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120917. /**
  120918. * Fired when the grip button on this controller is modified
  120919. */
  120920. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120921. /**
  120922. * Fired when the thumbstick button on this controller is modified
  120923. */
  120924. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120925. /**
  120926. * Fired when the touchpad button on this controller is modified
  120927. */
  120928. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120929. /**
  120930. * Fired when the touchpad values on this controller are modified
  120931. */
  120932. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  120933. protected _updateTrackpad(): void;
  120934. /**
  120935. * Called once per frame by the engine.
  120936. */
  120937. update(): void;
  120938. /**
  120939. * Called once for each button that changed state since the last frame
  120940. * @param buttonIdx Which button index changed
  120941. * @param state New state of the button
  120942. * @param changes Which properties on the state changed since last frame
  120943. */
  120944. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120945. /**
  120946. * Moves the buttons on the controller mesh based on their current state
  120947. * @param buttonName the name of the button to move
  120948. * @param buttonValue the value of the button which determines the buttons new position
  120949. */
  120950. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  120951. /**
  120952. * Moves the axis on the controller mesh based on its current state
  120953. * @param axis the index of the axis
  120954. * @param axisValue the value of the axis which determines the meshes new position
  120955. * @hidden
  120956. */
  120957. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  120958. /**
  120959. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120960. * @param scene scene in which to add meshes
  120961. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120962. */
  120963. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  120964. /**
  120965. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  120966. * can be transformed by button presses and axes values, based on this._mapping.
  120967. *
  120968. * @param scene scene in which the meshes exist
  120969. * @param meshes list of meshes that make up the controller model to process
  120970. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  120971. */
  120972. private processModel;
  120973. private createMeshInfo;
  120974. /**
  120975. * Gets the ray of the controller in the direction the controller is pointing
  120976. * @param length the length the resulting ray should be
  120977. * @returns a ray in the direction the controller is pointing
  120978. */
  120979. getForwardRay(length?: number): Ray;
  120980. /**
  120981. * Disposes of the controller
  120982. */
  120983. dispose(): void;
  120984. }
  120985. /**
  120986. * This class represents a new windows motion controller in XR.
  120987. */
  120988. export class XRWindowsMotionController extends WindowsMotionController {
  120989. /**
  120990. * Changing the original WIndowsMotionController mapping to fir the new mapping
  120991. */
  120992. protected readonly _mapping: {
  120993. buttons: string[];
  120994. buttonMeshNames: {
  120995. 'trigger': string;
  120996. 'menu': string;
  120997. 'grip': string;
  120998. 'thumbstick': string;
  120999. 'trackpad': string;
  121000. };
  121001. buttonObservableNames: {
  121002. 'trigger': string;
  121003. 'menu': string;
  121004. 'grip': string;
  121005. 'thumbstick': string;
  121006. 'trackpad': string;
  121007. };
  121008. axisMeshNames: string[];
  121009. pointingPoseMeshName: string;
  121010. };
  121011. /**
  121012. * Construct a new XR-Based windows motion controller
  121013. *
  121014. * @param gamepadInfo the gamepad object from the browser
  121015. */
  121016. constructor(gamepadInfo: any);
  121017. /**
  121018. * holds the thumbstick values (X,Y)
  121019. */
  121020. thumbstickValues: StickValues;
  121021. /**
  121022. * Fired when the thumbstick on this controller is clicked
  121023. */
  121024. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121025. /**
  121026. * Fired when the thumbstick on this controller is modified
  121027. */
  121028. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121029. /**
  121030. * Fired when the touchpad button on this controller is modified
  121031. */
  121032. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121033. /**
  121034. * Fired when the touchpad values on this controller are modified
  121035. */
  121036. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121037. /**
  121038. * Fired when the thumbstick button on this controller is modified
  121039. * here to prevent breaking changes
  121040. */
  121041. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121042. /**
  121043. * updating the thumbstick(!) and not the trackpad.
  121044. * This is named this way due to the difference between WebVR and XR and to avoid
  121045. * changing the parent class.
  121046. */
  121047. protected _updateTrackpad(): void;
  121048. /**
  121049. * Disposes the class with joy
  121050. */
  121051. dispose(): void;
  121052. }
  121053. }
  121054. declare module BABYLON {
  121055. /**
  121056. * Class containing static functions to help procedurally build meshes
  121057. */
  121058. export class PolyhedronBuilder {
  121059. /**
  121060. * Creates a polyhedron mesh
  121061. * * 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
  121062. * * The parameter `size` (positive float, default 1) sets the polygon size
  121063. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121064. * * 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`
  121065. * * 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
  121066. * * 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)`)
  121067. * * 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
  121068. * * 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
  121069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121072. * @param name defines the name of the mesh
  121073. * @param options defines the options used to create the mesh
  121074. * @param scene defines the hosting scene
  121075. * @returns the polyhedron mesh
  121076. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121077. */
  121078. static CreatePolyhedron(name: string, options: {
  121079. type?: number;
  121080. size?: number;
  121081. sizeX?: number;
  121082. sizeY?: number;
  121083. sizeZ?: number;
  121084. custom?: any;
  121085. faceUV?: Vector4[];
  121086. faceColors?: Color4[];
  121087. flat?: boolean;
  121088. updatable?: boolean;
  121089. sideOrientation?: number;
  121090. frontUVs?: Vector4;
  121091. backUVs?: Vector4;
  121092. }, scene?: Nullable<Scene>): Mesh;
  121093. }
  121094. }
  121095. declare module BABYLON {
  121096. /**
  121097. * Gizmo that enables scaling a mesh along 3 axis
  121098. */
  121099. export class ScaleGizmo extends Gizmo {
  121100. /**
  121101. * Internal gizmo used for interactions on the x axis
  121102. */
  121103. xGizmo: AxisScaleGizmo;
  121104. /**
  121105. * Internal gizmo used for interactions on the y axis
  121106. */
  121107. yGizmo: AxisScaleGizmo;
  121108. /**
  121109. * Internal gizmo used for interactions on the z axis
  121110. */
  121111. zGizmo: AxisScaleGizmo;
  121112. /**
  121113. * Internal gizmo used to scale all axis equally
  121114. */
  121115. uniformScaleGizmo: AxisScaleGizmo;
  121116. private _meshAttached;
  121117. private _updateGizmoRotationToMatchAttachedMesh;
  121118. private _snapDistance;
  121119. private _scaleRatio;
  121120. private _uniformScalingMesh;
  121121. private _octahedron;
  121122. private _sensitivity;
  121123. /** Fires an event when any of it's sub gizmos are dragged */
  121124. onDragStartObservable: Observable<unknown>;
  121125. /** Fires an event when any of it's sub gizmos are released from dragging */
  121126. onDragEndObservable: Observable<unknown>;
  121127. get attachedMesh(): Nullable<AbstractMesh>;
  121128. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121129. /**
  121130. * Creates a ScaleGizmo
  121131. * @param gizmoLayer The utility layer the gizmo will be added to
  121132. */
  121133. constructor(gizmoLayer?: UtilityLayerRenderer);
  121134. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121135. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121136. /**
  121137. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121138. */
  121139. set snapDistance(value: number);
  121140. get snapDistance(): number;
  121141. /**
  121142. * Ratio for the scale of the gizmo (Default: 1)
  121143. */
  121144. set scaleRatio(value: number);
  121145. get scaleRatio(): number;
  121146. /**
  121147. * Sensitivity factor for dragging (Default: 1)
  121148. */
  121149. set sensitivity(value: number);
  121150. get sensitivity(): number;
  121151. /**
  121152. * Disposes of the gizmo
  121153. */
  121154. dispose(): void;
  121155. }
  121156. }
  121157. declare module BABYLON {
  121158. /**
  121159. * Single axis scale gizmo
  121160. */
  121161. export class AxisScaleGizmo extends Gizmo {
  121162. /**
  121163. * Drag behavior responsible for the gizmos dragging interactions
  121164. */
  121165. dragBehavior: PointerDragBehavior;
  121166. private _pointerObserver;
  121167. /**
  121168. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121169. */
  121170. snapDistance: number;
  121171. /**
  121172. * Event that fires each time the gizmo snaps to a new location.
  121173. * * snapDistance is the the change in distance
  121174. */
  121175. onSnapObservable: Observable<{
  121176. snapDistance: number;
  121177. }>;
  121178. /**
  121179. * If the scaling operation should be done on all axis (default: false)
  121180. */
  121181. uniformScaling: boolean;
  121182. /**
  121183. * Custom sensitivity value for the drag strength
  121184. */
  121185. sensitivity: number;
  121186. private _isEnabled;
  121187. private _parent;
  121188. private _arrow;
  121189. private _coloredMaterial;
  121190. private _hoverMaterial;
  121191. /**
  121192. * Creates an AxisScaleGizmo
  121193. * @param gizmoLayer The utility layer the gizmo will be added to
  121194. * @param dragAxis The axis which the gizmo will be able to scale on
  121195. * @param color The color of the gizmo
  121196. */
  121197. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121198. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121199. /**
  121200. * If the gizmo is enabled
  121201. */
  121202. set isEnabled(value: boolean);
  121203. get isEnabled(): boolean;
  121204. /**
  121205. * Disposes of the gizmo
  121206. */
  121207. dispose(): void;
  121208. /**
  121209. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121210. * @param mesh The mesh to replace the default mesh of the gizmo
  121211. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121212. */
  121213. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121214. }
  121215. }
  121216. declare module BABYLON {
  121217. /**
  121218. * Bounding box gizmo
  121219. */
  121220. export class BoundingBoxGizmo extends Gizmo {
  121221. private _lineBoundingBox;
  121222. private _rotateSpheresParent;
  121223. private _scaleBoxesParent;
  121224. private _boundingDimensions;
  121225. private _renderObserver;
  121226. private _pointerObserver;
  121227. private _scaleDragSpeed;
  121228. private _tmpQuaternion;
  121229. private _tmpVector;
  121230. private _tmpRotationMatrix;
  121231. /**
  121232. * 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)
  121233. */
  121234. ignoreChildren: boolean;
  121235. /**
  121236. * 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)
  121237. */
  121238. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121239. /**
  121240. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121241. */
  121242. rotationSphereSize: number;
  121243. /**
  121244. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121245. */
  121246. scaleBoxSize: number;
  121247. /**
  121248. * 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)
  121249. */
  121250. fixedDragMeshScreenSize: boolean;
  121251. /**
  121252. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121253. */
  121254. fixedDragMeshScreenSizeDistanceFactor: number;
  121255. /**
  121256. * Fired when a rotation sphere or scale box is dragged
  121257. */
  121258. onDragStartObservable: Observable<{}>;
  121259. /**
  121260. * Fired when a scale box is dragged
  121261. */
  121262. onScaleBoxDragObservable: Observable<{}>;
  121263. /**
  121264. * Fired when a scale box drag is ended
  121265. */
  121266. onScaleBoxDragEndObservable: Observable<{}>;
  121267. /**
  121268. * Fired when a rotation sphere is dragged
  121269. */
  121270. onRotationSphereDragObservable: Observable<{}>;
  121271. /**
  121272. * Fired when a rotation sphere drag is ended
  121273. */
  121274. onRotationSphereDragEndObservable: Observable<{}>;
  121275. /**
  121276. * 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)
  121277. */
  121278. scalePivot: Nullable<Vector3>;
  121279. /**
  121280. * Mesh used as a pivot to rotate the attached mesh
  121281. */
  121282. private _anchorMesh;
  121283. private _existingMeshScale;
  121284. private _dragMesh;
  121285. private pointerDragBehavior;
  121286. private coloredMaterial;
  121287. private hoverColoredMaterial;
  121288. /**
  121289. * Sets the color of the bounding box gizmo
  121290. * @param color the color to set
  121291. */
  121292. setColor(color: Color3): void;
  121293. /**
  121294. * Creates an BoundingBoxGizmo
  121295. * @param gizmoLayer The utility layer the gizmo will be added to
  121296. * @param color The color of the gizmo
  121297. */
  121298. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121299. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121300. private _selectNode;
  121301. /**
  121302. * Updates the bounding box information for the Gizmo
  121303. */
  121304. updateBoundingBox(): void;
  121305. private _updateRotationSpheres;
  121306. private _updateScaleBoxes;
  121307. /**
  121308. * Enables rotation on the specified axis and disables rotation on the others
  121309. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121310. */
  121311. setEnabledRotationAxis(axis: string): void;
  121312. /**
  121313. * Enables/disables scaling
  121314. * @param enable if scaling should be enabled
  121315. */
  121316. setEnabledScaling(enable: boolean): void;
  121317. private _updateDummy;
  121318. /**
  121319. * Enables a pointer drag behavior on the bounding box of the gizmo
  121320. */
  121321. enableDragBehavior(): void;
  121322. /**
  121323. * Disposes of the gizmo
  121324. */
  121325. dispose(): void;
  121326. /**
  121327. * 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)
  121328. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121329. * @returns the bounding box mesh with the passed in mesh as a child
  121330. */
  121331. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121332. /**
  121333. * CustomMeshes are not supported by this gizmo
  121334. * @param mesh The mesh to replace the default mesh of the gizmo
  121335. */
  121336. setCustomMesh(mesh: Mesh): void;
  121337. }
  121338. }
  121339. declare module BABYLON {
  121340. /**
  121341. * Single plane rotation gizmo
  121342. */
  121343. export class PlaneRotationGizmo extends Gizmo {
  121344. /**
  121345. * Drag behavior responsible for the gizmos dragging interactions
  121346. */
  121347. dragBehavior: PointerDragBehavior;
  121348. private _pointerObserver;
  121349. /**
  121350. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121351. */
  121352. snapDistance: number;
  121353. /**
  121354. * Event that fires each time the gizmo snaps to a new location.
  121355. * * snapDistance is the the change in distance
  121356. */
  121357. onSnapObservable: Observable<{
  121358. snapDistance: number;
  121359. }>;
  121360. private _isEnabled;
  121361. private _parent;
  121362. /**
  121363. * Creates a PlaneRotationGizmo
  121364. * @param gizmoLayer The utility layer the gizmo will be added to
  121365. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121366. * @param color The color of the gizmo
  121367. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121368. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121369. */
  121370. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121371. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121372. /**
  121373. * If the gizmo is enabled
  121374. */
  121375. set isEnabled(value: boolean);
  121376. get isEnabled(): boolean;
  121377. /**
  121378. * Disposes of the gizmo
  121379. */
  121380. dispose(): void;
  121381. }
  121382. }
  121383. declare module BABYLON {
  121384. /**
  121385. * Gizmo that enables rotating a mesh along 3 axis
  121386. */
  121387. export class RotationGizmo extends Gizmo {
  121388. /**
  121389. * Internal gizmo used for interactions on the x axis
  121390. */
  121391. xGizmo: PlaneRotationGizmo;
  121392. /**
  121393. * Internal gizmo used for interactions on the y axis
  121394. */
  121395. yGizmo: PlaneRotationGizmo;
  121396. /**
  121397. * Internal gizmo used for interactions on the z axis
  121398. */
  121399. zGizmo: PlaneRotationGizmo;
  121400. /** Fires an event when any of it's sub gizmos are dragged */
  121401. onDragStartObservable: Observable<unknown>;
  121402. /** Fires an event when any of it's sub gizmos are released from dragging */
  121403. onDragEndObservable: Observable<unknown>;
  121404. private _meshAttached;
  121405. get attachedMesh(): Nullable<AbstractMesh>;
  121406. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121407. /**
  121408. * Creates a RotationGizmo
  121409. * @param gizmoLayer The utility layer the gizmo will be added to
  121410. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121411. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121412. */
  121413. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121414. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121415. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121416. /**
  121417. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121418. */
  121419. set snapDistance(value: number);
  121420. get snapDistance(): number;
  121421. /**
  121422. * Ratio for the scale of the gizmo (Default: 1)
  121423. */
  121424. set scaleRatio(value: number);
  121425. get scaleRatio(): number;
  121426. /**
  121427. * Disposes of the gizmo
  121428. */
  121429. dispose(): void;
  121430. /**
  121431. * CustomMeshes are not supported by this gizmo
  121432. * @param mesh The mesh to replace the default mesh of the gizmo
  121433. */
  121434. setCustomMesh(mesh: Mesh): void;
  121435. }
  121436. }
  121437. declare module BABYLON {
  121438. /**
  121439. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121440. */
  121441. export class GizmoManager implements IDisposable {
  121442. private scene;
  121443. /**
  121444. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121445. */
  121446. gizmos: {
  121447. positionGizmo: Nullable<PositionGizmo>;
  121448. rotationGizmo: Nullable<RotationGizmo>;
  121449. scaleGizmo: Nullable<ScaleGizmo>;
  121450. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121451. };
  121452. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121453. clearGizmoOnEmptyPointerEvent: boolean;
  121454. /** Fires an event when the manager is attached to a mesh */
  121455. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121456. private _gizmosEnabled;
  121457. private _pointerObserver;
  121458. private _attachedMesh;
  121459. private _boundingBoxColor;
  121460. private _defaultUtilityLayer;
  121461. private _defaultKeepDepthUtilityLayer;
  121462. /**
  121463. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121464. */
  121465. boundingBoxDragBehavior: SixDofDragBehavior;
  121466. /**
  121467. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121468. */
  121469. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121470. /**
  121471. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121472. */
  121473. usePointerToAttachGizmos: boolean;
  121474. /**
  121475. * Utility layer that the bounding box gizmo belongs to
  121476. */
  121477. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121478. /**
  121479. * Utility layer that all gizmos besides bounding box belong to
  121480. */
  121481. get utilityLayer(): UtilityLayerRenderer;
  121482. /**
  121483. * Instatiates a gizmo manager
  121484. * @param scene the scene to overlay the gizmos on top of
  121485. */
  121486. constructor(scene: Scene);
  121487. /**
  121488. * Attaches a set of gizmos to the specified mesh
  121489. * @param mesh The mesh the gizmo's should be attached to
  121490. */
  121491. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121492. /**
  121493. * If the position gizmo is enabled
  121494. */
  121495. set positionGizmoEnabled(value: boolean);
  121496. get positionGizmoEnabled(): boolean;
  121497. /**
  121498. * If the rotation gizmo is enabled
  121499. */
  121500. set rotationGizmoEnabled(value: boolean);
  121501. get rotationGizmoEnabled(): boolean;
  121502. /**
  121503. * If the scale gizmo is enabled
  121504. */
  121505. set scaleGizmoEnabled(value: boolean);
  121506. get scaleGizmoEnabled(): boolean;
  121507. /**
  121508. * If the boundingBox gizmo is enabled
  121509. */
  121510. set boundingBoxGizmoEnabled(value: boolean);
  121511. get boundingBoxGizmoEnabled(): boolean;
  121512. /**
  121513. * Disposes of the gizmo manager
  121514. */
  121515. dispose(): void;
  121516. }
  121517. }
  121518. declare module BABYLON {
  121519. /**
  121520. * A directional light is defined by a direction (what a surprise!).
  121521. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121522. * 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.
  121523. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121524. */
  121525. export class DirectionalLight extends ShadowLight {
  121526. private _shadowFrustumSize;
  121527. /**
  121528. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121529. */
  121530. get shadowFrustumSize(): number;
  121531. /**
  121532. * Specifies a fix frustum size for the shadow generation.
  121533. */
  121534. set shadowFrustumSize(value: number);
  121535. private _shadowOrthoScale;
  121536. /**
  121537. * Gets the shadow projection scale against the optimal computed one.
  121538. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121539. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121540. */
  121541. get shadowOrthoScale(): number;
  121542. /**
  121543. * Sets the shadow projection scale against the optimal computed one.
  121544. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121545. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121546. */
  121547. set shadowOrthoScale(value: number);
  121548. /**
  121549. * Automatically compute the projection matrix to best fit (including all the casters)
  121550. * on each frame.
  121551. */
  121552. autoUpdateExtends: boolean;
  121553. /**
  121554. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121555. * on each frame. autoUpdateExtends must be set to true for this to work
  121556. */
  121557. autoCalcShadowZBounds: boolean;
  121558. private _orthoLeft;
  121559. private _orthoRight;
  121560. private _orthoTop;
  121561. private _orthoBottom;
  121562. /**
  121563. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121564. * The directional light is emitted from everywhere in the given direction.
  121565. * It can cast shadows.
  121566. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121567. * @param name The friendly name of the light
  121568. * @param direction The direction of the light
  121569. * @param scene The scene the light belongs to
  121570. */
  121571. constructor(name: string, direction: Vector3, scene: Scene);
  121572. /**
  121573. * Returns the string "DirectionalLight".
  121574. * @return The class name
  121575. */
  121576. getClassName(): string;
  121577. /**
  121578. * Returns the integer 1.
  121579. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121580. */
  121581. getTypeID(): number;
  121582. /**
  121583. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121584. * Returns the DirectionalLight Shadow projection matrix.
  121585. */
  121586. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121587. /**
  121588. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121589. * Returns the DirectionalLight Shadow projection matrix.
  121590. */
  121591. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121592. /**
  121593. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121594. * Returns the DirectionalLight Shadow projection matrix.
  121595. */
  121596. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121597. protected _buildUniformLayout(): void;
  121598. /**
  121599. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121600. * @param effect The effect to update
  121601. * @param lightIndex The index of the light in the effect to update
  121602. * @returns The directional light
  121603. */
  121604. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121605. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  121606. /**
  121607. * Gets the minZ used for shadow according to both the scene and the light.
  121608. *
  121609. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121610. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121611. * @param activeCamera The camera we are returning the min for
  121612. * @returns the depth min z
  121613. */
  121614. getDepthMinZ(activeCamera: Camera): number;
  121615. /**
  121616. * Gets the maxZ used for shadow according to both the scene and the light.
  121617. *
  121618. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121619. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121620. * @param activeCamera The camera we are returning the max for
  121621. * @returns the depth max z
  121622. */
  121623. getDepthMaxZ(activeCamera: Camera): number;
  121624. /**
  121625. * Prepares the list of defines specific to the light type.
  121626. * @param defines the list of defines
  121627. * @param lightIndex defines the index of the light for the effect
  121628. */
  121629. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121630. }
  121631. }
  121632. declare module BABYLON {
  121633. /**
  121634. * Class containing static functions to help procedurally build meshes
  121635. */
  121636. export class HemisphereBuilder {
  121637. /**
  121638. * Creates a hemisphere mesh
  121639. * @param name defines the name of the mesh
  121640. * @param options defines the options used to create the mesh
  121641. * @param scene defines the hosting scene
  121642. * @returns the hemisphere mesh
  121643. */
  121644. static CreateHemisphere(name: string, options: {
  121645. segments?: number;
  121646. diameter?: number;
  121647. sideOrientation?: number;
  121648. }, scene: any): Mesh;
  121649. }
  121650. }
  121651. declare module BABYLON {
  121652. /**
  121653. * A spot light is defined by a position, a direction, an angle, and an exponent.
  121654. * These values define a cone of light starting from the position, emitting toward the direction.
  121655. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  121656. * and the exponent defines the speed of the decay of the light with distance (reach).
  121657. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121658. */
  121659. export class SpotLight extends ShadowLight {
  121660. private _angle;
  121661. private _innerAngle;
  121662. private _cosHalfAngle;
  121663. private _lightAngleScale;
  121664. private _lightAngleOffset;
  121665. /**
  121666. * Gets the cone angle of the spot light in Radians.
  121667. */
  121668. get angle(): number;
  121669. /**
  121670. * Sets the cone angle of the spot light in Radians.
  121671. */
  121672. set angle(value: number);
  121673. /**
  121674. * Only used in gltf falloff mode, this defines the angle where
  121675. * the directional falloff will start before cutting at angle which could be seen
  121676. * as outer angle.
  121677. */
  121678. get innerAngle(): number;
  121679. /**
  121680. * Only used in gltf falloff mode, this defines the angle where
  121681. * the directional falloff will start before cutting at angle which could be seen
  121682. * as outer angle.
  121683. */
  121684. set innerAngle(value: number);
  121685. private _shadowAngleScale;
  121686. /**
  121687. * Allows scaling the angle of the light for shadow generation only.
  121688. */
  121689. get shadowAngleScale(): number;
  121690. /**
  121691. * Allows scaling the angle of the light for shadow generation only.
  121692. */
  121693. set shadowAngleScale(value: number);
  121694. /**
  121695. * The light decay speed with the distance from the emission spot.
  121696. */
  121697. exponent: number;
  121698. private _projectionTextureMatrix;
  121699. /**
  121700. * Allows reading the projecton texture
  121701. */
  121702. get projectionTextureMatrix(): Matrix;
  121703. protected _projectionTextureLightNear: number;
  121704. /**
  121705. * Gets the near clip of the Spotlight for texture projection.
  121706. */
  121707. get projectionTextureLightNear(): number;
  121708. /**
  121709. * Sets the near clip of the Spotlight for texture projection.
  121710. */
  121711. set projectionTextureLightNear(value: number);
  121712. protected _projectionTextureLightFar: number;
  121713. /**
  121714. * Gets the far clip of the Spotlight for texture projection.
  121715. */
  121716. get projectionTextureLightFar(): number;
  121717. /**
  121718. * Sets the far clip of the Spotlight for texture projection.
  121719. */
  121720. set projectionTextureLightFar(value: number);
  121721. protected _projectionTextureUpDirection: Vector3;
  121722. /**
  121723. * Gets the Up vector of the Spotlight for texture projection.
  121724. */
  121725. get projectionTextureUpDirection(): Vector3;
  121726. /**
  121727. * Sets the Up vector of the Spotlight for texture projection.
  121728. */
  121729. set projectionTextureUpDirection(value: Vector3);
  121730. private _projectionTexture;
  121731. /**
  121732. * Gets the projection texture of the light.
  121733. */
  121734. get projectionTexture(): Nullable<BaseTexture>;
  121735. /**
  121736. * Sets the projection texture of the light.
  121737. */
  121738. set projectionTexture(value: Nullable<BaseTexture>);
  121739. private _projectionTextureViewLightDirty;
  121740. private _projectionTextureProjectionLightDirty;
  121741. private _projectionTextureDirty;
  121742. private _projectionTextureViewTargetVector;
  121743. private _projectionTextureViewLightMatrix;
  121744. private _projectionTextureProjectionLightMatrix;
  121745. private _projectionTextureScalingMatrix;
  121746. /**
  121747. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  121748. * It can cast shadows.
  121749. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121750. * @param name The light friendly name
  121751. * @param position The position of the spot light in the scene
  121752. * @param direction The direction of the light in the scene
  121753. * @param angle The cone angle of the light in Radians
  121754. * @param exponent The light decay speed with the distance from the emission spot
  121755. * @param scene The scene the lights belongs to
  121756. */
  121757. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  121758. /**
  121759. * Returns the string "SpotLight".
  121760. * @returns the class name
  121761. */
  121762. getClassName(): string;
  121763. /**
  121764. * Returns the integer 2.
  121765. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121766. */
  121767. getTypeID(): number;
  121768. /**
  121769. * Overrides the direction setter to recompute the projection texture view light Matrix.
  121770. */
  121771. protected _setDirection(value: Vector3): void;
  121772. /**
  121773. * Overrides the position setter to recompute the projection texture view light Matrix.
  121774. */
  121775. protected _setPosition(value: Vector3): void;
  121776. /**
  121777. * 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.
  121778. * Returns the SpotLight.
  121779. */
  121780. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121781. protected _computeProjectionTextureViewLightMatrix(): void;
  121782. protected _computeProjectionTextureProjectionLightMatrix(): void;
  121783. /**
  121784. * Main function for light texture projection matrix computing.
  121785. */
  121786. protected _computeProjectionTextureMatrix(): void;
  121787. protected _buildUniformLayout(): void;
  121788. private _computeAngleValues;
  121789. /**
  121790. * Sets the passed Effect "effect" with the Light textures.
  121791. * @param effect The effect to update
  121792. * @param lightIndex The index of the light in the effect to update
  121793. * @returns The light
  121794. */
  121795. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  121796. /**
  121797. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  121798. * @param effect The effect to update
  121799. * @param lightIndex The index of the light in the effect to update
  121800. * @returns The spot light
  121801. */
  121802. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  121803. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121804. /**
  121805. * Disposes the light and the associated resources.
  121806. */
  121807. dispose(): void;
  121808. /**
  121809. * Prepares the list of defines specific to the light type.
  121810. * @param defines the list of defines
  121811. * @param lightIndex defines the index of the light for the effect
  121812. */
  121813. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121814. }
  121815. }
  121816. declare module BABYLON {
  121817. /**
  121818. * Gizmo that enables viewing a light
  121819. */
  121820. export class LightGizmo extends Gizmo {
  121821. private _lightMesh;
  121822. private _material;
  121823. private _cachedPosition;
  121824. private _cachedForward;
  121825. private _attachedMeshParent;
  121826. /**
  121827. * Creates a LightGizmo
  121828. * @param gizmoLayer The utility layer the gizmo will be added to
  121829. */
  121830. constructor(gizmoLayer?: UtilityLayerRenderer);
  121831. private _light;
  121832. /**
  121833. * The light that the gizmo is attached to
  121834. */
  121835. set light(light: Nullable<Light>);
  121836. get light(): Nullable<Light>;
  121837. /**
  121838. * Gets the material used to render the light gizmo
  121839. */
  121840. get material(): StandardMaterial;
  121841. /**
  121842. * @hidden
  121843. * Updates the gizmo to match the attached mesh's position/rotation
  121844. */
  121845. protected _update(): void;
  121846. private static _Scale;
  121847. /**
  121848. * Creates the lines for a light mesh
  121849. */
  121850. private static _CreateLightLines;
  121851. /**
  121852. * Disposes of the light gizmo
  121853. */
  121854. dispose(): void;
  121855. private static _CreateHemisphericLightMesh;
  121856. private static _CreatePointLightMesh;
  121857. private static _CreateSpotLightMesh;
  121858. private static _CreateDirectionalLightMesh;
  121859. }
  121860. }
  121861. declare module BABYLON {
  121862. /** @hidden */
  121863. export var backgroundFragmentDeclaration: {
  121864. name: string;
  121865. shader: string;
  121866. };
  121867. }
  121868. declare module BABYLON {
  121869. /** @hidden */
  121870. export var backgroundUboDeclaration: {
  121871. name: string;
  121872. shader: string;
  121873. };
  121874. }
  121875. declare module BABYLON {
  121876. /** @hidden */
  121877. export var backgroundPixelShader: {
  121878. name: string;
  121879. shader: string;
  121880. };
  121881. }
  121882. declare module BABYLON {
  121883. /** @hidden */
  121884. export var backgroundVertexDeclaration: {
  121885. name: string;
  121886. shader: string;
  121887. };
  121888. }
  121889. declare module BABYLON {
  121890. /** @hidden */
  121891. export var backgroundVertexShader: {
  121892. name: string;
  121893. shader: string;
  121894. };
  121895. }
  121896. declare module BABYLON {
  121897. /**
  121898. * Background material used to create an efficient environement around your scene.
  121899. */
  121900. export class BackgroundMaterial extends PushMaterial {
  121901. /**
  121902. * Standard reflectance value at parallel view angle.
  121903. */
  121904. static StandardReflectance0: number;
  121905. /**
  121906. * Standard reflectance value at grazing angle.
  121907. */
  121908. static StandardReflectance90: number;
  121909. protected _primaryColor: Color3;
  121910. /**
  121911. * Key light Color (multiply against the environement texture)
  121912. */
  121913. primaryColor: Color3;
  121914. protected __perceptualColor: Nullable<Color3>;
  121915. /**
  121916. * Experimental Internal Use Only.
  121917. *
  121918. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  121919. * This acts as a helper to set the primary color to a more "human friendly" value.
  121920. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  121921. * output color as close as possible from the chosen value.
  121922. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  121923. * part of lighting setup.)
  121924. */
  121925. get _perceptualColor(): Nullable<Color3>;
  121926. set _perceptualColor(value: Nullable<Color3>);
  121927. protected _primaryColorShadowLevel: float;
  121928. /**
  121929. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  121930. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  121931. */
  121932. get primaryColorShadowLevel(): float;
  121933. set primaryColorShadowLevel(value: float);
  121934. protected _primaryColorHighlightLevel: float;
  121935. /**
  121936. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  121937. * The primary color is used at the level chosen to define what the white area would look.
  121938. */
  121939. get primaryColorHighlightLevel(): float;
  121940. set primaryColorHighlightLevel(value: float);
  121941. protected _reflectionTexture: Nullable<BaseTexture>;
  121942. /**
  121943. * Reflection Texture used in the material.
  121944. * Should be author in a specific way for the best result (refer to the documentation).
  121945. */
  121946. reflectionTexture: Nullable<BaseTexture>;
  121947. protected _reflectionBlur: float;
  121948. /**
  121949. * Reflection Texture level of blur.
  121950. *
  121951. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  121952. * texture twice.
  121953. */
  121954. reflectionBlur: float;
  121955. protected _diffuseTexture: Nullable<BaseTexture>;
  121956. /**
  121957. * Diffuse Texture used in the material.
  121958. * Should be author in a specific way for the best result (refer to the documentation).
  121959. */
  121960. diffuseTexture: Nullable<BaseTexture>;
  121961. protected _shadowLights: Nullable<IShadowLight[]>;
  121962. /**
  121963. * Specify the list of lights casting shadow on the material.
  121964. * All scene shadow lights will be included if null.
  121965. */
  121966. shadowLights: Nullable<IShadowLight[]>;
  121967. protected _shadowLevel: float;
  121968. /**
  121969. * Helps adjusting the shadow to a softer level if required.
  121970. * 0 means black shadows and 1 means no shadows.
  121971. */
  121972. shadowLevel: float;
  121973. protected _sceneCenter: Vector3;
  121974. /**
  121975. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  121976. * It is usually zero but might be interesting to modify according to your setup.
  121977. */
  121978. sceneCenter: Vector3;
  121979. protected _opacityFresnel: boolean;
  121980. /**
  121981. * This helps specifying that the material is falling off to the sky box at grazing angle.
  121982. * This helps ensuring a nice transition when the camera goes under the ground.
  121983. */
  121984. opacityFresnel: boolean;
  121985. protected _reflectionFresnel: boolean;
  121986. /**
  121987. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  121988. * This helps adding a mirror texture on the ground.
  121989. */
  121990. reflectionFresnel: boolean;
  121991. protected _reflectionFalloffDistance: number;
  121992. /**
  121993. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  121994. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  121995. */
  121996. reflectionFalloffDistance: number;
  121997. protected _reflectionAmount: number;
  121998. /**
  121999. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122000. */
  122001. reflectionAmount: number;
  122002. protected _reflectionReflectance0: number;
  122003. /**
  122004. * This specifies the weight of the reflection at grazing angle.
  122005. */
  122006. reflectionReflectance0: number;
  122007. protected _reflectionReflectance90: number;
  122008. /**
  122009. * This specifies the weight of the reflection at a perpendicular point of view.
  122010. */
  122011. reflectionReflectance90: number;
  122012. /**
  122013. * Sets the reflection reflectance fresnel values according to the default standard
  122014. * empirically know to work well :-)
  122015. */
  122016. set reflectionStandardFresnelWeight(value: number);
  122017. protected _useRGBColor: boolean;
  122018. /**
  122019. * Helps to directly use the maps channels instead of their level.
  122020. */
  122021. useRGBColor: boolean;
  122022. protected _enableNoise: boolean;
  122023. /**
  122024. * This helps reducing the banding effect that could occur on the background.
  122025. */
  122026. enableNoise: boolean;
  122027. /**
  122028. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122029. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122030. * Recommended to be keep at 1.0 except for special cases.
  122031. */
  122032. get fovMultiplier(): number;
  122033. set fovMultiplier(value: number);
  122034. private _fovMultiplier;
  122035. /**
  122036. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122037. */
  122038. useEquirectangularFOV: boolean;
  122039. private _maxSimultaneousLights;
  122040. /**
  122041. * Number of Simultaneous lights allowed on the material.
  122042. */
  122043. maxSimultaneousLights: int;
  122044. /**
  122045. * Default configuration related to image processing available in the Background Material.
  122046. */
  122047. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122048. /**
  122049. * Keep track of the image processing observer to allow dispose and replace.
  122050. */
  122051. private _imageProcessingObserver;
  122052. /**
  122053. * Attaches a new image processing configuration to the PBR Material.
  122054. * @param configuration (if null the scene configuration will be use)
  122055. */
  122056. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122057. /**
  122058. * Gets the image processing configuration used either in this material.
  122059. */
  122060. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122061. /**
  122062. * Sets the Default image processing configuration used either in the this material.
  122063. *
  122064. * If sets to null, the scene one is in use.
  122065. */
  122066. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122067. /**
  122068. * Gets wether the color curves effect is enabled.
  122069. */
  122070. get cameraColorCurvesEnabled(): boolean;
  122071. /**
  122072. * Sets wether the color curves effect is enabled.
  122073. */
  122074. set cameraColorCurvesEnabled(value: boolean);
  122075. /**
  122076. * Gets wether the color grading effect is enabled.
  122077. */
  122078. get cameraColorGradingEnabled(): boolean;
  122079. /**
  122080. * Gets wether the color grading effect is enabled.
  122081. */
  122082. set cameraColorGradingEnabled(value: boolean);
  122083. /**
  122084. * Gets wether tonemapping is enabled or not.
  122085. */
  122086. get cameraToneMappingEnabled(): boolean;
  122087. /**
  122088. * Sets wether tonemapping is enabled or not
  122089. */
  122090. set cameraToneMappingEnabled(value: boolean);
  122091. /**
  122092. * The camera exposure used on this material.
  122093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122094. * This corresponds to a photographic exposure.
  122095. */
  122096. get cameraExposure(): float;
  122097. /**
  122098. * The camera exposure used on this material.
  122099. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122100. * This corresponds to a photographic exposure.
  122101. */
  122102. set cameraExposure(value: float);
  122103. /**
  122104. * Gets The camera contrast used on this material.
  122105. */
  122106. get cameraContrast(): float;
  122107. /**
  122108. * Sets The camera contrast used on this material.
  122109. */
  122110. set cameraContrast(value: float);
  122111. /**
  122112. * Gets the Color Grading 2D Lookup Texture.
  122113. */
  122114. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122115. /**
  122116. * Sets the Color Grading 2D Lookup Texture.
  122117. */
  122118. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122119. /**
  122120. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122121. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122122. * 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;
  122123. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122124. */
  122125. get cameraColorCurves(): Nullable<ColorCurves>;
  122126. /**
  122127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122129. * 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;
  122130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122131. */
  122132. set cameraColorCurves(value: Nullable<ColorCurves>);
  122133. /**
  122134. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122135. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122136. */
  122137. switchToBGR: boolean;
  122138. private _renderTargets;
  122139. private _reflectionControls;
  122140. private _white;
  122141. private _primaryShadowColor;
  122142. private _primaryHighlightColor;
  122143. /**
  122144. * Instantiates a Background Material in the given scene
  122145. * @param name The friendly name of the material
  122146. * @param scene The scene to add the material to
  122147. */
  122148. constructor(name: string, scene: Scene);
  122149. /**
  122150. * Gets a boolean indicating that current material needs to register RTT
  122151. */
  122152. get hasRenderTargetTextures(): boolean;
  122153. /**
  122154. * The entire material has been created in order to prevent overdraw.
  122155. * @returns false
  122156. */
  122157. needAlphaTesting(): boolean;
  122158. /**
  122159. * The entire material has been created in order to prevent overdraw.
  122160. * @returns true if blending is enable
  122161. */
  122162. needAlphaBlending(): boolean;
  122163. /**
  122164. * Checks wether the material is ready to be rendered for a given mesh.
  122165. * @param mesh The mesh to render
  122166. * @param subMesh The submesh to check against
  122167. * @param useInstances Specify wether or not the material is used with instances
  122168. * @returns true if all the dependencies are ready (Textures, Effects...)
  122169. */
  122170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122171. /**
  122172. * Compute the primary color according to the chosen perceptual color.
  122173. */
  122174. private _computePrimaryColorFromPerceptualColor;
  122175. /**
  122176. * Compute the highlights and shadow colors according to their chosen levels.
  122177. */
  122178. private _computePrimaryColors;
  122179. /**
  122180. * Build the uniform buffer used in the material.
  122181. */
  122182. buildUniformLayout(): void;
  122183. /**
  122184. * Unbind the material.
  122185. */
  122186. unbind(): void;
  122187. /**
  122188. * Bind only the world matrix to the material.
  122189. * @param world The world matrix to bind.
  122190. */
  122191. bindOnlyWorldMatrix(world: Matrix): void;
  122192. /**
  122193. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122194. * @param world The world matrix to bind.
  122195. * @param subMesh The submesh to bind for.
  122196. */
  122197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122198. /**
  122199. * Checks to see if a texture is used in the material.
  122200. * @param texture - Base texture to use.
  122201. * @returns - Boolean specifying if a texture is used in the material.
  122202. */
  122203. hasTexture(texture: BaseTexture): boolean;
  122204. /**
  122205. * Dispose the material.
  122206. * @param forceDisposeEffect Force disposal of the associated effect.
  122207. * @param forceDisposeTextures Force disposal of the associated textures.
  122208. */
  122209. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122210. /**
  122211. * Clones the material.
  122212. * @param name The cloned name.
  122213. * @returns The cloned material.
  122214. */
  122215. clone(name: string): BackgroundMaterial;
  122216. /**
  122217. * Serializes the current material to its JSON representation.
  122218. * @returns The JSON representation.
  122219. */
  122220. serialize(): any;
  122221. /**
  122222. * Gets the class name of the material
  122223. * @returns "BackgroundMaterial"
  122224. */
  122225. getClassName(): string;
  122226. /**
  122227. * Parse a JSON input to create back a background material.
  122228. * @param source The JSON data to parse
  122229. * @param scene The scene to create the parsed material in
  122230. * @param rootUrl The root url of the assets the material depends upon
  122231. * @returns the instantiated BackgroundMaterial.
  122232. */
  122233. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122234. }
  122235. }
  122236. declare module BABYLON {
  122237. /**
  122238. * Represents the different options available during the creation of
  122239. * a Environment helper.
  122240. *
  122241. * This can control the default ground, skybox and image processing setup of your scene.
  122242. */
  122243. export interface IEnvironmentHelperOptions {
  122244. /**
  122245. * Specifies wether or not to create a ground.
  122246. * True by default.
  122247. */
  122248. createGround: boolean;
  122249. /**
  122250. * Specifies the ground size.
  122251. * 15 by default.
  122252. */
  122253. groundSize: number;
  122254. /**
  122255. * The texture used on the ground for the main color.
  122256. * Comes from the BabylonJS CDN by default.
  122257. *
  122258. * Remarks: Can be either a texture or a url.
  122259. */
  122260. groundTexture: string | BaseTexture;
  122261. /**
  122262. * The color mixed in the ground texture by default.
  122263. * BabylonJS clearColor by default.
  122264. */
  122265. groundColor: Color3;
  122266. /**
  122267. * Specifies the ground opacity.
  122268. * 1 by default.
  122269. */
  122270. groundOpacity: number;
  122271. /**
  122272. * Enables the ground to receive shadows.
  122273. * True by default.
  122274. */
  122275. enableGroundShadow: boolean;
  122276. /**
  122277. * Helps preventing the shadow to be fully black on the ground.
  122278. * 0.5 by default.
  122279. */
  122280. groundShadowLevel: number;
  122281. /**
  122282. * Creates a mirror texture attach to the ground.
  122283. * false by default.
  122284. */
  122285. enableGroundMirror: boolean;
  122286. /**
  122287. * Specifies the ground mirror size ratio.
  122288. * 0.3 by default as the default kernel is 64.
  122289. */
  122290. groundMirrorSizeRatio: number;
  122291. /**
  122292. * Specifies the ground mirror blur kernel size.
  122293. * 64 by default.
  122294. */
  122295. groundMirrorBlurKernel: number;
  122296. /**
  122297. * Specifies the ground mirror visibility amount.
  122298. * 1 by default
  122299. */
  122300. groundMirrorAmount: number;
  122301. /**
  122302. * Specifies the ground mirror reflectance weight.
  122303. * This uses the standard weight of the background material to setup the fresnel effect
  122304. * of the mirror.
  122305. * 1 by default.
  122306. */
  122307. groundMirrorFresnelWeight: number;
  122308. /**
  122309. * Specifies the ground mirror Falloff distance.
  122310. * This can helps reducing the size of the reflection.
  122311. * 0 by Default.
  122312. */
  122313. groundMirrorFallOffDistance: number;
  122314. /**
  122315. * Specifies the ground mirror texture type.
  122316. * Unsigned Int by Default.
  122317. */
  122318. groundMirrorTextureType: number;
  122319. /**
  122320. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122321. * the shown objects.
  122322. */
  122323. groundYBias: number;
  122324. /**
  122325. * Specifies wether or not to create a skybox.
  122326. * True by default.
  122327. */
  122328. createSkybox: boolean;
  122329. /**
  122330. * Specifies the skybox size.
  122331. * 20 by default.
  122332. */
  122333. skyboxSize: number;
  122334. /**
  122335. * The texture used on the skybox for the main color.
  122336. * Comes from the BabylonJS CDN by default.
  122337. *
  122338. * Remarks: Can be either a texture or a url.
  122339. */
  122340. skyboxTexture: string | BaseTexture;
  122341. /**
  122342. * The color mixed in the skybox texture by default.
  122343. * BabylonJS clearColor by default.
  122344. */
  122345. skyboxColor: Color3;
  122346. /**
  122347. * The background rotation around the Y axis of the scene.
  122348. * This helps aligning the key lights of your scene with the background.
  122349. * 0 by default.
  122350. */
  122351. backgroundYRotation: number;
  122352. /**
  122353. * Compute automatically the size of the elements to best fit with the scene.
  122354. */
  122355. sizeAuto: boolean;
  122356. /**
  122357. * Default position of the rootMesh if autoSize is not true.
  122358. */
  122359. rootPosition: Vector3;
  122360. /**
  122361. * Sets up the image processing in the scene.
  122362. * true by default.
  122363. */
  122364. setupImageProcessing: boolean;
  122365. /**
  122366. * The texture used as your environment texture in the scene.
  122367. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122368. *
  122369. * Remarks: Can be either a texture or a url.
  122370. */
  122371. environmentTexture: string | BaseTexture;
  122372. /**
  122373. * The value of the exposure to apply to the scene.
  122374. * 0.6 by default if setupImageProcessing is true.
  122375. */
  122376. cameraExposure: number;
  122377. /**
  122378. * The value of the contrast to apply to the scene.
  122379. * 1.6 by default if setupImageProcessing is true.
  122380. */
  122381. cameraContrast: number;
  122382. /**
  122383. * Specifies wether or not tonemapping should be enabled in the scene.
  122384. * true by default if setupImageProcessing is true.
  122385. */
  122386. toneMappingEnabled: boolean;
  122387. }
  122388. /**
  122389. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122390. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122391. * It also helps with the default setup of your imageProcessing configuration.
  122392. */
  122393. export class EnvironmentHelper {
  122394. /**
  122395. * Default ground texture URL.
  122396. */
  122397. private static _groundTextureCDNUrl;
  122398. /**
  122399. * Default skybox texture URL.
  122400. */
  122401. private static _skyboxTextureCDNUrl;
  122402. /**
  122403. * Default environment texture URL.
  122404. */
  122405. private static _environmentTextureCDNUrl;
  122406. /**
  122407. * Creates the default options for the helper.
  122408. */
  122409. private static _getDefaultOptions;
  122410. private _rootMesh;
  122411. /**
  122412. * Gets the root mesh created by the helper.
  122413. */
  122414. get rootMesh(): Mesh;
  122415. private _skybox;
  122416. /**
  122417. * Gets the skybox created by the helper.
  122418. */
  122419. get skybox(): Nullable<Mesh>;
  122420. private _skyboxTexture;
  122421. /**
  122422. * Gets the skybox texture created by the helper.
  122423. */
  122424. get skyboxTexture(): Nullable<BaseTexture>;
  122425. private _skyboxMaterial;
  122426. /**
  122427. * Gets the skybox material created by the helper.
  122428. */
  122429. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122430. private _ground;
  122431. /**
  122432. * Gets the ground mesh created by the helper.
  122433. */
  122434. get ground(): Nullable<Mesh>;
  122435. private _groundTexture;
  122436. /**
  122437. * Gets the ground texture created by the helper.
  122438. */
  122439. get groundTexture(): Nullable<BaseTexture>;
  122440. private _groundMirror;
  122441. /**
  122442. * Gets the ground mirror created by the helper.
  122443. */
  122444. get groundMirror(): Nullable<MirrorTexture>;
  122445. /**
  122446. * Gets the ground mirror render list to helps pushing the meshes
  122447. * you wish in the ground reflection.
  122448. */
  122449. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122450. private _groundMaterial;
  122451. /**
  122452. * Gets the ground material created by the helper.
  122453. */
  122454. get groundMaterial(): Nullable<BackgroundMaterial>;
  122455. /**
  122456. * Stores the creation options.
  122457. */
  122458. private readonly _scene;
  122459. private _options;
  122460. /**
  122461. * This observable will be notified with any error during the creation of the environment,
  122462. * mainly texture creation errors.
  122463. */
  122464. onErrorObservable: Observable<{
  122465. message?: string;
  122466. exception?: any;
  122467. }>;
  122468. /**
  122469. * constructor
  122470. * @param options Defines the options we want to customize the helper
  122471. * @param scene The scene to add the material to
  122472. */
  122473. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122474. /**
  122475. * Updates the background according to the new options
  122476. * @param options
  122477. */
  122478. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122479. /**
  122480. * Sets the primary color of all the available elements.
  122481. * @param color the main color to affect to the ground and the background
  122482. */
  122483. setMainColor(color: Color3): void;
  122484. /**
  122485. * Setup the image processing according to the specified options.
  122486. */
  122487. private _setupImageProcessing;
  122488. /**
  122489. * Setup the environment texture according to the specified options.
  122490. */
  122491. private _setupEnvironmentTexture;
  122492. /**
  122493. * Setup the background according to the specified options.
  122494. */
  122495. private _setupBackground;
  122496. /**
  122497. * Get the scene sizes according to the setup.
  122498. */
  122499. private _getSceneSize;
  122500. /**
  122501. * Setup the ground according to the specified options.
  122502. */
  122503. private _setupGround;
  122504. /**
  122505. * Setup the ground material according to the specified options.
  122506. */
  122507. private _setupGroundMaterial;
  122508. /**
  122509. * Setup the ground diffuse texture according to the specified options.
  122510. */
  122511. private _setupGroundDiffuseTexture;
  122512. /**
  122513. * Setup the ground mirror texture according to the specified options.
  122514. */
  122515. private _setupGroundMirrorTexture;
  122516. /**
  122517. * Setup the ground to receive the mirror texture.
  122518. */
  122519. private _setupMirrorInGroundMaterial;
  122520. /**
  122521. * Setup the skybox according to the specified options.
  122522. */
  122523. private _setupSkybox;
  122524. /**
  122525. * Setup the skybox material according to the specified options.
  122526. */
  122527. private _setupSkyboxMaterial;
  122528. /**
  122529. * Setup the skybox reflection texture according to the specified options.
  122530. */
  122531. private _setupSkyboxReflectionTexture;
  122532. private _errorHandler;
  122533. /**
  122534. * Dispose all the elements created by the Helper.
  122535. */
  122536. dispose(): void;
  122537. }
  122538. }
  122539. declare module BABYLON {
  122540. /**
  122541. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122542. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122543. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122544. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122545. */
  122546. export class PhotoDome extends TransformNode {
  122547. /**
  122548. * Define the image as a Monoscopic panoramic 360 image.
  122549. */
  122550. static readonly MODE_MONOSCOPIC: number;
  122551. /**
  122552. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122553. */
  122554. static readonly MODE_TOPBOTTOM: number;
  122555. /**
  122556. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122557. */
  122558. static readonly MODE_SIDEBYSIDE: number;
  122559. private _useDirectMapping;
  122560. /**
  122561. * The texture being displayed on the sphere
  122562. */
  122563. protected _photoTexture: Texture;
  122564. /**
  122565. * Gets or sets the texture being displayed on the sphere
  122566. */
  122567. get photoTexture(): Texture;
  122568. set photoTexture(value: Texture);
  122569. /**
  122570. * Observable raised when an error occured while loading the 360 image
  122571. */
  122572. onLoadErrorObservable: Observable<string>;
  122573. /**
  122574. * The skybox material
  122575. */
  122576. protected _material: BackgroundMaterial;
  122577. /**
  122578. * The surface used for the skybox
  122579. */
  122580. protected _mesh: Mesh;
  122581. /**
  122582. * Gets the mesh used for the skybox.
  122583. */
  122584. get mesh(): Mesh;
  122585. /**
  122586. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122587. * Also see the options.resolution property.
  122588. */
  122589. get fovMultiplier(): number;
  122590. set fovMultiplier(value: number);
  122591. private _imageMode;
  122592. /**
  122593. * Gets or set the current video mode for the video. It can be:
  122594. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122595. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122596. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122597. */
  122598. get imageMode(): number;
  122599. set imageMode(value: number);
  122600. /**
  122601. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  122602. * @param name Element's name, child elements will append suffixes for their own names.
  122603. * @param urlsOfPhoto defines the url of the photo to display
  122604. * @param options defines an object containing optional or exposed sub element properties
  122605. * @param onError defines a callback called when an error occured while loading the texture
  122606. */
  122607. constructor(name: string, urlOfPhoto: string, options: {
  122608. resolution?: number;
  122609. size?: number;
  122610. useDirectMapping?: boolean;
  122611. faceForward?: boolean;
  122612. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  122613. private _onBeforeCameraRenderObserver;
  122614. private _changeImageMode;
  122615. /**
  122616. * Releases resources associated with this node.
  122617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122619. */
  122620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122621. }
  122622. }
  122623. declare module BABYLON {
  122624. /**
  122625. * Class used to host RGBD texture specific utilities
  122626. */
  122627. export class RGBDTextureTools {
  122628. /**
  122629. * Expand the RGBD Texture from RGBD to Half Float if possible.
  122630. * @param texture the texture to expand.
  122631. */
  122632. static ExpandRGBDTexture(texture: Texture): void;
  122633. }
  122634. }
  122635. declare module BABYLON {
  122636. /**
  122637. * Class used to host texture specific utilities
  122638. */
  122639. export class BRDFTextureTools {
  122640. /**
  122641. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  122642. * @param scene defines the hosting scene
  122643. * @returns the environment BRDF texture
  122644. */
  122645. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  122646. private static _environmentBRDFBase64Texture;
  122647. }
  122648. }
  122649. declare module BABYLON {
  122650. /**
  122651. * @hidden
  122652. */
  122653. export interface IMaterialClearCoatDefines {
  122654. CLEARCOAT: boolean;
  122655. CLEARCOAT_DEFAULTIOR: boolean;
  122656. CLEARCOAT_TEXTURE: boolean;
  122657. CLEARCOAT_TEXTUREDIRECTUV: number;
  122658. CLEARCOAT_BUMP: boolean;
  122659. CLEARCOAT_BUMPDIRECTUV: number;
  122660. CLEARCOAT_TINT: boolean;
  122661. CLEARCOAT_TINT_TEXTURE: boolean;
  122662. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122663. /** @hidden */
  122664. _areTexturesDirty: boolean;
  122665. }
  122666. /**
  122667. * Define the code related to the clear coat parameters of the pbr material.
  122668. */
  122669. export class PBRClearCoatConfiguration {
  122670. /**
  122671. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122672. * The default fits with a polyurethane material.
  122673. */
  122674. private static readonly _DefaultIndexOfRefraction;
  122675. private _isEnabled;
  122676. /**
  122677. * Defines if the clear coat is enabled in the material.
  122678. */
  122679. isEnabled: boolean;
  122680. /**
  122681. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  122682. */
  122683. intensity: number;
  122684. /**
  122685. * Defines the clear coat layer roughness.
  122686. */
  122687. roughness: number;
  122688. private _indexOfRefraction;
  122689. /**
  122690. * Defines the index of refraction of the clear coat.
  122691. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122692. * The default fits with a polyurethane material.
  122693. * Changing the default value is more performance intensive.
  122694. */
  122695. indexOfRefraction: number;
  122696. private _texture;
  122697. /**
  122698. * Stores the clear coat values in a texture.
  122699. */
  122700. texture: Nullable<BaseTexture>;
  122701. private _bumpTexture;
  122702. /**
  122703. * Define the clear coat specific bump texture.
  122704. */
  122705. bumpTexture: Nullable<BaseTexture>;
  122706. private _isTintEnabled;
  122707. /**
  122708. * Defines if the clear coat tint is enabled in the material.
  122709. */
  122710. isTintEnabled: boolean;
  122711. /**
  122712. * Defines the clear coat tint of the material.
  122713. * This is only use if tint is enabled
  122714. */
  122715. tintColor: Color3;
  122716. /**
  122717. * Defines the distance at which the tint color should be found in the
  122718. * clear coat media.
  122719. * This is only use if tint is enabled
  122720. */
  122721. tintColorAtDistance: number;
  122722. /**
  122723. * Defines the clear coat layer thickness.
  122724. * This is only use if tint is enabled
  122725. */
  122726. tintThickness: number;
  122727. private _tintTexture;
  122728. /**
  122729. * Stores the clear tint values in a texture.
  122730. * rgb is tint
  122731. * a is a thickness factor
  122732. */
  122733. tintTexture: Nullable<BaseTexture>;
  122734. /** @hidden */
  122735. private _internalMarkAllSubMeshesAsTexturesDirty;
  122736. /** @hidden */
  122737. _markAllSubMeshesAsTexturesDirty(): void;
  122738. /**
  122739. * Instantiate a new istance of clear coat configuration.
  122740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122741. */
  122742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122743. /**
  122744. * Gets wehter the submesh is ready to be used or not.
  122745. * @param defines the list of "defines" to update.
  122746. * @param scene defines the scene the material belongs to.
  122747. * @param engine defines the engine the material belongs to.
  122748. * @param disableBumpMap defines wether the material disables bump or not.
  122749. * @returns - boolean indicating that the submesh is ready or not.
  122750. */
  122751. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  122752. /**
  122753. * Checks to see if a texture is used in the material.
  122754. * @param defines the list of "defines" to update.
  122755. * @param scene defines the scene to the material belongs to.
  122756. */
  122757. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  122758. /**
  122759. * Binds the material data.
  122760. * @param uniformBuffer defines the Uniform buffer to fill in.
  122761. * @param scene defines the scene the material belongs to.
  122762. * @param engine defines the engine the material belongs to.
  122763. * @param disableBumpMap defines wether the material disables bump or not.
  122764. * @param isFrozen defines wether the material is frozen or not.
  122765. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122766. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122767. */
  122768. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  122769. /**
  122770. * Checks to see if a texture is used in the material.
  122771. * @param texture - Base texture to use.
  122772. * @returns - Boolean specifying if a texture is used in the material.
  122773. */
  122774. hasTexture(texture: BaseTexture): boolean;
  122775. /**
  122776. * Returns an array of the actively used textures.
  122777. * @param activeTextures Array of BaseTextures
  122778. */
  122779. getActiveTextures(activeTextures: BaseTexture[]): void;
  122780. /**
  122781. * Returns the animatable textures.
  122782. * @param animatables Array of animatable textures.
  122783. */
  122784. getAnimatables(animatables: IAnimatable[]): void;
  122785. /**
  122786. * Disposes the resources of the material.
  122787. * @param forceDisposeTextures - Forces the disposal of all textures.
  122788. */
  122789. dispose(forceDisposeTextures?: boolean): void;
  122790. /**
  122791. * Get the current class name of the texture useful for serialization or dynamic coding.
  122792. * @returns "PBRClearCoatConfiguration"
  122793. */
  122794. getClassName(): string;
  122795. /**
  122796. * Add fallbacks to the effect fallbacks list.
  122797. * @param defines defines the Base texture to use.
  122798. * @param fallbacks defines the current fallback list.
  122799. * @param currentRank defines the current fallback rank.
  122800. * @returns the new fallback rank.
  122801. */
  122802. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122803. /**
  122804. * Add the required uniforms to the current list.
  122805. * @param uniforms defines the current uniform list.
  122806. */
  122807. static AddUniforms(uniforms: string[]): void;
  122808. /**
  122809. * Add the required samplers to the current list.
  122810. * @param samplers defines the current sampler list.
  122811. */
  122812. static AddSamplers(samplers: string[]): void;
  122813. /**
  122814. * Add the required uniforms to the current buffer.
  122815. * @param uniformBuffer defines the current uniform buffer.
  122816. */
  122817. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122818. /**
  122819. * Makes a duplicate of the current configuration into another one.
  122820. * @param clearCoatConfiguration define the config where to copy the info
  122821. */
  122822. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  122823. /**
  122824. * Serializes this clear coat configuration.
  122825. * @returns - An object with the serialized config.
  122826. */
  122827. serialize(): any;
  122828. /**
  122829. * Parses a anisotropy Configuration from a serialized object.
  122830. * @param source - Serialized object.
  122831. * @param scene Defines the scene we are parsing for
  122832. * @param rootUrl Defines the rootUrl to load from
  122833. */
  122834. parse(source: any, scene: Scene, rootUrl: string): void;
  122835. }
  122836. }
  122837. declare module BABYLON {
  122838. /**
  122839. * @hidden
  122840. */
  122841. export interface IMaterialAnisotropicDefines {
  122842. ANISOTROPIC: boolean;
  122843. ANISOTROPIC_TEXTURE: boolean;
  122844. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122845. MAINUV1: boolean;
  122846. _areTexturesDirty: boolean;
  122847. _needUVs: boolean;
  122848. }
  122849. /**
  122850. * Define the code related to the anisotropic parameters of the pbr material.
  122851. */
  122852. export class PBRAnisotropicConfiguration {
  122853. private _isEnabled;
  122854. /**
  122855. * Defines if the anisotropy is enabled in the material.
  122856. */
  122857. isEnabled: boolean;
  122858. /**
  122859. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  122860. */
  122861. intensity: number;
  122862. /**
  122863. * Defines if the effect is along the tangents, bitangents or in between.
  122864. * By default, the effect is "strectching" the highlights along the tangents.
  122865. */
  122866. direction: Vector2;
  122867. private _texture;
  122868. /**
  122869. * Stores the anisotropy values in a texture.
  122870. * rg is direction (like normal from -1 to 1)
  122871. * b is a intensity
  122872. */
  122873. texture: Nullable<BaseTexture>;
  122874. /** @hidden */
  122875. private _internalMarkAllSubMeshesAsTexturesDirty;
  122876. /** @hidden */
  122877. _markAllSubMeshesAsTexturesDirty(): void;
  122878. /**
  122879. * Instantiate a new istance of anisotropy configuration.
  122880. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122881. */
  122882. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122883. /**
  122884. * Specifies that the submesh is ready to be used.
  122885. * @param defines the list of "defines" to update.
  122886. * @param scene defines the scene the material belongs to.
  122887. * @returns - boolean indicating that the submesh is ready or not.
  122888. */
  122889. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  122890. /**
  122891. * Checks to see if a texture is used in the material.
  122892. * @param defines the list of "defines" to update.
  122893. * @param mesh the mesh we are preparing the defines for.
  122894. * @param scene defines the scene the material belongs to.
  122895. */
  122896. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  122897. /**
  122898. * Binds the material data.
  122899. * @param uniformBuffer defines the Uniform buffer to fill in.
  122900. * @param scene defines the scene the material belongs to.
  122901. * @param isFrozen defines wether the material is frozen or not.
  122902. */
  122903. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122904. /**
  122905. * Checks to see if a texture is used in the material.
  122906. * @param texture - Base texture to use.
  122907. * @returns - Boolean specifying if a texture is used in the material.
  122908. */
  122909. hasTexture(texture: BaseTexture): boolean;
  122910. /**
  122911. * Returns an array of the actively used textures.
  122912. * @param activeTextures Array of BaseTextures
  122913. */
  122914. getActiveTextures(activeTextures: BaseTexture[]): void;
  122915. /**
  122916. * Returns the animatable textures.
  122917. * @param animatables Array of animatable textures.
  122918. */
  122919. getAnimatables(animatables: IAnimatable[]): void;
  122920. /**
  122921. * Disposes the resources of the material.
  122922. * @param forceDisposeTextures - Forces the disposal of all textures.
  122923. */
  122924. dispose(forceDisposeTextures?: boolean): void;
  122925. /**
  122926. * Get the current class name of the texture useful for serialization or dynamic coding.
  122927. * @returns "PBRAnisotropicConfiguration"
  122928. */
  122929. getClassName(): string;
  122930. /**
  122931. * Add fallbacks to the effect fallbacks list.
  122932. * @param defines defines the Base texture to use.
  122933. * @param fallbacks defines the current fallback list.
  122934. * @param currentRank defines the current fallback rank.
  122935. * @returns the new fallback rank.
  122936. */
  122937. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122938. /**
  122939. * Add the required uniforms to the current list.
  122940. * @param uniforms defines the current uniform list.
  122941. */
  122942. static AddUniforms(uniforms: string[]): void;
  122943. /**
  122944. * Add the required uniforms to the current buffer.
  122945. * @param uniformBuffer defines the current uniform buffer.
  122946. */
  122947. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122948. /**
  122949. * Add the required samplers to the current list.
  122950. * @param samplers defines the current sampler list.
  122951. */
  122952. static AddSamplers(samplers: string[]): void;
  122953. /**
  122954. * Makes a duplicate of the current configuration into another one.
  122955. * @param anisotropicConfiguration define the config where to copy the info
  122956. */
  122957. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  122958. /**
  122959. * Serializes this anisotropy configuration.
  122960. * @returns - An object with the serialized config.
  122961. */
  122962. serialize(): any;
  122963. /**
  122964. * Parses a anisotropy Configuration from a serialized object.
  122965. * @param source - Serialized object.
  122966. * @param scene Defines the scene we are parsing for
  122967. * @param rootUrl Defines the rootUrl to load from
  122968. */
  122969. parse(source: any, scene: Scene, rootUrl: string): void;
  122970. }
  122971. }
  122972. declare module BABYLON {
  122973. /**
  122974. * @hidden
  122975. */
  122976. export interface IMaterialBRDFDefines {
  122977. BRDF_V_HEIGHT_CORRELATED: boolean;
  122978. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122979. SPHERICAL_HARMONICS: boolean;
  122980. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122981. /** @hidden */
  122982. _areMiscDirty: boolean;
  122983. }
  122984. /**
  122985. * Define the code related to the BRDF parameters of the pbr material.
  122986. */
  122987. export class PBRBRDFConfiguration {
  122988. /**
  122989. * Default value used for the energy conservation.
  122990. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122991. */
  122992. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  122993. /**
  122994. * Default value used for the Smith Visibility Height Correlated mode.
  122995. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122996. */
  122997. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  122998. /**
  122999. * Default value used for the IBL diffuse part.
  123000. * This can help switching back to the polynomials mode globally which is a tiny bit
  123001. * less GPU intensive at the drawback of a lower quality.
  123002. */
  123003. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123004. /**
  123005. * Default value used for activating energy conservation for the specular workflow.
  123006. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123007. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123008. */
  123009. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123010. private _useEnergyConservation;
  123011. /**
  123012. * Defines if the material uses energy conservation.
  123013. */
  123014. useEnergyConservation: boolean;
  123015. private _useSmithVisibilityHeightCorrelated;
  123016. /**
  123017. * LEGACY Mode set to false
  123018. * Defines if the material uses height smith correlated visibility term.
  123019. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123020. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123021. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123022. * Not relying on height correlated will also disable energy conservation.
  123023. */
  123024. useSmithVisibilityHeightCorrelated: boolean;
  123025. private _useSphericalHarmonics;
  123026. /**
  123027. * LEGACY Mode set to false
  123028. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123029. * diffuse part of the IBL.
  123030. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123031. * to the ground truth.
  123032. */
  123033. useSphericalHarmonics: boolean;
  123034. private _useSpecularGlossinessInputEnergyConservation;
  123035. /**
  123036. * Defines if the material uses energy conservation, when the specular workflow is active.
  123037. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123038. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123039. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123040. */
  123041. useSpecularGlossinessInputEnergyConservation: boolean;
  123042. /** @hidden */
  123043. private _internalMarkAllSubMeshesAsMiscDirty;
  123044. /** @hidden */
  123045. _markAllSubMeshesAsMiscDirty(): void;
  123046. /**
  123047. * Instantiate a new istance of clear coat configuration.
  123048. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123049. */
  123050. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123051. /**
  123052. * Checks to see if a texture is used in the material.
  123053. * @param defines the list of "defines" to update.
  123054. */
  123055. prepareDefines(defines: IMaterialBRDFDefines): void;
  123056. /**
  123057. * Get the current class name of the texture useful for serialization or dynamic coding.
  123058. * @returns "PBRClearCoatConfiguration"
  123059. */
  123060. getClassName(): string;
  123061. /**
  123062. * Makes a duplicate of the current configuration into another one.
  123063. * @param brdfConfiguration define the config where to copy the info
  123064. */
  123065. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123066. /**
  123067. * Serializes this BRDF configuration.
  123068. * @returns - An object with the serialized config.
  123069. */
  123070. serialize(): any;
  123071. /**
  123072. * Parses a anisotropy Configuration from a serialized object.
  123073. * @param source - Serialized object.
  123074. * @param scene Defines the scene we are parsing for
  123075. * @param rootUrl Defines the rootUrl to load from
  123076. */
  123077. parse(source: any, scene: Scene, rootUrl: string): void;
  123078. }
  123079. }
  123080. declare module BABYLON {
  123081. /**
  123082. * @hidden
  123083. */
  123084. export interface IMaterialSheenDefines {
  123085. SHEEN: boolean;
  123086. SHEEN_TEXTURE: boolean;
  123087. SHEEN_TEXTUREDIRECTUV: number;
  123088. SHEEN_LINKWITHALBEDO: boolean;
  123089. /** @hidden */
  123090. _areTexturesDirty: boolean;
  123091. }
  123092. /**
  123093. * Define the code related to the Sheen parameters of the pbr material.
  123094. */
  123095. export class PBRSheenConfiguration {
  123096. private _isEnabled;
  123097. /**
  123098. * Defines if the material uses sheen.
  123099. */
  123100. isEnabled: boolean;
  123101. private _linkSheenWithAlbedo;
  123102. /**
  123103. * Defines if the sheen is linked to the sheen color.
  123104. */
  123105. linkSheenWithAlbedo: boolean;
  123106. /**
  123107. * Defines the sheen intensity.
  123108. */
  123109. intensity: number;
  123110. /**
  123111. * Defines the sheen color.
  123112. */
  123113. color: Color3;
  123114. private _texture;
  123115. /**
  123116. * Stores the sheen tint values in a texture.
  123117. * rgb is tint
  123118. * a is a intensity
  123119. */
  123120. texture: Nullable<BaseTexture>;
  123121. /** @hidden */
  123122. private _internalMarkAllSubMeshesAsTexturesDirty;
  123123. /** @hidden */
  123124. _markAllSubMeshesAsTexturesDirty(): void;
  123125. /**
  123126. * Instantiate a new istance of clear coat configuration.
  123127. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123128. */
  123129. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123130. /**
  123131. * Specifies that the submesh is ready to be used.
  123132. * @param defines the list of "defines" to update.
  123133. * @param scene defines the scene the material belongs to.
  123134. * @returns - boolean indicating that the submesh is ready or not.
  123135. */
  123136. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123137. /**
  123138. * Checks to see if a texture is used in the material.
  123139. * @param defines the list of "defines" to update.
  123140. * @param scene defines the scene the material belongs to.
  123141. */
  123142. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123143. /**
  123144. * Binds the material data.
  123145. * @param uniformBuffer defines the Uniform buffer to fill in.
  123146. * @param scene defines the scene the material belongs to.
  123147. * @param isFrozen defines wether the material is frozen or not.
  123148. */
  123149. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123150. /**
  123151. * Checks to see if a texture is used in the material.
  123152. * @param texture - Base texture to use.
  123153. * @returns - Boolean specifying if a texture is used in the material.
  123154. */
  123155. hasTexture(texture: BaseTexture): boolean;
  123156. /**
  123157. * Returns an array of the actively used textures.
  123158. * @param activeTextures Array of BaseTextures
  123159. */
  123160. getActiveTextures(activeTextures: BaseTexture[]): void;
  123161. /**
  123162. * Returns the animatable textures.
  123163. * @param animatables Array of animatable textures.
  123164. */
  123165. getAnimatables(animatables: IAnimatable[]): void;
  123166. /**
  123167. * Disposes the resources of the material.
  123168. * @param forceDisposeTextures - Forces the disposal of all textures.
  123169. */
  123170. dispose(forceDisposeTextures?: boolean): void;
  123171. /**
  123172. * Get the current class name of the texture useful for serialization or dynamic coding.
  123173. * @returns "PBRSheenConfiguration"
  123174. */
  123175. getClassName(): string;
  123176. /**
  123177. * Add fallbacks to the effect fallbacks list.
  123178. * @param defines defines the Base texture to use.
  123179. * @param fallbacks defines the current fallback list.
  123180. * @param currentRank defines the current fallback rank.
  123181. * @returns the new fallback rank.
  123182. */
  123183. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123184. /**
  123185. * Add the required uniforms to the current list.
  123186. * @param uniforms defines the current uniform list.
  123187. */
  123188. static AddUniforms(uniforms: string[]): void;
  123189. /**
  123190. * Add the required uniforms to the current buffer.
  123191. * @param uniformBuffer defines the current uniform buffer.
  123192. */
  123193. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123194. /**
  123195. * Add the required samplers to the current list.
  123196. * @param samplers defines the current sampler list.
  123197. */
  123198. static AddSamplers(samplers: string[]): void;
  123199. /**
  123200. * Makes a duplicate of the current configuration into another one.
  123201. * @param sheenConfiguration define the config where to copy the info
  123202. */
  123203. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123204. /**
  123205. * Serializes this BRDF configuration.
  123206. * @returns - An object with the serialized config.
  123207. */
  123208. serialize(): any;
  123209. /**
  123210. * Parses a anisotropy Configuration from a serialized object.
  123211. * @param source - Serialized object.
  123212. * @param scene Defines the scene we are parsing for
  123213. * @param rootUrl Defines the rootUrl to load from
  123214. */
  123215. parse(source: any, scene: Scene, rootUrl: string): void;
  123216. }
  123217. }
  123218. declare module BABYLON {
  123219. /**
  123220. * @hidden
  123221. */
  123222. export interface IMaterialSubSurfaceDefines {
  123223. SUBSURFACE: boolean;
  123224. SS_REFRACTION: boolean;
  123225. SS_TRANSLUCENCY: boolean;
  123226. SS_SCATERRING: boolean;
  123227. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123228. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123229. SS_REFRACTIONMAP_3D: boolean;
  123230. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123231. SS_LODINREFRACTIONALPHA: boolean;
  123232. SS_GAMMAREFRACTION: boolean;
  123233. SS_RGBDREFRACTION: boolean;
  123234. SS_LINEARSPECULARREFRACTION: boolean;
  123235. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123236. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123237. /** @hidden */
  123238. _areTexturesDirty: boolean;
  123239. }
  123240. /**
  123241. * Define the code related to the sub surface parameters of the pbr material.
  123242. */
  123243. export class PBRSubSurfaceConfiguration {
  123244. private _isRefractionEnabled;
  123245. /**
  123246. * Defines if the refraction is enabled in the material.
  123247. */
  123248. isRefractionEnabled: boolean;
  123249. private _isTranslucencyEnabled;
  123250. /**
  123251. * Defines if the translucency is enabled in the material.
  123252. */
  123253. isTranslucencyEnabled: boolean;
  123254. private _isScatteringEnabled;
  123255. /**
  123256. * Defines the refraction intensity of the material.
  123257. * The refraction when enabled replaces the Diffuse part of the material.
  123258. * The intensity helps transitionning between diffuse and refraction.
  123259. */
  123260. refractionIntensity: number;
  123261. /**
  123262. * Defines the translucency intensity of the material.
  123263. * When translucency has been enabled, this defines how much of the "translucency"
  123264. * is addded to the diffuse part of the material.
  123265. */
  123266. translucencyIntensity: number;
  123267. /**
  123268. * Defines the scattering intensity of the material.
  123269. * When scattering has been enabled, this defines how much of the "scattered light"
  123270. * is addded to the diffuse part of the material.
  123271. */
  123272. scatteringIntensity: number;
  123273. private _thicknessTexture;
  123274. /**
  123275. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123276. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123277. * 0 would mean minimumThickness
  123278. * 1 would mean maximumThickness
  123279. * The other channels might be use as a mask to vary the different effects intensity.
  123280. */
  123281. thicknessTexture: Nullable<BaseTexture>;
  123282. private _refractionTexture;
  123283. /**
  123284. * Defines the texture to use for refraction.
  123285. */
  123286. refractionTexture: Nullable<BaseTexture>;
  123287. private _indexOfRefraction;
  123288. /**
  123289. * Defines the index of refraction used in the material.
  123290. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123291. */
  123292. indexOfRefraction: number;
  123293. private _invertRefractionY;
  123294. /**
  123295. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123296. */
  123297. invertRefractionY: boolean;
  123298. private _linkRefractionWithTransparency;
  123299. /**
  123300. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123301. * Materials half opaque for instance using refraction could benefit from this control.
  123302. */
  123303. linkRefractionWithTransparency: boolean;
  123304. /**
  123305. * Defines the minimum thickness stored in the thickness map.
  123306. * If no thickness map is defined, this value will be used to simulate thickness.
  123307. */
  123308. minimumThickness: number;
  123309. /**
  123310. * Defines the maximum thickness stored in the thickness map.
  123311. */
  123312. maximumThickness: number;
  123313. /**
  123314. * Defines the volume tint of the material.
  123315. * This is used for both translucency and scattering.
  123316. */
  123317. tintColor: Color3;
  123318. /**
  123319. * Defines the distance at which the tint color should be found in the media.
  123320. * This is used for refraction only.
  123321. */
  123322. tintColorAtDistance: number;
  123323. /**
  123324. * Defines how far each channel transmit through the media.
  123325. * It is defined as a color to simplify it selection.
  123326. */
  123327. diffusionDistance: Color3;
  123328. private _useMaskFromThicknessTexture;
  123329. /**
  123330. * Stores the intensity of the different subsurface effects in the thickness texture.
  123331. * * the green channel is the translucency intensity.
  123332. * * the blue channel is the scattering intensity.
  123333. * * the alpha channel is the refraction intensity.
  123334. */
  123335. useMaskFromThicknessTexture: boolean;
  123336. /** @hidden */
  123337. private _internalMarkAllSubMeshesAsTexturesDirty;
  123338. /** @hidden */
  123339. _markAllSubMeshesAsTexturesDirty(): void;
  123340. /**
  123341. * Instantiate a new istance of sub surface configuration.
  123342. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123343. */
  123344. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123345. /**
  123346. * Gets wehter the submesh is ready to be used or not.
  123347. * @param defines the list of "defines" to update.
  123348. * @param scene defines the scene the material belongs to.
  123349. * @returns - boolean indicating that the submesh is ready or not.
  123350. */
  123351. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123352. /**
  123353. * Checks to see if a texture is used in the material.
  123354. * @param defines the list of "defines" to update.
  123355. * @param scene defines the scene to the material belongs to.
  123356. */
  123357. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123358. /**
  123359. * Binds the material data.
  123360. * @param uniformBuffer defines the Uniform buffer to fill in.
  123361. * @param scene defines the scene the material belongs to.
  123362. * @param engine defines the engine the material belongs to.
  123363. * @param isFrozen defines wether the material is frozen or not.
  123364. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123365. */
  123366. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123367. /**
  123368. * Unbinds the material from the mesh.
  123369. * @param activeEffect defines the effect that should be unbound from.
  123370. * @returns true if unbound, otherwise false
  123371. */
  123372. unbind(activeEffect: Effect): boolean;
  123373. /**
  123374. * Returns the texture used for refraction or null if none is used.
  123375. * @param scene defines the scene the material belongs to.
  123376. * @returns - Refraction texture if present. If no refraction texture and refraction
  123377. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123378. */
  123379. private _getRefractionTexture;
  123380. /**
  123381. * Returns true if alpha blending should be disabled.
  123382. */
  123383. get disableAlphaBlending(): boolean;
  123384. /**
  123385. * Fills the list of render target textures.
  123386. * @param renderTargets the list of render targets to update
  123387. */
  123388. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123389. /**
  123390. * Checks to see if a texture is used in the material.
  123391. * @param texture - Base texture to use.
  123392. * @returns - Boolean specifying if a texture is used in the material.
  123393. */
  123394. hasTexture(texture: BaseTexture): boolean;
  123395. /**
  123396. * Gets a boolean indicating that current material needs to register RTT
  123397. * @returns true if this uses a render target otherwise false.
  123398. */
  123399. hasRenderTargetTextures(): boolean;
  123400. /**
  123401. * Returns an array of the actively used textures.
  123402. * @param activeTextures Array of BaseTextures
  123403. */
  123404. getActiveTextures(activeTextures: BaseTexture[]): void;
  123405. /**
  123406. * Returns the animatable textures.
  123407. * @param animatables Array of animatable textures.
  123408. */
  123409. getAnimatables(animatables: IAnimatable[]): void;
  123410. /**
  123411. * Disposes the resources of the material.
  123412. * @param forceDisposeTextures - Forces the disposal of all textures.
  123413. */
  123414. dispose(forceDisposeTextures?: boolean): void;
  123415. /**
  123416. * Get the current class name of the texture useful for serialization or dynamic coding.
  123417. * @returns "PBRSubSurfaceConfiguration"
  123418. */
  123419. getClassName(): string;
  123420. /**
  123421. * Add fallbacks to the effect fallbacks list.
  123422. * @param defines defines the Base texture to use.
  123423. * @param fallbacks defines the current fallback list.
  123424. * @param currentRank defines the current fallback rank.
  123425. * @returns the new fallback rank.
  123426. */
  123427. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123428. /**
  123429. * Add the required uniforms to the current list.
  123430. * @param uniforms defines the current uniform list.
  123431. */
  123432. static AddUniforms(uniforms: string[]): void;
  123433. /**
  123434. * Add the required samplers to the current list.
  123435. * @param samplers defines the current sampler list.
  123436. */
  123437. static AddSamplers(samplers: string[]): void;
  123438. /**
  123439. * Add the required uniforms to the current buffer.
  123440. * @param uniformBuffer defines the current uniform buffer.
  123441. */
  123442. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123443. /**
  123444. * Makes a duplicate of the current configuration into another one.
  123445. * @param configuration define the config where to copy the info
  123446. */
  123447. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123448. /**
  123449. * Serializes this Sub Surface configuration.
  123450. * @returns - An object with the serialized config.
  123451. */
  123452. serialize(): any;
  123453. /**
  123454. * Parses a anisotropy Configuration from a serialized object.
  123455. * @param source - Serialized object.
  123456. * @param scene Defines the scene we are parsing for
  123457. * @param rootUrl Defines the rootUrl to load from
  123458. */
  123459. parse(source: any, scene: Scene, rootUrl: string): void;
  123460. }
  123461. }
  123462. declare module BABYLON {
  123463. /** @hidden */
  123464. export var pbrFragmentDeclaration: {
  123465. name: string;
  123466. shader: string;
  123467. };
  123468. }
  123469. declare module BABYLON {
  123470. /** @hidden */
  123471. export var pbrUboDeclaration: {
  123472. name: string;
  123473. shader: string;
  123474. };
  123475. }
  123476. declare module BABYLON {
  123477. /** @hidden */
  123478. export var pbrFragmentExtraDeclaration: {
  123479. name: string;
  123480. shader: string;
  123481. };
  123482. }
  123483. declare module BABYLON {
  123484. /** @hidden */
  123485. export var pbrFragmentSamplersDeclaration: {
  123486. name: string;
  123487. shader: string;
  123488. };
  123489. }
  123490. declare module BABYLON {
  123491. /** @hidden */
  123492. export var pbrHelperFunctions: {
  123493. name: string;
  123494. shader: string;
  123495. };
  123496. }
  123497. declare module BABYLON {
  123498. /** @hidden */
  123499. export var harmonicsFunctions: {
  123500. name: string;
  123501. shader: string;
  123502. };
  123503. }
  123504. declare module BABYLON {
  123505. /** @hidden */
  123506. export var pbrDirectLightingSetupFunctions: {
  123507. name: string;
  123508. shader: string;
  123509. };
  123510. }
  123511. declare module BABYLON {
  123512. /** @hidden */
  123513. export var pbrDirectLightingFalloffFunctions: {
  123514. name: string;
  123515. shader: string;
  123516. };
  123517. }
  123518. declare module BABYLON {
  123519. /** @hidden */
  123520. export var pbrBRDFFunctions: {
  123521. name: string;
  123522. shader: string;
  123523. };
  123524. }
  123525. declare module BABYLON {
  123526. /** @hidden */
  123527. export var pbrDirectLightingFunctions: {
  123528. name: string;
  123529. shader: string;
  123530. };
  123531. }
  123532. declare module BABYLON {
  123533. /** @hidden */
  123534. export var pbrIBLFunctions: {
  123535. name: string;
  123536. shader: string;
  123537. };
  123538. }
  123539. declare module BABYLON {
  123540. /** @hidden */
  123541. export var pbrDebug: {
  123542. name: string;
  123543. shader: string;
  123544. };
  123545. }
  123546. declare module BABYLON {
  123547. /** @hidden */
  123548. export var pbrPixelShader: {
  123549. name: string;
  123550. shader: string;
  123551. };
  123552. }
  123553. declare module BABYLON {
  123554. /** @hidden */
  123555. export var pbrVertexDeclaration: {
  123556. name: string;
  123557. shader: string;
  123558. };
  123559. }
  123560. declare module BABYLON {
  123561. /** @hidden */
  123562. export var pbrVertexShader: {
  123563. name: string;
  123564. shader: string;
  123565. };
  123566. }
  123567. declare module BABYLON {
  123568. /**
  123569. * Manages the defines for the PBR Material.
  123570. * @hidden
  123571. */
  123572. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123573. PBR: boolean;
  123574. MAINUV1: boolean;
  123575. MAINUV2: boolean;
  123576. UV1: boolean;
  123577. UV2: boolean;
  123578. ALBEDO: boolean;
  123579. ALBEDODIRECTUV: number;
  123580. VERTEXCOLOR: boolean;
  123581. AMBIENT: boolean;
  123582. AMBIENTDIRECTUV: number;
  123583. AMBIENTINGRAYSCALE: boolean;
  123584. OPACITY: boolean;
  123585. VERTEXALPHA: boolean;
  123586. OPACITYDIRECTUV: number;
  123587. OPACITYRGB: boolean;
  123588. ALPHATEST: boolean;
  123589. DEPTHPREPASS: boolean;
  123590. ALPHABLEND: boolean;
  123591. ALPHAFROMALBEDO: boolean;
  123592. ALPHATESTVALUE: string;
  123593. SPECULAROVERALPHA: boolean;
  123594. RADIANCEOVERALPHA: boolean;
  123595. ALPHAFRESNEL: boolean;
  123596. LINEARALPHAFRESNEL: boolean;
  123597. PREMULTIPLYALPHA: boolean;
  123598. EMISSIVE: boolean;
  123599. EMISSIVEDIRECTUV: number;
  123600. REFLECTIVITY: boolean;
  123601. REFLECTIVITYDIRECTUV: number;
  123602. SPECULARTERM: boolean;
  123603. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  123604. MICROSURFACEAUTOMATIC: boolean;
  123605. LODBASEDMICROSFURACE: boolean;
  123606. MICROSURFACEMAP: boolean;
  123607. MICROSURFACEMAPDIRECTUV: number;
  123608. METALLICWORKFLOW: boolean;
  123609. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  123610. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  123611. METALLNESSSTOREINMETALMAPBLUE: boolean;
  123612. AOSTOREINMETALMAPRED: boolean;
  123613. METALLICF0FACTORFROMMETALLICMAP: boolean;
  123614. ENVIRONMENTBRDF: boolean;
  123615. ENVIRONMENTBRDF_RGBD: boolean;
  123616. NORMAL: boolean;
  123617. TANGENT: boolean;
  123618. BUMP: boolean;
  123619. BUMPDIRECTUV: number;
  123620. OBJECTSPACE_NORMALMAP: boolean;
  123621. PARALLAX: boolean;
  123622. PARALLAXOCCLUSION: boolean;
  123623. NORMALXYSCALE: boolean;
  123624. LIGHTMAP: boolean;
  123625. LIGHTMAPDIRECTUV: number;
  123626. USELIGHTMAPASSHADOWMAP: boolean;
  123627. GAMMALIGHTMAP: boolean;
  123628. RGBDLIGHTMAP: boolean;
  123629. REFLECTION: boolean;
  123630. REFLECTIONMAP_3D: boolean;
  123631. REFLECTIONMAP_SPHERICAL: boolean;
  123632. REFLECTIONMAP_PLANAR: boolean;
  123633. REFLECTIONMAP_CUBIC: boolean;
  123634. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  123635. REFLECTIONMAP_PROJECTION: boolean;
  123636. REFLECTIONMAP_SKYBOX: boolean;
  123637. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  123638. REFLECTIONMAP_EXPLICIT: boolean;
  123639. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  123640. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  123641. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  123642. INVERTCUBICMAP: boolean;
  123643. USESPHERICALFROMREFLECTIONMAP: boolean;
  123644. USEIRRADIANCEMAP: boolean;
  123645. SPHERICAL_HARMONICS: boolean;
  123646. USESPHERICALINVERTEX: boolean;
  123647. REFLECTIONMAP_OPPOSITEZ: boolean;
  123648. LODINREFLECTIONALPHA: boolean;
  123649. GAMMAREFLECTION: boolean;
  123650. RGBDREFLECTION: boolean;
  123651. LINEARSPECULARREFLECTION: boolean;
  123652. RADIANCEOCCLUSION: boolean;
  123653. HORIZONOCCLUSION: boolean;
  123654. INSTANCES: boolean;
  123655. NUM_BONE_INFLUENCERS: number;
  123656. BonesPerMesh: number;
  123657. BONETEXTURE: boolean;
  123658. NONUNIFORMSCALING: boolean;
  123659. MORPHTARGETS: boolean;
  123660. MORPHTARGETS_NORMAL: boolean;
  123661. MORPHTARGETS_TANGENT: boolean;
  123662. MORPHTARGETS_UV: boolean;
  123663. NUM_MORPH_INFLUENCERS: number;
  123664. IMAGEPROCESSING: boolean;
  123665. VIGNETTE: boolean;
  123666. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123667. VIGNETTEBLENDMODEOPAQUE: boolean;
  123668. TONEMAPPING: boolean;
  123669. TONEMAPPING_ACES: boolean;
  123670. CONTRAST: boolean;
  123671. COLORCURVES: boolean;
  123672. COLORGRADING: boolean;
  123673. COLORGRADING3D: boolean;
  123674. SAMPLER3DGREENDEPTH: boolean;
  123675. SAMPLER3DBGRMAP: boolean;
  123676. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123677. EXPOSURE: boolean;
  123678. MULTIVIEW: boolean;
  123679. USEPHYSICALLIGHTFALLOFF: boolean;
  123680. USEGLTFLIGHTFALLOFF: boolean;
  123681. TWOSIDEDLIGHTING: boolean;
  123682. SHADOWFLOAT: boolean;
  123683. CLIPPLANE: boolean;
  123684. CLIPPLANE2: boolean;
  123685. CLIPPLANE3: boolean;
  123686. CLIPPLANE4: boolean;
  123687. CLIPPLANE5: boolean;
  123688. CLIPPLANE6: boolean;
  123689. POINTSIZE: boolean;
  123690. FOG: boolean;
  123691. LOGARITHMICDEPTH: boolean;
  123692. FORCENORMALFORWARD: boolean;
  123693. SPECULARAA: boolean;
  123694. CLEARCOAT: boolean;
  123695. CLEARCOAT_DEFAULTIOR: boolean;
  123696. CLEARCOAT_TEXTURE: boolean;
  123697. CLEARCOAT_TEXTUREDIRECTUV: number;
  123698. CLEARCOAT_BUMP: boolean;
  123699. CLEARCOAT_BUMPDIRECTUV: number;
  123700. CLEARCOAT_TINT: boolean;
  123701. CLEARCOAT_TINT_TEXTURE: boolean;
  123702. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123703. ANISOTROPIC: boolean;
  123704. ANISOTROPIC_TEXTURE: boolean;
  123705. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123706. BRDF_V_HEIGHT_CORRELATED: boolean;
  123707. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123708. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123709. SHEEN: boolean;
  123710. SHEEN_TEXTURE: boolean;
  123711. SHEEN_TEXTUREDIRECTUV: number;
  123712. SHEEN_LINKWITHALBEDO: boolean;
  123713. SUBSURFACE: boolean;
  123714. SS_REFRACTION: boolean;
  123715. SS_TRANSLUCENCY: boolean;
  123716. SS_SCATERRING: boolean;
  123717. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123718. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123719. SS_REFRACTIONMAP_3D: boolean;
  123720. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123721. SS_LODINREFRACTIONALPHA: boolean;
  123722. SS_GAMMAREFRACTION: boolean;
  123723. SS_RGBDREFRACTION: boolean;
  123724. SS_LINEARSPECULARREFRACTION: boolean;
  123725. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123726. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123727. UNLIT: boolean;
  123728. DEBUGMODE: number;
  123729. /**
  123730. * Initializes the PBR Material defines.
  123731. */
  123732. constructor();
  123733. /**
  123734. * Resets the PBR Material defines.
  123735. */
  123736. reset(): void;
  123737. }
  123738. /**
  123739. * The Physically based material base class of BJS.
  123740. *
  123741. * This offers the main features of a standard PBR material.
  123742. * For more information, please refer to the documentation :
  123743. * https://doc.babylonjs.com/how_to/physically_based_rendering
  123744. */
  123745. export abstract class PBRBaseMaterial extends PushMaterial {
  123746. /**
  123747. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  123748. */
  123749. static readonly PBRMATERIAL_OPAQUE: number;
  123750. /**
  123751. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  123752. */
  123753. static readonly PBRMATERIAL_ALPHATEST: number;
  123754. /**
  123755. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123756. */
  123757. static readonly PBRMATERIAL_ALPHABLEND: number;
  123758. /**
  123759. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123760. * They are also discarded below the alpha cutoff threshold to improve performances.
  123761. */
  123762. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  123763. /**
  123764. * Defines the default value of how much AO map is occluding the analytical lights
  123765. * (point spot...).
  123766. */
  123767. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  123768. /**
  123769. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  123770. */
  123771. static readonly LIGHTFALLOFF_PHYSICAL: number;
  123772. /**
  123773. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  123774. * to enhance interoperability with other engines.
  123775. */
  123776. static readonly LIGHTFALLOFF_GLTF: number;
  123777. /**
  123778. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  123779. * to enhance interoperability with other materials.
  123780. */
  123781. static readonly LIGHTFALLOFF_STANDARD: number;
  123782. /**
  123783. * Intensity of the direct lights e.g. the four lights available in your scene.
  123784. * This impacts both the direct diffuse and specular highlights.
  123785. */
  123786. protected _directIntensity: number;
  123787. /**
  123788. * Intensity of the emissive part of the material.
  123789. * This helps controlling the emissive effect without modifying the emissive color.
  123790. */
  123791. protected _emissiveIntensity: number;
  123792. /**
  123793. * Intensity of the environment e.g. how much the environment will light the object
  123794. * either through harmonics for rough material or through the refelction for shiny ones.
  123795. */
  123796. protected _environmentIntensity: number;
  123797. /**
  123798. * This is a special control allowing the reduction of the specular highlights coming from the
  123799. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  123800. */
  123801. protected _specularIntensity: number;
  123802. /**
  123803. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  123804. */
  123805. private _lightingInfos;
  123806. /**
  123807. * Debug Control allowing disabling the bump map on this material.
  123808. */
  123809. protected _disableBumpMap: boolean;
  123810. /**
  123811. * AKA Diffuse Texture in standard nomenclature.
  123812. */
  123813. protected _albedoTexture: Nullable<BaseTexture>;
  123814. /**
  123815. * AKA Occlusion Texture in other nomenclature.
  123816. */
  123817. protected _ambientTexture: Nullable<BaseTexture>;
  123818. /**
  123819. * AKA Occlusion Texture Intensity in other nomenclature.
  123820. */
  123821. protected _ambientTextureStrength: number;
  123822. /**
  123823. * Defines how much the AO map is occluding the analytical lights (point spot...).
  123824. * 1 means it completely occludes it
  123825. * 0 mean it has no impact
  123826. */
  123827. protected _ambientTextureImpactOnAnalyticalLights: number;
  123828. /**
  123829. * Stores the alpha values in a texture.
  123830. */
  123831. protected _opacityTexture: Nullable<BaseTexture>;
  123832. /**
  123833. * Stores the reflection values in a texture.
  123834. */
  123835. protected _reflectionTexture: Nullable<BaseTexture>;
  123836. /**
  123837. * Stores the emissive values in a texture.
  123838. */
  123839. protected _emissiveTexture: Nullable<BaseTexture>;
  123840. /**
  123841. * AKA Specular texture in other nomenclature.
  123842. */
  123843. protected _reflectivityTexture: Nullable<BaseTexture>;
  123844. /**
  123845. * Used to switch from specular/glossiness to metallic/roughness workflow.
  123846. */
  123847. protected _metallicTexture: Nullable<BaseTexture>;
  123848. /**
  123849. * Specifies the metallic scalar of the metallic/roughness workflow.
  123850. * Can also be used to scale the metalness values of the metallic texture.
  123851. */
  123852. protected _metallic: Nullable<number>;
  123853. /**
  123854. * Specifies the roughness scalar of the metallic/roughness workflow.
  123855. * Can also be used to scale the roughness values of the metallic texture.
  123856. */
  123857. protected _roughness: Nullable<number>;
  123858. /**
  123859. * Specifies the an F0 factor to help configuring the material F0.
  123860. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  123861. * to 0.5 the previously hard coded value stays the same.
  123862. * Can also be used to scale the F0 values of the metallic texture.
  123863. */
  123864. protected _metallicF0Factor: number;
  123865. /**
  123866. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  123867. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  123868. * your expectation as it multiplies with the texture data.
  123869. */
  123870. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  123871. /**
  123872. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  123873. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  123874. */
  123875. protected _microSurfaceTexture: Nullable<BaseTexture>;
  123876. /**
  123877. * Stores surface normal data used to displace a mesh in a texture.
  123878. */
  123879. protected _bumpTexture: Nullable<BaseTexture>;
  123880. /**
  123881. * Stores the pre-calculated light information of a mesh in a texture.
  123882. */
  123883. protected _lightmapTexture: Nullable<BaseTexture>;
  123884. /**
  123885. * The color of a material in ambient lighting.
  123886. */
  123887. protected _ambientColor: Color3;
  123888. /**
  123889. * AKA Diffuse Color in other nomenclature.
  123890. */
  123891. protected _albedoColor: Color3;
  123892. /**
  123893. * AKA Specular Color in other nomenclature.
  123894. */
  123895. protected _reflectivityColor: Color3;
  123896. /**
  123897. * The color applied when light is reflected from a material.
  123898. */
  123899. protected _reflectionColor: Color3;
  123900. /**
  123901. * The color applied when light is emitted from a material.
  123902. */
  123903. protected _emissiveColor: Color3;
  123904. /**
  123905. * AKA Glossiness in other nomenclature.
  123906. */
  123907. protected _microSurface: number;
  123908. /**
  123909. * Specifies that the material will use the light map as a show map.
  123910. */
  123911. protected _useLightmapAsShadowmap: boolean;
  123912. /**
  123913. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  123914. * makes the reflect vector face the model (under horizon).
  123915. */
  123916. protected _useHorizonOcclusion: boolean;
  123917. /**
  123918. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  123919. * too much the area relying on ambient texture to define their ambient occlusion.
  123920. */
  123921. protected _useRadianceOcclusion: boolean;
  123922. /**
  123923. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  123924. */
  123925. protected _useAlphaFromAlbedoTexture: boolean;
  123926. /**
  123927. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  123928. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  123929. */
  123930. protected _useSpecularOverAlpha: boolean;
  123931. /**
  123932. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  123933. */
  123934. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  123935. /**
  123936. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  123937. */
  123938. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  123939. /**
  123940. * Specifies if the metallic texture contains the roughness information in its green channel.
  123941. */
  123942. protected _useRoughnessFromMetallicTextureGreen: boolean;
  123943. /**
  123944. * Specifies if the metallic texture contains the metallness information in its blue channel.
  123945. */
  123946. protected _useMetallnessFromMetallicTextureBlue: boolean;
  123947. /**
  123948. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  123949. */
  123950. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  123951. /**
  123952. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  123953. */
  123954. protected _useAmbientInGrayScale: boolean;
  123955. /**
  123956. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  123957. * The material will try to infer what glossiness each pixel should be.
  123958. */
  123959. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  123960. /**
  123961. * Defines the falloff type used in this material.
  123962. * It by default is Physical.
  123963. */
  123964. protected _lightFalloff: number;
  123965. /**
  123966. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  123967. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  123968. */
  123969. protected _useRadianceOverAlpha: boolean;
  123970. /**
  123971. * Allows using an object space normal map (instead of tangent space).
  123972. */
  123973. protected _useObjectSpaceNormalMap: boolean;
  123974. /**
  123975. * Allows using the bump map in parallax mode.
  123976. */
  123977. protected _useParallax: boolean;
  123978. /**
  123979. * Allows using the bump map in parallax occlusion mode.
  123980. */
  123981. protected _useParallaxOcclusion: boolean;
  123982. /**
  123983. * Controls the scale bias of the parallax mode.
  123984. */
  123985. protected _parallaxScaleBias: number;
  123986. /**
  123987. * If sets to true, disables all the lights affecting the material.
  123988. */
  123989. protected _disableLighting: boolean;
  123990. /**
  123991. * Number of Simultaneous lights allowed on the material.
  123992. */
  123993. protected _maxSimultaneousLights: number;
  123994. /**
  123995. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123996. */
  123997. protected _invertNormalMapX: boolean;
  123998. /**
  123999. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124000. */
  124001. protected _invertNormalMapY: boolean;
  124002. /**
  124003. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124004. */
  124005. protected _twoSidedLighting: boolean;
  124006. /**
  124007. * Defines the alpha limits in alpha test mode.
  124008. */
  124009. protected _alphaCutOff: number;
  124010. /**
  124011. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124012. */
  124013. protected _forceAlphaTest: boolean;
  124014. /**
  124015. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124016. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124017. */
  124018. protected _useAlphaFresnel: boolean;
  124019. /**
  124020. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124021. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124022. */
  124023. protected _useLinearAlphaFresnel: boolean;
  124024. /**
  124025. * The transparency mode of the material.
  124026. */
  124027. protected _transparencyMode: Nullable<number>;
  124028. /**
  124029. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124030. * from cos thetav and roughness:
  124031. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124032. */
  124033. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124034. /**
  124035. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124036. */
  124037. protected _forceIrradianceInFragment: boolean;
  124038. /**
  124039. * Force normal to face away from face.
  124040. */
  124041. protected _forceNormalForward: boolean;
  124042. /**
  124043. * Enables specular anti aliasing in the PBR shader.
  124044. * It will both interacts on the Geometry for analytical and IBL lighting.
  124045. * It also prefilter the roughness map based on the bump values.
  124046. */
  124047. protected _enableSpecularAntiAliasing: boolean;
  124048. /**
  124049. * Default configuration related to image processing available in the PBR Material.
  124050. */
  124051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124052. /**
  124053. * Keep track of the image processing observer to allow dispose and replace.
  124054. */
  124055. private _imageProcessingObserver;
  124056. /**
  124057. * Attaches a new image processing configuration to the PBR Material.
  124058. * @param configuration
  124059. */
  124060. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124061. /**
  124062. * Stores the available render targets.
  124063. */
  124064. private _renderTargets;
  124065. /**
  124066. * Sets the global ambient color for the material used in lighting calculations.
  124067. */
  124068. private _globalAmbientColor;
  124069. /**
  124070. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124071. */
  124072. private _useLogarithmicDepth;
  124073. /**
  124074. * If set to true, no lighting calculations will be applied.
  124075. */
  124076. private _unlit;
  124077. private _debugMode;
  124078. /**
  124079. * @hidden
  124080. * This is reserved for the inspector.
  124081. * Defines the material debug mode.
  124082. * It helps seeing only some components of the material while troubleshooting.
  124083. */
  124084. debugMode: number;
  124085. /**
  124086. * @hidden
  124087. * This is reserved for the inspector.
  124088. * Specify from where on screen the debug mode should start.
  124089. * The value goes from -1 (full screen) to 1 (not visible)
  124090. * It helps with side by side comparison against the final render
  124091. * This defaults to -1
  124092. */
  124093. private debugLimit;
  124094. /**
  124095. * @hidden
  124096. * This is reserved for the inspector.
  124097. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124098. * You can use the factor to better multiply the final value.
  124099. */
  124100. private debugFactor;
  124101. /**
  124102. * Defines the clear coat layer parameters for the material.
  124103. */
  124104. readonly clearCoat: PBRClearCoatConfiguration;
  124105. /**
  124106. * Defines the anisotropic parameters for the material.
  124107. */
  124108. readonly anisotropy: PBRAnisotropicConfiguration;
  124109. /**
  124110. * Defines the BRDF parameters for the material.
  124111. */
  124112. readonly brdf: PBRBRDFConfiguration;
  124113. /**
  124114. * Defines the Sheen parameters for the material.
  124115. */
  124116. readonly sheen: PBRSheenConfiguration;
  124117. /**
  124118. * Defines the SubSurface parameters for the material.
  124119. */
  124120. readonly subSurface: PBRSubSurfaceConfiguration;
  124121. /**
  124122. * Custom callback helping to override the default shader used in the material.
  124123. */
  124124. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124125. protected _rebuildInParallel: boolean;
  124126. /**
  124127. * Instantiates a new PBRMaterial instance.
  124128. *
  124129. * @param name The material name
  124130. * @param scene The scene the material will be use in.
  124131. */
  124132. constructor(name: string, scene: Scene);
  124133. /**
  124134. * Gets a boolean indicating that current material needs to register RTT
  124135. */
  124136. get hasRenderTargetTextures(): boolean;
  124137. /**
  124138. * Gets the name of the material class.
  124139. */
  124140. getClassName(): string;
  124141. /**
  124142. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124143. */
  124144. get useLogarithmicDepth(): boolean;
  124145. /**
  124146. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124147. */
  124148. set useLogarithmicDepth(value: boolean);
  124149. /**
  124150. * Gets the current transparency mode.
  124151. */
  124152. get transparencyMode(): Nullable<number>;
  124153. /**
  124154. * Sets the transparency mode of the material.
  124155. *
  124156. * | Value | Type | Description |
  124157. * | ----- | ----------------------------------- | ----------- |
  124158. * | 0 | OPAQUE | |
  124159. * | 1 | ALPHATEST | |
  124160. * | 2 | ALPHABLEND | |
  124161. * | 3 | ALPHATESTANDBLEND | |
  124162. *
  124163. */
  124164. set transparencyMode(value: Nullable<number>);
  124165. /**
  124166. * Returns true if alpha blending should be disabled.
  124167. */
  124168. private get _disableAlphaBlending();
  124169. /**
  124170. * Specifies whether or not this material should be rendered in alpha blend mode.
  124171. */
  124172. needAlphaBlending(): boolean;
  124173. /**
  124174. * Specifies if the mesh will require alpha blending.
  124175. * @param mesh - BJS mesh.
  124176. */
  124177. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124178. /**
  124179. * Specifies whether or not this material should be rendered in alpha test mode.
  124180. */
  124181. needAlphaTesting(): boolean;
  124182. /**
  124183. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124184. */
  124185. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124186. /**
  124187. * Gets the texture used for the alpha test.
  124188. */
  124189. getAlphaTestTexture(): Nullable<BaseTexture>;
  124190. /**
  124191. * Specifies that the submesh is ready to be used.
  124192. * @param mesh - BJS mesh.
  124193. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124194. * @param useInstances - Specifies that instances should be used.
  124195. * @returns - boolean indicating that the submesh is ready or not.
  124196. */
  124197. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124198. /**
  124199. * Specifies if the material uses metallic roughness workflow.
  124200. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124201. */
  124202. isMetallicWorkflow(): boolean;
  124203. private _prepareEffect;
  124204. private _prepareDefines;
  124205. /**
  124206. * Force shader compilation
  124207. */
  124208. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124209. /**
  124210. * Initializes the uniform buffer layout for the shader.
  124211. */
  124212. buildUniformLayout(): void;
  124213. /**
  124214. * Unbinds the material from the mesh
  124215. */
  124216. unbind(): void;
  124217. /**
  124218. * Binds the submesh data.
  124219. * @param world - The world matrix.
  124220. * @param mesh - The BJS mesh.
  124221. * @param subMesh - A submesh of the BJS mesh.
  124222. */
  124223. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124224. /**
  124225. * Returns the animatable textures.
  124226. * @returns - Array of animatable textures.
  124227. */
  124228. getAnimatables(): IAnimatable[];
  124229. /**
  124230. * Returns the texture used for reflections.
  124231. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124232. */
  124233. private _getReflectionTexture;
  124234. /**
  124235. * Returns an array of the actively used textures.
  124236. * @returns - Array of BaseTextures
  124237. */
  124238. getActiveTextures(): BaseTexture[];
  124239. /**
  124240. * Checks to see if a texture is used in the material.
  124241. * @param texture - Base texture to use.
  124242. * @returns - Boolean specifying if a texture is used in the material.
  124243. */
  124244. hasTexture(texture: BaseTexture): boolean;
  124245. /**
  124246. * Disposes the resources of the material.
  124247. * @param forceDisposeEffect - Forces the disposal of effects.
  124248. * @param forceDisposeTextures - Forces the disposal of all textures.
  124249. */
  124250. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124251. }
  124252. }
  124253. declare module BABYLON {
  124254. /**
  124255. * The Physically based material of BJS.
  124256. *
  124257. * This offers the main features of a standard PBR material.
  124258. * For more information, please refer to the documentation :
  124259. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124260. */
  124261. export class PBRMaterial extends PBRBaseMaterial {
  124262. /**
  124263. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124264. */
  124265. static readonly PBRMATERIAL_OPAQUE: number;
  124266. /**
  124267. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124268. */
  124269. static readonly PBRMATERIAL_ALPHATEST: number;
  124270. /**
  124271. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124272. */
  124273. static readonly PBRMATERIAL_ALPHABLEND: number;
  124274. /**
  124275. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124276. * They are also discarded below the alpha cutoff threshold to improve performances.
  124277. */
  124278. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124279. /**
  124280. * Defines the default value of how much AO map is occluding the analytical lights
  124281. * (point spot...).
  124282. */
  124283. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124284. /**
  124285. * Intensity of the direct lights e.g. the four lights available in your scene.
  124286. * This impacts both the direct diffuse and specular highlights.
  124287. */
  124288. directIntensity: number;
  124289. /**
  124290. * Intensity of the emissive part of the material.
  124291. * This helps controlling the emissive effect without modifying the emissive color.
  124292. */
  124293. emissiveIntensity: number;
  124294. /**
  124295. * Intensity of the environment e.g. how much the environment will light the object
  124296. * either through harmonics for rough material or through the refelction for shiny ones.
  124297. */
  124298. environmentIntensity: number;
  124299. /**
  124300. * This is a special control allowing the reduction of the specular highlights coming from the
  124301. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124302. */
  124303. specularIntensity: number;
  124304. /**
  124305. * Debug Control allowing disabling the bump map on this material.
  124306. */
  124307. disableBumpMap: boolean;
  124308. /**
  124309. * AKA Diffuse Texture in standard nomenclature.
  124310. */
  124311. albedoTexture: BaseTexture;
  124312. /**
  124313. * AKA Occlusion Texture in other nomenclature.
  124314. */
  124315. ambientTexture: BaseTexture;
  124316. /**
  124317. * AKA Occlusion Texture Intensity in other nomenclature.
  124318. */
  124319. ambientTextureStrength: number;
  124320. /**
  124321. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124322. * 1 means it completely occludes it
  124323. * 0 mean it has no impact
  124324. */
  124325. ambientTextureImpactOnAnalyticalLights: number;
  124326. /**
  124327. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124328. */
  124329. opacityTexture: BaseTexture;
  124330. /**
  124331. * Stores the reflection values in a texture.
  124332. */
  124333. reflectionTexture: Nullable<BaseTexture>;
  124334. /**
  124335. * Stores the emissive values in a texture.
  124336. */
  124337. emissiveTexture: BaseTexture;
  124338. /**
  124339. * AKA Specular texture in other nomenclature.
  124340. */
  124341. reflectivityTexture: BaseTexture;
  124342. /**
  124343. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124344. */
  124345. metallicTexture: BaseTexture;
  124346. /**
  124347. * Specifies the metallic scalar of the metallic/roughness workflow.
  124348. * Can also be used to scale the metalness values of the metallic texture.
  124349. */
  124350. metallic: Nullable<number>;
  124351. /**
  124352. * Specifies the roughness scalar of the metallic/roughness workflow.
  124353. * Can also be used to scale the roughness values of the metallic texture.
  124354. */
  124355. roughness: Nullable<number>;
  124356. /**
  124357. * Specifies the an F0 factor to help configuring the material F0.
  124358. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124359. * to 0.5 the previously hard coded value stays the same.
  124360. * Can also be used to scale the F0 values of the metallic texture.
  124361. */
  124362. metallicF0Factor: number;
  124363. /**
  124364. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124365. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124366. * your expectation as it multiplies with the texture data.
  124367. */
  124368. useMetallicF0FactorFromMetallicTexture: boolean;
  124369. /**
  124370. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124371. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124372. */
  124373. microSurfaceTexture: BaseTexture;
  124374. /**
  124375. * Stores surface normal data used to displace a mesh in a texture.
  124376. */
  124377. bumpTexture: BaseTexture;
  124378. /**
  124379. * Stores the pre-calculated light information of a mesh in a texture.
  124380. */
  124381. lightmapTexture: BaseTexture;
  124382. /**
  124383. * Stores the refracted light information in a texture.
  124384. */
  124385. get refractionTexture(): Nullable<BaseTexture>;
  124386. set refractionTexture(value: Nullable<BaseTexture>);
  124387. /**
  124388. * The color of a material in ambient lighting.
  124389. */
  124390. ambientColor: Color3;
  124391. /**
  124392. * AKA Diffuse Color in other nomenclature.
  124393. */
  124394. albedoColor: Color3;
  124395. /**
  124396. * AKA Specular Color in other nomenclature.
  124397. */
  124398. reflectivityColor: Color3;
  124399. /**
  124400. * The color reflected from the material.
  124401. */
  124402. reflectionColor: Color3;
  124403. /**
  124404. * The color emitted from the material.
  124405. */
  124406. emissiveColor: Color3;
  124407. /**
  124408. * AKA Glossiness in other nomenclature.
  124409. */
  124410. microSurface: number;
  124411. /**
  124412. * source material index of refraction (IOR)' / 'destination material IOR.
  124413. */
  124414. get indexOfRefraction(): number;
  124415. set indexOfRefraction(value: number);
  124416. /**
  124417. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124418. */
  124419. get invertRefractionY(): boolean;
  124420. set invertRefractionY(value: boolean);
  124421. /**
  124422. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124423. * Materials half opaque for instance using refraction could benefit from this control.
  124424. */
  124425. get linkRefractionWithTransparency(): boolean;
  124426. set linkRefractionWithTransparency(value: boolean);
  124427. /**
  124428. * If true, the light map contains occlusion information instead of lighting info.
  124429. */
  124430. useLightmapAsShadowmap: boolean;
  124431. /**
  124432. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124433. */
  124434. useAlphaFromAlbedoTexture: boolean;
  124435. /**
  124436. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124437. */
  124438. forceAlphaTest: boolean;
  124439. /**
  124440. * Defines the alpha limits in alpha test mode.
  124441. */
  124442. alphaCutOff: number;
  124443. /**
  124444. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124445. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124446. */
  124447. useSpecularOverAlpha: boolean;
  124448. /**
  124449. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124450. */
  124451. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124452. /**
  124453. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124454. */
  124455. useRoughnessFromMetallicTextureAlpha: boolean;
  124456. /**
  124457. * Specifies if the metallic texture contains the roughness information in its green channel.
  124458. */
  124459. useRoughnessFromMetallicTextureGreen: boolean;
  124460. /**
  124461. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124462. */
  124463. useMetallnessFromMetallicTextureBlue: boolean;
  124464. /**
  124465. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124466. */
  124467. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124468. /**
  124469. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124470. */
  124471. useAmbientInGrayScale: boolean;
  124472. /**
  124473. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124474. * The material will try to infer what glossiness each pixel should be.
  124475. */
  124476. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124477. /**
  124478. * BJS is using an harcoded light falloff based on a manually sets up range.
  124479. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124480. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124481. */
  124482. get usePhysicalLightFalloff(): boolean;
  124483. /**
  124484. * BJS is using an harcoded light falloff based on a manually sets up range.
  124485. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124486. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124487. */
  124488. set usePhysicalLightFalloff(value: boolean);
  124489. /**
  124490. * In order to support the falloff compatibility with gltf, a special mode has been added
  124491. * to reproduce the gltf light falloff.
  124492. */
  124493. get useGLTFLightFalloff(): boolean;
  124494. /**
  124495. * In order to support the falloff compatibility with gltf, a special mode has been added
  124496. * to reproduce the gltf light falloff.
  124497. */
  124498. set useGLTFLightFalloff(value: boolean);
  124499. /**
  124500. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124501. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124502. */
  124503. useRadianceOverAlpha: boolean;
  124504. /**
  124505. * Allows using an object space normal map (instead of tangent space).
  124506. */
  124507. useObjectSpaceNormalMap: boolean;
  124508. /**
  124509. * Allows using the bump map in parallax mode.
  124510. */
  124511. useParallax: boolean;
  124512. /**
  124513. * Allows using the bump map in parallax occlusion mode.
  124514. */
  124515. useParallaxOcclusion: boolean;
  124516. /**
  124517. * Controls the scale bias of the parallax mode.
  124518. */
  124519. parallaxScaleBias: number;
  124520. /**
  124521. * If sets to true, disables all the lights affecting the material.
  124522. */
  124523. disableLighting: boolean;
  124524. /**
  124525. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124526. */
  124527. forceIrradianceInFragment: boolean;
  124528. /**
  124529. * Number of Simultaneous lights allowed on the material.
  124530. */
  124531. maxSimultaneousLights: number;
  124532. /**
  124533. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124534. */
  124535. invertNormalMapX: boolean;
  124536. /**
  124537. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124538. */
  124539. invertNormalMapY: boolean;
  124540. /**
  124541. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124542. */
  124543. twoSidedLighting: boolean;
  124544. /**
  124545. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124546. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124547. */
  124548. useAlphaFresnel: boolean;
  124549. /**
  124550. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124551. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124552. */
  124553. useLinearAlphaFresnel: boolean;
  124554. /**
  124555. * Let user defines the brdf lookup texture used for IBL.
  124556. * A default 8bit version is embedded but you could point at :
  124557. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124558. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124559. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124560. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124561. */
  124562. environmentBRDFTexture: Nullable<BaseTexture>;
  124563. /**
  124564. * Force normal to face away from face.
  124565. */
  124566. forceNormalForward: boolean;
  124567. /**
  124568. * Enables specular anti aliasing in the PBR shader.
  124569. * It will both interacts on the Geometry for analytical and IBL lighting.
  124570. * It also prefilter the roughness map based on the bump values.
  124571. */
  124572. enableSpecularAntiAliasing: boolean;
  124573. /**
  124574. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124575. * makes the reflect vector face the model (under horizon).
  124576. */
  124577. useHorizonOcclusion: boolean;
  124578. /**
  124579. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124580. * too much the area relying on ambient texture to define their ambient occlusion.
  124581. */
  124582. useRadianceOcclusion: boolean;
  124583. /**
  124584. * If set to true, no lighting calculations will be applied.
  124585. */
  124586. unlit: boolean;
  124587. /**
  124588. * Gets the image processing configuration used either in this material.
  124589. */
  124590. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124591. /**
  124592. * Sets the Default image processing configuration used either in the this material.
  124593. *
  124594. * If sets to null, the scene one is in use.
  124595. */
  124596. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124597. /**
  124598. * Gets wether the color curves effect is enabled.
  124599. */
  124600. get cameraColorCurvesEnabled(): boolean;
  124601. /**
  124602. * Sets wether the color curves effect is enabled.
  124603. */
  124604. set cameraColorCurvesEnabled(value: boolean);
  124605. /**
  124606. * Gets wether the color grading effect is enabled.
  124607. */
  124608. get cameraColorGradingEnabled(): boolean;
  124609. /**
  124610. * Gets wether the color grading effect is enabled.
  124611. */
  124612. set cameraColorGradingEnabled(value: boolean);
  124613. /**
  124614. * Gets wether tonemapping is enabled or not.
  124615. */
  124616. get cameraToneMappingEnabled(): boolean;
  124617. /**
  124618. * Sets wether tonemapping is enabled or not
  124619. */
  124620. set cameraToneMappingEnabled(value: boolean);
  124621. /**
  124622. * The camera exposure used on this material.
  124623. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124624. * This corresponds to a photographic exposure.
  124625. */
  124626. get cameraExposure(): number;
  124627. /**
  124628. * The camera exposure used on this material.
  124629. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124630. * This corresponds to a photographic exposure.
  124631. */
  124632. set cameraExposure(value: number);
  124633. /**
  124634. * Gets The camera contrast used on this material.
  124635. */
  124636. get cameraContrast(): number;
  124637. /**
  124638. * Sets The camera contrast used on this material.
  124639. */
  124640. set cameraContrast(value: number);
  124641. /**
  124642. * Gets the Color Grading 2D Lookup Texture.
  124643. */
  124644. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124645. /**
  124646. * Sets the Color Grading 2D Lookup Texture.
  124647. */
  124648. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124649. /**
  124650. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124651. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124652. * 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;
  124653. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124654. */
  124655. get cameraColorCurves(): Nullable<ColorCurves>;
  124656. /**
  124657. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124658. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124659. * 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;
  124660. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124661. */
  124662. set cameraColorCurves(value: Nullable<ColorCurves>);
  124663. /**
  124664. * Instantiates a new PBRMaterial instance.
  124665. *
  124666. * @param name The material name
  124667. * @param scene The scene the material will be use in.
  124668. */
  124669. constructor(name: string, scene: Scene);
  124670. /**
  124671. * Returns the name of this material class.
  124672. */
  124673. getClassName(): string;
  124674. /**
  124675. * Makes a duplicate of the current material.
  124676. * @param name - name to use for the new material.
  124677. */
  124678. clone(name: string): PBRMaterial;
  124679. /**
  124680. * Serializes this PBR Material.
  124681. * @returns - An object with the serialized material.
  124682. */
  124683. serialize(): any;
  124684. /**
  124685. * Parses a PBR Material from a serialized object.
  124686. * @param source - Serialized object.
  124687. * @param scene - BJS scene instance.
  124688. * @param rootUrl - url for the scene object
  124689. * @returns - PBRMaterial
  124690. */
  124691. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  124692. }
  124693. }
  124694. declare module BABYLON {
  124695. /**
  124696. * Direct draw surface info
  124697. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  124698. */
  124699. export interface DDSInfo {
  124700. /**
  124701. * Width of the texture
  124702. */
  124703. width: number;
  124704. /**
  124705. * Width of the texture
  124706. */
  124707. height: number;
  124708. /**
  124709. * Number of Mipmaps for the texture
  124710. * @see https://en.wikipedia.org/wiki/Mipmap
  124711. */
  124712. mipmapCount: number;
  124713. /**
  124714. * If the textures format is a known fourCC format
  124715. * @see https://www.fourcc.org/
  124716. */
  124717. isFourCC: boolean;
  124718. /**
  124719. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  124720. */
  124721. isRGB: boolean;
  124722. /**
  124723. * If the texture is a lumincance format
  124724. */
  124725. isLuminance: boolean;
  124726. /**
  124727. * If this is a cube texture
  124728. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  124729. */
  124730. isCube: boolean;
  124731. /**
  124732. * If the texture is a compressed format eg. FOURCC_DXT1
  124733. */
  124734. isCompressed: boolean;
  124735. /**
  124736. * The dxgiFormat of the texture
  124737. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  124738. */
  124739. dxgiFormat: number;
  124740. /**
  124741. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  124742. */
  124743. textureType: number;
  124744. /**
  124745. * Sphericle polynomial created for the dds texture
  124746. */
  124747. sphericalPolynomial?: SphericalPolynomial;
  124748. }
  124749. /**
  124750. * Class used to provide DDS decompression tools
  124751. */
  124752. export class DDSTools {
  124753. /**
  124754. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  124755. */
  124756. static StoreLODInAlphaChannel: boolean;
  124757. /**
  124758. * Gets DDS information from an array buffer
  124759. * @param arrayBuffer defines the array buffer to read data from
  124760. * @returns the DDS information
  124761. */
  124762. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  124763. private static _FloatView;
  124764. private static _Int32View;
  124765. private static _ToHalfFloat;
  124766. private static _FromHalfFloat;
  124767. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  124768. private static _GetHalfFloatRGBAArrayBuffer;
  124769. private static _GetFloatRGBAArrayBuffer;
  124770. private static _GetFloatAsUIntRGBAArrayBuffer;
  124771. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  124772. private static _GetRGBAArrayBuffer;
  124773. private static _ExtractLongWordOrder;
  124774. private static _GetRGBArrayBuffer;
  124775. private static _GetLuminanceArrayBuffer;
  124776. /**
  124777. * Uploads DDS Levels to a Babylon Texture
  124778. * @hidden
  124779. */
  124780. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  124781. }
  124782. interface ThinEngine {
  124783. /**
  124784. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  124785. * @param rootUrl defines the url where the file to load is located
  124786. * @param scene defines the current scene
  124787. * @param lodScale defines scale to apply to the mip map selection
  124788. * @param lodOffset defines offset to apply to the mip map selection
  124789. * @param onLoad defines an optional callback raised when the texture is loaded
  124790. * @param onError defines an optional callback raised if there is an issue to load the texture
  124791. * @param format defines the format of the data
  124792. * @param forcedExtension defines the extension to use to pick the right loader
  124793. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  124794. * @returns the cube texture as an InternalTexture
  124795. */
  124796. 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;
  124797. }
  124798. }
  124799. declare module BABYLON {
  124800. /**
  124801. * Implementation of the DDS Texture Loader.
  124802. * @hidden
  124803. */
  124804. export class _DDSTextureLoader implements IInternalTextureLoader {
  124805. /**
  124806. * Defines wether the loader supports cascade loading the different faces.
  124807. */
  124808. readonly supportCascades: boolean;
  124809. /**
  124810. * This returns if the loader support the current file information.
  124811. * @param extension defines the file extension of the file being loaded
  124812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124813. * @param fallback defines the fallback internal texture if any
  124814. * @param isBase64 defines whether the texture is encoded as a base64
  124815. * @param isBuffer defines whether the texture data are stored as a buffer
  124816. * @returns true if the loader can load the specified file
  124817. */
  124818. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124819. /**
  124820. * Transform the url before loading if required.
  124821. * @param rootUrl the url of the texture
  124822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124823. * @returns the transformed texture
  124824. */
  124825. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124826. /**
  124827. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124828. * @param rootUrl the url of the texture
  124829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124830. * @returns the fallback texture
  124831. */
  124832. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124833. /**
  124834. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124835. * @param data contains the texture data
  124836. * @param texture defines the BabylonJS internal texture
  124837. * @param createPolynomials will be true if polynomials have been requested
  124838. * @param onLoad defines the callback to trigger once the texture is ready
  124839. * @param onError defines the callback to trigger in case of error
  124840. */
  124841. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124842. /**
  124843. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124844. * @param data contains the texture data
  124845. * @param texture defines the BabylonJS internal texture
  124846. * @param callback defines the method to call once ready to upload
  124847. */
  124848. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124849. }
  124850. }
  124851. declare module BABYLON {
  124852. /**
  124853. * Implementation of the ENV Texture Loader.
  124854. * @hidden
  124855. */
  124856. export class _ENVTextureLoader implements IInternalTextureLoader {
  124857. /**
  124858. * Defines wether the loader supports cascade loading the different faces.
  124859. */
  124860. readonly supportCascades: boolean;
  124861. /**
  124862. * This returns if the loader support the current file information.
  124863. * @param extension defines the file extension of the file being loaded
  124864. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124865. * @param fallback defines the fallback internal texture if any
  124866. * @param isBase64 defines whether the texture is encoded as a base64
  124867. * @param isBuffer defines whether the texture data are stored as a buffer
  124868. * @returns true if the loader can load the specified file
  124869. */
  124870. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124871. /**
  124872. * Transform the url before loading if required.
  124873. * @param rootUrl the url of the texture
  124874. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124875. * @returns the transformed texture
  124876. */
  124877. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124878. /**
  124879. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124880. * @param rootUrl the url of the texture
  124881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124882. * @returns the fallback texture
  124883. */
  124884. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124885. /**
  124886. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124887. * @param data contains the texture data
  124888. * @param texture defines the BabylonJS internal texture
  124889. * @param createPolynomials will be true if polynomials have been requested
  124890. * @param onLoad defines the callback to trigger once the texture is ready
  124891. * @param onError defines the callback to trigger in case of error
  124892. */
  124893. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124894. /**
  124895. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124896. * @param data contains the texture data
  124897. * @param texture defines the BabylonJS internal texture
  124898. * @param callback defines the method to call once ready to upload
  124899. */
  124900. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124901. }
  124902. }
  124903. declare module BABYLON {
  124904. /**
  124905. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  124906. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  124907. */
  124908. export class KhronosTextureContainer {
  124909. /** contents of the KTX container file */
  124910. arrayBuffer: any;
  124911. private static HEADER_LEN;
  124912. private static COMPRESSED_2D;
  124913. private static COMPRESSED_3D;
  124914. private static TEX_2D;
  124915. private static TEX_3D;
  124916. /**
  124917. * Gets the openGL type
  124918. */
  124919. glType: number;
  124920. /**
  124921. * Gets the openGL type size
  124922. */
  124923. glTypeSize: number;
  124924. /**
  124925. * Gets the openGL format
  124926. */
  124927. glFormat: number;
  124928. /**
  124929. * Gets the openGL internal format
  124930. */
  124931. glInternalFormat: number;
  124932. /**
  124933. * Gets the base internal format
  124934. */
  124935. glBaseInternalFormat: number;
  124936. /**
  124937. * Gets image width in pixel
  124938. */
  124939. pixelWidth: number;
  124940. /**
  124941. * Gets image height in pixel
  124942. */
  124943. pixelHeight: number;
  124944. /**
  124945. * Gets image depth in pixels
  124946. */
  124947. pixelDepth: number;
  124948. /**
  124949. * Gets the number of array elements
  124950. */
  124951. numberOfArrayElements: number;
  124952. /**
  124953. * Gets the number of faces
  124954. */
  124955. numberOfFaces: number;
  124956. /**
  124957. * Gets the number of mipmap levels
  124958. */
  124959. numberOfMipmapLevels: number;
  124960. /**
  124961. * Gets the bytes of key value data
  124962. */
  124963. bytesOfKeyValueData: number;
  124964. /**
  124965. * Gets the load type
  124966. */
  124967. loadType: number;
  124968. /**
  124969. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  124970. */
  124971. isInvalid: boolean;
  124972. /**
  124973. * Creates a new KhronosTextureContainer
  124974. * @param arrayBuffer contents of the KTX container file
  124975. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  124976. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  124977. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  124978. */
  124979. constructor(
  124980. /** contents of the KTX container file */
  124981. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  124982. /**
  124983. * Uploads KTX content to a Babylon Texture.
  124984. * It is assumed that the texture has already been created & is currently bound
  124985. * @hidden
  124986. */
  124987. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  124988. private _upload2DCompressedLevels;
  124989. }
  124990. }
  124991. declare module BABYLON {
  124992. /**
  124993. * Implementation of the KTX Texture Loader.
  124994. * @hidden
  124995. */
  124996. export class _KTXTextureLoader implements IInternalTextureLoader {
  124997. /**
  124998. * Defines wether the loader supports cascade loading the different faces.
  124999. */
  125000. readonly supportCascades: boolean;
  125001. /**
  125002. * This returns if the loader support the current file information.
  125003. * @param extension defines the file extension of the file being loaded
  125004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125005. * @param fallback defines the fallback internal texture if any
  125006. * @param isBase64 defines whether the texture is encoded as a base64
  125007. * @param isBuffer defines whether the texture data are stored as a buffer
  125008. * @returns true if the loader can load the specified file
  125009. */
  125010. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125011. /**
  125012. * Transform the url before loading if required.
  125013. * @param rootUrl the url of the texture
  125014. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125015. * @returns the transformed texture
  125016. */
  125017. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125018. /**
  125019. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125020. * @param rootUrl the url of the texture
  125021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125022. * @returns the fallback texture
  125023. */
  125024. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125025. /**
  125026. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125027. * @param data contains the texture data
  125028. * @param texture defines the BabylonJS internal texture
  125029. * @param createPolynomials will be true if polynomials have been requested
  125030. * @param onLoad defines the callback to trigger once the texture is ready
  125031. * @param onError defines the callback to trigger in case of error
  125032. */
  125033. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125034. /**
  125035. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125036. * @param data contains the texture data
  125037. * @param texture defines the BabylonJS internal texture
  125038. * @param callback defines the method to call once ready to upload
  125039. */
  125040. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125041. }
  125042. }
  125043. declare module BABYLON {
  125044. /** @hidden */
  125045. export var _forceSceneHelpersToBundle: boolean;
  125046. interface Scene {
  125047. /**
  125048. * Creates a default light for the scene.
  125049. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125050. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125051. */
  125052. createDefaultLight(replace?: boolean): void;
  125053. /**
  125054. * Creates a default camera for the scene.
  125055. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125056. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125057. * @param replace has default false, when true replaces the active camera in the scene
  125058. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125059. */
  125060. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125061. /**
  125062. * Creates a default camera and a default light.
  125063. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125064. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125065. * @param replace has the default false, when true replaces the active camera/light in the scene
  125066. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125067. */
  125068. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125069. /**
  125070. * Creates a new sky box
  125071. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125072. * @param environmentTexture defines the texture to use as environment texture
  125073. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125074. * @param scale defines the overall scale of the skybox
  125075. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125076. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125077. * @returns a new mesh holding the sky box
  125078. */
  125079. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125080. /**
  125081. * Creates a new environment
  125082. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125083. * @param options defines the options you can use to configure the environment
  125084. * @returns the new EnvironmentHelper
  125085. */
  125086. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125087. /**
  125088. * Creates a new VREXperienceHelper
  125089. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125090. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125091. * @returns a new VREXperienceHelper
  125092. */
  125093. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125094. /**
  125095. * Creates a new WebXRDefaultExperience
  125096. * @see http://doc.babylonjs.com/how_to/webxr
  125097. * @param options experience options
  125098. * @returns a promise for a new WebXRDefaultExperience
  125099. */
  125100. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125101. }
  125102. }
  125103. declare module BABYLON {
  125104. /**
  125105. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125106. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125107. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125108. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125109. */
  125110. export class VideoDome extends TransformNode {
  125111. /**
  125112. * Define the video source as a Monoscopic panoramic 360 video.
  125113. */
  125114. static readonly MODE_MONOSCOPIC: number;
  125115. /**
  125116. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125117. */
  125118. static readonly MODE_TOPBOTTOM: number;
  125119. /**
  125120. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125121. */
  125122. static readonly MODE_SIDEBYSIDE: number;
  125123. private _halfDome;
  125124. private _useDirectMapping;
  125125. /**
  125126. * The video texture being displayed on the sphere
  125127. */
  125128. protected _videoTexture: VideoTexture;
  125129. /**
  125130. * Gets the video texture being displayed on the sphere
  125131. */
  125132. get videoTexture(): VideoTexture;
  125133. /**
  125134. * The skybox material
  125135. */
  125136. protected _material: BackgroundMaterial;
  125137. /**
  125138. * The surface used for the skybox
  125139. */
  125140. protected _mesh: Mesh;
  125141. /**
  125142. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125143. */
  125144. private _halfDomeMask;
  125145. /**
  125146. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125147. * Also see the options.resolution property.
  125148. */
  125149. get fovMultiplier(): number;
  125150. set fovMultiplier(value: number);
  125151. private _videoMode;
  125152. /**
  125153. * Gets or set the current video mode for the video. It can be:
  125154. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125155. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125156. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125157. */
  125158. get videoMode(): number;
  125159. set videoMode(value: number);
  125160. /**
  125161. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125162. *
  125163. */
  125164. get halfDome(): boolean;
  125165. /**
  125166. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125167. */
  125168. set halfDome(enabled: boolean);
  125169. /**
  125170. * Oberserver used in Stereoscopic VR Mode.
  125171. */
  125172. private _onBeforeCameraRenderObserver;
  125173. /**
  125174. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125175. * @param name Element's name, child elements will append suffixes for their own names.
  125176. * @param urlsOrVideo defines the url(s) or the video element to use
  125177. * @param options An object containing optional or exposed sub element properties
  125178. */
  125179. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125180. resolution?: number;
  125181. clickToPlay?: boolean;
  125182. autoPlay?: boolean;
  125183. loop?: boolean;
  125184. size?: number;
  125185. poster?: string;
  125186. faceForward?: boolean;
  125187. useDirectMapping?: boolean;
  125188. halfDomeMode?: boolean;
  125189. }, scene: Scene);
  125190. private _changeVideoMode;
  125191. /**
  125192. * Releases resources associated with this node.
  125193. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125194. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125195. */
  125196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125197. }
  125198. }
  125199. declare module BABYLON {
  125200. /**
  125201. * This class can be used to get instrumentation data from a Babylon engine
  125202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125203. */
  125204. export class EngineInstrumentation implements IDisposable {
  125205. /**
  125206. * Define the instrumented engine.
  125207. */
  125208. engine: Engine;
  125209. private _captureGPUFrameTime;
  125210. private _gpuFrameTimeToken;
  125211. private _gpuFrameTime;
  125212. private _captureShaderCompilationTime;
  125213. private _shaderCompilationTime;
  125214. private _onBeginFrameObserver;
  125215. private _onEndFrameObserver;
  125216. private _onBeforeShaderCompilationObserver;
  125217. private _onAfterShaderCompilationObserver;
  125218. /**
  125219. * Gets the perf counter used for GPU frame time
  125220. */
  125221. get gpuFrameTimeCounter(): PerfCounter;
  125222. /**
  125223. * Gets the GPU frame time capture status
  125224. */
  125225. get captureGPUFrameTime(): boolean;
  125226. /**
  125227. * Enable or disable the GPU frame time capture
  125228. */
  125229. set captureGPUFrameTime(value: boolean);
  125230. /**
  125231. * Gets the perf counter used for shader compilation time
  125232. */
  125233. get shaderCompilationTimeCounter(): PerfCounter;
  125234. /**
  125235. * Gets the shader compilation time capture status
  125236. */
  125237. get captureShaderCompilationTime(): boolean;
  125238. /**
  125239. * Enable or disable the shader compilation time capture
  125240. */
  125241. set captureShaderCompilationTime(value: boolean);
  125242. /**
  125243. * Instantiates a new engine instrumentation.
  125244. * This class can be used to get instrumentation data from a Babylon engine
  125245. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125246. * @param engine Defines the engine to instrument
  125247. */
  125248. constructor(
  125249. /**
  125250. * Define the instrumented engine.
  125251. */
  125252. engine: Engine);
  125253. /**
  125254. * Dispose and release associated resources.
  125255. */
  125256. dispose(): void;
  125257. }
  125258. }
  125259. declare module BABYLON {
  125260. /**
  125261. * This class can be used to get instrumentation data from a Babylon engine
  125262. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125263. */
  125264. export class SceneInstrumentation implements IDisposable {
  125265. /**
  125266. * Defines the scene to instrument
  125267. */
  125268. scene: Scene;
  125269. private _captureActiveMeshesEvaluationTime;
  125270. private _activeMeshesEvaluationTime;
  125271. private _captureRenderTargetsRenderTime;
  125272. private _renderTargetsRenderTime;
  125273. private _captureFrameTime;
  125274. private _frameTime;
  125275. private _captureRenderTime;
  125276. private _renderTime;
  125277. private _captureInterFrameTime;
  125278. private _interFrameTime;
  125279. private _captureParticlesRenderTime;
  125280. private _particlesRenderTime;
  125281. private _captureSpritesRenderTime;
  125282. private _spritesRenderTime;
  125283. private _capturePhysicsTime;
  125284. private _physicsTime;
  125285. private _captureAnimationsTime;
  125286. private _animationsTime;
  125287. private _captureCameraRenderTime;
  125288. private _cameraRenderTime;
  125289. private _onBeforeActiveMeshesEvaluationObserver;
  125290. private _onAfterActiveMeshesEvaluationObserver;
  125291. private _onBeforeRenderTargetsRenderObserver;
  125292. private _onAfterRenderTargetsRenderObserver;
  125293. private _onAfterRenderObserver;
  125294. private _onBeforeDrawPhaseObserver;
  125295. private _onAfterDrawPhaseObserver;
  125296. private _onBeforeAnimationsObserver;
  125297. private _onBeforeParticlesRenderingObserver;
  125298. private _onAfterParticlesRenderingObserver;
  125299. private _onBeforeSpritesRenderingObserver;
  125300. private _onAfterSpritesRenderingObserver;
  125301. private _onBeforePhysicsObserver;
  125302. private _onAfterPhysicsObserver;
  125303. private _onAfterAnimationsObserver;
  125304. private _onBeforeCameraRenderObserver;
  125305. private _onAfterCameraRenderObserver;
  125306. /**
  125307. * Gets the perf counter used for active meshes evaluation time
  125308. */
  125309. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125310. /**
  125311. * Gets the active meshes evaluation time capture status
  125312. */
  125313. get captureActiveMeshesEvaluationTime(): boolean;
  125314. /**
  125315. * Enable or disable the active meshes evaluation time capture
  125316. */
  125317. set captureActiveMeshesEvaluationTime(value: boolean);
  125318. /**
  125319. * Gets the perf counter used for render targets render time
  125320. */
  125321. get renderTargetsRenderTimeCounter(): PerfCounter;
  125322. /**
  125323. * Gets the render targets render time capture status
  125324. */
  125325. get captureRenderTargetsRenderTime(): boolean;
  125326. /**
  125327. * Enable or disable the render targets render time capture
  125328. */
  125329. set captureRenderTargetsRenderTime(value: boolean);
  125330. /**
  125331. * Gets the perf counter used for particles render time
  125332. */
  125333. get particlesRenderTimeCounter(): PerfCounter;
  125334. /**
  125335. * Gets the particles render time capture status
  125336. */
  125337. get captureParticlesRenderTime(): boolean;
  125338. /**
  125339. * Enable or disable the particles render time capture
  125340. */
  125341. set captureParticlesRenderTime(value: boolean);
  125342. /**
  125343. * Gets the perf counter used for sprites render time
  125344. */
  125345. get spritesRenderTimeCounter(): PerfCounter;
  125346. /**
  125347. * Gets the sprites render time capture status
  125348. */
  125349. get captureSpritesRenderTime(): boolean;
  125350. /**
  125351. * Enable or disable the sprites render time capture
  125352. */
  125353. set captureSpritesRenderTime(value: boolean);
  125354. /**
  125355. * Gets the perf counter used for physics time
  125356. */
  125357. get physicsTimeCounter(): PerfCounter;
  125358. /**
  125359. * Gets the physics time capture status
  125360. */
  125361. get capturePhysicsTime(): boolean;
  125362. /**
  125363. * Enable or disable the physics time capture
  125364. */
  125365. set capturePhysicsTime(value: boolean);
  125366. /**
  125367. * Gets the perf counter used for animations time
  125368. */
  125369. get animationsTimeCounter(): PerfCounter;
  125370. /**
  125371. * Gets the animations time capture status
  125372. */
  125373. get captureAnimationsTime(): boolean;
  125374. /**
  125375. * Enable or disable the animations time capture
  125376. */
  125377. set captureAnimationsTime(value: boolean);
  125378. /**
  125379. * Gets the perf counter used for frame time capture
  125380. */
  125381. get frameTimeCounter(): PerfCounter;
  125382. /**
  125383. * Gets the frame time capture status
  125384. */
  125385. get captureFrameTime(): boolean;
  125386. /**
  125387. * Enable or disable the frame time capture
  125388. */
  125389. set captureFrameTime(value: boolean);
  125390. /**
  125391. * Gets the perf counter used for inter-frames time capture
  125392. */
  125393. get interFrameTimeCounter(): PerfCounter;
  125394. /**
  125395. * Gets the inter-frames time capture status
  125396. */
  125397. get captureInterFrameTime(): boolean;
  125398. /**
  125399. * Enable or disable the inter-frames time capture
  125400. */
  125401. set captureInterFrameTime(value: boolean);
  125402. /**
  125403. * Gets the perf counter used for render time capture
  125404. */
  125405. get renderTimeCounter(): PerfCounter;
  125406. /**
  125407. * Gets the render time capture status
  125408. */
  125409. get captureRenderTime(): boolean;
  125410. /**
  125411. * Enable or disable the render time capture
  125412. */
  125413. set captureRenderTime(value: boolean);
  125414. /**
  125415. * Gets the perf counter used for camera render time capture
  125416. */
  125417. get cameraRenderTimeCounter(): PerfCounter;
  125418. /**
  125419. * Gets the camera render time capture status
  125420. */
  125421. get captureCameraRenderTime(): boolean;
  125422. /**
  125423. * Enable or disable the camera render time capture
  125424. */
  125425. set captureCameraRenderTime(value: boolean);
  125426. /**
  125427. * Gets the perf counter used for draw calls
  125428. */
  125429. get drawCallsCounter(): PerfCounter;
  125430. /**
  125431. * Instantiates a new scene instrumentation.
  125432. * This class can be used to get instrumentation data from a Babylon engine
  125433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125434. * @param scene Defines the scene to instrument
  125435. */
  125436. constructor(
  125437. /**
  125438. * Defines the scene to instrument
  125439. */
  125440. scene: Scene);
  125441. /**
  125442. * Dispose and release associated resources.
  125443. */
  125444. dispose(): void;
  125445. }
  125446. }
  125447. declare module BABYLON {
  125448. /** @hidden */
  125449. export var glowMapGenerationPixelShader: {
  125450. name: string;
  125451. shader: string;
  125452. };
  125453. }
  125454. declare module BABYLON {
  125455. /** @hidden */
  125456. export var glowMapGenerationVertexShader: {
  125457. name: string;
  125458. shader: string;
  125459. };
  125460. }
  125461. declare module BABYLON {
  125462. /**
  125463. * Effect layer options. This helps customizing the behaviour
  125464. * of the effect layer.
  125465. */
  125466. export interface IEffectLayerOptions {
  125467. /**
  125468. * Multiplication factor apply to the canvas size to compute the render target size
  125469. * used to generated the objects (the smaller the faster).
  125470. */
  125471. mainTextureRatio: number;
  125472. /**
  125473. * Enforces a fixed size texture to ensure effect stability across devices.
  125474. */
  125475. mainTextureFixedSize?: number;
  125476. /**
  125477. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125478. */
  125479. alphaBlendingMode: number;
  125480. /**
  125481. * The camera attached to the layer.
  125482. */
  125483. camera: Nullable<Camera>;
  125484. /**
  125485. * The rendering group to draw the layer in.
  125486. */
  125487. renderingGroupId: number;
  125488. }
  125489. /**
  125490. * The effect layer Helps adding post process effect blended with the main pass.
  125491. *
  125492. * This can be for instance use to generate glow or higlight effects on the scene.
  125493. *
  125494. * The effect layer class can not be used directly and is intented to inherited from to be
  125495. * customized per effects.
  125496. */
  125497. export abstract class EffectLayer {
  125498. private _vertexBuffers;
  125499. private _indexBuffer;
  125500. private _cachedDefines;
  125501. private _effectLayerMapGenerationEffect;
  125502. private _effectLayerOptions;
  125503. private _mergeEffect;
  125504. protected _scene: Scene;
  125505. protected _engine: Engine;
  125506. protected _maxSize: number;
  125507. protected _mainTextureDesiredSize: ISize;
  125508. protected _mainTexture: RenderTargetTexture;
  125509. protected _shouldRender: boolean;
  125510. protected _postProcesses: PostProcess[];
  125511. protected _textures: BaseTexture[];
  125512. protected _emissiveTextureAndColor: {
  125513. texture: Nullable<BaseTexture>;
  125514. color: Color4;
  125515. };
  125516. /**
  125517. * The name of the layer
  125518. */
  125519. name: string;
  125520. /**
  125521. * The clear color of the texture used to generate the glow map.
  125522. */
  125523. neutralColor: Color4;
  125524. /**
  125525. * Specifies wether the highlight layer is enabled or not.
  125526. */
  125527. isEnabled: boolean;
  125528. /**
  125529. * Gets the camera attached to the layer.
  125530. */
  125531. get camera(): Nullable<Camera>;
  125532. /**
  125533. * Gets the rendering group id the layer should render in.
  125534. */
  125535. get renderingGroupId(): number;
  125536. set renderingGroupId(renderingGroupId: number);
  125537. /**
  125538. * An event triggered when the effect layer has been disposed.
  125539. */
  125540. onDisposeObservable: Observable<EffectLayer>;
  125541. /**
  125542. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125543. */
  125544. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125545. /**
  125546. * An event triggered when the generated texture is being merged in the scene.
  125547. */
  125548. onBeforeComposeObservable: Observable<EffectLayer>;
  125549. /**
  125550. * An event triggered when the mesh is rendered into the effect render target.
  125551. */
  125552. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125553. /**
  125554. * An event triggered after the mesh has been rendered into the effect render target.
  125555. */
  125556. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125557. /**
  125558. * An event triggered when the generated texture has been merged in the scene.
  125559. */
  125560. onAfterComposeObservable: Observable<EffectLayer>;
  125561. /**
  125562. * An event triggered when the efffect layer changes its size.
  125563. */
  125564. onSizeChangedObservable: Observable<EffectLayer>;
  125565. /** @hidden */
  125566. static _SceneComponentInitialization: (scene: Scene) => void;
  125567. /**
  125568. * Instantiates a new effect Layer and references it in the scene.
  125569. * @param name The name of the layer
  125570. * @param scene The scene to use the layer in
  125571. */
  125572. constructor(
  125573. /** The Friendly of the effect in the scene */
  125574. name: string, scene: Scene);
  125575. /**
  125576. * Get the effect name of the layer.
  125577. * @return The effect name
  125578. */
  125579. abstract getEffectName(): string;
  125580. /**
  125581. * Checks for the readiness of the element composing the layer.
  125582. * @param subMesh the mesh to check for
  125583. * @param useInstances specify wether or not to use instances to render the mesh
  125584. * @return true if ready otherwise, false
  125585. */
  125586. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125587. /**
  125588. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125589. * @returns true if the effect requires stencil during the main canvas render pass.
  125590. */
  125591. abstract needStencil(): boolean;
  125592. /**
  125593. * Create the merge effect. This is the shader use to blit the information back
  125594. * to the main canvas at the end of the scene rendering.
  125595. * @returns The effect containing the shader used to merge the effect on the main canvas
  125596. */
  125597. protected abstract _createMergeEffect(): Effect;
  125598. /**
  125599. * Creates the render target textures and post processes used in the effect layer.
  125600. */
  125601. protected abstract _createTextureAndPostProcesses(): void;
  125602. /**
  125603. * Implementation specific of rendering the generating effect on the main canvas.
  125604. * @param effect The effect used to render through
  125605. */
  125606. protected abstract _internalRender(effect: Effect): void;
  125607. /**
  125608. * Sets the required values for both the emissive texture and and the main color.
  125609. */
  125610. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125611. /**
  125612. * Free any resources and references associated to a mesh.
  125613. * Internal use
  125614. * @param mesh The mesh to free.
  125615. */
  125616. abstract _disposeMesh(mesh: Mesh): void;
  125617. /**
  125618. * Serializes this layer (Glow or Highlight for example)
  125619. * @returns a serialized layer object
  125620. */
  125621. abstract serialize?(): any;
  125622. /**
  125623. * Initializes the effect layer with the required options.
  125624. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125625. */
  125626. protected _init(options: Partial<IEffectLayerOptions>): void;
  125627. /**
  125628. * Generates the index buffer of the full screen quad blending to the main canvas.
  125629. */
  125630. private _generateIndexBuffer;
  125631. /**
  125632. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  125633. */
  125634. private _generateVertexBuffer;
  125635. /**
  125636. * Sets the main texture desired size which is the closest power of two
  125637. * of the engine canvas size.
  125638. */
  125639. private _setMainTextureSize;
  125640. /**
  125641. * Creates the main texture for the effect layer.
  125642. */
  125643. protected _createMainTexture(): void;
  125644. /**
  125645. * Adds specific effects defines.
  125646. * @param defines The defines to add specifics to.
  125647. */
  125648. protected _addCustomEffectDefines(defines: string[]): void;
  125649. /**
  125650. * Checks for the readiness of the element composing the layer.
  125651. * @param subMesh the mesh to check for
  125652. * @param useInstances specify wether or not to use instances to render the mesh
  125653. * @param emissiveTexture the associated emissive texture used to generate the glow
  125654. * @return true if ready otherwise, false
  125655. */
  125656. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  125657. /**
  125658. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  125659. */
  125660. render(): void;
  125661. /**
  125662. * Determine if a given mesh will be used in the current effect.
  125663. * @param mesh mesh to test
  125664. * @returns true if the mesh will be used
  125665. */
  125666. hasMesh(mesh: AbstractMesh): boolean;
  125667. /**
  125668. * Returns true if the layer contains information to display, otherwise false.
  125669. * @returns true if the glow layer should be rendered
  125670. */
  125671. shouldRender(): boolean;
  125672. /**
  125673. * Returns true if the mesh should render, otherwise false.
  125674. * @param mesh The mesh to render
  125675. * @returns true if it should render otherwise false
  125676. */
  125677. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  125678. /**
  125679. * Returns true if the mesh can be rendered, otherwise false.
  125680. * @param mesh The mesh to render
  125681. * @param material The material used on the mesh
  125682. * @returns true if it can be rendered otherwise false
  125683. */
  125684. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125685. /**
  125686. * Returns true if the mesh should render, otherwise false.
  125687. * @param mesh The mesh to render
  125688. * @returns true if it should render otherwise false
  125689. */
  125690. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  125691. /**
  125692. * Renders the submesh passed in parameter to the generation map.
  125693. */
  125694. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  125695. /**
  125696. * Defines wether the current material of the mesh should be use to render the effect.
  125697. * @param mesh defines the current mesh to render
  125698. */
  125699. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125700. /**
  125701. * Rebuild the required buffers.
  125702. * @hidden Internal use only.
  125703. */
  125704. _rebuild(): void;
  125705. /**
  125706. * Dispose only the render target textures and post process.
  125707. */
  125708. private _disposeTextureAndPostProcesses;
  125709. /**
  125710. * Dispose the highlight layer and free resources.
  125711. */
  125712. dispose(): void;
  125713. /**
  125714. * Gets the class name of the effect layer
  125715. * @returns the string with the class name of the effect layer
  125716. */
  125717. getClassName(): string;
  125718. /**
  125719. * Creates an effect layer from parsed effect layer data
  125720. * @param parsedEffectLayer defines effect layer data
  125721. * @param scene defines the current scene
  125722. * @param rootUrl defines the root URL containing the effect layer information
  125723. * @returns a parsed effect Layer
  125724. */
  125725. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  125726. }
  125727. }
  125728. declare module BABYLON {
  125729. interface AbstractScene {
  125730. /**
  125731. * The list of effect layers (highlights/glow) added to the scene
  125732. * @see http://doc.babylonjs.com/how_to/highlight_layer
  125733. * @see http://doc.babylonjs.com/how_to/glow_layer
  125734. */
  125735. effectLayers: Array<EffectLayer>;
  125736. /**
  125737. * Removes the given effect layer from this scene.
  125738. * @param toRemove defines the effect layer to remove
  125739. * @returns the index of the removed effect layer
  125740. */
  125741. removeEffectLayer(toRemove: EffectLayer): number;
  125742. /**
  125743. * Adds the given effect layer to this scene
  125744. * @param newEffectLayer defines the effect layer to add
  125745. */
  125746. addEffectLayer(newEffectLayer: EffectLayer): void;
  125747. }
  125748. /**
  125749. * Defines the layer scene component responsible to manage any effect layers
  125750. * in a given scene.
  125751. */
  125752. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  125753. /**
  125754. * The component name helpfull to identify the component in the list of scene components.
  125755. */
  125756. readonly name: string;
  125757. /**
  125758. * The scene the component belongs to.
  125759. */
  125760. scene: Scene;
  125761. private _engine;
  125762. private _renderEffects;
  125763. private _needStencil;
  125764. private _previousStencilState;
  125765. /**
  125766. * Creates a new instance of the component for the given scene
  125767. * @param scene Defines the scene to register the component in
  125768. */
  125769. constructor(scene: Scene);
  125770. /**
  125771. * Registers the component in a given scene
  125772. */
  125773. register(): void;
  125774. /**
  125775. * Rebuilds the elements related to this component in case of
  125776. * context lost for instance.
  125777. */
  125778. rebuild(): void;
  125779. /**
  125780. * Serializes the component data to the specified json object
  125781. * @param serializationObject The object to serialize to
  125782. */
  125783. serialize(serializationObject: any): void;
  125784. /**
  125785. * Adds all the elements from the container to the scene
  125786. * @param container the container holding the elements
  125787. */
  125788. addFromContainer(container: AbstractScene): void;
  125789. /**
  125790. * Removes all the elements in the container from the scene
  125791. * @param container contains the elements to remove
  125792. * @param dispose if the removed element should be disposed (default: false)
  125793. */
  125794. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125795. /**
  125796. * Disposes the component and the associated ressources.
  125797. */
  125798. dispose(): void;
  125799. private _isReadyForMesh;
  125800. private _renderMainTexture;
  125801. private _setStencil;
  125802. private _setStencilBack;
  125803. private _draw;
  125804. private _drawCamera;
  125805. private _drawRenderingGroup;
  125806. }
  125807. }
  125808. declare module BABYLON {
  125809. /** @hidden */
  125810. export var glowMapMergePixelShader: {
  125811. name: string;
  125812. shader: string;
  125813. };
  125814. }
  125815. declare module BABYLON {
  125816. /** @hidden */
  125817. export var glowMapMergeVertexShader: {
  125818. name: string;
  125819. shader: string;
  125820. };
  125821. }
  125822. declare module BABYLON {
  125823. interface AbstractScene {
  125824. /**
  125825. * Return a the first highlight layer of the scene with a given name.
  125826. * @param name The name of the highlight layer to look for.
  125827. * @return The highlight layer if found otherwise null.
  125828. */
  125829. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  125830. }
  125831. /**
  125832. * Glow layer options. This helps customizing the behaviour
  125833. * of the glow layer.
  125834. */
  125835. export interface IGlowLayerOptions {
  125836. /**
  125837. * Multiplication factor apply to the canvas size to compute the render target size
  125838. * used to generated the glowing objects (the smaller the faster).
  125839. */
  125840. mainTextureRatio: number;
  125841. /**
  125842. * Enforces a fixed size texture to ensure resize independant blur.
  125843. */
  125844. mainTextureFixedSize?: number;
  125845. /**
  125846. * How big is the kernel of the blur texture.
  125847. */
  125848. blurKernelSize: number;
  125849. /**
  125850. * The camera attached to the layer.
  125851. */
  125852. camera: Nullable<Camera>;
  125853. /**
  125854. * Enable MSAA by chosing the number of samples.
  125855. */
  125856. mainTextureSamples?: number;
  125857. /**
  125858. * The rendering group to draw the layer in.
  125859. */
  125860. renderingGroupId: number;
  125861. }
  125862. /**
  125863. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  125864. *
  125865. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  125866. *
  125867. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  125868. */
  125869. export class GlowLayer extends EffectLayer {
  125870. /**
  125871. * Effect Name of the layer.
  125872. */
  125873. static readonly EffectName: string;
  125874. /**
  125875. * The default blur kernel size used for the glow.
  125876. */
  125877. static DefaultBlurKernelSize: number;
  125878. /**
  125879. * The default texture size ratio used for the glow.
  125880. */
  125881. static DefaultTextureRatio: number;
  125882. /**
  125883. * Sets the kernel size of the blur.
  125884. */
  125885. set blurKernelSize(value: number);
  125886. /**
  125887. * Gets the kernel size of the blur.
  125888. */
  125889. get blurKernelSize(): number;
  125890. /**
  125891. * Sets the glow intensity.
  125892. */
  125893. set intensity(value: number);
  125894. /**
  125895. * Gets the glow intensity.
  125896. */
  125897. get intensity(): number;
  125898. private _options;
  125899. private _intensity;
  125900. private _horizontalBlurPostprocess1;
  125901. private _verticalBlurPostprocess1;
  125902. private _horizontalBlurPostprocess2;
  125903. private _verticalBlurPostprocess2;
  125904. private _blurTexture1;
  125905. private _blurTexture2;
  125906. private _postProcesses1;
  125907. private _postProcesses2;
  125908. private _includedOnlyMeshes;
  125909. private _excludedMeshes;
  125910. private _meshesUsingTheirOwnMaterials;
  125911. /**
  125912. * Callback used to let the user override the color selection on a per mesh basis
  125913. */
  125914. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  125915. /**
  125916. * Callback used to let the user override the texture selection on a per mesh basis
  125917. */
  125918. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  125919. /**
  125920. * Instantiates a new glow Layer and references it to the scene.
  125921. * @param name The name of the layer
  125922. * @param scene The scene to use the layer in
  125923. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  125924. */
  125925. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  125926. /**
  125927. * Get the effect name of the layer.
  125928. * @return The effect name
  125929. */
  125930. getEffectName(): string;
  125931. /**
  125932. * Create the merge effect. This is the shader use to blit the information back
  125933. * to the main canvas at the end of the scene rendering.
  125934. */
  125935. protected _createMergeEffect(): Effect;
  125936. /**
  125937. * Creates the render target textures and post processes used in the glow layer.
  125938. */
  125939. protected _createTextureAndPostProcesses(): void;
  125940. /**
  125941. * Checks for the readiness of the element composing the layer.
  125942. * @param subMesh the mesh to check for
  125943. * @param useInstances specify wether or not to use instances to render the mesh
  125944. * @param emissiveTexture the associated emissive texture used to generate the glow
  125945. * @return true if ready otherwise, false
  125946. */
  125947. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125948. /**
  125949. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125950. */
  125951. needStencil(): boolean;
  125952. /**
  125953. * Returns true if the mesh can be rendered, otherwise false.
  125954. * @param mesh The mesh to render
  125955. * @param material The material used on the mesh
  125956. * @returns true if it can be rendered otherwise false
  125957. */
  125958. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125959. /**
  125960. * Implementation specific of rendering the generating effect on the main canvas.
  125961. * @param effect The effect used to render through
  125962. */
  125963. protected _internalRender(effect: Effect): void;
  125964. /**
  125965. * Sets the required values for both the emissive texture and and the main color.
  125966. */
  125967. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125968. /**
  125969. * Returns true if the mesh should render, otherwise false.
  125970. * @param mesh The mesh to render
  125971. * @returns true if it should render otherwise false
  125972. */
  125973. protected _shouldRenderMesh(mesh: Mesh): boolean;
  125974. /**
  125975. * Adds specific effects defines.
  125976. * @param defines The defines to add specifics to.
  125977. */
  125978. protected _addCustomEffectDefines(defines: string[]): void;
  125979. /**
  125980. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  125981. * @param mesh The mesh to exclude from the glow layer
  125982. */
  125983. addExcludedMesh(mesh: Mesh): void;
  125984. /**
  125985. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  125986. * @param mesh The mesh to remove
  125987. */
  125988. removeExcludedMesh(mesh: Mesh): void;
  125989. /**
  125990. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  125991. * @param mesh The mesh to include in the glow layer
  125992. */
  125993. addIncludedOnlyMesh(mesh: Mesh): void;
  125994. /**
  125995. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  125996. * @param mesh The mesh to remove
  125997. */
  125998. removeIncludedOnlyMesh(mesh: Mesh): void;
  125999. /**
  126000. * Determine if a given mesh will be used in the glow layer
  126001. * @param mesh The mesh to test
  126002. * @returns true if the mesh will be highlighted by the current glow layer
  126003. */
  126004. hasMesh(mesh: AbstractMesh): boolean;
  126005. /**
  126006. * Defines wether the current material of the mesh should be use to render the effect.
  126007. * @param mesh defines the current mesh to render
  126008. */
  126009. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126010. /**
  126011. * Add a mesh to be rendered through its own material and not with emissive only.
  126012. * @param mesh The mesh for which we need to use its material
  126013. */
  126014. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126015. /**
  126016. * Remove a mesh from being rendered through its own material and not with emissive only.
  126017. * @param mesh The mesh for which we need to not use its material
  126018. */
  126019. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126020. /**
  126021. * Free any resources and references associated to a mesh.
  126022. * Internal use
  126023. * @param mesh The mesh to free.
  126024. * @hidden
  126025. */
  126026. _disposeMesh(mesh: Mesh): void;
  126027. /**
  126028. * Gets the class name of the effect layer
  126029. * @returns the string with the class name of the effect layer
  126030. */
  126031. getClassName(): string;
  126032. /**
  126033. * Serializes this glow layer
  126034. * @returns a serialized glow layer object
  126035. */
  126036. serialize(): any;
  126037. /**
  126038. * Creates a Glow Layer from parsed glow layer data
  126039. * @param parsedGlowLayer defines glow layer data
  126040. * @param scene defines the current scene
  126041. * @param rootUrl defines the root URL containing the glow layer information
  126042. * @returns a parsed Glow Layer
  126043. */
  126044. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126045. }
  126046. }
  126047. declare module BABYLON {
  126048. /** @hidden */
  126049. export var glowBlurPostProcessPixelShader: {
  126050. name: string;
  126051. shader: string;
  126052. };
  126053. }
  126054. declare module BABYLON {
  126055. interface AbstractScene {
  126056. /**
  126057. * Return a the first highlight layer of the scene with a given name.
  126058. * @param name The name of the highlight layer to look for.
  126059. * @return The highlight layer if found otherwise null.
  126060. */
  126061. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126062. }
  126063. /**
  126064. * Highlight layer options. This helps customizing the behaviour
  126065. * of the highlight layer.
  126066. */
  126067. export interface IHighlightLayerOptions {
  126068. /**
  126069. * Multiplication factor apply to the canvas size to compute the render target size
  126070. * used to generated the glowing objects (the smaller the faster).
  126071. */
  126072. mainTextureRatio: number;
  126073. /**
  126074. * Enforces a fixed size texture to ensure resize independant blur.
  126075. */
  126076. mainTextureFixedSize?: number;
  126077. /**
  126078. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126079. * of the picture to blur (the smaller the faster).
  126080. */
  126081. blurTextureSizeRatio: number;
  126082. /**
  126083. * How big in texel of the blur texture is the vertical blur.
  126084. */
  126085. blurVerticalSize: number;
  126086. /**
  126087. * How big in texel of the blur texture is the horizontal blur.
  126088. */
  126089. blurHorizontalSize: number;
  126090. /**
  126091. * Alpha blending mode used to apply the blur. Default is combine.
  126092. */
  126093. alphaBlendingMode: number;
  126094. /**
  126095. * The camera attached to the layer.
  126096. */
  126097. camera: Nullable<Camera>;
  126098. /**
  126099. * Should we display highlight as a solid stroke?
  126100. */
  126101. isStroke?: boolean;
  126102. /**
  126103. * The rendering group to draw the layer in.
  126104. */
  126105. renderingGroupId: number;
  126106. }
  126107. /**
  126108. * The highlight layer Helps adding a glow effect around a mesh.
  126109. *
  126110. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126111. * glowy meshes to your scene.
  126112. *
  126113. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126114. */
  126115. export class HighlightLayer extends EffectLayer {
  126116. name: string;
  126117. /**
  126118. * Effect Name of the highlight layer.
  126119. */
  126120. static readonly EffectName: string;
  126121. /**
  126122. * The neutral color used during the preparation of the glow effect.
  126123. * This is black by default as the blend operation is a blend operation.
  126124. */
  126125. static NeutralColor: Color4;
  126126. /**
  126127. * Stencil value used for glowing meshes.
  126128. */
  126129. static GlowingMeshStencilReference: number;
  126130. /**
  126131. * Stencil value used for the other meshes in the scene.
  126132. */
  126133. static NormalMeshStencilReference: number;
  126134. /**
  126135. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126136. */
  126137. innerGlow: boolean;
  126138. /**
  126139. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126140. */
  126141. outerGlow: boolean;
  126142. /**
  126143. * Specifies the horizontal size of the blur.
  126144. */
  126145. set blurHorizontalSize(value: number);
  126146. /**
  126147. * Specifies the vertical size of the blur.
  126148. */
  126149. set blurVerticalSize(value: number);
  126150. /**
  126151. * Gets the horizontal size of the blur.
  126152. */
  126153. get blurHorizontalSize(): number;
  126154. /**
  126155. * Gets the vertical size of the blur.
  126156. */
  126157. get blurVerticalSize(): number;
  126158. /**
  126159. * An event triggered when the highlight layer is being blurred.
  126160. */
  126161. onBeforeBlurObservable: Observable<HighlightLayer>;
  126162. /**
  126163. * An event triggered when the highlight layer has been blurred.
  126164. */
  126165. onAfterBlurObservable: Observable<HighlightLayer>;
  126166. private _instanceGlowingMeshStencilReference;
  126167. private _options;
  126168. private _downSamplePostprocess;
  126169. private _horizontalBlurPostprocess;
  126170. private _verticalBlurPostprocess;
  126171. private _blurTexture;
  126172. private _meshes;
  126173. private _excludedMeshes;
  126174. /**
  126175. * Instantiates a new highlight Layer and references it to the scene..
  126176. * @param name The name of the layer
  126177. * @param scene The scene to use the layer in
  126178. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126179. */
  126180. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126181. /**
  126182. * Get the effect name of the layer.
  126183. * @return The effect name
  126184. */
  126185. getEffectName(): string;
  126186. /**
  126187. * Create the merge effect. This is the shader use to blit the information back
  126188. * to the main canvas at the end of the scene rendering.
  126189. */
  126190. protected _createMergeEffect(): Effect;
  126191. /**
  126192. * Creates the render target textures and post processes used in the highlight layer.
  126193. */
  126194. protected _createTextureAndPostProcesses(): void;
  126195. /**
  126196. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126197. */
  126198. needStencil(): boolean;
  126199. /**
  126200. * Checks for the readiness of the element composing the layer.
  126201. * @param subMesh the mesh to check for
  126202. * @param useInstances specify wether or not to use instances to render the mesh
  126203. * @param emissiveTexture the associated emissive texture used to generate the glow
  126204. * @return true if ready otherwise, false
  126205. */
  126206. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126207. /**
  126208. * Implementation specific of rendering the generating effect on the main canvas.
  126209. * @param effect The effect used to render through
  126210. */
  126211. protected _internalRender(effect: Effect): void;
  126212. /**
  126213. * Returns true if the layer contains information to display, otherwise false.
  126214. */
  126215. shouldRender(): boolean;
  126216. /**
  126217. * Returns true if the mesh should render, otherwise false.
  126218. * @param mesh The mesh to render
  126219. * @returns true if it should render otherwise false
  126220. */
  126221. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126222. /**
  126223. * Sets the required values for both the emissive texture and and the main color.
  126224. */
  126225. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126226. /**
  126227. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126228. * @param mesh The mesh to exclude from the highlight layer
  126229. */
  126230. addExcludedMesh(mesh: Mesh): void;
  126231. /**
  126232. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126233. * @param mesh The mesh to highlight
  126234. */
  126235. removeExcludedMesh(mesh: Mesh): void;
  126236. /**
  126237. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126238. * @param mesh mesh to test
  126239. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126240. */
  126241. hasMesh(mesh: AbstractMesh): boolean;
  126242. /**
  126243. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126244. * @param mesh The mesh to highlight
  126245. * @param color The color of the highlight
  126246. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126247. */
  126248. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126249. /**
  126250. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126251. * @param mesh The mesh to highlight
  126252. */
  126253. removeMesh(mesh: Mesh): void;
  126254. /**
  126255. * Force the stencil to the normal expected value for none glowing parts
  126256. */
  126257. private _defaultStencilReference;
  126258. /**
  126259. * Free any resources and references associated to a mesh.
  126260. * Internal use
  126261. * @param mesh The mesh to free.
  126262. * @hidden
  126263. */
  126264. _disposeMesh(mesh: Mesh): void;
  126265. /**
  126266. * Dispose the highlight layer and free resources.
  126267. */
  126268. dispose(): void;
  126269. /**
  126270. * Gets the class name of the effect layer
  126271. * @returns the string with the class name of the effect layer
  126272. */
  126273. getClassName(): string;
  126274. /**
  126275. * Serializes this Highlight layer
  126276. * @returns a serialized Highlight layer object
  126277. */
  126278. serialize(): any;
  126279. /**
  126280. * Creates a Highlight layer from parsed Highlight layer data
  126281. * @param parsedHightlightLayer defines the Highlight layer data
  126282. * @param scene defines the current scene
  126283. * @param rootUrl defines the root URL containing the Highlight layer information
  126284. * @returns a parsed Highlight layer
  126285. */
  126286. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126287. }
  126288. }
  126289. declare module BABYLON {
  126290. interface AbstractScene {
  126291. /**
  126292. * The list of layers (background and foreground) of the scene
  126293. */
  126294. layers: Array<Layer>;
  126295. }
  126296. /**
  126297. * Defines the layer scene component responsible to manage any layers
  126298. * in a given scene.
  126299. */
  126300. export class LayerSceneComponent implements ISceneComponent {
  126301. /**
  126302. * The component name helpfull to identify the component in the list of scene components.
  126303. */
  126304. readonly name: string;
  126305. /**
  126306. * The scene the component belongs to.
  126307. */
  126308. scene: Scene;
  126309. private _engine;
  126310. /**
  126311. * Creates a new instance of the component for the given scene
  126312. * @param scene Defines the scene to register the component in
  126313. */
  126314. constructor(scene: Scene);
  126315. /**
  126316. * Registers the component in a given scene
  126317. */
  126318. register(): void;
  126319. /**
  126320. * Rebuilds the elements related to this component in case of
  126321. * context lost for instance.
  126322. */
  126323. rebuild(): void;
  126324. /**
  126325. * Disposes the component and the associated ressources.
  126326. */
  126327. dispose(): void;
  126328. private _draw;
  126329. private _drawCameraPredicate;
  126330. private _drawCameraBackground;
  126331. private _drawCameraForeground;
  126332. private _drawRenderTargetPredicate;
  126333. private _drawRenderTargetBackground;
  126334. private _drawRenderTargetForeground;
  126335. /**
  126336. * Adds all the elements from the container to the scene
  126337. * @param container the container holding the elements
  126338. */
  126339. addFromContainer(container: AbstractScene): void;
  126340. /**
  126341. * Removes all the elements in the container from the scene
  126342. * @param container contains the elements to remove
  126343. * @param dispose if the removed element should be disposed (default: false)
  126344. */
  126345. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126346. }
  126347. }
  126348. declare module BABYLON {
  126349. /** @hidden */
  126350. export var layerPixelShader: {
  126351. name: string;
  126352. shader: string;
  126353. };
  126354. }
  126355. declare module BABYLON {
  126356. /** @hidden */
  126357. export var layerVertexShader: {
  126358. name: string;
  126359. shader: string;
  126360. };
  126361. }
  126362. declare module BABYLON {
  126363. /**
  126364. * This represents a full screen 2d layer.
  126365. * This can be useful to display a picture in the background of your scene for instance.
  126366. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126367. */
  126368. export class Layer {
  126369. /**
  126370. * Define the name of the layer.
  126371. */
  126372. name: string;
  126373. /**
  126374. * Define the texture the layer should display.
  126375. */
  126376. texture: Nullable<Texture>;
  126377. /**
  126378. * Is the layer in background or foreground.
  126379. */
  126380. isBackground: boolean;
  126381. /**
  126382. * Define the color of the layer (instead of texture).
  126383. */
  126384. color: Color4;
  126385. /**
  126386. * Define the scale of the layer in order to zoom in out of the texture.
  126387. */
  126388. scale: Vector2;
  126389. /**
  126390. * Define an offset for the layer in order to shift the texture.
  126391. */
  126392. offset: Vector2;
  126393. /**
  126394. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126395. */
  126396. alphaBlendingMode: number;
  126397. /**
  126398. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126399. * Alpha test will not mix with the background color in case of transparency.
  126400. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126401. */
  126402. alphaTest: boolean;
  126403. /**
  126404. * Define a mask to restrict the layer to only some of the scene cameras.
  126405. */
  126406. layerMask: number;
  126407. /**
  126408. * Define the list of render target the layer is visible into.
  126409. */
  126410. renderTargetTextures: RenderTargetTexture[];
  126411. /**
  126412. * Define if the layer is only used in renderTarget or if it also
  126413. * renders in the main frame buffer of the canvas.
  126414. */
  126415. renderOnlyInRenderTargetTextures: boolean;
  126416. private _scene;
  126417. private _vertexBuffers;
  126418. private _indexBuffer;
  126419. private _effect;
  126420. private _previousDefines;
  126421. /**
  126422. * An event triggered when the layer is disposed.
  126423. */
  126424. onDisposeObservable: Observable<Layer>;
  126425. private _onDisposeObserver;
  126426. /**
  126427. * Back compatibility with callback before the onDisposeObservable existed.
  126428. * The set callback will be triggered when the layer has been disposed.
  126429. */
  126430. set onDispose(callback: () => void);
  126431. /**
  126432. * An event triggered before rendering the scene
  126433. */
  126434. onBeforeRenderObservable: Observable<Layer>;
  126435. private _onBeforeRenderObserver;
  126436. /**
  126437. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126438. * The set callback will be triggered just before rendering the layer.
  126439. */
  126440. set onBeforeRender(callback: () => void);
  126441. /**
  126442. * An event triggered after rendering the scene
  126443. */
  126444. onAfterRenderObservable: Observable<Layer>;
  126445. private _onAfterRenderObserver;
  126446. /**
  126447. * Back compatibility with callback before the onAfterRenderObservable existed.
  126448. * The set callback will be triggered just after rendering the layer.
  126449. */
  126450. set onAfterRender(callback: () => void);
  126451. /**
  126452. * Instantiates a new layer.
  126453. * This represents a full screen 2d layer.
  126454. * This can be useful to display a picture in the background of your scene for instance.
  126455. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126456. * @param name Define the name of the layer in the scene
  126457. * @param imgUrl Define the url of the texture to display in the layer
  126458. * @param scene Define the scene the layer belongs to
  126459. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126460. * @param color Defines a color for the layer
  126461. */
  126462. constructor(
  126463. /**
  126464. * Define the name of the layer.
  126465. */
  126466. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126467. private _createIndexBuffer;
  126468. /** @hidden */
  126469. _rebuild(): void;
  126470. /**
  126471. * Renders the layer in the scene.
  126472. */
  126473. render(): void;
  126474. /**
  126475. * Disposes and releases the associated ressources.
  126476. */
  126477. dispose(): void;
  126478. }
  126479. }
  126480. declare module BABYLON {
  126481. /** @hidden */
  126482. export var lensFlarePixelShader: {
  126483. name: string;
  126484. shader: string;
  126485. };
  126486. }
  126487. declare module BABYLON {
  126488. /** @hidden */
  126489. export var lensFlareVertexShader: {
  126490. name: string;
  126491. shader: string;
  126492. };
  126493. }
  126494. declare module BABYLON {
  126495. /**
  126496. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126497. * It is usually composed of several `lensFlare`.
  126498. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126499. */
  126500. export class LensFlareSystem {
  126501. /**
  126502. * Define the name of the lens flare system
  126503. */
  126504. name: string;
  126505. /**
  126506. * List of lens flares used in this system.
  126507. */
  126508. lensFlares: LensFlare[];
  126509. /**
  126510. * Define a limit from the border the lens flare can be visible.
  126511. */
  126512. borderLimit: number;
  126513. /**
  126514. * Define a viewport border we do not want to see the lens flare in.
  126515. */
  126516. viewportBorder: number;
  126517. /**
  126518. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126519. */
  126520. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126521. /**
  126522. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126523. */
  126524. layerMask: number;
  126525. /**
  126526. * Define the id of the lens flare system in the scene.
  126527. * (equal to name by default)
  126528. */
  126529. id: string;
  126530. private _scene;
  126531. private _emitter;
  126532. private _vertexBuffers;
  126533. private _indexBuffer;
  126534. private _effect;
  126535. private _positionX;
  126536. private _positionY;
  126537. private _isEnabled;
  126538. /** @hidden */
  126539. static _SceneComponentInitialization: (scene: Scene) => void;
  126540. /**
  126541. * Instantiates a lens flare system.
  126542. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126543. * It is usually composed of several `lensFlare`.
  126544. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126545. * @param name Define the name of the lens flare system in the scene
  126546. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126547. * @param scene Define the scene the lens flare system belongs to
  126548. */
  126549. constructor(
  126550. /**
  126551. * Define the name of the lens flare system
  126552. */
  126553. name: string, emitter: any, scene: Scene);
  126554. /**
  126555. * Define if the lens flare system is enabled.
  126556. */
  126557. get isEnabled(): boolean;
  126558. set isEnabled(value: boolean);
  126559. /**
  126560. * Get the scene the effects belongs to.
  126561. * @returns the scene holding the lens flare system
  126562. */
  126563. getScene(): Scene;
  126564. /**
  126565. * Get the emitter of the lens flare system.
  126566. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126567. * @returns the emitter of the lens flare system
  126568. */
  126569. getEmitter(): any;
  126570. /**
  126571. * Set the emitter of the lens flare system.
  126572. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126573. * @param newEmitter Define the new emitter of the system
  126574. */
  126575. setEmitter(newEmitter: any): void;
  126576. /**
  126577. * Get the lens flare system emitter position.
  126578. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126579. * @returns the position
  126580. */
  126581. getEmitterPosition(): Vector3;
  126582. /**
  126583. * @hidden
  126584. */
  126585. computeEffectivePosition(globalViewport: Viewport): boolean;
  126586. /** @hidden */
  126587. _isVisible(): boolean;
  126588. /**
  126589. * @hidden
  126590. */
  126591. render(): boolean;
  126592. /**
  126593. * Dispose and release the lens flare with its associated resources.
  126594. */
  126595. dispose(): void;
  126596. /**
  126597. * Parse a lens flare system from a JSON repressentation
  126598. * @param parsedLensFlareSystem Define the JSON to parse
  126599. * @param scene Define the scene the parsed system should be instantiated in
  126600. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126601. * @returns the parsed system
  126602. */
  126603. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126604. /**
  126605. * Serialize the current Lens Flare System into a JSON representation.
  126606. * @returns the serialized JSON
  126607. */
  126608. serialize(): any;
  126609. }
  126610. }
  126611. declare module BABYLON {
  126612. /**
  126613. * This represents one of the lens effect in a `lensFlareSystem`.
  126614. * It controls one of the indiviual texture used in the effect.
  126615. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126616. */
  126617. export class LensFlare {
  126618. /**
  126619. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126620. */
  126621. size: number;
  126622. /**
  126623. * 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.
  126624. */
  126625. position: number;
  126626. /**
  126627. * Define the lens color.
  126628. */
  126629. color: Color3;
  126630. /**
  126631. * Define the lens texture.
  126632. */
  126633. texture: Nullable<Texture>;
  126634. /**
  126635. * Define the alpha mode to render this particular lens.
  126636. */
  126637. alphaMode: number;
  126638. private _system;
  126639. /**
  126640. * Creates a new Lens Flare.
  126641. * This represents one of the lens effect in a `lensFlareSystem`.
  126642. * It controls one of the indiviual texture used in the effect.
  126643. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126644. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  126645. * @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.
  126646. * @param color Define the lens color
  126647. * @param imgUrl Define the lens texture url
  126648. * @param system Define the `lensFlareSystem` this flare is part of
  126649. * @returns The newly created Lens Flare
  126650. */
  126651. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  126652. /**
  126653. * Instantiates a new Lens Flare.
  126654. * This represents one of the lens effect in a `lensFlareSystem`.
  126655. * It controls one of the indiviual texture used in the effect.
  126656. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126657. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  126658. * @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.
  126659. * @param color Define the lens color
  126660. * @param imgUrl Define the lens texture url
  126661. * @param system Define the `lensFlareSystem` this flare is part of
  126662. */
  126663. constructor(
  126664. /**
  126665. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126666. */
  126667. size: number,
  126668. /**
  126669. * 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.
  126670. */
  126671. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  126672. /**
  126673. * Dispose and release the lens flare with its associated resources.
  126674. */
  126675. dispose(): void;
  126676. }
  126677. }
  126678. declare module BABYLON {
  126679. interface AbstractScene {
  126680. /**
  126681. * The list of lens flare system added to the scene
  126682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126683. */
  126684. lensFlareSystems: Array<LensFlareSystem>;
  126685. /**
  126686. * Removes the given lens flare system from this scene.
  126687. * @param toRemove The lens flare system to remove
  126688. * @returns The index of the removed lens flare system
  126689. */
  126690. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  126691. /**
  126692. * Adds the given lens flare system to this scene
  126693. * @param newLensFlareSystem The lens flare system to add
  126694. */
  126695. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  126696. /**
  126697. * Gets a lens flare system using its name
  126698. * @param name defines the name to look for
  126699. * @returns the lens flare system or null if not found
  126700. */
  126701. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  126702. /**
  126703. * Gets a lens flare system using its id
  126704. * @param id defines the id to look for
  126705. * @returns the lens flare system or null if not found
  126706. */
  126707. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  126708. }
  126709. /**
  126710. * Defines the lens flare scene component responsible to manage any lens flares
  126711. * in a given scene.
  126712. */
  126713. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  126714. /**
  126715. * The component name helpfull to identify the component in the list of scene components.
  126716. */
  126717. readonly name: string;
  126718. /**
  126719. * The scene the component belongs to.
  126720. */
  126721. scene: Scene;
  126722. /**
  126723. * Creates a new instance of the component for the given scene
  126724. * @param scene Defines the scene to register the component in
  126725. */
  126726. constructor(scene: Scene);
  126727. /**
  126728. * Registers the component in a given scene
  126729. */
  126730. register(): void;
  126731. /**
  126732. * Rebuilds the elements related to this component in case of
  126733. * context lost for instance.
  126734. */
  126735. rebuild(): void;
  126736. /**
  126737. * Adds all the elements from the container to the scene
  126738. * @param container the container holding the elements
  126739. */
  126740. addFromContainer(container: AbstractScene): void;
  126741. /**
  126742. * Removes all the elements in the container from the scene
  126743. * @param container contains the elements to remove
  126744. * @param dispose if the removed element should be disposed (default: false)
  126745. */
  126746. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126747. /**
  126748. * Serializes the component data to the specified json object
  126749. * @param serializationObject The object to serialize to
  126750. */
  126751. serialize(serializationObject: any): void;
  126752. /**
  126753. * Disposes the component and the associated ressources.
  126754. */
  126755. dispose(): void;
  126756. private _draw;
  126757. }
  126758. }
  126759. declare module BABYLON {
  126760. /** @hidden */
  126761. export var depthPixelShader: {
  126762. name: string;
  126763. shader: string;
  126764. };
  126765. }
  126766. declare module BABYLON {
  126767. /** @hidden */
  126768. export var depthVertexShader: {
  126769. name: string;
  126770. shader: string;
  126771. };
  126772. }
  126773. declare module BABYLON {
  126774. /**
  126775. * This represents a depth renderer in Babylon.
  126776. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126777. */
  126778. export class DepthRenderer {
  126779. private _scene;
  126780. private _depthMap;
  126781. private _effect;
  126782. private readonly _storeNonLinearDepth;
  126783. private readonly _clearColor;
  126784. /** Get if the depth renderer is using packed depth or not */
  126785. readonly isPacked: boolean;
  126786. private _cachedDefines;
  126787. private _camera;
  126788. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  126789. enabled: boolean;
  126790. /**
  126791. * Specifiess that the depth renderer will only be used within
  126792. * the camera it is created for.
  126793. * This can help forcing its rendering during the camera processing.
  126794. */
  126795. useOnlyInActiveCamera: boolean;
  126796. /** @hidden */
  126797. static _SceneComponentInitialization: (scene: Scene) => void;
  126798. /**
  126799. * Instantiates a depth renderer
  126800. * @param scene The scene the renderer belongs to
  126801. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126802. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126803. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126804. */
  126805. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126806. /**
  126807. * Creates the depth rendering effect and checks if the effect is ready.
  126808. * @param subMesh The submesh to be used to render the depth map of
  126809. * @param useInstances If multiple world instances should be used
  126810. * @returns if the depth renderer is ready to render the depth map
  126811. */
  126812. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126813. /**
  126814. * Gets the texture which the depth map will be written to.
  126815. * @returns The depth map texture
  126816. */
  126817. getDepthMap(): RenderTargetTexture;
  126818. /**
  126819. * Disposes of the depth renderer.
  126820. */
  126821. dispose(): void;
  126822. }
  126823. }
  126824. declare module BABYLON {
  126825. /** @hidden */
  126826. export var minmaxReduxPixelShader: {
  126827. name: string;
  126828. shader: string;
  126829. };
  126830. }
  126831. declare module BABYLON {
  126832. /**
  126833. * This class computes a min/max reduction from a texture: it means it computes the minimum
  126834. * and maximum values from all values of the texture.
  126835. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  126836. * The source values are read from the red channel of the texture.
  126837. */
  126838. export class MinMaxReducer {
  126839. /**
  126840. * Observable triggered when the computation has been performed
  126841. */
  126842. onAfterReductionPerformed: Observable<{
  126843. min: number;
  126844. max: number;
  126845. }>;
  126846. protected _camera: Camera;
  126847. protected _sourceTexture: Nullable<RenderTargetTexture>;
  126848. protected _reductionSteps: Nullable<Array<PostProcess>>;
  126849. protected _postProcessManager: PostProcessManager;
  126850. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  126851. protected _forceFullscreenViewport: boolean;
  126852. /**
  126853. * Creates a min/max reducer
  126854. * @param camera The camera to use for the post processes
  126855. */
  126856. constructor(camera: Camera);
  126857. /**
  126858. * Gets the texture used to read the values from.
  126859. */
  126860. get sourceTexture(): Nullable<RenderTargetTexture>;
  126861. /**
  126862. * Sets the source texture to read the values from.
  126863. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  126864. * because in such textures '1' value must not be taken into account to compute the maximum
  126865. * as this value is used to clear the texture.
  126866. * Note that the computation is not activated by calling this function, you must call activate() for that!
  126867. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  126868. * @param depthRedux Indicates if the texture is a depth texture or not
  126869. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  126870. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126871. */
  126872. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126873. /**
  126874. * Defines the refresh rate of the computation.
  126875. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  126876. */
  126877. get refreshRate(): number;
  126878. set refreshRate(value: number);
  126879. protected _activated: boolean;
  126880. /**
  126881. * Gets the activation status of the reducer
  126882. */
  126883. get activated(): boolean;
  126884. /**
  126885. * Activates the reduction computation.
  126886. * When activated, the observers registered in onAfterReductionPerformed are
  126887. * called after the compuation is performed
  126888. */
  126889. activate(): void;
  126890. /**
  126891. * Deactivates the reduction computation.
  126892. */
  126893. deactivate(): void;
  126894. /**
  126895. * Disposes the min/max reducer
  126896. * @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.
  126897. */
  126898. dispose(disposeAll?: boolean): void;
  126899. }
  126900. }
  126901. declare module BABYLON {
  126902. /**
  126903. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  126904. */
  126905. export class DepthReducer extends MinMaxReducer {
  126906. private _depthRenderer;
  126907. private _depthRendererId;
  126908. /**
  126909. * Gets the depth renderer used for the computation.
  126910. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  126911. */
  126912. get depthRenderer(): Nullable<DepthRenderer>;
  126913. /**
  126914. * Creates a depth reducer
  126915. * @param camera The camera used to render the depth texture
  126916. */
  126917. constructor(camera: Camera);
  126918. /**
  126919. * Sets the depth renderer to use to generate the depth map
  126920. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  126921. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  126922. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126923. */
  126924. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  126925. /** @hidden */
  126926. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126927. /**
  126928. * Activates the reduction computation.
  126929. * When activated, the observers registered in onAfterReductionPerformed are
  126930. * called after the compuation is performed
  126931. */
  126932. activate(): void;
  126933. /**
  126934. * Deactivates the reduction computation.
  126935. */
  126936. deactivate(): void;
  126937. /**
  126938. * Disposes the depth reducer
  126939. * @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.
  126940. */
  126941. dispose(disposeAll?: boolean): void;
  126942. }
  126943. }
  126944. declare module BABYLON {
  126945. /**
  126946. * A CSM implementation allowing casting shadows on large scenes.
  126947. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  126948. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  126949. */
  126950. export class CascadedShadowGenerator implements IShadowGenerator {
  126951. private static readonly frustumCornersNDCSpace;
  126952. /**
  126953. * Name of the CSM class
  126954. */
  126955. static readonly CLASSNAME: string;
  126956. /**
  126957. * Defines the default number of cascades used by the CSM.
  126958. */
  126959. static readonly DEFAULT_CASCADES_COUNT: number;
  126960. /**
  126961. * Defines the minimum number of cascades used by the CSM.
  126962. */
  126963. static readonly MIN_CASCADES_COUNT: number;
  126964. /**
  126965. * Defines the maximum number of cascades used by the CSM.
  126966. */
  126967. static readonly MAX_CASCADES_COUNT: number;
  126968. /**
  126969. * Shadow generator mode None: no filtering applied.
  126970. */
  126971. static readonly FILTER_NONE: number;
  126972. /**
  126973. * Shadow generator mode PCF: Percentage Closer Filtering
  126974. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  126975. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  126976. */
  126977. static readonly FILTER_PCF: number;
  126978. /**
  126979. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  126980. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  126981. * Contact Hardening
  126982. */
  126983. static readonly FILTER_PCSS: number;
  126984. /**
  126985. * Reserved for PCF and PCSS
  126986. * Highest Quality.
  126987. *
  126988. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  126989. *
  126990. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  126991. */
  126992. static readonly QUALITY_HIGH: number;
  126993. /**
  126994. * Reserved for PCF and PCSS
  126995. * Good tradeoff for quality/perf cross devices
  126996. *
  126997. * Execute PCF on a 3*3 kernel.
  126998. *
  126999. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  127000. */
  127001. static readonly QUALITY_MEDIUM: number;
  127002. /**
  127003. * Reserved for PCF and PCSS
  127004. * The lowest quality but the fastest.
  127005. *
  127006. * Execute PCF on a 1*1 kernel.
  127007. *
  127008. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  127009. */
  127010. static readonly QUALITY_LOW: number;
  127011. private static readonly _CLEARONE;
  127012. /**
  127013. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  127014. */
  127015. onBeforeShadowMapRenderObservable: Observable<Effect>;
  127016. /**
  127017. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  127018. */
  127019. onAfterShadowMapRenderObservable: Observable<Effect>;
  127020. /**
  127021. * Observable triggered before a mesh is rendered in the shadow map.
  127022. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  127023. */
  127024. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  127025. /**
  127026. * Observable triggered after a mesh is rendered in the shadow map.
  127027. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  127028. */
  127029. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  127030. private _bias;
  127031. /**
  127032. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  127033. */
  127034. get bias(): number;
  127035. /**
  127036. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  127037. */
  127038. set bias(bias: number);
  127039. private _normalBias;
  127040. /**
  127041. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  127042. */
  127043. get normalBias(): number;
  127044. /**
  127045. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  127046. */
  127047. set normalBias(normalBias: number);
  127048. private _filter;
  127049. /**
  127050. * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
  127051. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  127052. */
  127053. get filter(): number;
  127054. /**
  127055. * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
  127056. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  127057. */
  127058. set filter(value: number);
  127059. /**
  127060. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  127061. */
  127062. get usePercentageCloserFiltering(): boolean;
  127063. /**
  127064. * Sets the current filter to "PCF" (percentage closer filtering).
  127065. */
  127066. set usePercentageCloserFiltering(value: boolean);
  127067. private _filteringQuality;
  127068. /**
  127069. * Gets the PCF or PCSS Quality.
  127070. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  127071. */
  127072. get filteringQuality(): number;
  127073. /**
  127074. * Sets the PCF or PCSS Quality.
  127075. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  127076. */
  127077. set filteringQuality(filteringQuality: number);
  127078. /**
  127079. * Gets if the current filter is set to "PCSS" (contact hardening).
  127080. */
  127081. get useContactHardeningShadow(): boolean;
  127082. /**
  127083. * Sets the current filter to "PCSS" (contact hardening).
  127084. */
  127085. set useContactHardeningShadow(value: boolean);
  127086. private _contactHardeningLightSizeUVRatio;
  127087. /**
  127088. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  127089. * Using a ratio helps keeping shape stability independently of the map size.
  127090. *
  127091. * It does not account for the light projection as it was having too much
  127092. * instability during the light setup or during light position changes.
  127093. *
  127094. * Only valid if useContactHardeningShadow is true.
  127095. */
  127096. get contactHardeningLightSizeUVRatio(): number;
  127097. /**
  127098. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  127099. * Using a ratio helps keeping shape stability independently of the map size.
  127100. *
  127101. * It does not account for the light projection as it was having too much
  127102. * instability during the light setup or during light position changes.
  127103. *
  127104. * Only valid if useContactHardeningShadow is true.
  127105. */
  127106. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  127107. private _darkness;
  127108. /** Gets or sets the actual darkness of a shadow */
  127109. get darkness(): number;
  127110. set darkness(value: number);
  127111. /**
  127112. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  127113. * 0 means strongest and 1 would means no shadow.
  127114. * @returns the darkness.
  127115. */
  127116. getDarkness(): number;
  127117. /**
  127118. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  127119. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  127120. * @returns the shadow generator allowing fluent coding.
  127121. */
  127122. setDarkness(darkness: number): CascadedShadowGenerator;
  127123. /**
  127124. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127125. */
  127126. penumbraDarkness: number;
  127127. private _transparencyShadow;
  127128. /** Gets or sets the ability to have transparent shadow */
  127129. get transparencyShadow(): boolean;
  127130. set transparencyShadow(value: boolean);
  127131. /**
  127132. * Sets the ability to have transparent shadow (boolean).
  127133. * @param transparent True if transparent else False
  127134. * @returns the shadow generator allowing fluent coding
  127135. */
  127136. setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
  127137. private _numCascades;
  127138. /**
  127139. * Gets or set the number of cascades used by the CSM.
  127140. */
  127141. get numCascades(): number;
  127142. set numCascades(value: number);
  127143. /**
  127144. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127145. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127146. */
  127147. stabilizeCascades: boolean;
  127148. private _shadowMap;
  127149. /**
  127150. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  127151. * @returns The render target texture if present otherwise, null
  127152. */
  127153. getShadowMap(): Nullable<RenderTargetTexture>;
  127154. protected _freezeShadowCastersBoundingInfo: boolean;
  127155. private _freezeShadowCastersBoundingInfoObservable;
  127156. /**
  127157. * Enables or disables the shadow casters bounding info computation.
  127158. * If your shadow casters don't move, you can disable this feature.
  127159. * If it is enabled, the bounding box computation is done every frame.
  127160. */
  127161. get freezeShadowCastersBoundingInfo(): boolean;
  127162. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127163. private _scbiMin;
  127164. private _scbiMax;
  127165. protected _computeShadowCastersBoundingInfo(): void;
  127166. protected _shadowCastersBoundingInfo: BoundingInfo;
  127167. /**
  127168. * Gets or sets the shadow casters bounding info.
  127169. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127170. * so that the system won't overwrite the bounds you provide
  127171. */
  127172. get shadowCastersBoundingInfo(): BoundingInfo;
  127173. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127174. protected _breaksAreDirty: boolean;
  127175. protected _minDistance: number;
  127176. protected _maxDistance: number;
  127177. /**
  127178. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127179. *
  127180. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127181. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127182. * @param min minimal distance for the breaks (default to 0.)
  127183. * @param max maximal distance for the breaks (default to 1.)
  127184. */
  127185. setMinMaxDistance(min: number, max: number): void;
  127186. /** Gets the minimal distance used in the cascade break computation */
  127187. get minDistance(): number;
  127188. /** Gets the maximal distance used in the cascade break computation */
  127189. get maxDistance(): number;
  127190. /**
  127191. * Gets the class name of that object
  127192. * @returns "ShadowGenerator"
  127193. */
  127194. getClassName(): string;
  127195. /**
  127196. * Helper function to add a mesh and its descendants to the list of shadow casters.
  127197. * @param mesh Mesh to add
  127198. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  127199. * @returns the Shadow Generator itself
  127200. */
  127201. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  127202. /**
  127203. * Helper function to remove a mesh and its descendants from the list of shadow casters
  127204. * @param mesh Mesh to remove
  127205. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  127206. * @returns the Shadow Generator itself
  127207. */
  127208. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  127209. /**
  127210. * Controls the extent to which the shadows fade out at the edge of the frustum
  127211. */
  127212. frustumEdgeFalloff: number;
  127213. private _light;
  127214. /**
  127215. * Returns the associated light object.
  127216. * @returns the light generating the shadow
  127217. */
  127218. getLight(): DirectionalLight;
  127219. /**
  127220. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  127221. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  127222. * It might on the other hand introduce peter panning.
  127223. */
  127224. forceBackFacesOnly: boolean;
  127225. private _cascadeMinExtents;
  127226. private _cascadeMaxExtents;
  127227. /**
  127228. * Gets a cascade minimum extents
  127229. * @param cascadeIndex index of the cascade
  127230. * @returns the minimum cascade extents
  127231. */
  127232. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127233. /**
  127234. * Gets a cascade maximum extents
  127235. * @param cascadeIndex index of the cascade
  127236. * @returns the maximum cascade extents
  127237. */
  127238. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127239. private _scene;
  127240. private _lightDirection;
  127241. private _effect;
  127242. private _cascades;
  127243. private _cachedDirection;
  127244. private _cachedDefines;
  127245. private _mapSize;
  127246. private _currentLayer;
  127247. private _textureType;
  127248. private _defaultTextureMatrix;
  127249. private _storedUniqueId;
  127250. private _viewSpaceFrustumsZ;
  127251. private _viewMatrices;
  127252. private _projectionMatrices;
  127253. private _transformMatrices;
  127254. private _transformMatricesAsArray;
  127255. private _frustumLengths;
  127256. private _lightSizeUVCorrection;
  127257. private _depthCorrection;
  127258. private _frustumCornersWorldSpace;
  127259. private _frustumCenter;
  127260. private _shadowCameraPos;
  127261. private _shadowMaxZ;
  127262. /**
  127263. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127264. * It defaults to camera.maxZ
  127265. */
  127266. get shadowMaxZ(): number;
  127267. /**
  127268. * Sets the shadow max z distance.
  127269. */
  127270. set shadowMaxZ(value: number);
  127271. protected _debug: boolean;
  127272. /**
  127273. * Gets or sets the debug flag.
  127274. * When enabled, the cascades are materialized by different colors on the screen.
  127275. */
  127276. get debug(): boolean;
  127277. set debug(dbg: boolean);
  127278. private _depthClamp;
  127279. /**
  127280. * Gets or sets the depth clamping value.
  127281. *
  127282. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127283. * to account for the shadow casters far away.
  127284. *
  127285. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127286. */
  127287. get depthClamp(): boolean;
  127288. set depthClamp(value: boolean);
  127289. private _cascadeBlendPercentage;
  127290. /**
  127291. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127292. * It defaults to 0.1 (10% blending).
  127293. */
  127294. get cascadeBlendPercentage(): number;
  127295. set cascadeBlendPercentage(value: number);
  127296. private _lambda;
  127297. /**
  127298. * Gets or set the lambda parameter.
  127299. * This parameter is used to split the camera frustum and create the cascades.
  127300. * 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.
  127301. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127302. */
  127303. get lambda(): number;
  127304. set lambda(value: number);
  127305. /**
  127306. * Gets the view matrix corresponding to a given cascade
  127307. * @param cascadeNum cascade to retrieve the view matrix from
  127308. * @returns the cascade view matrix
  127309. */
  127310. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127311. /**
  127312. * Gets the projection matrix corresponding to a given cascade
  127313. * @param cascadeNum cascade to retrieve the projection matrix from
  127314. * @returns the cascade projection matrix
  127315. */
  127316. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127317. private _depthRenderer;
  127318. /**
  127319. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127320. *
  127321. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127322. *
  127323. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127324. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127325. * @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
  127326. */
  127327. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127328. private _depthReducer;
  127329. private _autoCalcDepthBounds;
  127330. /**
  127331. * Gets or sets the autoCalcDepthBounds property.
  127332. *
  127333. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127334. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127335. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127336. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127337. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127338. */
  127339. get autoCalcDepthBounds(): boolean;
  127340. set autoCalcDepthBounds(value: boolean);
  127341. /**
  127342. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127343. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127344. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127345. * for setting the refresh rate on the renderer yourself!
  127346. */
  127347. get autoCalcDepthBoundsRefreshRate(): number;
  127348. set autoCalcDepthBoundsRefreshRate(value: number);
  127349. /**
  127350. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127351. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127352. * you change the camera near/far planes!
  127353. */
  127354. splitFrustum(): void;
  127355. private _splitFrustum;
  127356. /**
  127357. * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
  127358. * (eq to view projection * shadow projection matrices)
  127359. * @param cascadeIndex index number of the cascaded shadow map
  127360. * @returns The transform matrix used to create the CSM shadow map
  127361. */
  127362. getCSMTransformMatrix(cascadeIndex: number): Matrix;
  127363. private _computeMatrices;
  127364. private _computeFrustumInWorldSpace;
  127365. private _computeCascadeFrustum;
  127366. /** @hidden */
  127367. static _SceneComponentInitialization: (scene: Scene) => void;
  127368. /**
  127369. * Creates a Cascaded Shadow Generator object.
  127370. * A ShadowGenerator is the required tool to use the shadows.
  127371. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127372. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127373. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127374. * @param light The directional light object generating the shadows.
  127375. * @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.
  127376. */
  127377. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127378. private _initializeGenerator;
  127379. private _initializeShadowMap;
  127380. private _renderForShadowMap;
  127381. private _renderSubMeshForShadowMap;
  127382. private _applyFilterValues;
  127383. /**
  127384. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  127385. * @param onCompiled Callback triggered at the and of the effects compilation
  127386. * @param options Sets of optional options forcing the compilation with different modes
  127387. */
  127388. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  127389. useInstances: boolean;
  127390. }>): void;
  127391. /**
  127392. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  127393. * @param options Sets of optional options forcing the compilation with different modes
  127394. * @returns A promise that resolves when the compilation completes
  127395. */
  127396. forceCompilationAsync(options?: Partial<{
  127397. useInstances: boolean;
  127398. }>): Promise<void>;
  127399. /**
  127400. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  127401. * @param subMesh The submesh we want to render in the shadow map
  127402. * @param useInstances Defines wether will draw in the map using instances
  127403. * @returns true if ready otherwise, false
  127404. */
  127405. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127406. /**
  127407. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127408. * @param defines Defines of the material we want to update
  127409. * @param lightIndex Index of the light in the enabled light list of the material
  127410. */
  127411. prepareDefines(defines: any, lightIndex: number): void;
  127412. /**
  127413. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127414. * defined in the generator but impacting the effect).
  127415. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127416. * @param effect The effect we are binfing the information for
  127417. */
  127418. bindShadowLight(lightIndex: string, effect: Effect): void;
  127419. /**
  127420. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127421. * (eq to view projection * shadow projection matrices)
  127422. * @returns The transform matrix used to create the shadow map
  127423. */
  127424. getTransformMatrix(): Matrix;
  127425. /**
  127426. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  127427. * Cube and 2D textures for instance.
  127428. */
  127429. recreateShadowMap(): void;
  127430. private _disposeRTT;
  127431. /**
  127432. * Disposes the ShadowGenerator.
  127433. * Returns nothing.
  127434. */
  127435. dispose(): void;
  127436. /**
  127437. * Serializes the shadow generator setup to a json object.
  127438. * @returns The serialized JSON object
  127439. */
  127440. serialize(): any;
  127441. /**
  127442. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127443. * @param parsedShadowGenerator The JSON object to parse
  127444. * @param scene The scene to create the shadow map for
  127445. * @returns The parsed shadow generator
  127446. */
  127447. static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
  127448. }
  127449. }
  127450. declare module BABYLON {
  127451. /**
  127452. * Defines the shadow generator component responsible to manage any shadow generators
  127453. * in a given scene.
  127454. */
  127455. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127456. /**
  127457. * The component name helpfull to identify the component in the list of scene components.
  127458. */
  127459. readonly name: string;
  127460. /**
  127461. * The scene the component belongs to.
  127462. */
  127463. scene: Scene;
  127464. /**
  127465. * Creates a new instance of the component for the given scene
  127466. * @param scene Defines the scene to register the component in
  127467. */
  127468. constructor(scene: Scene);
  127469. /**
  127470. * Registers the component in a given scene
  127471. */
  127472. register(): void;
  127473. /**
  127474. * Rebuilds the elements related to this component in case of
  127475. * context lost for instance.
  127476. */
  127477. rebuild(): void;
  127478. /**
  127479. * Serializes the component data to the specified json object
  127480. * @param serializationObject The object to serialize to
  127481. */
  127482. serialize(serializationObject: any): void;
  127483. /**
  127484. * Adds all the elements from the container to the scene
  127485. * @param container the container holding the elements
  127486. */
  127487. addFromContainer(container: AbstractScene): void;
  127488. /**
  127489. * Removes all the elements in the container from the scene
  127490. * @param container contains the elements to remove
  127491. * @param dispose if the removed element should be disposed (default: false)
  127492. */
  127493. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127494. /**
  127495. * Rebuilds the elements related to this component in case of
  127496. * context lost for instance.
  127497. */
  127498. dispose(): void;
  127499. private _gatherRenderTargets;
  127500. }
  127501. }
  127502. declare module BABYLON {
  127503. /**
  127504. * A point light is a light defined by an unique point in world space.
  127505. * The light is emitted in every direction from this point.
  127506. * A good example of a point light is a standard light bulb.
  127507. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127508. */
  127509. export class PointLight extends ShadowLight {
  127510. private _shadowAngle;
  127511. /**
  127512. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127513. * This specifies what angle the shadow will use to be created.
  127514. *
  127515. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127516. */
  127517. get shadowAngle(): number;
  127518. /**
  127519. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127520. * This specifies what angle the shadow will use to be created.
  127521. *
  127522. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127523. */
  127524. set shadowAngle(value: number);
  127525. /**
  127526. * Gets the direction if it has been set.
  127527. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127528. */
  127529. get direction(): Vector3;
  127530. /**
  127531. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127532. */
  127533. set direction(value: Vector3);
  127534. /**
  127535. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127536. * A PointLight emits the light in every direction.
  127537. * It can cast shadows.
  127538. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127539. * ```javascript
  127540. * var pointLight = new PointLight("pl", camera.position, scene);
  127541. * ```
  127542. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127543. * @param name The light friendly name
  127544. * @param position The position of the point light in the scene
  127545. * @param scene The scene the lights belongs to
  127546. */
  127547. constructor(name: string, position: Vector3, scene: Scene);
  127548. /**
  127549. * Returns the string "PointLight"
  127550. * @returns the class name
  127551. */
  127552. getClassName(): string;
  127553. /**
  127554. * Returns the integer 0.
  127555. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127556. */
  127557. getTypeID(): number;
  127558. /**
  127559. * Specifies wether or not the shadowmap should be a cube texture.
  127560. * @returns true if the shadowmap needs to be a cube texture.
  127561. */
  127562. needCube(): boolean;
  127563. /**
  127564. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127565. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127566. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127567. */
  127568. getShadowDirection(faceIndex?: number): Vector3;
  127569. /**
  127570. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127571. * - fov = PI / 2
  127572. * - aspect ratio : 1.0
  127573. * - z-near and far equal to the active camera minZ and maxZ.
  127574. * Returns the PointLight.
  127575. */
  127576. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127577. protected _buildUniformLayout(): void;
  127578. /**
  127579. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127580. * @param effect The effect to update
  127581. * @param lightIndex The index of the light in the effect to update
  127582. * @returns The point light
  127583. */
  127584. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127585. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127586. /**
  127587. * Prepares the list of defines specific to the light type.
  127588. * @param defines the list of defines
  127589. * @param lightIndex defines the index of the light for the effect
  127590. */
  127591. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127592. }
  127593. }
  127594. declare module BABYLON {
  127595. /**
  127596. * Header information of HDR texture files.
  127597. */
  127598. export interface HDRInfo {
  127599. /**
  127600. * The height of the texture in pixels.
  127601. */
  127602. height: number;
  127603. /**
  127604. * The width of the texture in pixels.
  127605. */
  127606. width: number;
  127607. /**
  127608. * The index of the beginning of the data in the binary file.
  127609. */
  127610. dataPosition: number;
  127611. }
  127612. /**
  127613. * This groups tools to convert HDR texture to native colors array.
  127614. */
  127615. export class HDRTools {
  127616. private static Ldexp;
  127617. private static Rgbe2float;
  127618. private static readStringLine;
  127619. /**
  127620. * Reads header information from an RGBE texture stored in a native array.
  127621. * More information on this format are available here:
  127622. * https://en.wikipedia.org/wiki/RGBE_image_format
  127623. *
  127624. * @param uint8array The binary file stored in native array.
  127625. * @return The header information.
  127626. */
  127627. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127628. /**
  127629. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127630. * This RGBE texture needs to store the information as a panorama.
  127631. *
  127632. * More information on this format are available here:
  127633. * https://en.wikipedia.org/wiki/RGBE_image_format
  127634. *
  127635. * @param buffer The binary file stored in an array buffer.
  127636. * @param size The expected size of the extracted cubemap.
  127637. * @return The Cube Map information.
  127638. */
  127639. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127640. /**
  127641. * Returns the pixels data extracted from an RGBE texture.
  127642. * This pixels will be stored left to right up to down in the R G B order in one array.
  127643. *
  127644. * More information on this format are available here:
  127645. * https://en.wikipedia.org/wiki/RGBE_image_format
  127646. *
  127647. * @param uint8array The binary file stored in an array buffer.
  127648. * @param hdrInfo The header information of the file.
  127649. * @return The pixels data in RGB right to left up to down order.
  127650. */
  127651. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127652. private static RGBE_ReadPixels_RLE;
  127653. }
  127654. }
  127655. declare module BABYLON {
  127656. /**
  127657. * This represents a texture coming from an HDR input.
  127658. *
  127659. * The only supported format is currently panorama picture stored in RGBE format.
  127660. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127661. */
  127662. export class HDRCubeTexture extends BaseTexture {
  127663. private static _facesMapping;
  127664. private _generateHarmonics;
  127665. private _noMipmap;
  127666. private _textureMatrix;
  127667. private _size;
  127668. private _onLoad;
  127669. private _onError;
  127670. /**
  127671. * The texture URL.
  127672. */
  127673. url: string;
  127674. /**
  127675. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127676. */
  127677. coordinatesMode: number;
  127678. protected _isBlocking: boolean;
  127679. /**
  127680. * Sets wether or not the texture is blocking during loading.
  127681. */
  127682. set isBlocking(value: boolean);
  127683. /**
  127684. * Gets wether or not the texture is blocking during loading.
  127685. */
  127686. get isBlocking(): boolean;
  127687. protected _rotationY: number;
  127688. /**
  127689. * Sets texture matrix rotation angle around Y axis in radians.
  127690. */
  127691. set rotationY(value: number);
  127692. /**
  127693. * Gets texture matrix rotation angle around Y axis radians.
  127694. */
  127695. get rotationY(): number;
  127696. /**
  127697. * Gets or sets the center of the bounding box associated with the cube texture
  127698. * It must define where the camera used to render the texture was set
  127699. */
  127700. boundingBoxPosition: Vector3;
  127701. private _boundingBoxSize;
  127702. /**
  127703. * Gets or sets the size of the bounding box associated with the cube texture
  127704. * When defined, the cubemap will switch to local mode
  127705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127706. * @example https://www.babylonjs-playground.com/#RNASML
  127707. */
  127708. set boundingBoxSize(value: Vector3);
  127709. get boundingBoxSize(): Vector3;
  127710. /**
  127711. * Instantiates an HDRTexture from the following parameters.
  127712. *
  127713. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127714. * @param scene The scene the texture will be used in
  127715. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127716. * @param noMipmap Forces to not generate the mipmap if true
  127717. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127718. * @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)
  127719. * @param reserved Reserved flag for internal use.
  127720. */
  127721. 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>);
  127722. /**
  127723. * Get the current class name of the texture useful for serialization or dynamic coding.
  127724. * @returns "HDRCubeTexture"
  127725. */
  127726. getClassName(): string;
  127727. /**
  127728. * Occurs when the file is raw .hdr file.
  127729. */
  127730. private loadTexture;
  127731. clone(): HDRCubeTexture;
  127732. delayLoad(): void;
  127733. /**
  127734. * Get the texture reflection matrix used to rotate/transform the reflection.
  127735. * @returns the reflection matrix
  127736. */
  127737. getReflectionTextureMatrix(): Matrix;
  127738. /**
  127739. * Set the texture reflection matrix used to rotate/transform the reflection.
  127740. * @param value Define the reflection matrix to set
  127741. */
  127742. setReflectionTextureMatrix(value: Matrix): void;
  127743. /**
  127744. * Parses a JSON representation of an HDR Texture in order to create the texture
  127745. * @param parsedTexture Define the JSON representation
  127746. * @param scene Define the scene the texture should be created in
  127747. * @param rootUrl Define the root url in case we need to load relative dependencies
  127748. * @returns the newly created texture after parsing
  127749. */
  127750. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127751. serialize(): any;
  127752. }
  127753. }
  127754. declare module BABYLON {
  127755. /**
  127756. * Class used to control physics engine
  127757. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127758. */
  127759. export class PhysicsEngine implements IPhysicsEngine {
  127760. private _physicsPlugin;
  127761. /**
  127762. * Global value used to control the smallest number supported by the simulation
  127763. */
  127764. static Epsilon: number;
  127765. private _impostors;
  127766. private _joints;
  127767. private _subTimeStep;
  127768. /**
  127769. * Gets the gravity vector used by the simulation
  127770. */
  127771. gravity: Vector3;
  127772. /**
  127773. * Factory used to create the default physics plugin.
  127774. * @returns The default physics plugin
  127775. */
  127776. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127777. /**
  127778. * Creates a new Physics Engine
  127779. * @param gravity defines the gravity vector used by the simulation
  127780. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127781. */
  127782. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127783. /**
  127784. * Sets the gravity vector used by the simulation
  127785. * @param gravity defines the gravity vector to use
  127786. */
  127787. setGravity(gravity: Vector3): void;
  127788. /**
  127789. * Set the time step of the physics engine.
  127790. * Default is 1/60.
  127791. * To slow it down, enter 1/600 for example.
  127792. * To speed it up, 1/30
  127793. * @param newTimeStep defines the new timestep to apply to this world.
  127794. */
  127795. setTimeStep(newTimeStep?: number): void;
  127796. /**
  127797. * Get the time step of the physics engine.
  127798. * @returns the current time step
  127799. */
  127800. getTimeStep(): number;
  127801. /**
  127802. * Set the sub time step of the physics engine.
  127803. * Default is 0 meaning there is no sub steps
  127804. * To increase physics resolution precision, set a small value (like 1 ms)
  127805. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127806. */
  127807. setSubTimeStep(subTimeStep?: number): void;
  127808. /**
  127809. * Get the sub time step of the physics engine.
  127810. * @returns the current sub time step
  127811. */
  127812. getSubTimeStep(): number;
  127813. /**
  127814. * Release all resources
  127815. */
  127816. dispose(): void;
  127817. /**
  127818. * Gets the name of the current physics plugin
  127819. * @returns the name of the plugin
  127820. */
  127821. getPhysicsPluginName(): string;
  127822. /**
  127823. * Adding a new impostor for the impostor tracking.
  127824. * This will be done by the impostor itself.
  127825. * @param impostor the impostor to add
  127826. */
  127827. addImpostor(impostor: PhysicsImpostor): void;
  127828. /**
  127829. * Remove an impostor from the engine.
  127830. * This impostor and its mesh will not longer be updated by the physics engine.
  127831. * @param impostor the impostor to remove
  127832. */
  127833. removeImpostor(impostor: PhysicsImpostor): void;
  127834. /**
  127835. * Add a joint to the physics engine
  127836. * @param mainImpostor defines the main impostor to which the joint is added.
  127837. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127838. * @param joint defines the joint that will connect both impostors.
  127839. */
  127840. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127841. /**
  127842. * Removes a joint from the simulation
  127843. * @param mainImpostor defines the impostor used with the joint
  127844. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127845. * @param joint defines the joint to remove
  127846. */
  127847. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127848. /**
  127849. * Called by the scene. No need to call it.
  127850. * @param delta defines the timespam between frames
  127851. */
  127852. _step(delta: number): void;
  127853. /**
  127854. * Gets the current plugin used to run the simulation
  127855. * @returns current plugin
  127856. */
  127857. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127858. /**
  127859. * Gets the list of physic impostors
  127860. * @returns an array of PhysicsImpostor
  127861. */
  127862. getImpostors(): Array<PhysicsImpostor>;
  127863. /**
  127864. * Gets the impostor for a physics enabled object
  127865. * @param object defines the object impersonated by the impostor
  127866. * @returns the PhysicsImpostor or null if not found
  127867. */
  127868. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  127869. /**
  127870. * Gets the impostor for a physics body object
  127871. * @param body defines physics body used by the impostor
  127872. * @returns the PhysicsImpostor or null if not found
  127873. */
  127874. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  127875. /**
  127876. * Does a raycast in the physics world
  127877. * @param from when should the ray start?
  127878. * @param to when should the ray end?
  127879. * @returns PhysicsRaycastResult
  127880. */
  127881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127882. }
  127883. }
  127884. declare module BABYLON {
  127885. /** @hidden */
  127886. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  127887. private _useDeltaForWorldStep;
  127888. world: any;
  127889. name: string;
  127890. private _physicsMaterials;
  127891. private _fixedTimeStep;
  127892. private _cannonRaycastResult;
  127893. private _raycastResult;
  127894. private _physicsBodysToRemoveAfterStep;
  127895. BJSCANNON: any;
  127896. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  127897. setGravity(gravity: Vector3): void;
  127898. setTimeStep(timeStep: number): void;
  127899. getTimeStep(): number;
  127900. executeStep(delta: number): void;
  127901. private _removeMarkedPhysicsBodiesFromWorld;
  127902. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127903. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127904. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127905. private _processChildMeshes;
  127906. removePhysicsBody(impostor: PhysicsImpostor): void;
  127907. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127908. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127909. private _addMaterial;
  127910. private _checkWithEpsilon;
  127911. private _createShape;
  127912. private _createHeightmap;
  127913. private _minus90X;
  127914. private _plus90X;
  127915. private _tmpPosition;
  127916. private _tmpDeltaPosition;
  127917. private _tmpUnityRotation;
  127918. private _updatePhysicsBodyTransformation;
  127919. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127920. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127921. isSupported(): boolean;
  127922. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127923. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127924. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127925. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127926. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127927. getBodyMass(impostor: PhysicsImpostor): number;
  127928. getBodyFriction(impostor: PhysicsImpostor): number;
  127929. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127930. getBodyRestitution(impostor: PhysicsImpostor): number;
  127931. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127932. sleepBody(impostor: PhysicsImpostor): void;
  127933. wakeUpBody(impostor: PhysicsImpostor): void;
  127934. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  127935. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  127936. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  127937. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127938. getRadius(impostor: PhysicsImpostor): number;
  127939. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127940. dispose(): void;
  127941. private _extendNamespace;
  127942. /**
  127943. * Does a raycast in the physics world
  127944. * @param from when should the ray start?
  127945. * @param to when should the ray end?
  127946. * @returns PhysicsRaycastResult
  127947. */
  127948. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127949. }
  127950. }
  127951. declare module BABYLON {
  127952. /** @hidden */
  127953. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  127954. world: any;
  127955. name: string;
  127956. BJSOIMO: any;
  127957. private _raycastResult;
  127958. constructor(iterations?: number, oimoInjection?: any);
  127959. setGravity(gravity: Vector3): void;
  127960. setTimeStep(timeStep: number): void;
  127961. getTimeStep(): number;
  127962. private _tmpImpostorsArray;
  127963. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127964. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127965. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127966. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127967. private _tmpPositionVector;
  127968. removePhysicsBody(impostor: PhysicsImpostor): void;
  127969. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127970. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127971. isSupported(): boolean;
  127972. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127973. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127974. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127975. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127976. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127977. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127978. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127979. getBodyMass(impostor: PhysicsImpostor): number;
  127980. getBodyFriction(impostor: PhysicsImpostor): number;
  127981. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127982. getBodyRestitution(impostor: PhysicsImpostor): number;
  127983. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127984. sleepBody(impostor: PhysicsImpostor): void;
  127985. wakeUpBody(impostor: PhysicsImpostor): void;
  127986. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  127987. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  127988. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  127989. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127990. getRadius(impostor: PhysicsImpostor): number;
  127991. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127992. dispose(): void;
  127993. /**
  127994. * Does a raycast in the physics world
  127995. * @param from when should the ray start?
  127996. * @param to when should the ray end?
  127997. * @returns PhysicsRaycastResult
  127998. */
  127999. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128000. }
  128001. }
  128002. declare module BABYLON {
  128003. /**
  128004. * Class containing static functions to help procedurally build meshes
  128005. */
  128006. export class RibbonBuilder {
  128007. /**
  128008. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128009. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128010. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128011. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128012. * * 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
  128013. * * 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
  128014. * * 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
  128015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128018. * * 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
  128019. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128020. * * 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
  128021. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128023. * @param name defines the name of the mesh
  128024. * @param options defines the options used to create the mesh
  128025. * @param scene defines the hosting scene
  128026. * @returns the ribbon mesh
  128027. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128029. */
  128030. static CreateRibbon(name: string, options: {
  128031. pathArray: Vector3[][];
  128032. closeArray?: boolean;
  128033. closePath?: boolean;
  128034. offset?: number;
  128035. updatable?: boolean;
  128036. sideOrientation?: number;
  128037. frontUVs?: Vector4;
  128038. backUVs?: Vector4;
  128039. instance?: Mesh;
  128040. invertUV?: boolean;
  128041. uvs?: Vector2[];
  128042. colors?: Color4[];
  128043. }, scene?: Nullable<Scene>): Mesh;
  128044. }
  128045. }
  128046. declare module BABYLON {
  128047. /**
  128048. * Class containing static functions to help procedurally build meshes
  128049. */
  128050. export class ShapeBuilder {
  128051. /**
  128052. * 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.
  128053. * * 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.
  128054. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128055. * * 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.
  128056. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128057. * * 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
  128058. * * 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
  128059. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128064. * @param name defines the name of the mesh
  128065. * @param options defines the options used to create the mesh
  128066. * @param scene defines the hosting scene
  128067. * @returns the extruded shape mesh
  128068. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128070. */
  128071. static ExtrudeShape(name: string, options: {
  128072. shape: Vector3[];
  128073. path: Vector3[];
  128074. scale?: number;
  128075. rotation?: number;
  128076. cap?: number;
  128077. updatable?: boolean;
  128078. sideOrientation?: number;
  128079. frontUVs?: Vector4;
  128080. backUVs?: Vector4;
  128081. instance?: Mesh;
  128082. invertUV?: boolean;
  128083. }, scene?: Nullable<Scene>): Mesh;
  128084. /**
  128085. * Creates an custom extruded shape mesh.
  128086. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128087. * * 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.
  128088. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128089. * * 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
  128090. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128091. * * 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
  128092. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128093. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128094. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128095. * * 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
  128096. * * 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
  128097. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128100. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128102. * @param name defines the name of the mesh
  128103. * @param options defines the options used to create the mesh
  128104. * @param scene defines the hosting scene
  128105. * @returns the custom extruded shape mesh
  128106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128107. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128109. */
  128110. static ExtrudeShapeCustom(name: string, options: {
  128111. shape: Vector3[];
  128112. path: Vector3[];
  128113. scaleFunction?: any;
  128114. rotationFunction?: any;
  128115. ribbonCloseArray?: boolean;
  128116. ribbonClosePath?: boolean;
  128117. cap?: number;
  128118. updatable?: boolean;
  128119. sideOrientation?: number;
  128120. frontUVs?: Vector4;
  128121. backUVs?: Vector4;
  128122. instance?: Mesh;
  128123. invertUV?: boolean;
  128124. }, scene?: Nullable<Scene>): Mesh;
  128125. private static _ExtrudeShapeGeneric;
  128126. }
  128127. }
  128128. declare module BABYLON {
  128129. /**
  128130. * AmmoJS Physics plugin
  128131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128132. * @see https://github.com/kripken/ammo.js/
  128133. */
  128134. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128135. private _useDeltaForWorldStep;
  128136. /**
  128137. * Reference to the Ammo library
  128138. */
  128139. bjsAMMO: any;
  128140. /**
  128141. * Created ammoJS world which physics bodies are added to
  128142. */
  128143. world: any;
  128144. /**
  128145. * Name of the plugin
  128146. */
  128147. name: string;
  128148. private _timeStep;
  128149. private _fixedTimeStep;
  128150. private _maxSteps;
  128151. private _tmpQuaternion;
  128152. private _tmpAmmoTransform;
  128153. private _tmpAmmoQuaternion;
  128154. private _tmpAmmoConcreteContactResultCallback;
  128155. private _collisionConfiguration;
  128156. private _dispatcher;
  128157. private _overlappingPairCache;
  128158. private _solver;
  128159. private _softBodySolver;
  128160. private _tmpAmmoVectorA;
  128161. private _tmpAmmoVectorB;
  128162. private _tmpAmmoVectorC;
  128163. private _tmpAmmoVectorD;
  128164. private _tmpContactCallbackResult;
  128165. private _tmpAmmoVectorRCA;
  128166. private _tmpAmmoVectorRCB;
  128167. private _raycastResult;
  128168. private static readonly DISABLE_COLLISION_FLAG;
  128169. private static readonly KINEMATIC_FLAG;
  128170. private static readonly DISABLE_DEACTIVATION_FLAG;
  128171. /**
  128172. * Initializes the ammoJS plugin
  128173. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128174. * @param ammoInjection can be used to inject your own ammo reference
  128175. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128176. */
  128177. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128178. /**
  128179. * Sets the gravity of the physics world (m/(s^2))
  128180. * @param gravity Gravity to set
  128181. */
  128182. setGravity(gravity: Vector3): void;
  128183. /**
  128184. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128185. * @param timeStep timestep to use in seconds
  128186. */
  128187. setTimeStep(timeStep: number): void;
  128188. /**
  128189. * 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)
  128190. * @param fixedTimeStep fixedTimeStep to use in seconds
  128191. */
  128192. setFixedTimeStep(fixedTimeStep: number): void;
  128193. /**
  128194. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128195. * @param maxSteps the maximum number of steps by the physics engine per frame
  128196. */
  128197. setMaxSteps(maxSteps: number): void;
  128198. /**
  128199. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128200. * @returns the current timestep in seconds
  128201. */
  128202. getTimeStep(): number;
  128203. /**
  128204. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128205. */
  128206. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128207. private _isImpostorInContact;
  128208. private _isImpostorPairInContact;
  128209. private _stepSimulation;
  128210. /**
  128211. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128212. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128213. * After the step the babylon meshes are set to the position of the physics imposters
  128214. * @param delta amount of time to step forward
  128215. * @param impostors array of imposters to update before/after the step
  128216. */
  128217. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128218. /**
  128219. * Update babylon mesh to match physics world object
  128220. * @param impostor imposter to match
  128221. */
  128222. private _afterSoftStep;
  128223. /**
  128224. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128225. * @param impostor imposter to match
  128226. */
  128227. private _ropeStep;
  128228. /**
  128229. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128230. * @param impostor imposter to match
  128231. */
  128232. private _softbodyOrClothStep;
  128233. private _tmpVector;
  128234. private _tmpMatrix;
  128235. /**
  128236. * Applies an impulse on the imposter
  128237. * @param impostor imposter to apply impulse to
  128238. * @param force amount of force to be applied to the imposter
  128239. * @param contactPoint the location to apply the impulse on the imposter
  128240. */
  128241. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128242. /**
  128243. * Applies a force on the imposter
  128244. * @param impostor imposter to apply force
  128245. * @param force amount of force to be applied to the imposter
  128246. * @param contactPoint the location to apply the force on the imposter
  128247. */
  128248. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128249. /**
  128250. * Creates a physics body using the plugin
  128251. * @param impostor the imposter to create the physics body on
  128252. */
  128253. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128254. /**
  128255. * Removes the physics body from the imposter and disposes of the body's memory
  128256. * @param impostor imposter to remove the physics body from
  128257. */
  128258. removePhysicsBody(impostor: PhysicsImpostor): void;
  128259. /**
  128260. * Generates a joint
  128261. * @param impostorJoint the imposter joint to create the joint with
  128262. */
  128263. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128264. /**
  128265. * Removes a joint
  128266. * @param impostorJoint the imposter joint to remove the joint from
  128267. */
  128268. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128269. private _addMeshVerts;
  128270. /**
  128271. * Initialise the soft body vertices to match its object's (mesh) vertices
  128272. * Softbody vertices (nodes) are in world space and to match this
  128273. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128274. * @param impostor to create the softbody for
  128275. */
  128276. private _softVertexData;
  128277. /**
  128278. * Create an impostor's soft body
  128279. * @param impostor to create the softbody for
  128280. */
  128281. private _createSoftbody;
  128282. /**
  128283. * Create cloth for an impostor
  128284. * @param impostor to create the softbody for
  128285. */
  128286. private _createCloth;
  128287. /**
  128288. * Create rope for an impostor
  128289. * @param impostor to create the softbody for
  128290. */
  128291. private _createRope;
  128292. /**
  128293. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128294. * @param impostor to create the custom physics shape for
  128295. */
  128296. private _createCustom;
  128297. private _addHullVerts;
  128298. private _createShape;
  128299. /**
  128300. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128301. * @param impostor imposter containing the physics body and babylon object
  128302. */
  128303. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128304. /**
  128305. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128306. * @param impostor imposter containing the physics body and babylon object
  128307. * @param newPosition new position
  128308. * @param newRotation new rotation
  128309. */
  128310. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128311. /**
  128312. * If this plugin is supported
  128313. * @returns true if its supported
  128314. */
  128315. isSupported(): boolean;
  128316. /**
  128317. * Sets the linear velocity of the physics body
  128318. * @param impostor imposter to set the velocity on
  128319. * @param velocity velocity to set
  128320. */
  128321. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128322. /**
  128323. * Sets the angular velocity of the physics body
  128324. * @param impostor imposter to set the velocity on
  128325. * @param velocity velocity to set
  128326. */
  128327. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128328. /**
  128329. * gets the linear velocity
  128330. * @param impostor imposter to get linear velocity from
  128331. * @returns linear velocity
  128332. */
  128333. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128334. /**
  128335. * gets the angular velocity
  128336. * @param impostor imposter to get angular velocity from
  128337. * @returns angular velocity
  128338. */
  128339. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128340. /**
  128341. * Sets the mass of physics body
  128342. * @param impostor imposter to set the mass on
  128343. * @param mass mass to set
  128344. */
  128345. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128346. /**
  128347. * Gets the mass of the physics body
  128348. * @param impostor imposter to get the mass from
  128349. * @returns mass
  128350. */
  128351. getBodyMass(impostor: PhysicsImpostor): number;
  128352. /**
  128353. * Gets friction of the impostor
  128354. * @param impostor impostor to get friction from
  128355. * @returns friction value
  128356. */
  128357. getBodyFriction(impostor: PhysicsImpostor): number;
  128358. /**
  128359. * Sets friction of the impostor
  128360. * @param impostor impostor to set friction on
  128361. * @param friction friction value
  128362. */
  128363. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128364. /**
  128365. * Gets restitution of the impostor
  128366. * @param impostor impostor to get restitution from
  128367. * @returns restitution value
  128368. */
  128369. getBodyRestitution(impostor: PhysicsImpostor): number;
  128370. /**
  128371. * Sets resitution of the impostor
  128372. * @param impostor impostor to set resitution on
  128373. * @param restitution resitution value
  128374. */
  128375. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128376. /**
  128377. * Gets pressure inside the impostor
  128378. * @param impostor impostor to get pressure from
  128379. * @returns pressure value
  128380. */
  128381. getBodyPressure(impostor: PhysicsImpostor): number;
  128382. /**
  128383. * Sets pressure inside a soft body impostor
  128384. * Cloth and rope must remain 0 pressure
  128385. * @param impostor impostor to set pressure on
  128386. * @param pressure pressure value
  128387. */
  128388. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128389. /**
  128390. * Gets stiffness of the impostor
  128391. * @param impostor impostor to get stiffness from
  128392. * @returns pressure value
  128393. */
  128394. getBodyStiffness(impostor: PhysicsImpostor): number;
  128395. /**
  128396. * Sets stiffness of the impostor
  128397. * @param impostor impostor to set stiffness on
  128398. * @param stiffness stiffness value from 0 to 1
  128399. */
  128400. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128401. /**
  128402. * Gets velocityIterations of the impostor
  128403. * @param impostor impostor to get velocity iterations from
  128404. * @returns velocityIterations value
  128405. */
  128406. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128407. /**
  128408. * Sets velocityIterations of the impostor
  128409. * @param impostor impostor to set velocity iterations on
  128410. * @param velocityIterations velocityIterations value
  128411. */
  128412. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128413. /**
  128414. * Gets positionIterations of the impostor
  128415. * @param impostor impostor to get position iterations from
  128416. * @returns positionIterations value
  128417. */
  128418. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128419. /**
  128420. * Sets positionIterations of the impostor
  128421. * @param impostor impostor to set position on
  128422. * @param positionIterations positionIterations value
  128423. */
  128424. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128425. /**
  128426. * Append an anchor to a cloth object
  128427. * @param impostor is the cloth impostor to add anchor to
  128428. * @param otherImpostor is the rigid impostor to anchor to
  128429. * @param width ratio across width from 0 to 1
  128430. * @param height ratio up height from 0 to 1
  128431. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128432. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128433. */
  128434. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128435. /**
  128436. * Append an hook to a rope object
  128437. * @param impostor is the rope impostor to add hook to
  128438. * @param otherImpostor is the rigid impostor to hook to
  128439. * @param length ratio along the rope from 0 to 1
  128440. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128441. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128442. */
  128443. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128444. /**
  128445. * Sleeps the physics body and stops it from being active
  128446. * @param impostor impostor to sleep
  128447. */
  128448. sleepBody(impostor: PhysicsImpostor): void;
  128449. /**
  128450. * Activates the physics body
  128451. * @param impostor impostor to activate
  128452. */
  128453. wakeUpBody(impostor: PhysicsImpostor): void;
  128454. /**
  128455. * Updates the distance parameters of the joint
  128456. * @param joint joint to update
  128457. * @param maxDistance maximum distance of the joint
  128458. * @param minDistance minimum distance of the joint
  128459. */
  128460. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128461. /**
  128462. * Sets a motor on the joint
  128463. * @param joint joint to set motor on
  128464. * @param speed speed of the motor
  128465. * @param maxForce maximum force of the motor
  128466. * @param motorIndex index of the motor
  128467. */
  128468. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128469. /**
  128470. * Sets the motors limit
  128471. * @param joint joint to set limit on
  128472. * @param upperLimit upper limit
  128473. * @param lowerLimit lower limit
  128474. */
  128475. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128476. /**
  128477. * Syncs the position and rotation of a mesh with the impostor
  128478. * @param mesh mesh to sync
  128479. * @param impostor impostor to update the mesh with
  128480. */
  128481. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128482. /**
  128483. * Gets the radius of the impostor
  128484. * @param impostor impostor to get radius from
  128485. * @returns the radius
  128486. */
  128487. getRadius(impostor: PhysicsImpostor): number;
  128488. /**
  128489. * Gets the box size of the impostor
  128490. * @param impostor impostor to get box size from
  128491. * @param result the resulting box size
  128492. */
  128493. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128494. /**
  128495. * Disposes of the impostor
  128496. */
  128497. dispose(): void;
  128498. /**
  128499. * Does a raycast in the physics world
  128500. * @param from when should the ray start?
  128501. * @param to when should the ray end?
  128502. * @returns PhysicsRaycastResult
  128503. */
  128504. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128505. }
  128506. }
  128507. declare module BABYLON {
  128508. interface AbstractScene {
  128509. /**
  128510. * The list of reflection probes added to the scene
  128511. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128512. */
  128513. reflectionProbes: Array<ReflectionProbe>;
  128514. /**
  128515. * Removes the given reflection probe from this scene.
  128516. * @param toRemove The reflection probe to remove
  128517. * @returns The index of the removed reflection probe
  128518. */
  128519. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128520. /**
  128521. * Adds the given reflection probe to this scene.
  128522. * @param newReflectionProbe The reflection probe to add
  128523. */
  128524. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128525. }
  128526. /**
  128527. * Class used to generate realtime reflection / refraction cube textures
  128528. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128529. */
  128530. export class ReflectionProbe {
  128531. /** defines the name of the probe */
  128532. name: string;
  128533. private _scene;
  128534. private _renderTargetTexture;
  128535. private _projectionMatrix;
  128536. private _viewMatrix;
  128537. private _target;
  128538. private _add;
  128539. private _attachedMesh;
  128540. private _invertYAxis;
  128541. /** Gets or sets probe position (center of the cube map) */
  128542. position: Vector3;
  128543. /**
  128544. * Creates a new reflection probe
  128545. * @param name defines the name of the probe
  128546. * @param size defines the texture resolution (for each face)
  128547. * @param scene defines the hosting scene
  128548. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128549. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128550. */
  128551. constructor(
  128552. /** defines the name of the probe */
  128553. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128554. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128555. get samples(): number;
  128556. set samples(value: number);
  128557. /** Gets or sets the refresh rate to use (on every frame by default) */
  128558. get refreshRate(): number;
  128559. set refreshRate(value: number);
  128560. /**
  128561. * Gets the hosting scene
  128562. * @returns a Scene
  128563. */
  128564. getScene(): Scene;
  128565. /** Gets the internal CubeTexture used to render to */
  128566. get cubeTexture(): RenderTargetTexture;
  128567. /** Gets the list of meshes to render */
  128568. get renderList(): Nullable<AbstractMesh[]>;
  128569. /**
  128570. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128571. * @param mesh defines the mesh to attach to
  128572. */
  128573. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128574. /**
  128575. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128576. * @param renderingGroupId The rendering group id corresponding to its index
  128577. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128578. */
  128579. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128580. /**
  128581. * Clean all associated resources
  128582. */
  128583. dispose(): void;
  128584. /**
  128585. * Converts the reflection probe information to a readable string for debug purpose.
  128586. * @param fullDetails Supports for multiple levels of logging within scene loading
  128587. * @returns the human readable reflection probe info
  128588. */
  128589. toString(fullDetails?: boolean): string;
  128590. /**
  128591. * Get the class name of the relfection probe.
  128592. * @returns "ReflectionProbe"
  128593. */
  128594. getClassName(): string;
  128595. /**
  128596. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128597. * @returns The JSON representation of the texture
  128598. */
  128599. serialize(): any;
  128600. /**
  128601. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128602. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128603. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128604. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128605. * @returns The parsed reflection probe if successful
  128606. */
  128607. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128608. }
  128609. }
  128610. declare module BABYLON {
  128611. /** @hidden */
  128612. export var _BabylonLoaderRegistered: boolean;
  128613. /**
  128614. * Helps setting up some configuration for the babylon file loader.
  128615. */
  128616. export class BabylonFileLoaderConfiguration {
  128617. /**
  128618. * The loader does not allow injecting custom physix engine into the plugins.
  128619. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128620. * So you could set this variable to your engine import to make it work.
  128621. */
  128622. static LoaderInjectedPhysicsEngine: any;
  128623. }
  128624. }
  128625. declare module BABYLON {
  128626. /**
  128627. * The Physically based simple base material of BJS.
  128628. *
  128629. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128630. * It is used as the base class for both the specGloss and metalRough conventions.
  128631. */
  128632. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128633. /**
  128634. * Number of Simultaneous lights allowed on the material.
  128635. */
  128636. maxSimultaneousLights: number;
  128637. /**
  128638. * If sets to true, disables all the lights affecting the material.
  128639. */
  128640. disableLighting: boolean;
  128641. /**
  128642. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128643. */
  128644. environmentTexture: BaseTexture;
  128645. /**
  128646. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128647. */
  128648. invertNormalMapX: boolean;
  128649. /**
  128650. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128651. */
  128652. invertNormalMapY: boolean;
  128653. /**
  128654. * Normal map used in the model.
  128655. */
  128656. normalTexture: BaseTexture;
  128657. /**
  128658. * Emissivie color used to self-illuminate the model.
  128659. */
  128660. emissiveColor: Color3;
  128661. /**
  128662. * Emissivie texture used to self-illuminate the model.
  128663. */
  128664. emissiveTexture: BaseTexture;
  128665. /**
  128666. * Occlusion Channel Strenght.
  128667. */
  128668. occlusionStrength: number;
  128669. /**
  128670. * Occlusion Texture of the material (adding extra occlusion effects).
  128671. */
  128672. occlusionTexture: BaseTexture;
  128673. /**
  128674. * Defines the alpha limits in alpha test mode.
  128675. */
  128676. alphaCutOff: number;
  128677. /**
  128678. * Gets the current double sided mode.
  128679. */
  128680. get doubleSided(): boolean;
  128681. /**
  128682. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128683. */
  128684. set doubleSided(value: boolean);
  128685. /**
  128686. * Stores the pre-calculated light information of a mesh in a texture.
  128687. */
  128688. lightmapTexture: BaseTexture;
  128689. /**
  128690. * If true, the light map contains occlusion information instead of lighting info.
  128691. */
  128692. useLightmapAsShadowmap: boolean;
  128693. /**
  128694. * Instantiates a new PBRMaterial instance.
  128695. *
  128696. * @param name The material name
  128697. * @param scene The scene the material will be use in.
  128698. */
  128699. constructor(name: string, scene: Scene);
  128700. getClassName(): string;
  128701. }
  128702. }
  128703. declare module BABYLON {
  128704. /**
  128705. * The PBR material of BJS following the metal roughness convention.
  128706. *
  128707. * This fits to the PBR convention in the GLTF definition:
  128708. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128709. */
  128710. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128711. /**
  128712. * The base color has two different interpretations depending on the value of metalness.
  128713. * When the material is a metal, the base color is the specific measured reflectance value
  128714. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128715. * of the material.
  128716. */
  128717. baseColor: Color3;
  128718. /**
  128719. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128720. * well as opacity information in the alpha channel.
  128721. */
  128722. baseTexture: BaseTexture;
  128723. /**
  128724. * Specifies the metallic scalar value of the material.
  128725. * Can also be used to scale the metalness values of the metallic texture.
  128726. */
  128727. metallic: number;
  128728. /**
  128729. * Specifies the roughness scalar value of the material.
  128730. * Can also be used to scale the roughness values of the metallic texture.
  128731. */
  128732. roughness: number;
  128733. /**
  128734. * Texture containing both the metallic value in the B channel and the
  128735. * roughness value in the G channel to keep better precision.
  128736. */
  128737. metallicRoughnessTexture: BaseTexture;
  128738. /**
  128739. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128740. *
  128741. * @param name The material name
  128742. * @param scene The scene the material will be use in.
  128743. */
  128744. constructor(name: string, scene: Scene);
  128745. /**
  128746. * Return the currrent class name of the material.
  128747. */
  128748. getClassName(): string;
  128749. /**
  128750. * Makes a duplicate of the current material.
  128751. * @param name - name to use for the new material.
  128752. */
  128753. clone(name: string): PBRMetallicRoughnessMaterial;
  128754. /**
  128755. * Serialize the material to a parsable JSON object.
  128756. */
  128757. serialize(): any;
  128758. /**
  128759. * Parses a JSON object correponding to the serialize function.
  128760. */
  128761. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128762. }
  128763. }
  128764. declare module BABYLON {
  128765. /**
  128766. * The PBR material of BJS following the specular glossiness convention.
  128767. *
  128768. * This fits to the PBR convention in the GLTF definition:
  128769. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128770. */
  128771. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128772. /**
  128773. * Specifies the diffuse color of the material.
  128774. */
  128775. diffuseColor: Color3;
  128776. /**
  128777. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128778. * channel.
  128779. */
  128780. diffuseTexture: BaseTexture;
  128781. /**
  128782. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128783. */
  128784. specularColor: Color3;
  128785. /**
  128786. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128787. */
  128788. glossiness: number;
  128789. /**
  128790. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128791. */
  128792. specularGlossinessTexture: BaseTexture;
  128793. /**
  128794. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128795. *
  128796. * @param name The material name
  128797. * @param scene The scene the material will be use in.
  128798. */
  128799. constructor(name: string, scene: Scene);
  128800. /**
  128801. * Return the currrent class name of the material.
  128802. */
  128803. getClassName(): string;
  128804. /**
  128805. * Makes a duplicate of the current material.
  128806. * @param name - name to use for the new material.
  128807. */
  128808. clone(name: string): PBRSpecularGlossinessMaterial;
  128809. /**
  128810. * Serialize the material to a parsable JSON object.
  128811. */
  128812. serialize(): any;
  128813. /**
  128814. * Parses a JSON object correponding to the serialize function.
  128815. */
  128816. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128817. }
  128818. }
  128819. declare module BABYLON {
  128820. /**
  128821. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128822. * It can help converting any input color in a desired output one. This can then be used to create effects
  128823. * from sepia, black and white to sixties or futuristic rendering...
  128824. *
  128825. * The only supported format is currently 3dl.
  128826. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128827. */
  128828. export class ColorGradingTexture extends BaseTexture {
  128829. /**
  128830. * The current texture matrix. (will always be identity in color grading texture)
  128831. */
  128832. private _textureMatrix;
  128833. /**
  128834. * The texture URL.
  128835. */
  128836. url: string;
  128837. /**
  128838. * Empty line regex stored for GC.
  128839. */
  128840. private static _noneEmptyLineRegex;
  128841. private _engine;
  128842. /**
  128843. * Instantiates a ColorGradingTexture from the following parameters.
  128844. *
  128845. * @param url The location of the color gradind data (currently only supporting 3dl)
  128846. * @param scene The scene the texture will be used in
  128847. */
  128848. constructor(url: string, scene: Scene);
  128849. /**
  128850. * Returns the texture matrix used in most of the material.
  128851. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128852. */
  128853. getTextureMatrix(): Matrix;
  128854. /**
  128855. * Occurs when the file being loaded is a .3dl LUT file.
  128856. */
  128857. private load3dlTexture;
  128858. /**
  128859. * Starts the loading process of the texture.
  128860. */
  128861. private loadTexture;
  128862. /**
  128863. * Clones the color gradind texture.
  128864. */
  128865. clone(): ColorGradingTexture;
  128866. /**
  128867. * Called during delayed load for textures.
  128868. */
  128869. delayLoad(): void;
  128870. /**
  128871. * Parses a color grading texture serialized by Babylon.
  128872. * @param parsedTexture The texture information being parsedTexture
  128873. * @param scene The scene to load the texture in
  128874. * @param rootUrl The root url of the data assets to load
  128875. * @return A color gradind texture
  128876. */
  128877. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  128878. /**
  128879. * Serializes the LUT texture to json format.
  128880. */
  128881. serialize(): any;
  128882. }
  128883. }
  128884. declare module BABYLON {
  128885. /**
  128886. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  128887. */
  128888. export class EquiRectangularCubeTexture extends BaseTexture {
  128889. /** The six faces of the cube. */
  128890. private static _FacesMapping;
  128891. private _noMipmap;
  128892. private _onLoad;
  128893. private _onError;
  128894. /** The size of the cubemap. */
  128895. private _size;
  128896. /** The buffer of the image. */
  128897. private _buffer;
  128898. /** The width of the input image. */
  128899. private _width;
  128900. /** The height of the input image. */
  128901. private _height;
  128902. /** The URL to the image. */
  128903. url: string;
  128904. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  128905. coordinatesMode: number;
  128906. /**
  128907. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  128908. * @param url The location of the image
  128909. * @param scene The scene the texture will be used in
  128910. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128911. * @param noMipmap Forces to not generate the mipmap if true
  128912. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128913. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128914. * @param onLoad — defines a callback called when texture is loaded
  128915. * @param onError — defines a callback called if there is an error
  128916. */
  128917. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  128918. /**
  128919. * Load the image data, by putting the image on a canvas and extracting its buffer.
  128920. */
  128921. private loadImage;
  128922. /**
  128923. * Convert the image buffer into a cubemap and create a CubeTexture.
  128924. */
  128925. private loadTexture;
  128926. /**
  128927. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  128928. * @param buffer The ArrayBuffer that should be converted.
  128929. * @returns The buffer as Float32Array.
  128930. */
  128931. private getFloat32ArrayFromArrayBuffer;
  128932. /**
  128933. * Get the current class name of the texture useful for serialization or dynamic coding.
  128934. * @returns "EquiRectangularCubeTexture"
  128935. */
  128936. getClassName(): string;
  128937. /**
  128938. * Create a clone of the current EquiRectangularCubeTexture and return it.
  128939. * @returns A clone of the current EquiRectangularCubeTexture.
  128940. */
  128941. clone(): EquiRectangularCubeTexture;
  128942. }
  128943. }
  128944. declare module BABYLON {
  128945. /**
  128946. * Based on jsTGALoader - Javascript loader for TGA file
  128947. * By Vincent Thibault
  128948. * @see http://blog.robrowser.com/javascript-tga-loader.html
  128949. */
  128950. export class TGATools {
  128951. private static _TYPE_INDEXED;
  128952. private static _TYPE_RGB;
  128953. private static _TYPE_GREY;
  128954. private static _TYPE_RLE_INDEXED;
  128955. private static _TYPE_RLE_RGB;
  128956. private static _TYPE_RLE_GREY;
  128957. private static _ORIGIN_MASK;
  128958. private static _ORIGIN_SHIFT;
  128959. private static _ORIGIN_BL;
  128960. private static _ORIGIN_BR;
  128961. private static _ORIGIN_UL;
  128962. private static _ORIGIN_UR;
  128963. /**
  128964. * Gets the header of a TGA file
  128965. * @param data defines the TGA data
  128966. * @returns the header
  128967. */
  128968. static GetTGAHeader(data: Uint8Array): any;
  128969. /**
  128970. * Uploads TGA content to a Babylon Texture
  128971. * @hidden
  128972. */
  128973. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  128974. /** @hidden */
  128975. 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;
  128976. /** @hidden */
  128977. 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;
  128978. /** @hidden */
  128979. 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;
  128980. /** @hidden */
  128981. 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;
  128982. /** @hidden */
  128983. 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;
  128984. /** @hidden */
  128985. 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;
  128986. }
  128987. }
  128988. declare module BABYLON {
  128989. /**
  128990. * Implementation of the TGA Texture Loader.
  128991. * @hidden
  128992. */
  128993. export class _TGATextureLoader implements IInternalTextureLoader {
  128994. /**
  128995. * Defines wether the loader supports cascade loading the different faces.
  128996. */
  128997. readonly supportCascades: boolean;
  128998. /**
  128999. * This returns if the loader support the current file information.
  129000. * @param extension defines the file extension of the file being loaded
  129001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129002. * @param fallback defines the fallback internal texture if any
  129003. * @param isBase64 defines whether the texture is encoded as a base64
  129004. * @param isBuffer defines whether the texture data are stored as a buffer
  129005. * @returns true if the loader can load the specified file
  129006. */
  129007. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129008. /**
  129009. * Transform the url before loading if required.
  129010. * @param rootUrl the url of the texture
  129011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129012. * @returns the transformed texture
  129013. */
  129014. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129015. /**
  129016. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129017. * @param rootUrl the url of the texture
  129018. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129019. * @returns the fallback texture
  129020. */
  129021. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129022. /**
  129023. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129024. * @param data contains the texture data
  129025. * @param texture defines the BabylonJS internal texture
  129026. * @param createPolynomials will be true if polynomials have been requested
  129027. * @param onLoad defines the callback to trigger once the texture is ready
  129028. * @param onError defines the callback to trigger in case of error
  129029. */
  129030. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129031. /**
  129032. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129033. * @param data contains the texture data
  129034. * @param texture defines the BabylonJS internal texture
  129035. * @param callback defines the method to call once ready to upload
  129036. */
  129037. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129038. }
  129039. }
  129040. declare module BABYLON {
  129041. /**
  129042. * Info about the .basis files
  129043. */
  129044. class BasisFileInfo {
  129045. /**
  129046. * If the file has alpha
  129047. */
  129048. hasAlpha: boolean;
  129049. /**
  129050. * Info about each image of the basis file
  129051. */
  129052. images: Array<{
  129053. levels: Array<{
  129054. width: number;
  129055. height: number;
  129056. transcodedPixels: ArrayBufferView;
  129057. }>;
  129058. }>;
  129059. }
  129060. /**
  129061. * Result of transcoding a basis file
  129062. */
  129063. class TranscodeResult {
  129064. /**
  129065. * Info about the .basis file
  129066. */
  129067. fileInfo: BasisFileInfo;
  129068. /**
  129069. * Format to use when loading the file
  129070. */
  129071. format: number;
  129072. }
  129073. /**
  129074. * Configuration options for the Basis transcoder
  129075. */
  129076. export class BasisTranscodeConfiguration {
  129077. /**
  129078. * Supported compression formats used to determine the supported output format of the transcoder
  129079. */
  129080. supportedCompressionFormats?: {
  129081. /**
  129082. * etc1 compression format
  129083. */
  129084. etc1?: boolean;
  129085. /**
  129086. * s3tc compression format
  129087. */
  129088. s3tc?: boolean;
  129089. /**
  129090. * pvrtc compression format
  129091. */
  129092. pvrtc?: boolean;
  129093. /**
  129094. * etc2 compression format
  129095. */
  129096. etc2?: boolean;
  129097. };
  129098. /**
  129099. * If mipmap levels should be loaded for transcoded images (Default: true)
  129100. */
  129101. loadMipmapLevels?: boolean;
  129102. /**
  129103. * Index of a single image to load (Default: all images)
  129104. */
  129105. loadSingleImage?: number;
  129106. }
  129107. /**
  129108. * Used to load .Basis files
  129109. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129110. */
  129111. export class BasisTools {
  129112. private static _IgnoreSupportedFormats;
  129113. /**
  129114. * URL to use when loading the basis transcoder
  129115. */
  129116. static JSModuleURL: string;
  129117. /**
  129118. * URL to use when loading the wasm module for the transcoder
  129119. */
  129120. static WasmModuleURL: string;
  129121. /**
  129122. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129123. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129124. * @returns internal format corresponding to the Basis format
  129125. */
  129126. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129127. private static _WorkerPromise;
  129128. private static _Worker;
  129129. private static _actionId;
  129130. private static _CreateWorkerAsync;
  129131. /**
  129132. * Transcodes a loaded image file to compressed pixel data
  129133. * @param imageData image data to transcode
  129134. * @param config configuration options for the transcoding
  129135. * @returns a promise resulting in the transcoded image
  129136. */
  129137. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129138. /**
  129139. * Loads a texture from the transcode result
  129140. * @param texture texture load to
  129141. * @param transcodeResult the result of transcoding the basis file to load from
  129142. */
  129143. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129144. }
  129145. }
  129146. declare module BABYLON {
  129147. /**
  129148. * Loader for .basis file format
  129149. */
  129150. export class _BasisTextureLoader implements IInternalTextureLoader {
  129151. /**
  129152. * Defines whether the loader supports cascade loading the different faces.
  129153. */
  129154. readonly supportCascades: boolean;
  129155. /**
  129156. * This returns if the loader support the current file information.
  129157. * @param extension defines the file extension of the file being loaded
  129158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129159. * @param fallback defines the fallback internal texture if any
  129160. * @param isBase64 defines whether the texture is encoded as a base64
  129161. * @param isBuffer defines whether the texture data are stored as a buffer
  129162. * @returns true if the loader can load the specified file
  129163. */
  129164. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129165. /**
  129166. * Transform the url before loading if required.
  129167. * @param rootUrl the url of the texture
  129168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129169. * @returns the transformed texture
  129170. */
  129171. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129172. /**
  129173. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129174. * @param rootUrl the url of the texture
  129175. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129176. * @returns the fallback texture
  129177. */
  129178. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129179. /**
  129180. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129181. * @param data contains the texture data
  129182. * @param texture defines the BabylonJS internal texture
  129183. * @param createPolynomials will be true if polynomials have been requested
  129184. * @param onLoad defines the callback to trigger once the texture is ready
  129185. * @param onError defines the callback to trigger in case of error
  129186. */
  129187. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129188. /**
  129189. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129190. * @param data contains the texture data
  129191. * @param texture defines the BabylonJS internal texture
  129192. * @param callback defines the method to call once ready to upload
  129193. */
  129194. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129195. }
  129196. }
  129197. declare module BABYLON {
  129198. /**
  129199. * 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.
  129200. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129202. */
  129203. export class CustomProceduralTexture extends ProceduralTexture {
  129204. private _animate;
  129205. private _time;
  129206. private _config;
  129207. private _texturePath;
  129208. /**
  129209. * Instantiates a new Custom Procedural Texture.
  129210. * 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.
  129211. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129212. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129213. * @param name Define the name of the texture
  129214. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129215. * @param size Define the size of the texture to create
  129216. * @param scene Define the scene the texture belongs to
  129217. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129218. * @param generateMipMaps Define if the texture should creates mip maps or not
  129219. */
  129220. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129221. private _loadJson;
  129222. /**
  129223. * Is the texture ready to be used ? (rendered at least once)
  129224. * @returns true if ready, otherwise, false.
  129225. */
  129226. isReady(): boolean;
  129227. /**
  129228. * Render the texture to its associated render target.
  129229. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129230. */
  129231. render(useCameraPostProcess?: boolean): void;
  129232. /**
  129233. * Update the list of dependant textures samplers in the shader.
  129234. */
  129235. updateTextures(): void;
  129236. /**
  129237. * Update the uniform values of the procedural texture in the shader.
  129238. */
  129239. updateShaderUniforms(): void;
  129240. /**
  129241. * Define if the texture animates or not.
  129242. */
  129243. get animate(): boolean;
  129244. set animate(value: boolean);
  129245. }
  129246. }
  129247. declare module BABYLON {
  129248. /** @hidden */
  129249. export var noisePixelShader: {
  129250. name: string;
  129251. shader: string;
  129252. };
  129253. }
  129254. declare module BABYLON {
  129255. /**
  129256. * Class used to generate noise procedural textures
  129257. */
  129258. export class NoiseProceduralTexture extends ProceduralTexture {
  129259. private _time;
  129260. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129261. brightness: number;
  129262. /** Defines the number of octaves to process */
  129263. octaves: number;
  129264. /** Defines the level of persistence (0.8 by default) */
  129265. persistence: number;
  129266. /** Gets or sets animation speed factor (default is 1) */
  129267. animationSpeedFactor: number;
  129268. /**
  129269. * Creates a new NoiseProceduralTexture
  129270. * @param name defines the name fo the texture
  129271. * @param size defines the size of the texture (default is 256)
  129272. * @param scene defines the hosting scene
  129273. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129274. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129275. */
  129276. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129277. private _updateShaderUniforms;
  129278. protected _getDefines(): string;
  129279. /** Generate the current state of the procedural texture */
  129280. render(useCameraPostProcess?: boolean): void;
  129281. /**
  129282. * Serializes this noise procedural texture
  129283. * @returns a serialized noise procedural texture object
  129284. */
  129285. serialize(): any;
  129286. /**
  129287. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129288. * @param parsedTexture defines parsed texture data
  129289. * @param scene defines the current scene
  129290. * @param rootUrl defines the root URL containing noise procedural texture information
  129291. * @returns a parsed NoiseProceduralTexture
  129292. */
  129293. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129294. }
  129295. }
  129296. declare module BABYLON {
  129297. /**
  129298. * Raw cube texture where the raw buffers are passed in
  129299. */
  129300. export class RawCubeTexture extends CubeTexture {
  129301. /**
  129302. * Creates a cube texture where the raw buffers are passed in.
  129303. * @param scene defines the scene the texture is attached to
  129304. * @param data defines the array of data to use to create each face
  129305. * @param size defines the size of the textures
  129306. * @param format defines the format of the data
  129307. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129308. * @param generateMipMaps defines if the engine should generate the mip levels
  129309. * @param invertY defines if data must be stored with Y axis inverted
  129310. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129311. * @param compression defines the compression used (null by default)
  129312. */
  129313. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129314. /**
  129315. * Updates the raw cube texture.
  129316. * @param data defines the data to store
  129317. * @param format defines the data format
  129318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129319. * @param invertY defines if data must be stored with Y axis inverted
  129320. * @param compression defines the compression used (null by default)
  129321. * @param level defines which level of the texture to update
  129322. */
  129323. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129324. /**
  129325. * Updates a raw cube texture with RGBD encoded data.
  129326. * @param data defines the array of data [mipmap][face] to use to create each face
  129327. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129328. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129329. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129330. * @returns a promsie that resolves when the operation is complete
  129331. */
  129332. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129333. /**
  129334. * Clones the raw cube texture.
  129335. * @return a new cube texture
  129336. */
  129337. clone(): CubeTexture;
  129338. /** @hidden */
  129339. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129340. }
  129341. }
  129342. declare module BABYLON {
  129343. /**
  129344. * Class used to store 3D textures containing user data
  129345. */
  129346. export class RawTexture3D extends Texture {
  129347. /** Gets or sets the texture format to use */
  129348. format: number;
  129349. private _engine;
  129350. /**
  129351. * Create a new RawTexture3D
  129352. * @param data defines the data of the texture
  129353. * @param width defines the width of the texture
  129354. * @param height defines the height of the texture
  129355. * @param depth defines the depth of the texture
  129356. * @param format defines the texture format to use
  129357. * @param scene defines the hosting scene
  129358. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129359. * @param invertY defines if texture must be stored with Y axis inverted
  129360. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129361. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129362. */
  129363. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129364. /** Gets or sets the texture format to use */
  129365. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129366. /**
  129367. * Update the texture with new data
  129368. * @param data defines the data to store in the texture
  129369. */
  129370. update(data: ArrayBufferView): void;
  129371. }
  129372. }
  129373. declare module BABYLON {
  129374. /**
  129375. * Class used to store 2D array textures containing user data
  129376. */
  129377. export class RawTexture2DArray extends Texture {
  129378. /** Gets or sets the texture format to use */
  129379. format: number;
  129380. private _engine;
  129381. /**
  129382. * Create a new RawTexture2DArray
  129383. * @param data defines the data of the texture
  129384. * @param width defines the width of the texture
  129385. * @param height defines the height of the texture
  129386. * @param depth defines the number of layers of the texture
  129387. * @param format defines the texture format to use
  129388. * @param scene defines the hosting scene
  129389. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129390. * @param invertY defines if texture must be stored with Y axis inverted
  129391. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129392. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129393. */
  129394. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129395. /** Gets or sets the texture format to use */
  129396. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129397. /**
  129398. * Update the texture with new data
  129399. * @param data defines the data to store in the texture
  129400. */
  129401. update(data: ArrayBufferView): void;
  129402. }
  129403. }
  129404. declare module BABYLON {
  129405. /**
  129406. * Creates a refraction texture used by refraction channel of the standard material.
  129407. * It is like a mirror but to see through a material.
  129408. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129409. */
  129410. export class RefractionTexture extends RenderTargetTexture {
  129411. /**
  129412. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129413. * 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.
  129414. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129415. */
  129416. refractionPlane: Plane;
  129417. /**
  129418. * Define how deep under the surface we should see.
  129419. */
  129420. depth: number;
  129421. /**
  129422. * Creates a refraction texture used by refraction channel of the standard material.
  129423. * It is like a mirror but to see through a material.
  129424. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129425. * @param name Define the texture name
  129426. * @param size Define the size of the underlying texture
  129427. * @param scene Define the scene the refraction belongs to
  129428. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129429. */
  129430. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129431. /**
  129432. * Clone the refraction texture.
  129433. * @returns the cloned texture
  129434. */
  129435. clone(): RefractionTexture;
  129436. /**
  129437. * Serialize the texture to a JSON representation you could use in Parse later on
  129438. * @returns the serialized JSON representation
  129439. */
  129440. serialize(): any;
  129441. }
  129442. }
  129443. declare module BABYLON {
  129444. /**
  129445. * Defines the options related to the creation of an HtmlElementTexture
  129446. */
  129447. export interface IHtmlElementTextureOptions {
  129448. /**
  129449. * Defines wether mip maps should be created or not.
  129450. */
  129451. generateMipMaps?: boolean;
  129452. /**
  129453. * Defines the sampling mode of the texture.
  129454. */
  129455. samplingMode?: number;
  129456. /**
  129457. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129458. */
  129459. engine: Nullable<ThinEngine>;
  129460. /**
  129461. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129462. */
  129463. scene: Nullable<Scene>;
  129464. }
  129465. /**
  129466. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129467. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129468. * is automatically managed.
  129469. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129470. * in your application.
  129471. *
  129472. * As the update is not automatic, you need to call them manually.
  129473. */
  129474. export class HtmlElementTexture extends BaseTexture {
  129475. /**
  129476. * The texture URL.
  129477. */
  129478. element: HTMLVideoElement | HTMLCanvasElement;
  129479. private static readonly DefaultOptions;
  129480. private _textureMatrix;
  129481. private _engine;
  129482. private _isVideo;
  129483. private _generateMipMaps;
  129484. private _samplingMode;
  129485. /**
  129486. * Instantiates a HtmlElementTexture from the following parameters.
  129487. *
  129488. * @param name Defines the name of the texture
  129489. * @param element Defines the video or canvas the texture is filled with
  129490. * @param options Defines the other none mandatory texture creation options
  129491. */
  129492. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129493. private _createInternalTexture;
  129494. /**
  129495. * Returns the texture matrix used in most of the material.
  129496. */
  129497. getTextureMatrix(): Matrix;
  129498. /**
  129499. * Updates the content of the texture.
  129500. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129501. */
  129502. update(invertY?: Nullable<boolean>): void;
  129503. }
  129504. }
  129505. declare module BABYLON {
  129506. /**
  129507. * Enum used to define the target of a block
  129508. */
  129509. export enum NodeMaterialBlockTargets {
  129510. /** Vertex shader */
  129511. Vertex = 1,
  129512. /** Fragment shader */
  129513. Fragment = 2,
  129514. /** Neutral */
  129515. Neutral = 4,
  129516. /** Vertex and Fragment */
  129517. VertexAndFragment = 3
  129518. }
  129519. }
  129520. declare module BABYLON {
  129521. /**
  129522. * Defines the kind of connection point for node based material
  129523. */
  129524. export enum NodeMaterialBlockConnectionPointTypes {
  129525. /** Float */
  129526. Float = 1,
  129527. /** Int */
  129528. Int = 2,
  129529. /** Vector2 */
  129530. Vector2 = 4,
  129531. /** Vector3 */
  129532. Vector3 = 8,
  129533. /** Vector4 */
  129534. Vector4 = 16,
  129535. /** Color3 */
  129536. Color3 = 32,
  129537. /** Color4 */
  129538. Color4 = 64,
  129539. /** Matrix */
  129540. Matrix = 128,
  129541. /** Detect type based on connection */
  129542. AutoDetect = 1024,
  129543. /** Output type that will be defined by input type */
  129544. BasedOnInput = 2048
  129545. }
  129546. }
  129547. declare module BABYLON {
  129548. /**
  129549. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129550. */
  129551. export enum NodeMaterialBlockConnectionPointMode {
  129552. /** Value is an uniform */
  129553. Uniform = 0,
  129554. /** Value is a mesh attribute */
  129555. Attribute = 1,
  129556. /** Value is a varying between vertex and fragment shaders */
  129557. Varying = 2,
  129558. /** Mode is undefined */
  129559. Undefined = 3
  129560. }
  129561. }
  129562. declare module BABYLON {
  129563. /**
  129564. * Enum used to define system values e.g. values automatically provided by the system
  129565. */
  129566. export enum NodeMaterialSystemValues {
  129567. /** World */
  129568. World = 1,
  129569. /** View */
  129570. View = 2,
  129571. /** Projection */
  129572. Projection = 3,
  129573. /** ViewProjection */
  129574. ViewProjection = 4,
  129575. /** WorldView */
  129576. WorldView = 5,
  129577. /** WorldViewProjection */
  129578. WorldViewProjection = 6,
  129579. /** CameraPosition */
  129580. CameraPosition = 7,
  129581. /** Fog Color */
  129582. FogColor = 8,
  129583. /** Delta time */
  129584. DeltaTime = 9
  129585. }
  129586. }
  129587. declare module BABYLON {
  129588. /**
  129589. * Root class for all node material optimizers
  129590. */
  129591. export class NodeMaterialOptimizer {
  129592. /**
  129593. * Function used to optimize a NodeMaterial graph
  129594. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129595. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129596. */
  129597. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129598. }
  129599. }
  129600. declare module BABYLON {
  129601. /**
  129602. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129603. */
  129604. export class TransformBlock extends NodeMaterialBlock {
  129605. /**
  129606. * Defines the value to use to complement W value to transform it to a Vector4
  129607. */
  129608. complementW: number;
  129609. /**
  129610. * Defines the value to use to complement z value to transform it to a Vector4
  129611. */
  129612. complementZ: number;
  129613. /**
  129614. * Creates a new TransformBlock
  129615. * @param name defines the block name
  129616. */
  129617. constructor(name: string);
  129618. /**
  129619. * Gets the current class name
  129620. * @returns the class name
  129621. */
  129622. getClassName(): string;
  129623. /**
  129624. * Gets the vector input
  129625. */
  129626. get vector(): NodeMaterialConnectionPoint;
  129627. /**
  129628. * Gets the output component
  129629. */
  129630. get output(): NodeMaterialConnectionPoint;
  129631. /**
  129632. * Gets the matrix transform input
  129633. */
  129634. get transform(): NodeMaterialConnectionPoint;
  129635. protected _buildBlock(state: NodeMaterialBuildState): this;
  129636. serialize(): any;
  129637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129638. protected _dumpPropertiesCode(): string;
  129639. }
  129640. }
  129641. declare module BABYLON {
  129642. /**
  129643. * Block used to output the vertex position
  129644. */
  129645. export class VertexOutputBlock extends NodeMaterialBlock {
  129646. /**
  129647. * Creates a new VertexOutputBlock
  129648. * @param name defines the block name
  129649. */
  129650. constructor(name: string);
  129651. /**
  129652. * Gets the current class name
  129653. * @returns the class name
  129654. */
  129655. getClassName(): string;
  129656. /**
  129657. * Gets the vector input component
  129658. */
  129659. get vector(): NodeMaterialConnectionPoint;
  129660. protected _buildBlock(state: NodeMaterialBuildState): this;
  129661. }
  129662. }
  129663. declare module BABYLON {
  129664. /**
  129665. * Block used to output the final color
  129666. */
  129667. export class FragmentOutputBlock extends NodeMaterialBlock {
  129668. /**
  129669. * Create a new FragmentOutputBlock
  129670. * @param name defines the block name
  129671. */
  129672. constructor(name: string);
  129673. /**
  129674. * Gets the current class name
  129675. * @returns the class name
  129676. */
  129677. getClassName(): string;
  129678. /**
  129679. * Gets the rgba input component
  129680. */
  129681. get rgba(): NodeMaterialConnectionPoint;
  129682. /**
  129683. * Gets the rgb input component
  129684. */
  129685. get rgb(): NodeMaterialConnectionPoint;
  129686. /**
  129687. * Gets the a input component
  129688. */
  129689. get a(): NodeMaterialConnectionPoint;
  129690. protected _buildBlock(state: NodeMaterialBuildState): this;
  129691. }
  129692. }
  129693. declare module BABYLON {
  129694. /**
  129695. * Block used to read a reflection texture from a sampler
  129696. */
  129697. export class ReflectionTextureBlock extends NodeMaterialBlock {
  129698. private _define3DName;
  129699. private _defineCubicName;
  129700. private _defineExplicitName;
  129701. private _defineProjectionName;
  129702. private _defineLocalCubicName;
  129703. private _defineSphericalName;
  129704. private _definePlanarName;
  129705. private _defineEquirectangularName;
  129706. private _defineMirroredEquirectangularFixedName;
  129707. private _defineEquirectangularFixedName;
  129708. private _defineSkyboxName;
  129709. private _cubeSamplerName;
  129710. private _2DSamplerName;
  129711. private _positionUVWName;
  129712. private _directionWName;
  129713. private _reflectionCoordsName;
  129714. private _reflection2DCoordsName;
  129715. private _reflectionColorName;
  129716. private _reflectionMatrixName;
  129717. /**
  129718. * Gets or sets the texture associated with the node
  129719. */
  129720. texture: Nullable<BaseTexture>;
  129721. /**
  129722. * Create a new TextureBlock
  129723. * @param name defines the block name
  129724. */
  129725. constructor(name: string);
  129726. /**
  129727. * Gets the current class name
  129728. * @returns the class name
  129729. */
  129730. getClassName(): string;
  129731. /**
  129732. * Gets the world position input component
  129733. */
  129734. get position(): NodeMaterialConnectionPoint;
  129735. /**
  129736. * Gets the world position input component
  129737. */
  129738. get worldPosition(): NodeMaterialConnectionPoint;
  129739. /**
  129740. * Gets the world normal input component
  129741. */
  129742. get worldNormal(): NodeMaterialConnectionPoint;
  129743. /**
  129744. * Gets the world input component
  129745. */
  129746. get world(): NodeMaterialConnectionPoint;
  129747. /**
  129748. * Gets the camera (or eye) position component
  129749. */
  129750. get cameraPosition(): NodeMaterialConnectionPoint;
  129751. /**
  129752. * Gets the view input component
  129753. */
  129754. get view(): NodeMaterialConnectionPoint;
  129755. /**
  129756. * Gets the rgb output component
  129757. */
  129758. get rgb(): NodeMaterialConnectionPoint;
  129759. /**
  129760. * Gets the r output component
  129761. */
  129762. get r(): NodeMaterialConnectionPoint;
  129763. /**
  129764. * Gets the g output component
  129765. */
  129766. get g(): NodeMaterialConnectionPoint;
  129767. /**
  129768. * Gets the b output component
  129769. */
  129770. get b(): NodeMaterialConnectionPoint;
  129771. autoConfigure(material: NodeMaterial): void;
  129772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129773. isReady(): boolean;
  129774. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129775. private _injectVertexCode;
  129776. private _writeOutput;
  129777. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129778. protected _dumpPropertiesCode(): string;
  129779. serialize(): any;
  129780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129781. }
  129782. }
  129783. declare module BABYLON {
  129784. /**
  129785. * Interface used to configure the node material editor
  129786. */
  129787. export interface INodeMaterialEditorOptions {
  129788. /** Define the URl to load node editor script */
  129789. editorURL?: string;
  129790. }
  129791. /** @hidden */
  129792. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  129793. NORMAL: boolean;
  129794. TANGENT: boolean;
  129795. UV1: boolean;
  129796. /** BONES */
  129797. NUM_BONE_INFLUENCERS: number;
  129798. BonesPerMesh: number;
  129799. BONETEXTURE: boolean;
  129800. /** MORPH TARGETS */
  129801. MORPHTARGETS: boolean;
  129802. MORPHTARGETS_NORMAL: boolean;
  129803. MORPHTARGETS_TANGENT: boolean;
  129804. MORPHTARGETS_UV: boolean;
  129805. NUM_MORPH_INFLUENCERS: number;
  129806. /** IMAGE PROCESSING */
  129807. IMAGEPROCESSING: boolean;
  129808. VIGNETTE: boolean;
  129809. VIGNETTEBLENDMODEMULTIPLY: boolean;
  129810. VIGNETTEBLENDMODEOPAQUE: boolean;
  129811. TONEMAPPING: boolean;
  129812. TONEMAPPING_ACES: boolean;
  129813. CONTRAST: boolean;
  129814. EXPOSURE: boolean;
  129815. COLORCURVES: boolean;
  129816. COLORGRADING: boolean;
  129817. COLORGRADING3D: boolean;
  129818. SAMPLER3DGREENDEPTH: boolean;
  129819. SAMPLER3DBGRMAP: boolean;
  129820. IMAGEPROCESSINGPOSTPROCESS: boolean;
  129821. /** MISC. */
  129822. BUMPDIRECTUV: number;
  129823. constructor();
  129824. setValue(name: string, value: boolean): void;
  129825. }
  129826. /**
  129827. * Class used to configure NodeMaterial
  129828. */
  129829. export interface INodeMaterialOptions {
  129830. /**
  129831. * Defines if blocks should emit comments
  129832. */
  129833. emitComments: boolean;
  129834. }
  129835. /**
  129836. * Class used to create a node based material built by assembling shader blocks
  129837. */
  129838. export class NodeMaterial extends PushMaterial {
  129839. private static _BuildIdGenerator;
  129840. private _options;
  129841. private _vertexCompilationState;
  129842. private _fragmentCompilationState;
  129843. private _sharedData;
  129844. private _buildId;
  129845. private _buildWasSuccessful;
  129846. private _cachedWorldViewMatrix;
  129847. private _cachedWorldViewProjectionMatrix;
  129848. private _optimizers;
  129849. private _animationFrame;
  129850. /** Define the Url to load node editor script */
  129851. static EditorURL: string;
  129852. /** Define the Url to load snippets */
  129853. static SnippetUrl: string;
  129854. private BJSNODEMATERIALEDITOR;
  129855. /** Get the inspector from bundle or global */
  129856. private _getGlobalNodeMaterialEditor;
  129857. /**
  129858. * Gets or sets data used by visual editor
  129859. * @see https://nme.babylonjs.com
  129860. */
  129861. editorData: any;
  129862. /**
  129863. * 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)
  129864. */
  129865. ignoreAlpha: boolean;
  129866. /**
  129867. * Defines the maximum number of lights that can be used in the material
  129868. */
  129869. maxSimultaneousLights: number;
  129870. /**
  129871. * Observable raised when the material is built
  129872. */
  129873. onBuildObservable: Observable<NodeMaterial>;
  129874. /**
  129875. * Gets or sets the root nodes of the material vertex shader
  129876. */
  129877. _vertexOutputNodes: NodeMaterialBlock[];
  129878. /**
  129879. * Gets or sets the root nodes of the material fragment (pixel) shader
  129880. */
  129881. _fragmentOutputNodes: NodeMaterialBlock[];
  129882. /** Gets or sets options to control the node material overall behavior */
  129883. get options(): INodeMaterialOptions;
  129884. set options(options: INodeMaterialOptions);
  129885. /**
  129886. * Default configuration related to image processing available in the standard Material.
  129887. */
  129888. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129889. /**
  129890. * Gets the image processing configuration used either in this material.
  129891. */
  129892. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  129893. /**
  129894. * Sets the Default image processing configuration used either in the this material.
  129895. *
  129896. * If sets to null, the scene one is in use.
  129897. */
  129898. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  129899. /**
  129900. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  129901. */
  129902. attachedBlocks: NodeMaterialBlock[];
  129903. /**
  129904. * Create a new node based material
  129905. * @param name defines the material name
  129906. * @param scene defines the hosting scene
  129907. * @param options defines creation option
  129908. */
  129909. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  129910. /**
  129911. * Gets the current class name of the material e.g. "NodeMaterial"
  129912. * @returns the class name
  129913. */
  129914. getClassName(): string;
  129915. /**
  129916. * Keep track of the image processing observer to allow dispose and replace.
  129917. */
  129918. private _imageProcessingObserver;
  129919. /**
  129920. * Attaches a new image processing configuration to the Standard Material.
  129921. * @param configuration
  129922. */
  129923. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129924. /**
  129925. * Get a block by its name
  129926. * @param name defines the name of the block to retrieve
  129927. * @returns the required block or null if not found
  129928. */
  129929. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  129930. /**
  129931. * Get a block by its name
  129932. * @param predicate defines the predicate used to find the good candidate
  129933. * @returns the required block or null if not found
  129934. */
  129935. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  129936. /**
  129937. * Get an input block by its name
  129938. * @param predicate defines the predicate used to find the good candidate
  129939. * @returns the required input block or null if not found
  129940. */
  129941. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  129942. /**
  129943. * Gets the list of input blocks attached to this material
  129944. * @returns an array of InputBlocks
  129945. */
  129946. getInputBlocks(): InputBlock[];
  129947. /**
  129948. * Adds a new optimizer to the list of optimizers
  129949. * @param optimizer defines the optimizers to add
  129950. * @returns the current material
  129951. */
  129952. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129953. /**
  129954. * Remove an optimizer from the list of optimizers
  129955. * @param optimizer defines the optimizers to remove
  129956. * @returns the current material
  129957. */
  129958. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129959. /**
  129960. * Add a new block to the list of output nodes
  129961. * @param node defines the node to add
  129962. * @returns the current material
  129963. */
  129964. addOutputNode(node: NodeMaterialBlock): this;
  129965. /**
  129966. * Remove a block from the list of root nodes
  129967. * @param node defines the node to remove
  129968. * @returns the current material
  129969. */
  129970. removeOutputNode(node: NodeMaterialBlock): this;
  129971. private _addVertexOutputNode;
  129972. private _removeVertexOutputNode;
  129973. private _addFragmentOutputNode;
  129974. private _removeFragmentOutputNode;
  129975. /**
  129976. * Specifies if the material will require alpha blending
  129977. * @returns a boolean specifying if alpha blending is needed
  129978. */
  129979. needAlphaBlending(): boolean;
  129980. /**
  129981. * Specifies if this material should be rendered in alpha test mode
  129982. * @returns a boolean specifying if an alpha test is needed.
  129983. */
  129984. needAlphaTesting(): boolean;
  129985. private _initializeBlock;
  129986. private _resetDualBlocks;
  129987. /**
  129988. * Remove a block from the current node material
  129989. * @param block defines the block to remove
  129990. */
  129991. removeBlock(block: NodeMaterialBlock): void;
  129992. /**
  129993. * Build the material and generates the inner effect
  129994. * @param verbose defines if the build should log activity
  129995. */
  129996. build(verbose?: boolean): void;
  129997. /**
  129998. * Runs an otpimization phase to try to improve the shader code
  129999. */
  130000. optimize(): void;
  130001. private _prepareDefinesForAttributes;
  130002. /**
  130003. * Get if the submesh is ready to be used and all its information available.
  130004. * Child classes can use it to update shaders
  130005. * @param mesh defines the mesh to check
  130006. * @param subMesh defines which submesh to check
  130007. * @param useInstances specifies that instances should be used
  130008. * @returns a boolean indicating that the submesh is ready or not
  130009. */
  130010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130011. /**
  130012. * Get a string representing the shaders built by the current node graph
  130013. */
  130014. get compiledShaders(): string;
  130015. /**
  130016. * Binds the world matrix to the material
  130017. * @param world defines the world transformation matrix
  130018. */
  130019. bindOnlyWorldMatrix(world: Matrix): void;
  130020. /**
  130021. * Binds the submesh to this material by preparing the effect and shader to draw
  130022. * @param world defines the world transformation matrix
  130023. * @param mesh defines the mesh containing the submesh
  130024. * @param subMesh defines the submesh to bind the material to
  130025. */
  130026. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130027. /**
  130028. * Gets the active textures from the material
  130029. * @returns an array of textures
  130030. */
  130031. getActiveTextures(): BaseTexture[];
  130032. /**
  130033. * Gets the list of texture blocks
  130034. * @returns an array of texture blocks
  130035. */
  130036. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130037. /**
  130038. * Specifies if the material uses a texture
  130039. * @param texture defines the texture to check against the material
  130040. * @returns a boolean specifying if the material uses the texture
  130041. */
  130042. hasTexture(texture: BaseTexture): boolean;
  130043. /**
  130044. * Disposes the material
  130045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130047. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130048. */
  130049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130050. /** Creates the node editor window. */
  130051. private _createNodeEditor;
  130052. /**
  130053. * Launch the node material editor
  130054. * @param config Define the configuration of the editor
  130055. * @return a promise fulfilled when the node editor is visible
  130056. */
  130057. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130058. /**
  130059. * Clear the current material
  130060. */
  130061. clear(): void;
  130062. /**
  130063. * Clear the current material and set it to a default state
  130064. */
  130065. setToDefault(): void;
  130066. /**
  130067. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130068. * @param url defines the url to load from
  130069. * @returns a promise that will fullfil when the material is fully loaded
  130070. */
  130071. loadAsync(url: string): Promise<void>;
  130072. private _gatherBlocks;
  130073. /**
  130074. * Generate a string containing the code declaration required to create an equivalent of this material
  130075. * @returns a string
  130076. */
  130077. generateCode(): string;
  130078. /**
  130079. * Serializes this material in a JSON representation
  130080. * @returns the serialized material object
  130081. */
  130082. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130083. private _restoreConnections;
  130084. /**
  130085. * Clear the current graph and load a new one from a serialization object
  130086. * @param source defines the JSON representation of the material
  130087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130088. */
  130089. loadFromSerialization(source: any, rootUrl?: string): void;
  130090. /**
  130091. * Creates a node material from parsed material data
  130092. * @param source defines the JSON representation of the material
  130093. * @param scene defines the hosting scene
  130094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130095. * @returns a new node material
  130096. */
  130097. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130098. /**
  130099. * Creates a node material from a snippet saved by the node material editor
  130100. * @param snippetId defines the snippet to load
  130101. * @param scene defines the hosting scene
  130102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130103. * @returns a promise that will resolve to the new node material
  130104. */
  130105. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130106. /**
  130107. * Creates a new node material set to default basic configuration
  130108. * @param name defines the name of the material
  130109. * @param scene defines the hosting scene
  130110. * @returns a new NodeMaterial
  130111. */
  130112. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130113. }
  130114. }
  130115. declare module BABYLON {
  130116. /**
  130117. * Block used to read a texture from a sampler
  130118. */
  130119. export class TextureBlock extends NodeMaterialBlock {
  130120. private _defineName;
  130121. private _linearDefineName;
  130122. private _tempTextureRead;
  130123. private _samplerName;
  130124. private _transformedUVName;
  130125. private _textureTransformName;
  130126. private _textureInfoName;
  130127. private _mainUVName;
  130128. private _mainUVDefineName;
  130129. /**
  130130. * Gets or sets the texture associated with the node
  130131. */
  130132. texture: Nullable<Texture>;
  130133. /**
  130134. * Create a new TextureBlock
  130135. * @param name defines the block name
  130136. */
  130137. constructor(name: string);
  130138. /**
  130139. * Gets the current class name
  130140. * @returns the class name
  130141. */
  130142. getClassName(): string;
  130143. /**
  130144. * Gets the uv input component
  130145. */
  130146. get uv(): NodeMaterialConnectionPoint;
  130147. /**
  130148. * Gets the rgba output component
  130149. */
  130150. get rgba(): NodeMaterialConnectionPoint;
  130151. /**
  130152. * Gets the rgb output component
  130153. */
  130154. get rgb(): NodeMaterialConnectionPoint;
  130155. /**
  130156. * Gets the r output component
  130157. */
  130158. get r(): NodeMaterialConnectionPoint;
  130159. /**
  130160. * Gets the g output component
  130161. */
  130162. get g(): NodeMaterialConnectionPoint;
  130163. /**
  130164. * Gets the b output component
  130165. */
  130166. get b(): NodeMaterialConnectionPoint;
  130167. /**
  130168. * Gets the a output component
  130169. */
  130170. get a(): NodeMaterialConnectionPoint;
  130171. get target(): NodeMaterialBlockTargets;
  130172. autoConfigure(material: NodeMaterial): void;
  130173. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130175. isReady(): boolean;
  130176. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130177. private get _isMixed();
  130178. private _injectVertexCode;
  130179. private _writeTextureRead;
  130180. private _writeOutput;
  130181. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130182. protected _dumpPropertiesCode(): string;
  130183. serialize(): any;
  130184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130185. }
  130186. }
  130187. declare module BABYLON {
  130188. /**
  130189. * Class used to store shared data between 2 NodeMaterialBuildState
  130190. */
  130191. export class NodeMaterialBuildStateSharedData {
  130192. /**
  130193. * Gets the list of emitted varyings
  130194. */
  130195. temps: string[];
  130196. /**
  130197. * Gets the list of emitted varyings
  130198. */
  130199. varyings: string[];
  130200. /**
  130201. * Gets the varying declaration string
  130202. */
  130203. varyingDeclaration: string;
  130204. /**
  130205. * Input blocks
  130206. */
  130207. inputBlocks: InputBlock[];
  130208. /**
  130209. * Input blocks
  130210. */
  130211. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130212. /**
  130213. * Bindable blocks (Blocks that need to set data to the effect)
  130214. */
  130215. bindableBlocks: NodeMaterialBlock[];
  130216. /**
  130217. * List of blocks that can provide a compilation fallback
  130218. */
  130219. blocksWithFallbacks: NodeMaterialBlock[];
  130220. /**
  130221. * List of blocks that can provide a define update
  130222. */
  130223. blocksWithDefines: NodeMaterialBlock[];
  130224. /**
  130225. * List of blocks that can provide a repeatable content
  130226. */
  130227. repeatableContentBlocks: NodeMaterialBlock[];
  130228. /**
  130229. * List of blocks that can provide a dynamic list of uniforms
  130230. */
  130231. dynamicUniformBlocks: NodeMaterialBlock[];
  130232. /**
  130233. * List of blocks that can block the isReady function for the material
  130234. */
  130235. blockingBlocks: NodeMaterialBlock[];
  130236. /**
  130237. * Gets the list of animated inputs
  130238. */
  130239. animatedInputs: InputBlock[];
  130240. /**
  130241. * Build Id used to avoid multiple recompilations
  130242. */
  130243. buildId: number;
  130244. /** List of emitted variables */
  130245. variableNames: {
  130246. [key: string]: number;
  130247. };
  130248. /** List of emitted defines */
  130249. defineNames: {
  130250. [key: string]: number;
  130251. };
  130252. /** Should emit comments? */
  130253. emitComments: boolean;
  130254. /** Emit build activity */
  130255. verbose: boolean;
  130256. /** Gets or sets the hosting scene */
  130257. scene: Scene;
  130258. /**
  130259. * Gets the compilation hints emitted at compilation time
  130260. */
  130261. hints: {
  130262. needWorldViewMatrix: boolean;
  130263. needWorldViewProjectionMatrix: boolean;
  130264. needAlphaBlending: boolean;
  130265. needAlphaTesting: boolean;
  130266. };
  130267. /**
  130268. * List of compilation checks
  130269. */
  130270. checks: {
  130271. emitVertex: boolean;
  130272. emitFragment: boolean;
  130273. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130274. };
  130275. /** Creates a new shared data */
  130276. constructor();
  130277. /**
  130278. * Emits console errors and exceptions if there is a failing check
  130279. */
  130280. emitErrors(): void;
  130281. }
  130282. }
  130283. declare module BABYLON {
  130284. /**
  130285. * Class used to store node based material build state
  130286. */
  130287. export class NodeMaterialBuildState {
  130288. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130289. supportUniformBuffers: boolean;
  130290. /**
  130291. * Gets the list of emitted attributes
  130292. */
  130293. attributes: string[];
  130294. /**
  130295. * Gets the list of emitted uniforms
  130296. */
  130297. uniforms: string[];
  130298. /**
  130299. * Gets the list of emitted constants
  130300. */
  130301. constants: string[];
  130302. /**
  130303. * Gets the list of emitted samplers
  130304. */
  130305. samplers: string[];
  130306. /**
  130307. * Gets the list of emitted functions
  130308. */
  130309. functions: {
  130310. [key: string]: string;
  130311. };
  130312. /**
  130313. * Gets the list of emitted extensions
  130314. */
  130315. extensions: {
  130316. [key: string]: string;
  130317. };
  130318. /**
  130319. * Gets the target of the compilation state
  130320. */
  130321. target: NodeMaterialBlockTargets;
  130322. /**
  130323. * Gets the list of emitted counters
  130324. */
  130325. counters: {
  130326. [key: string]: number;
  130327. };
  130328. /**
  130329. * Shared data between multiple NodeMaterialBuildState instances
  130330. */
  130331. sharedData: NodeMaterialBuildStateSharedData;
  130332. /** @hidden */
  130333. _vertexState: NodeMaterialBuildState;
  130334. /** @hidden */
  130335. _attributeDeclaration: string;
  130336. /** @hidden */
  130337. _uniformDeclaration: string;
  130338. /** @hidden */
  130339. _constantDeclaration: string;
  130340. /** @hidden */
  130341. _samplerDeclaration: string;
  130342. /** @hidden */
  130343. _varyingTransfer: string;
  130344. private _repeatableContentAnchorIndex;
  130345. /** @hidden */
  130346. _builtCompilationString: string;
  130347. /**
  130348. * Gets the emitted compilation strings
  130349. */
  130350. compilationString: string;
  130351. /**
  130352. * Finalize the compilation strings
  130353. * @param state defines the current compilation state
  130354. */
  130355. finalize(state: NodeMaterialBuildState): void;
  130356. /** @hidden */
  130357. get _repeatableContentAnchor(): string;
  130358. /** @hidden */
  130359. _getFreeVariableName(prefix: string): string;
  130360. /** @hidden */
  130361. _getFreeDefineName(prefix: string): string;
  130362. /** @hidden */
  130363. _excludeVariableName(name: string): void;
  130364. /** @hidden */
  130365. _emit2DSampler(name: string): void;
  130366. /** @hidden */
  130367. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130368. /** @hidden */
  130369. _emitExtension(name: string, extension: string): void;
  130370. /** @hidden */
  130371. _emitFunction(name: string, code: string, comments: string): void;
  130372. /** @hidden */
  130373. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130374. replaceStrings?: {
  130375. search: RegExp;
  130376. replace: string;
  130377. }[];
  130378. repeatKey?: string;
  130379. }): string;
  130380. /** @hidden */
  130381. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130382. repeatKey?: string;
  130383. removeAttributes?: boolean;
  130384. removeUniforms?: boolean;
  130385. removeVaryings?: boolean;
  130386. removeIfDef?: boolean;
  130387. replaceStrings?: {
  130388. search: RegExp;
  130389. replace: string;
  130390. }[];
  130391. }, storeKey?: string): void;
  130392. /** @hidden */
  130393. _registerTempVariable(name: string): boolean;
  130394. /** @hidden */
  130395. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130396. /** @hidden */
  130397. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130398. /** @hidden */
  130399. _emitFloat(value: number): string;
  130400. }
  130401. }
  130402. declare module BABYLON {
  130403. /**
  130404. * Defines a block that can be used inside a node based material
  130405. */
  130406. export class NodeMaterialBlock {
  130407. private _buildId;
  130408. private _buildTarget;
  130409. private _target;
  130410. private _isFinalMerger;
  130411. private _isInput;
  130412. protected _isUnique: boolean;
  130413. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130414. inputsAreExclusive: boolean;
  130415. /** @hidden */
  130416. _codeVariableName: string;
  130417. /** @hidden */
  130418. _inputs: NodeMaterialConnectionPoint[];
  130419. /** @hidden */
  130420. _outputs: NodeMaterialConnectionPoint[];
  130421. /** @hidden */
  130422. _preparationId: number;
  130423. /**
  130424. * Gets or sets the name of the block
  130425. */
  130426. name: string;
  130427. /**
  130428. * Gets or sets the unique id of the node
  130429. */
  130430. uniqueId: number;
  130431. /**
  130432. * Gets or sets the comments associated with this block
  130433. */
  130434. comments: string;
  130435. /**
  130436. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130437. */
  130438. get isUnique(): boolean;
  130439. /**
  130440. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130441. */
  130442. get isFinalMerger(): boolean;
  130443. /**
  130444. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130445. */
  130446. get isInput(): boolean;
  130447. /**
  130448. * Gets or sets the build Id
  130449. */
  130450. get buildId(): number;
  130451. set buildId(value: number);
  130452. /**
  130453. * Gets or sets the target of the block
  130454. */
  130455. get target(): NodeMaterialBlockTargets;
  130456. set target(value: NodeMaterialBlockTargets);
  130457. /**
  130458. * Gets the list of input points
  130459. */
  130460. get inputs(): NodeMaterialConnectionPoint[];
  130461. /** Gets the list of output points */
  130462. get outputs(): NodeMaterialConnectionPoint[];
  130463. /**
  130464. * Find an input by its name
  130465. * @param name defines the name of the input to look for
  130466. * @returns the input or null if not found
  130467. */
  130468. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130469. /**
  130470. * Find an output by its name
  130471. * @param name defines the name of the outputto look for
  130472. * @returns the output or null if not found
  130473. */
  130474. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130475. /**
  130476. * Creates a new NodeMaterialBlock
  130477. * @param name defines the block name
  130478. * @param target defines the target of that block (Vertex by default)
  130479. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130480. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130481. */
  130482. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130483. /**
  130484. * Initialize the block and prepare the context for build
  130485. * @param state defines the state that will be used for the build
  130486. */
  130487. initialize(state: NodeMaterialBuildState): void;
  130488. /**
  130489. * Bind data to effect. Will only be called for blocks with isBindable === true
  130490. * @param effect defines the effect to bind data to
  130491. * @param nodeMaterial defines the hosting NodeMaterial
  130492. * @param mesh defines the mesh that will be rendered
  130493. */
  130494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130495. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130496. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130497. protected _writeFloat(value: number): string;
  130498. /**
  130499. * Gets the current class name e.g. "NodeMaterialBlock"
  130500. * @returns the class name
  130501. */
  130502. getClassName(): string;
  130503. /**
  130504. * Register a new input. Must be called inside a block constructor
  130505. * @param name defines the connection point name
  130506. * @param type defines the connection point type
  130507. * @param isOptional defines a boolean indicating that this input can be omitted
  130508. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130509. * @returns the current block
  130510. */
  130511. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130512. /**
  130513. * Register a new output. Must be called inside a block constructor
  130514. * @param name defines the connection point name
  130515. * @param type defines the connection point type
  130516. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130517. * @returns the current block
  130518. */
  130519. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130520. /**
  130521. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130522. * @param forOutput defines an optional connection point to check compatibility with
  130523. * @returns the first available input or null
  130524. */
  130525. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130526. /**
  130527. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130528. * @param forBlock defines an optional block to check compatibility with
  130529. * @returns the first available input or null
  130530. */
  130531. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130532. /**
  130533. * Gets the sibling of the given output
  130534. * @param current defines the current output
  130535. * @returns the next output in the list or null
  130536. */
  130537. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130538. /**
  130539. * Connect current block with another block
  130540. * @param other defines the block to connect with
  130541. * @param options define the various options to help pick the right connections
  130542. * @returns the current block
  130543. */
  130544. connectTo(other: NodeMaterialBlock, options?: {
  130545. input?: string;
  130546. output?: string;
  130547. outputSwizzle?: string;
  130548. }): this | undefined;
  130549. protected _buildBlock(state: NodeMaterialBuildState): void;
  130550. /**
  130551. * Add uniforms, samplers and uniform buffers at compilation time
  130552. * @param state defines the state to update
  130553. * @param nodeMaterial defines the node material requesting the update
  130554. * @param defines defines the material defines to update
  130555. * @param uniformBuffers defines the list of uniform buffer names
  130556. */
  130557. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130558. /**
  130559. * Add potential fallbacks if shader compilation fails
  130560. * @param mesh defines the mesh to be rendered
  130561. * @param fallbacks defines the current prioritized list of fallbacks
  130562. */
  130563. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130564. /**
  130565. * Initialize defines for shader compilation
  130566. * @param mesh defines the mesh to be rendered
  130567. * @param nodeMaterial defines the node material requesting the update
  130568. * @param defines defines the material defines to update
  130569. * @param useInstances specifies that instances should be used
  130570. */
  130571. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130572. /**
  130573. * Update defines for shader compilation
  130574. * @param mesh defines the mesh to be rendered
  130575. * @param nodeMaterial defines the node material requesting the update
  130576. * @param defines defines the material defines to update
  130577. * @param useInstances specifies that instances should be used
  130578. */
  130579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130580. /**
  130581. * Lets the block try to connect some inputs automatically
  130582. * @param material defines the hosting NodeMaterial
  130583. */
  130584. autoConfigure(material: NodeMaterial): void;
  130585. /**
  130586. * Function called when a block is declared as repeatable content generator
  130587. * @param vertexShaderState defines the current compilation state for the vertex shader
  130588. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130589. * @param mesh defines the mesh to be rendered
  130590. * @param defines defines the material defines to update
  130591. */
  130592. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130593. /**
  130594. * Checks if the block is ready
  130595. * @param mesh defines the mesh to be rendered
  130596. * @param nodeMaterial defines the node material requesting the update
  130597. * @param defines defines the material defines to update
  130598. * @param useInstances specifies that instances should be used
  130599. * @returns true if the block is ready
  130600. */
  130601. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130602. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130603. private _processBuild;
  130604. /**
  130605. * Compile the current node and generate the shader code
  130606. * @param state defines the current compilation state (uniforms, samplers, current string)
  130607. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130608. * @returns true if already built
  130609. */
  130610. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130611. protected _inputRename(name: string): string;
  130612. protected _outputRename(name: string): string;
  130613. protected _dumpPropertiesCode(): string;
  130614. /** @hidden */
  130615. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130616. /** @hidden */
  130617. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130618. /**
  130619. * Clone the current block to a new identical block
  130620. * @param scene defines the hosting scene
  130621. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130622. * @returns a copy of the current block
  130623. */
  130624. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130625. /**
  130626. * Serializes this block in a JSON representation
  130627. * @returns the serialized block object
  130628. */
  130629. serialize(): any;
  130630. /** @hidden */
  130631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130632. /**
  130633. * Release resources
  130634. */
  130635. dispose(): void;
  130636. }
  130637. }
  130638. declare module BABYLON {
  130639. /**
  130640. * Enum defining the type of animations supported by InputBlock
  130641. */
  130642. export enum AnimatedInputBlockTypes {
  130643. /** No animation */
  130644. None = 0,
  130645. /** Time based animation. Will only work for floats */
  130646. Time = 1
  130647. }
  130648. }
  130649. declare module BABYLON {
  130650. /**
  130651. * Block used to expose an input value
  130652. */
  130653. export class InputBlock extends NodeMaterialBlock {
  130654. private _mode;
  130655. private _associatedVariableName;
  130656. private _storedValue;
  130657. private _valueCallback;
  130658. private _type;
  130659. private _animationType;
  130660. /** Gets or set a value used to limit the range of float values */
  130661. min: number;
  130662. /** Gets or set a value used to limit the range of float values */
  130663. max: number;
  130664. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  130665. isBoolean: boolean;
  130666. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  130667. matrixMode: number;
  130668. /** @hidden */
  130669. _systemValue: Nullable<NodeMaterialSystemValues>;
  130670. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  130671. visibleInInspector: boolean;
  130672. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  130673. isConstant: boolean;
  130674. /** Gets or sets the group to use to display this block in the Inspector */
  130675. groupInInspector: string;
  130676. /**
  130677. * Gets or sets the connection point type (default is float)
  130678. */
  130679. get type(): NodeMaterialBlockConnectionPointTypes;
  130680. /**
  130681. * Creates a new InputBlock
  130682. * @param name defines the block name
  130683. * @param target defines the target of that block (Vertex by default)
  130684. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  130685. */
  130686. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  130687. /**
  130688. * Gets the output component
  130689. */
  130690. get output(): NodeMaterialConnectionPoint;
  130691. /**
  130692. * Set the source of this connection point to a vertex attribute
  130693. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  130694. * @returns the current connection point
  130695. */
  130696. setAsAttribute(attributeName?: string): InputBlock;
  130697. /**
  130698. * Set the source of this connection point to a system value
  130699. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  130700. * @returns the current connection point
  130701. */
  130702. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  130703. /**
  130704. * Gets or sets the value of that point.
  130705. * Please note that this value will be ignored if valueCallback is defined
  130706. */
  130707. get value(): any;
  130708. set value(value: any);
  130709. /**
  130710. * Gets or sets a callback used to get the value of that point.
  130711. * Please note that setting this value will force the connection point to ignore the value property
  130712. */
  130713. get valueCallback(): () => any;
  130714. set valueCallback(value: () => any);
  130715. /**
  130716. * Gets or sets the associated variable name in the shader
  130717. */
  130718. get associatedVariableName(): string;
  130719. set associatedVariableName(value: string);
  130720. /** Gets or sets the type of animation applied to the input */
  130721. get animationType(): AnimatedInputBlockTypes;
  130722. set animationType(value: AnimatedInputBlockTypes);
  130723. /**
  130724. * Gets a boolean indicating that this connection point not defined yet
  130725. */
  130726. get isUndefined(): boolean;
  130727. /**
  130728. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  130729. * In this case the connection point name must be the name of the uniform to use.
  130730. * Can only be set on inputs
  130731. */
  130732. get isUniform(): boolean;
  130733. set isUniform(value: boolean);
  130734. /**
  130735. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  130736. * In this case the connection point name must be the name of the attribute to use
  130737. * Can only be set on inputs
  130738. */
  130739. get isAttribute(): boolean;
  130740. set isAttribute(value: boolean);
  130741. /**
  130742. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  130743. * Can only be set on exit points
  130744. */
  130745. get isVarying(): boolean;
  130746. set isVarying(value: boolean);
  130747. /**
  130748. * Gets a boolean indicating that the current connection point is a system value
  130749. */
  130750. get isSystemValue(): boolean;
  130751. /**
  130752. * Gets or sets the current well known value or null if not defined as a system value
  130753. */
  130754. get systemValue(): Nullable<NodeMaterialSystemValues>;
  130755. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  130756. /**
  130757. * Gets the current class name
  130758. * @returns the class name
  130759. */
  130760. getClassName(): string;
  130761. /**
  130762. * Animate the input if animationType !== None
  130763. * @param scene defines the rendering scene
  130764. */
  130765. animate(scene: Scene): void;
  130766. private _emitDefine;
  130767. initialize(state: NodeMaterialBuildState): void;
  130768. /**
  130769. * Set the input block to its default value (based on its type)
  130770. */
  130771. setDefaultValue(): void;
  130772. private _emitConstant;
  130773. private _emit;
  130774. /** @hidden */
  130775. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  130776. /** @hidden */
  130777. _transmit(effect: Effect, scene: Scene): void;
  130778. protected _buildBlock(state: NodeMaterialBuildState): void;
  130779. protected _dumpPropertiesCode(): string;
  130780. serialize(): any;
  130781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130782. }
  130783. }
  130784. declare module BABYLON {
  130785. /**
  130786. * Enum used to define the compatibility state between two connection points
  130787. */
  130788. export enum NodeMaterialConnectionPointCompatibilityStates {
  130789. /** Points are compatibles */
  130790. Compatible = 0,
  130791. /** Points are incompatible because of their types */
  130792. TypeIncompatible = 1,
  130793. /** Points are incompatible because of their targets (vertex vs fragment) */
  130794. TargetIncompatible = 2
  130795. }
  130796. /**
  130797. * Defines the direction of a connection point
  130798. */
  130799. export enum NodeMaterialConnectionPointDirection {
  130800. /** Input */
  130801. Input = 0,
  130802. /** Output */
  130803. Output = 1
  130804. }
  130805. /**
  130806. * Defines a connection point for a block
  130807. */
  130808. export class NodeMaterialConnectionPoint {
  130809. /** @hidden */
  130810. _ownerBlock: NodeMaterialBlock;
  130811. /** @hidden */
  130812. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  130813. private _endpoints;
  130814. private _associatedVariableName;
  130815. private _direction;
  130816. /** @hidden */
  130817. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130818. /** @hidden */
  130819. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130820. private _type;
  130821. /** @hidden */
  130822. _enforceAssociatedVariableName: boolean;
  130823. /** Gets the direction of the point */
  130824. get direction(): NodeMaterialConnectionPointDirection;
  130825. /**
  130826. * Gets or sets the additional types supported by this connection point
  130827. */
  130828. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130829. /**
  130830. * Gets or sets the additional types excluded by this connection point
  130831. */
  130832. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130833. /**
  130834. * Observable triggered when this point is connected
  130835. */
  130836. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  130837. /**
  130838. * Gets or sets the associated variable name in the shader
  130839. */
  130840. get associatedVariableName(): string;
  130841. set associatedVariableName(value: string);
  130842. /**
  130843. * Gets or sets the connection point type (default is float)
  130844. */
  130845. get type(): NodeMaterialBlockConnectionPointTypes;
  130846. set type(value: NodeMaterialBlockConnectionPointTypes);
  130847. /**
  130848. * Gets or sets the connection point name
  130849. */
  130850. name: string;
  130851. /**
  130852. * Gets or sets a boolean indicating that this connection point can be omitted
  130853. */
  130854. isOptional: boolean;
  130855. /**
  130856. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  130857. */
  130858. define: string;
  130859. /** @hidden */
  130860. _prioritizeVertex: boolean;
  130861. private _target;
  130862. /** Gets or sets the target of that connection point */
  130863. get target(): NodeMaterialBlockTargets;
  130864. set target(value: NodeMaterialBlockTargets);
  130865. /**
  130866. * Gets a boolean indicating that the current point is connected
  130867. */
  130868. get isConnected(): boolean;
  130869. /**
  130870. * Gets a boolean indicating that the current point is connected to an input block
  130871. */
  130872. get isConnectedToInputBlock(): boolean;
  130873. /**
  130874. * Gets a the connected input block (if any)
  130875. */
  130876. get connectInputBlock(): Nullable<InputBlock>;
  130877. /** Get the other side of the connection (if any) */
  130878. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  130879. /** Get the block that owns this connection point */
  130880. get ownerBlock(): NodeMaterialBlock;
  130881. /** Get the block connected on the other side of this connection (if any) */
  130882. get sourceBlock(): Nullable<NodeMaterialBlock>;
  130883. /** Get the block connected on the endpoints of this connection (if any) */
  130884. get connectedBlocks(): Array<NodeMaterialBlock>;
  130885. /** Gets the list of connected endpoints */
  130886. get endpoints(): NodeMaterialConnectionPoint[];
  130887. /** Gets a boolean indicating if that output point is connected to at least one input */
  130888. get hasEndpoints(): boolean;
  130889. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  130890. get isConnectedInVertexShader(): boolean;
  130891. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  130892. get isConnectedInFragmentShader(): boolean;
  130893. /**
  130894. * Creates a new connection point
  130895. * @param name defines the connection point name
  130896. * @param ownerBlock defines the block hosting this connection point
  130897. * @param direction defines the direction of the connection point
  130898. */
  130899. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  130900. /**
  130901. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  130902. * @returns the class name
  130903. */
  130904. getClassName(): string;
  130905. /**
  130906. * Gets a boolean indicating if the current point can be connected to another point
  130907. * @param connectionPoint defines the other connection point
  130908. * @returns a boolean
  130909. */
  130910. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  130911. /**
  130912. * Gets a number indicating if the current point can be connected to another point
  130913. * @param connectionPoint defines the other connection point
  130914. * @returns a number defining the compatibility state
  130915. */
  130916. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  130917. /**
  130918. * Connect this point to another connection point
  130919. * @param connectionPoint defines the other connection point
  130920. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  130921. * @returns the current connection point
  130922. */
  130923. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  130924. /**
  130925. * Disconnect this point from one of his endpoint
  130926. * @param endpoint defines the other connection point
  130927. * @returns the current connection point
  130928. */
  130929. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  130930. /**
  130931. * Serializes this point in a JSON representation
  130932. * @returns the serialized point object
  130933. */
  130934. serialize(): any;
  130935. /**
  130936. * Release resources
  130937. */
  130938. dispose(): void;
  130939. }
  130940. }
  130941. declare module BABYLON {
  130942. /**
  130943. * Block used to add support for vertex skinning (bones)
  130944. */
  130945. export class BonesBlock extends NodeMaterialBlock {
  130946. /**
  130947. * Creates a new BonesBlock
  130948. * @param name defines the block name
  130949. */
  130950. constructor(name: string);
  130951. /**
  130952. * Initialize the block and prepare the context for build
  130953. * @param state defines the state that will be used for the build
  130954. */
  130955. initialize(state: NodeMaterialBuildState): void;
  130956. /**
  130957. * Gets the current class name
  130958. * @returns the class name
  130959. */
  130960. getClassName(): string;
  130961. /**
  130962. * Gets the matrix indices input component
  130963. */
  130964. get matricesIndices(): NodeMaterialConnectionPoint;
  130965. /**
  130966. * Gets the matrix weights input component
  130967. */
  130968. get matricesWeights(): NodeMaterialConnectionPoint;
  130969. /**
  130970. * Gets the extra matrix indices input component
  130971. */
  130972. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  130973. /**
  130974. * Gets the extra matrix weights input component
  130975. */
  130976. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  130977. /**
  130978. * Gets the world input component
  130979. */
  130980. get world(): NodeMaterialConnectionPoint;
  130981. /**
  130982. * Gets the output component
  130983. */
  130984. get output(): NodeMaterialConnectionPoint;
  130985. autoConfigure(material: NodeMaterial): void;
  130986. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130989. protected _buildBlock(state: NodeMaterialBuildState): this;
  130990. }
  130991. }
  130992. declare module BABYLON {
  130993. /**
  130994. * Block used to add support for instances
  130995. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  130996. */
  130997. export class InstancesBlock extends NodeMaterialBlock {
  130998. /**
  130999. * Creates a new InstancesBlock
  131000. * @param name defines the block name
  131001. */
  131002. constructor(name: string);
  131003. /**
  131004. * Gets the current class name
  131005. * @returns the class name
  131006. */
  131007. getClassName(): string;
  131008. /**
  131009. * Gets the first world row input component
  131010. */
  131011. get world0(): NodeMaterialConnectionPoint;
  131012. /**
  131013. * Gets the second world row input component
  131014. */
  131015. get world1(): NodeMaterialConnectionPoint;
  131016. /**
  131017. * Gets the third world row input component
  131018. */
  131019. get world2(): NodeMaterialConnectionPoint;
  131020. /**
  131021. * Gets the forth world row input component
  131022. */
  131023. get world3(): NodeMaterialConnectionPoint;
  131024. /**
  131025. * Gets the world input component
  131026. */
  131027. get world(): NodeMaterialConnectionPoint;
  131028. /**
  131029. * Gets the output component
  131030. */
  131031. get output(): NodeMaterialConnectionPoint;
  131032. autoConfigure(material: NodeMaterial): void;
  131033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131034. protected _buildBlock(state: NodeMaterialBuildState): this;
  131035. }
  131036. }
  131037. declare module BABYLON {
  131038. /**
  131039. * Block used to add morph targets support to vertex shader
  131040. */
  131041. export class MorphTargetsBlock extends NodeMaterialBlock {
  131042. private _repeatableContentAnchor;
  131043. /**
  131044. * Create a new MorphTargetsBlock
  131045. * @param name defines the block name
  131046. */
  131047. constructor(name: string);
  131048. /**
  131049. * Gets the current class name
  131050. * @returns the class name
  131051. */
  131052. getClassName(): string;
  131053. /**
  131054. * Gets the position input component
  131055. */
  131056. get position(): NodeMaterialConnectionPoint;
  131057. /**
  131058. * Gets the normal input component
  131059. */
  131060. get normal(): NodeMaterialConnectionPoint;
  131061. /**
  131062. * Gets the tangent input component
  131063. */
  131064. get tangent(): NodeMaterialConnectionPoint;
  131065. /**
  131066. * Gets the tangent input component
  131067. */
  131068. get uv(): NodeMaterialConnectionPoint;
  131069. /**
  131070. * Gets the position output component
  131071. */
  131072. get positionOutput(): NodeMaterialConnectionPoint;
  131073. /**
  131074. * Gets the normal output component
  131075. */
  131076. get normalOutput(): NodeMaterialConnectionPoint;
  131077. /**
  131078. * Gets the tangent output component
  131079. */
  131080. get tangentOutput(): NodeMaterialConnectionPoint;
  131081. /**
  131082. * Gets the tangent output component
  131083. */
  131084. get uvOutput(): NodeMaterialConnectionPoint;
  131085. initialize(state: NodeMaterialBuildState): void;
  131086. autoConfigure(material: NodeMaterial): void;
  131087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131089. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131090. protected _buildBlock(state: NodeMaterialBuildState): this;
  131091. }
  131092. }
  131093. declare module BABYLON {
  131094. /**
  131095. * Block used to get data information from a light
  131096. */
  131097. export class LightInformationBlock extends NodeMaterialBlock {
  131098. private _lightDataUniformName;
  131099. private _lightColorUniformName;
  131100. private _lightTypeDefineName;
  131101. /**
  131102. * Gets or sets the light associated with this block
  131103. */
  131104. light: Nullable<Light>;
  131105. /**
  131106. * Creates a new LightInformationBlock
  131107. * @param name defines the block name
  131108. */
  131109. constructor(name: string);
  131110. /**
  131111. * Gets the current class name
  131112. * @returns the class name
  131113. */
  131114. getClassName(): string;
  131115. /**
  131116. * Gets the world position input component
  131117. */
  131118. get worldPosition(): NodeMaterialConnectionPoint;
  131119. /**
  131120. * Gets the direction output component
  131121. */
  131122. get direction(): NodeMaterialConnectionPoint;
  131123. /**
  131124. * Gets the direction output component
  131125. */
  131126. get color(): NodeMaterialConnectionPoint;
  131127. /**
  131128. * Gets the direction output component
  131129. */
  131130. get intensity(): NodeMaterialConnectionPoint;
  131131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131132. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131133. protected _buildBlock(state: NodeMaterialBuildState): this;
  131134. serialize(): any;
  131135. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131136. }
  131137. }
  131138. declare module BABYLON {
  131139. /**
  131140. * Block used to add image processing support to fragment shader
  131141. */
  131142. export class ImageProcessingBlock extends NodeMaterialBlock {
  131143. /**
  131144. * Create a new ImageProcessingBlock
  131145. * @param name defines the block name
  131146. */
  131147. constructor(name: string);
  131148. /**
  131149. * Gets the current class name
  131150. * @returns the class name
  131151. */
  131152. getClassName(): string;
  131153. /**
  131154. * Gets the color input component
  131155. */
  131156. get color(): NodeMaterialConnectionPoint;
  131157. /**
  131158. * Gets the output component
  131159. */
  131160. get output(): NodeMaterialConnectionPoint;
  131161. /**
  131162. * Initialize the block and prepare the context for build
  131163. * @param state defines the state that will be used for the build
  131164. */
  131165. initialize(state: NodeMaterialBuildState): void;
  131166. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131169. protected _buildBlock(state: NodeMaterialBuildState): this;
  131170. }
  131171. }
  131172. declare module BABYLON {
  131173. /**
  131174. * Block used to pertub normals based on a normal map
  131175. */
  131176. export class PerturbNormalBlock extends NodeMaterialBlock {
  131177. private _tangentSpaceParameterName;
  131178. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131179. invertX: boolean;
  131180. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131181. invertY: boolean;
  131182. /**
  131183. * Create a new PerturbNormalBlock
  131184. * @param name defines the block name
  131185. */
  131186. constructor(name: string);
  131187. /**
  131188. * Gets the current class name
  131189. * @returns the class name
  131190. */
  131191. getClassName(): string;
  131192. /**
  131193. * Gets the world position input component
  131194. */
  131195. get worldPosition(): NodeMaterialConnectionPoint;
  131196. /**
  131197. * Gets the world normal input component
  131198. */
  131199. get worldNormal(): NodeMaterialConnectionPoint;
  131200. /**
  131201. * Gets the uv input component
  131202. */
  131203. get uv(): NodeMaterialConnectionPoint;
  131204. /**
  131205. * Gets the normal map color input component
  131206. */
  131207. get normalMapColor(): NodeMaterialConnectionPoint;
  131208. /**
  131209. * Gets the strength input component
  131210. */
  131211. get strength(): NodeMaterialConnectionPoint;
  131212. /**
  131213. * Gets the output component
  131214. */
  131215. get output(): NodeMaterialConnectionPoint;
  131216. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131218. autoConfigure(material: NodeMaterial): void;
  131219. protected _buildBlock(state: NodeMaterialBuildState): this;
  131220. protected _dumpPropertiesCode(): string;
  131221. serialize(): any;
  131222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131223. }
  131224. }
  131225. declare module BABYLON {
  131226. /**
  131227. * Block used to discard a pixel if a value is smaller than a cutoff
  131228. */
  131229. export class DiscardBlock extends NodeMaterialBlock {
  131230. /**
  131231. * Create a new DiscardBlock
  131232. * @param name defines the block name
  131233. */
  131234. constructor(name: string);
  131235. /**
  131236. * Gets the current class name
  131237. * @returns the class name
  131238. */
  131239. getClassName(): string;
  131240. /**
  131241. * Gets the color input component
  131242. */
  131243. get value(): NodeMaterialConnectionPoint;
  131244. /**
  131245. * Gets the cutoff input component
  131246. */
  131247. get cutoff(): NodeMaterialConnectionPoint;
  131248. protected _buildBlock(state: NodeMaterialBuildState): this;
  131249. }
  131250. }
  131251. declare module BABYLON {
  131252. /**
  131253. * Block used to test if the fragment shader is front facing
  131254. */
  131255. export class FrontFacingBlock extends NodeMaterialBlock {
  131256. /**
  131257. * Creates a new FrontFacingBlock
  131258. * @param name defines the block name
  131259. */
  131260. constructor(name: string);
  131261. /**
  131262. * Gets the current class name
  131263. * @returns the class name
  131264. */
  131265. getClassName(): string;
  131266. /**
  131267. * Gets the output component
  131268. */
  131269. get output(): NodeMaterialConnectionPoint;
  131270. protected _buildBlock(state: NodeMaterialBuildState): this;
  131271. }
  131272. }
  131273. declare module BABYLON {
  131274. /**
  131275. * Block used to get the derivative value on x and y of a given input
  131276. */
  131277. export class DerivativeBlock extends NodeMaterialBlock {
  131278. /**
  131279. * Create a new DerivativeBlock
  131280. * @param name defines the block name
  131281. */
  131282. constructor(name: string);
  131283. /**
  131284. * Gets the current class name
  131285. * @returns the class name
  131286. */
  131287. getClassName(): string;
  131288. /**
  131289. * Gets the input component
  131290. */
  131291. get input(): NodeMaterialConnectionPoint;
  131292. /**
  131293. * Gets the derivative output on x
  131294. */
  131295. get dx(): NodeMaterialConnectionPoint;
  131296. /**
  131297. * Gets the derivative output on y
  131298. */
  131299. get dy(): NodeMaterialConnectionPoint;
  131300. protected _buildBlock(state: NodeMaterialBuildState): this;
  131301. }
  131302. }
  131303. declare module BABYLON {
  131304. /**
  131305. * Block used to add support for scene fog
  131306. */
  131307. export class FogBlock extends NodeMaterialBlock {
  131308. private _fogDistanceName;
  131309. private _fogParameters;
  131310. /**
  131311. * Create a new FogBlock
  131312. * @param name defines the block name
  131313. */
  131314. constructor(name: string);
  131315. /**
  131316. * Gets the current class name
  131317. * @returns the class name
  131318. */
  131319. getClassName(): string;
  131320. /**
  131321. * Gets the world position input component
  131322. */
  131323. get worldPosition(): NodeMaterialConnectionPoint;
  131324. /**
  131325. * Gets the view input component
  131326. */
  131327. get view(): NodeMaterialConnectionPoint;
  131328. /**
  131329. * Gets the color input component
  131330. */
  131331. get input(): NodeMaterialConnectionPoint;
  131332. /**
  131333. * Gets the fog color input component
  131334. */
  131335. get fogColor(): NodeMaterialConnectionPoint;
  131336. /**
  131337. * Gets the output component
  131338. */
  131339. get output(): NodeMaterialConnectionPoint;
  131340. autoConfigure(material: NodeMaterial): void;
  131341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131342. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131343. protected _buildBlock(state: NodeMaterialBuildState): this;
  131344. }
  131345. }
  131346. declare module BABYLON {
  131347. /**
  131348. * Block used to add light in the fragment shader
  131349. */
  131350. export class LightBlock extends NodeMaterialBlock {
  131351. private _lightId;
  131352. /**
  131353. * Gets or sets the light associated with this block
  131354. */
  131355. light: Nullable<Light>;
  131356. /**
  131357. * Create a new LightBlock
  131358. * @param name defines the block name
  131359. */
  131360. constructor(name: string);
  131361. /**
  131362. * Gets the current class name
  131363. * @returns the class name
  131364. */
  131365. getClassName(): string;
  131366. /**
  131367. * Gets the world position input component
  131368. */
  131369. get worldPosition(): NodeMaterialConnectionPoint;
  131370. /**
  131371. * Gets the world normal input component
  131372. */
  131373. get worldNormal(): NodeMaterialConnectionPoint;
  131374. /**
  131375. * Gets the camera (or eye) position component
  131376. */
  131377. get cameraPosition(): NodeMaterialConnectionPoint;
  131378. /**
  131379. * Gets the glossiness component
  131380. */
  131381. get glossiness(): NodeMaterialConnectionPoint;
  131382. /**
  131383. * Gets the glossinness power component
  131384. */
  131385. get glossPower(): NodeMaterialConnectionPoint;
  131386. /**
  131387. * Gets the diffuse color component
  131388. */
  131389. get diffuseColor(): NodeMaterialConnectionPoint;
  131390. /**
  131391. * Gets the specular color component
  131392. */
  131393. get specularColor(): NodeMaterialConnectionPoint;
  131394. /**
  131395. * Gets the diffuse output component
  131396. */
  131397. get diffuseOutput(): NodeMaterialConnectionPoint;
  131398. /**
  131399. * Gets the specular output component
  131400. */
  131401. get specularOutput(): NodeMaterialConnectionPoint;
  131402. /**
  131403. * Gets the shadow output component
  131404. */
  131405. get shadow(): NodeMaterialConnectionPoint;
  131406. autoConfigure(material: NodeMaterial): void;
  131407. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131408. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131409. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131410. private _injectVertexCode;
  131411. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131412. serialize(): any;
  131413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131414. }
  131415. }
  131416. declare module BABYLON {
  131417. /**
  131418. * Block used to multiply 2 values
  131419. */
  131420. export class MultiplyBlock extends NodeMaterialBlock {
  131421. /**
  131422. * Creates a new MultiplyBlock
  131423. * @param name defines the block name
  131424. */
  131425. constructor(name: string);
  131426. /**
  131427. * Gets the current class name
  131428. * @returns the class name
  131429. */
  131430. getClassName(): string;
  131431. /**
  131432. * Gets the left operand input component
  131433. */
  131434. get left(): NodeMaterialConnectionPoint;
  131435. /**
  131436. * Gets the right operand input component
  131437. */
  131438. get right(): NodeMaterialConnectionPoint;
  131439. /**
  131440. * Gets the output component
  131441. */
  131442. get output(): NodeMaterialConnectionPoint;
  131443. protected _buildBlock(state: NodeMaterialBuildState): this;
  131444. }
  131445. }
  131446. declare module BABYLON {
  131447. /**
  131448. * Block used to add 2 vectors
  131449. */
  131450. export class AddBlock extends NodeMaterialBlock {
  131451. /**
  131452. * Creates a new AddBlock
  131453. * @param name defines the block name
  131454. */
  131455. constructor(name: string);
  131456. /**
  131457. * Gets the current class name
  131458. * @returns the class name
  131459. */
  131460. getClassName(): string;
  131461. /**
  131462. * Gets the left operand input component
  131463. */
  131464. get left(): NodeMaterialConnectionPoint;
  131465. /**
  131466. * Gets the right operand input component
  131467. */
  131468. get right(): NodeMaterialConnectionPoint;
  131469. /**
  131470. * Gets the output component
  131471. */
  131472. get output(): NodeMaterialConnectionPoint;
  131473. protected _buildBlock(state: NodeMaterialBuildState): this;
  131474. }
  131475. }
  131476. declare module BABYLON {
  131477. /**
  131478. * Block used to scale a vector by a float
  131479. */
  131480. export class ScaleBlock extends NodeMaterialBlock {
  131481. /**
  131482. * Creates a new ScaleBlock
  131483. * @param name defines the block name
  131484. */
  131485. constructor(name: string);
  131486. /**
  131487. * Gets the current class name
  131488. * @returns the class name
  131489. */
  131490. getClassName(): string;
  131491. /**
  131492. * Gets the input component
  131493. */
  131494. get input(): NodeMaterialConnectionPoint;
  131495. /**
  131496. * Gets the factor input component
  131497. */
  131498. get factor(): NodeMaterialConnectionPoint;
  131499. /**
  131500. * Gets the output component
  131501. */
  131502. get output(): NodeMaterialConnectionPoint;
  131503. protected _buildBlock(state: NodeMaterialBuildState): this;
  131504. }
  131505. }
  131506. declare module BABYLON {
  131507. /**
  131508. * Block used to clamp a float
  131509. */
  131510. export class ClampBlock extends NodeMaterialBlock {
  131511. /** Gets or sets the minimum range */
  131512. minimum: number;
  131513. /** Gets or sets the maximum range */
  131514. maximum: number;
  131515. /**
  131516. * Creates a new ClampBlock
  131517. * @param name defines the block name
  131518. */
  131519. constructor(name: string);
  131520. /**
  131521. * Gets the current class name
  131522. * @returns the class name
  131523. */
  131524. getClassName(): string;
  131525. /**
  131526. * Gets the value input component
  131527. */
  131528. get value(): NodeMaterialConnectionPoint;
  131529. /**
  131530. * Gets the output component
  131531. */
  131532. get output(): NodeMaterialConnectionPoint;
  131533. protected _buildBlock(state: NodeMaterialBuildState): this;
  131534. protected _dumpPropertiesCode(): string;
  131535. serialize(): any;
  131536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131537. }
  131538. }
  131539. declare module BABYLON {
  131540. /**
  131541. * Block used to apply a cross product between 2 vectors
  131542. */
  131543. export class CrossBlock extends NodeMaterialBlock {
  131544. /**
  131545. * Creates a new CrossBlock
  131546. * @param name defines the block name
  131547. */
  131548. constructor(name: string);
  131549. /**
  131550. * Gets the current class name
  131551. * @returns the class name
  131552. */
  131553. getClassName(): string;
  131554. /**
  131555. * Gets the left operand input component
  131556. */
  131557. get left(): NodeMaterialConnectionPoint;
  131558. /**
  131559. * Gets the right operand input component
  131560. */
  131561. get right(): NodeMaterialConnectionPoint;
  131562. /**
  131563. * Gets the output component
  131564. */
  131565. get output(): NodeMaterialConnectionPoint;
  131566. protected _buildBlock(state: NodeMaterialBuildState): this;
  131567. }
  131568. }
  131569. declare module BABYLON {
  131570. /**
  131571. * Block used to apply a dot product between 2 vectors
  131572. */
  131573. export class DotBlock extends NodeMaterialBlock {
  131574. /**
  131575. * Creates a new DotBlock
  131576. * @param name defines the block name
  131577. */
  131578. constructor(name: string);
  131579. /**
  131580. * Gets the current class name
  131581. * @returns the class name
  131582. */
  131583. getClassName(): string;
  131584. /**
  131585. * Gets the left operand input component
  131586. */
  131587. get left(): NodeMaterialConnectionPoint;
  131588. /**
  131589. * Gets the right operand input component
  131590. */
  131591. get right(): NodeMaterialConnectionPoint;
  131592. /**
  131593. * Gets the output component
  131594. */
  131595. get output(): NodeMaterialConnectionPoint;
  131596. protected _buildBlock(state: NodeMaterialBuildState): this;
  131597. }
  131598. }
  131599. declare module BABYLON {
  131600. /**
  131601. * Block used to remap a float from a range to a new one
  131602. */
  131603. export class RemapBlock extends NodeMaterialBlock {
  131604. /**
  131605. * Gets or sets the source range
  131606. */
  131607. sourceRange: Vector2;
  131608. /**
  131609. * Gets or sets the target range
  131610. */
  131611. targetRange: Vector2;
  131612. /**
  131613. * Creates a new RemapBlock
  131614. * @param name defines the block name
  131615. */
  131616. constructor(name: string);
  131617. /**
  131618. * Gets the current class name
  131619. * @returns the class name
  131620. */
  131621. getClassName(): string;
  131622. /**
  131623. * Gets the input component
  131624. */
  131625. get input(): NodeMaterialConnectionPoint;
  131626. /**
  131627. * Gets the source min input component
  131628. */
  131629. get sourceMin(): NodeMaterialConnectionPoint;
  131630. /**
  131631. * Gets the source max input component
  131632. */
  131633. get sourceMax(): NodeMaterialConnectionPoint;
  131634. /**
  131635. * Gets the target min input component
  131636. */
  131637. get targetMin(): NodeMaterialConnectionPoint;
  131638. /**
  131639. * Gets the target max input component
  131640. */
  131641. get targetMax(): NodeMaterialConnectionPoint;
  131642. /**
  131643. * Gets the output component
  131644. */
  131645. get output(): NodeMaterialConnectionPoint;
  131646. protected _buildBlock(state: NodeMaterialBuildState): this;
  131647. protected _dumpPropertiesCode(): string;
  131648. serialize(): any;
  131649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131650. }
  131651. }
  131652. declare module BABYLON {
  131653. /**
  131654. * Block used to normalize a vector
  131655. */
  131656. export class NormalizeBlock extends NodeMaterialBlock {
  131657. /**
  131658. * Creates a new NormalizeBlock
  131659. * @param name defines the block name
  131660. */
  131661. constructor(name: string);
  131662. /**
  131663. * Gets the current class name
  131664. * @returns the class name
  131665. */
  131666. getClassName(): string;
  131667. /**
  131668. * Gets the input component
  131669. */
  131670. get input(): NodeMaterialConnectionPoint;
  131671. /**
  131672. * Gets the output component
  131673. */
  131674. get output(): NodeMaterialConnectionPoint;
  131675. protected _buildBlock(state: NodeMaterialBuildState): this;
  131676. }
  131677. }
  131678. declare module BABYLON {
  131679. /**
  131680. * Operations supported by the Trigonometry block
  131681. */
  131682. export enum TrigonometryBlockOperations {
  131683. /** Cos */
  131684. Cos = 0,
  131685. /** Sin */
  131686. Sin = 1,
  131687. /** Abs */
  131688. Abs = 2,
  131689. /** Exp */
  131690. Exp = 3,
  131691. /** Exp2 */
  131692. Exp2 = 4,
  131693. /** Round */
  131694. Round = 5,
  131695. /** Floor */
  131696. Floor = 6,
  131697. /** Ceiling */
  131698. Ceiling = 7,
  131699. /** Square root */
  131700. Sqrt = 8,
  131701. /** Log */
  131702. Log = 9,
  131703. /** Tangent */
  131704. Tan = 10,
  131705. /** Arc tangent */
  131706. ArcTan = 11,
  131707. /** Arc cosinus */
  131708. ArcCos = 12,
  131709. /** Arc sinus */
  131710. ArcSin = 13,
  131711. /** Fraction */
  131712. Fract = 14,
  131713. /** Sign */
  131714. Sign = 15,
  131715. /** To radians (from degrees) */
  131716. Radians = 16,
  131717. /** To degrees (from radians) */
  131718. Degrees = 17
  131719. }
  131720. /**
  131721. * Block used to apply trigonometry operation to floats
  131722. */
  131723. export class TrigonometryBlock extends NodeMaterialBlock {
  131724. /**
  131725. * Gets or sets the operation applied by the block
  131726. */
  131727. operation: TrigonometryBlockOperations;
  131728. /**
  131729. * Creates a new TrigonometryBlock
  131730. * @param name defines the block name
  131731. */
  131732. constructor(name: string);
  131733. /**
  131734. * Gets the current class name
  131735. * @returns the class name
  131736. */
  131737. getClassName(): string;
  131738. /**
  131739. * Gets the input component
  131740. */
  131741. get input(): NodeMaterialConnectionPoint;
  131742. /**
  131743. * Gets the output component
  131744. */
  131745. get output(): NodeMaterialConnectionPoint;
  131746. protected _buildBlock(state: NodeMaterialBuildState): this;
  131747. serialize(): any;
  131748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131749. protected _dumpPropertiesCode(): string;
  131750. }
  131751. }
  131752. declare module BABYLON {
  131753. /**
  131754. * Block used to create a Color3/4 out of individual inputs (one for each component)
  131755. */
  131756. export class ColorMergerBlock extends NodeMaterialBlock {
  131757. /**
  131758. * Create a new ColorMergerBlock
  131759. * @param name defines the block name
  131760. */
  131761. constructor(name: string);
  131762. /**
  131763. * Gets the current class name
  131764. * @returns the class name
  131765. */
  131766. getClassName(): string;
  131767. /**
  131768. * Gets the rgb component (input)
  131769. */
  131770. get rgbIn(): NodeMaterialConnectionPoint;
  131771. /**
  131772. * Gets the r component (input)
  131773. */
  131774. get r(): NodeMaterialConnectionPoint;
  131775. /**
  131776. * Gets the g component (input)
  131777. */
  131778. get g(): NodeMaterialConnectionPoint;
  131779. /**
  131780. * Gets the b component (input)
  131781. */
  131782. get b(): NodeMaterialConnectionPoint;
  131783. /**
  131784. * Gets the a component (input)
  131785. */
  131786. get a(): NodeMaterialConnectionPoint;
  131787. /**
  131788. * Gets the rgba component (output)
  131789. */
  131790. get rgba(): NodeMaterialConnectionPoint;
  131791. /**
  131792. * Gets the rgb component (output)
  131793. */
  131794. get rgbOut(): NodeMaterialConnectionPoint;
  131795. /**
  131796. * Gets the rgb component (output)
  131797. * @deprecated Please use rgbOut instead.
  131798. */
  131799. get rgb(): NodeMaterialConnectionPoint;
  131800. protected _buildBlock(state: NodeMaterialBuildState): this;
  131801. }
  131802. }
  131803. declare module BABYLON {
  131804. /**
  131805. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  131806. */
  131807. export class VectorMergerBlock extends NodeMaterialBlock {
  131808. /**
  131809. * Create a new VectorMergerBlock
  131810. * @param name defines the block name
  131811. */
  131812. constructor(name: string);
  131813. /**
  131814. * Gets the current class name
  131815. * @returns the class name
  131816. */
  131817. getClassName(): string;
  131818. /**
  131819. * Gets the xyz component (input)
  131820. */
  131821. get xyzIn(): NodeMaterialConnectionPoint;
  131822. /**
  131823. * Gets the xy component (input)
  131824. */
  131825. get xyIn(): NodeMaterialConnectionPoint;
  131826. /**
  131827. * Gets the x component (input)
  131828. */
  131829. get x(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the y component (input)
  131832. */
  131833. get y(): NodeMaterialConnectionPoint;
  131834. /**
  131835. * Gets the z component (input)
  131836. */
  131837. get z(): NodeMaterialConnectionPoint;
  131838. /**
  131839. * Gets the w component (input)
  131840. */
  131841. get w(): NodeMaterialConnectionPoint;
  131842. /**
  131843. * Gets the xyzw component (output)
  131844. */
  131845. get xyzw(): NodeMaterialConnectionPoint;
  131846. /**
  131847. * Gets the xyz component (output)
  131848. */
  131849. get xyzOut(): NodeMaterialConnectionPoint;
  131850. /**
  131851. * Gets the xy component (output)
  131852. */
  131853. get xyOut(): NodeMaterialConnectionPoint;
  131854. /**
  131855. * Gets the xy component (output)
  131856. * @deprecated Please use xyOut instead.
  131857. */
  131858. get xy(): NodeMaterialConnectionPoint;
  131859. /**
  131860. * Gets the xyz component (output)
  131861. * @deprecated Please use xyzOut instead.
  131862. */
  131863. get xyz(): NodeMaterialConnectionPoint;
  131864. protected _buildBlock(state: NodeMaterialBuildState): this;
  131865. }
  131866. }
  131867. declare module BABYLON {
  131868. /**
  131869. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  131870. */
  131871. export class ColorSplitterBlock extends NodeMaterialBlock {
  131872. /**
  131873. * Create a new ColorSplitterBlock
  131874. * @param name defines the block name
  131875. */
  131876. constructor(name: string);
  131877. /**
  131878. * Gets the current class name
  131879. * @returns the class name
  131880. */
  131881. getClassName(): string;
  131882. /**
  131883. * Gets the rgba component (input)
  131884. */
  131885. get rgba(): NodeMaterialConnectionPoint;
  131886. /**
  131887. * Gets the rgb component (input)
  131888. */
  131889. get rgbIn(): NodeMaterialConnectionPoint;
  131890. /**
  131891. * Gets the rgb component (output)
  131892. */
  131893. get rgbOut(): NodeMaterialConnectionPoint;
  131894. /**
  131895. * Gets the r component (output)
  131896. */
  131897. get r(): NodeMaterialConnectionPoint;
  131898. /**
  131899. * Gets the g component (output)
  131900. */
  131901. get g(): NodeMaterialConnectionPoint;
  131902. /**
  131903. * Gets the b component (output)
  131904. */
  131905. get b(): NodeMaterialConnectionPoint;
  131906. /**
  131907. * Gets the a component (output)
  131908. */
  131909. get a(): NodeMaterialConnectionPoint;
  131910. protected _inputRename(name: string): string;
  131911. protected _outputRename(name: string): string;
  131912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131913. }
  131914. }
  131915. declare module BABYLON {
  131916. /**
  131917. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  131918. */
  131919. export class VectorSplitterBlock extends NodeMaterialBlock {
  131920. /**
  131921. * Create a new VectorSplitterBlock
  131922. * @param name defines the block name
  131923. */
  131924. constructor(name: string);
  131925. /**
  131926. * Gets the current class name
  131927. * @returns the class name
  131928. */
  131929. getClassName(): string;
  131930. /**
  131931. * Gets the xyzw component (input)
  131932. */
  131933. get xyzw(): NodeMaterialConnectionPoint;
  131934. /**
  131935. * Gets the xyz component (input)
  131936. */
  131937. get xyzIn(): NodeMaterialConnectionPoint;
  131938. /**
  131939. * Gets the xy component (input)
  131940. */
  131941. get xyIn(): NodeMaterialConnectionPoint;
  131942. /**
  131943. * Gets the xyz component (output)
  131944. */
  131945. get xyzOut(): NodeMaterialConnectionPoint;
  131946. /**
  131947. * Gets the xy component (output)
  131948. */
  131949. get xyOut(): NodeMaterialConnectionPoint;
  131950. /**
  131951. * Gets the x component (output)
  131952. */
  131953. get x(): NodeMaterialConnectionPoint;
  131954. /**
  131955. * Gets the y component (output)
  131956. */
  131957. get y(): NodeMaterialConnectionPoint;
  131958. /**
  131959. * Gets the z component (output)
  131960. */
  131961. get z(): NodeMaterialConnectionPoint;
  131962. /**
  131963. * Gets the w component (output)
  131964. */
  131965. get w(): NodeMaterialConnectionPoint;
  131966. protected _inputRename(name: string): string;
  131967. protected _outputRename(name: string): string;
  131968. protected _buildBlock(state: NodeMaterialBuildState): this;
  131969. }
  131970. }
  131971. declare module BABYLON {
  131972. /**
  131973. * Block used to lerp between 2 values
  131974. */
  131975. export class LerpBlock extends NodeMaterialBlock {
  131976. /**
  131977. * Creates a new LerpBlock
  131978. * @param name defines the block name
  131979. */
  131980. constructor(name: string);
  131981. /**
  131982. * Gets the current class name
  131983. * @returns the class name
  131984. */
  131985. getClassName(): string;
  131986. /**
  131987. * Gets the left operand input component
  131988. */
  131989. get left(): NodeMaterialConnectionPoint;
  131990. /**
  131991. * Gets the right operand input component
  131992. */
  131993. get right(): NodeMaterialConnectionPoint;
  131994. /**
  131995. * Gets the gradient operand input component
  131996. */
  131997. get gradient(): NodeMaterialConnectionPoint;
  131998. /**
  131999. * Gets the output component
  132000. */
  132001. get output(): NodeMaterialConnectionPoint;
  132002. protected _buildBlock(state: NodeMaterialBuildState): this;
  132003. }
  132004. }
  132005. declare module BABYLON {
  132006. /**
  132007. * Block used to divide 2 vectors
  132008. */
  132009. export class DivideBlock extends NodeMaterialBlock {
  132010. /**
  132011. * Creates a new DivideBlock
  132012. * @param name defines the block name
  132013. */
  132014. constructor(name: string);
  132015. /**
  132016. * Gets the current class name
  132017. * @returns the class name
  132018. */
  132019. getClassName(): string;
  132020. /**
  132021. * Gets the left operand input component
  132022. */
  132023. get left(): NodeMaterialConnectionPoint;
  132024. /**
  132025. * Gets the right operand input component
  132026. */
  132027. get right(): NodeMaterialConnectionPoint;
  132028. /**
  132029. * Gets the output component
  132030. */
  132031. get output(): NodeMaterialConnectionPoint;
  132032. protected _buildBlock(state: NodeMaterialBuildState): this;
  132033. }
  132034. }
  132035. declare module BABYLON {
  132036. /**
  132037. * Block used to subtract 2 vectors
  132038. */
  132039. export class SubtractBlock extends NodeMaterialBlock {
  132040. /**
  132041. * Creates a new SubtractBlock
  132042. * @param name defines the block name
  132043. */
  132044. constructor(name: string);
  132045. /**
  132046. * Gets the current class name
  132047. * @returns the class name
  132048. */
  132049. getClassName(): string;
  132050. /**
  132051. * Gets the left operand input component
  132052. */
  132053. get left(): NodeMaterialConnectionPoint;
  132054. /**
  132055. * Gets the right operand input component
  132056. */
  132057. get right(): NodeMaterialConnectionPoint;
  132058. /**
  132059. * Gets the output component
  132060. */
  132061. get output(): NodeMaterialConnectionPoint;
  132062. protected _buildBlock(state: NodeMaterialBuildState): this;
  132063. }
  132064. }
  132065. declare module BABYLON {
  132066. /**
  132067. * Block used to step a value
  132068. */
  132069. export class StepBlock extends NodeMaterialBlock {
  132070. /**
  132071. * Creates a new StepBlock
  132072. * @param name defines the block name
  132073. */
  132074. constructor(name: string);
  132075. /**
  132076. * Gets the current class name
  132077. * @returns the class name
  132078. */
  132079. getClassName(): string;
  132080. /**
  132081. * Gets the value operand input component
  132082. */
  132083. get value(): NodeMaterialConnectionPoint;
  132084. /**
  132085. * Gets the edge operand input component
  132086. */
  132087. get edge(): NodeMaterialConnectionPoint;
  132088. /**
  132089. * Gets the output component
  132090. */
  132091. get output(): NodeMaterialConnectionPoint;
  132092. protected _buildBlock(state: NodeMaterialBuildState): this;
  132093. }
  132094. }
  132095. declare module BABYLON {
  132096. /**
  132097. * Block used to get the opposite (1 - x) of a value
  132098. */
  132099. export class OneMinusBlock extends NodeMaterialBlock {
  132100. /**
  132101. * Creates a new OneMinusBlock
  132102. * @param name defines the block name
  132103. */
  132104. constructor(name: string);
  132105. /**
  132106. * Gets the current class name
  132107. * @returns the class name
  132108. */
  132109. getClassName(): string;
  132110. /**
  132111. * Gets the input component
  132112. */
  132113. get input(): NodeMaterialConnectionPoint;
  132114. /**
  132115. * Gets the output component
  132116. */
  132117. get output(): NodeMaterialConnectionPoint;
  132118. protected _buildBlock(state: NodeMaterialBuildState): this;
  132119. }
  132120. }
  132121. declare module BABYLON {
  132122. /**
  132123. * Block used to get the view direction
  132124. */
  132125. export class ViewDirectionBlock extends NodeMaterialBlock {
  132126. /**
  132127. * Creates a new ViewDirectionBlock
  132128. * @param name defines the block name
  132129. */
  132130. constructor(name: string);
  132131. /**
  132132. * Gets the current class name
  132133. * @returns the class name
  132134. */
  132135. getClassName(): string;
  132136. /**
  132137. * Gets the world position component
  132138. */
  132139. get worldPosition(): NodeMaterialConnectionPoint;
  132140. /**
  132141. * Gets the camera position component
  132142. */
  132143. get cameraPosition(): NodeMaterialConnectionPoint;
  132144. /**
  132145. * Gets the output component
  132146. */
  132147. get output(): NodeMaterialConnectionPoint;
  132148. autoConfigure(material: NodeMaterial): void;
  132149. protected _buildBlock(state: NodeMaterialBuildState): this;
  132150. }
  132151. }
  132152. declare module BABYLON {
  132153. /**
  132154. * Block used to compute fresnel value
  132155. */
  132156. export class FresnelBlock extends NodeMaterialBlock {
  132157. /**
  132158. * Create a new FresnelBlock
  132159. * @param name defines the block name
  132160. */
  132161. constructor(name: string);
  132162. /**
  132163. * Gets the current class name
  132164. * @returns the class name
  132165. */
  132166. getClassName(): string;
  132167. /**
  132168. * Gets the world normal input component
  132169. */
  132170. get worldNormal(): NodeMaterialConnectionPoint;
  132171. /**
  132172. * Gets the view direction input component
  132173. */
  132174. get viewDirection(): NodeMaterialConnectionPoint;
  132175. /**
  132176. * Gets the bias input component
  132177. */
  132178. get bias(): NodeMaterialConnectionPoint;
  132179. /**
  132180. * Gets the camera (or eye) position component
  132181. */
  132182. get power(): NodeMaterialConnectionPoint;
  132183. /**
  132184. * Gets the fresnel output component
  132185. */
  132186. get fresnel(): NodeMaterialConnectionPoint;
  132187. autoConfigure(material: NodeMaterial): void;
  132188. protected _buildBlock(state: NodeMaterialBuildState): this;
  132189. }
  132190. }
  132191. declare module BABYLON {
  132192. /**
  132193. * Block used to get the max of 2 values
  132194. */
  132195. export class MaxBlock extends NodeMaterialBlock {
  132196. /**
  132197. * Creates a new MaxBlock
  132198. * @param name defines the block name
  132199. */
  132200. constructor(name: string);
  132201. /**
  132202. * Gets the current class name
  132203. * @returns the class name
  132204. */
  132205. getClassName(): string;
  132206. /**
  132207. * Gets the left operand input component
  132208. */
  132209. get left(): NodeMaterialConnectionPoint;
  132210. /**
  132211. * Gets the right operand input component
  132212. */
  132213. get right(): NodeMaterialConnectionPoint;
  132214. /**
  132215. * Gets the output component
  132216. */
  132217. get output(): NodeMaterialConnectionPoint;
  132218. protected _buildBlock(state: NodeMaterialBuildState): this;
  132219. }
  132220. }
  132221. declare module BABYLON {
  132222. /**
  132223. * Block used to get the min of 2 values
  132224. */
  132225. export class MinBlock extends NodeMaterialBlock {
  132226. /**
  132227. * Creates a new MinBlock
  132228. * @param name defines the block name
  132229. */
  132230. constructor(name: string);
  132231. /**
  132232. * Gets the current class name
  132233. * @returns the class name
  132234. */
  132235. getClassName(): string;
  132236. /**
  132237. * Gets the left operand input component
  132238. */
  132239. get left(): NodeMaterialConnectionPoint;
  132240. /**
  132241. * Gets the right operand input component
  132242. */
  132243. get right(): NodeMaterialConnectionPoint;
  132244. /**
  132245. * Gets the output component
  132246. */
  132247. get output(): NodeMaterialConnectionPoint;
  132248. protected _buildBlock(state: NodeMaterialBuildState): this;
  132249. }
  132250. }
  132251. declare module BABYLON {
  132252. /**
  132253. * Block used to get the distance between 2 values
  132254. */
  132255. export class DistanceBlock extends NodeMaterialBlock {
  132256. /**
  132257. * Creates a new DistanceBlock
  132258. * @param name defines the block name
  132259. */
  132260. constructor(name: string);
  132261. /**
  132262. * Gets the current class name
  132263. * @returns the class name
  132264. */
  132265. getClassName(): string;
  132266. /**
  132267. * Gets the left operand input component
  132268. */
  132269. get left(): NodeMaterialConnectionPoint;
  132270. /**
  132271. * Gets the right operand input component
  132272. */
  132273. get right(): NodeMaterialConnectionPoint;
  132274. /**
  132275. * Gets the output component
  132276. */
  132277. get output(): NodeMaterialConnectionPoint;
  132278. protected _buildBlock(state: NodeMaterialBuildState): this;
  132279. }
  132280. }
  132281. declare module BABYLON {
  132282. /**
  132283. * Block used to get the length of a vector
  132284. */
  132285. export class LengthBlock extends NodeMaterialBlock {
  132286. /**
  132287. * Creates a new LengthBlock
  132288. * @param name defines the block name
  132289. */
  132290. constructor(name: string);
  132291. /**
  132292. * Gets the current class name
  132293. * @returns the class name
  132294. */
  132295. getClassName(): string;
  132296. /**
  132297. * Gets the value input component
  132298. */
  132299. get value(): NodeMaterialConnectionPoint;
  132300. /**
  132301. * Gets the output component
  132302. */
  132303. get output(): NodeMaterialConnectionPoint;
  132304. protected _buildBlock(state: NodeMaterialBuildState): this;
  132305. }
  132306. }
  132307. declare module BABYLON {
  132308. /**
  132309. * Block used to get negative version of a value (i.e. x * -1)
  132310. */
  132311. export class NegateBlock extends NodeMaterialBlock {
  132312. /**
  132313. * Creates a new NegateBlock
  132314. * @param name defines the block name
  132315. */
  132316. constructor(name: string);
  132317. /**
  132318. * Gets the current class name
  132319. * @returns the class name
  132320. */
  132321. getClassName(): string;
  132322. /**
  132323. * Gets the value input component
  132324. */
  132325. get value(): NodeMaterialConnectionPoint;
  132326. /**
  132327. * Gets the output component
  132328. */
  132329. get output(): NodeMaterialConnectionPoint;
  132330. protected _buildBlock(state: NodeMaterialBuildState): this;
  132331. }
  132332. }
  132333. declare module BABYLON {
  132334. /**
  132335. * Block used to get the value of the first parameter raised to the power of the second
  132336. */
  132337. export class PowBlock extends NodeMaterialBlock {
  132338. /**
  132339. * Creates a new PowBlock
  132340. * @param name defines the block name
  132341. */
  132342. constructor(name: string);
  132343. /**
  132344. * Gets the current class name
  132345. * @returns the class name
  132346. */
  132347. getClassName(): string;
  132348. /**
  132349. * Gets the value operand input component
  132350. */
  132351. get value(): NodeMaterialConnectionPoint;
  132352. /**
  132353. * Gets the power operand input component
  132354. */
  132355. get power(): NodeMaterialConnectionPoint;
  132356. /**
  132357. * Gets the output component
  132358. */
  132359. get output(): NodeMaterialConnectionPoint;
  132360. protected _buildBlock(state: NodeMaterialBuildState): this;
  132361. }
  132362. }
  132363. declare module BABYLON {
  132364. /**
  132365. * Block used to get a random number
  132366. */
  132367. export class RandomNumberBlock extends NodeMaterialBlock {
  132368. /**
  132369. * Creates a new RandomNumberBlock
  132370. * @param name defines the block name
  132371. */
  132372. constructor(name: string);
  132373. /**
  132374. * Gets the current class name
  132375. * @returns the class name
  132376. */
  132377. getClassName(): string;
  132378. /**
  132379. * Gets the seed input component
  132380. */
  132381. get seed(): NodeMaterialConnectionPoint;
  132382. /**
  132383. * Gets the output component
  132384. */
  132385. get output(): NodeMaterialConnectionPoint;
  132386. protected _buildBlock(state: NodeMaterialBuildState): this;
  132387. }
  132388. }
  132389. declare module BABYLON {
  132390. /**
  132391. * Block used to compute arc tangent of 2 values
  132392. */
  132393. export class ArcTan2Block extends NodeMaterialBlock {
  132394. /**
  132395. * Creates a new ArcTan2Block
  132396. * @param name defines the block name
  132397. */
  132398. constructor(name: string);
  132399. /**
  132400. * Gets the current class name
  132401. * @returns the class name
  132402. */
  132403. getClassName(): string;
  132404. /**
  132405. * Gets the x operand input component
  132406. */
  132407. get x(): NodeMaterialConnectionPoint;
  132408. /**
  132409. * Gets the y operand input component
  132410. */
  132411. get y(): NodeMaterialConnectionPoint;
  132412. /**
  132413. * Gets the output component
  132414. */
  132415. get output(): NodeMaterialConnectionPoint;
  132416. protected _buildBlock(state: NodeMaterialBuildState): this;
  132417. }
  132418. }
  132419. declare module BABYLON {
  132420. /**
  132421. * Block used to smooth step a value
  132422. */
  132423. export class SmoothStepBlock extends NodeMaterialBlock {
  132424. /**
  132425. * Creates a new SmoothStepBlock
  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 value operand input component
  132436. */
  132437. get value(): NodeMaterialConnectionPoint;
  132438. /**
  132439. * Gets the first edge operand input component
  132440. */
  132441. get edge0(): NodeMaterialConnectionPoint;
  132442. /**
  132443. * Gets the second edge operand input component
  132444. */
  132445. get edge1(): NodeMaterialConnectionPoint;
  132446. /**
  132447. * Gets the output component
  132448. */
  132449. get output(): NodeMaterialConnectionPoint;
  132450. protected _buildBlock(state: NodeMaterialBuildState): this;
  132451. }
  132452. }
  132453. declare module BABYLON {
  132454. /**
  132455. * Block used to get the reciprocal (1 / x) of a value
  132456. */
  132457. export class ReciprocalBlock extends NodeMaterialBlock {
  132458. /**
  132459. * Creates a new ReciprocalBlock
  132460. * @param name defines the block name
  132461. */
  132462. constructor(name: string);
  132463. /**
  132464. * Gets the current class name
  132465. * @returns the class name
  132466. */
  132467. getClassName(): string;
  132468. /**
  132469. * Gets the input component
  132470. */
  132471. get input(): NodeMaterialConnectionPoint;
  132472. /**
  132473. * Gets the output component
  132474. */
  132475. get output(): NodeMaterialConnectionPoint;
  132476. protected _buildBlock(state: NodeMaterialBuildState): this;
  132477. }
  132478. }
  132479. declare module BABYLON {
  132480. /**
  132481. * Block used to replace a color by another one
  132482. */
  132483. export class ReplaceColorBlock extends NodeMaterialBlock {
  132484. /**
  132485. * Creates a new ReplaceColorBlock
  132486. * @param name defines the block name
  132487. */
  132488. constructor(name: string);
  132489. /**
  132490. * Gets the current class name
  132491. * @returns the class name
  132492. */
  132493. getClassName(): string;
  132494. /**
  132495. * Gets the value input component
  132496. */
  132497. get value(): NodeMaterialConnectionPoint;
  132498. /**
  132499. * Gets the reference input component
  132500. */
  132501. get reference(): NodeMaterialConnectionPoint;
  132502. /**
  132503. * Gets the distance input component
  132504. */
  132505. get distance(): NodeMaterialConnectionPoint;
  132506. /**
  132507. * Gets the replacement input component
  132508. */
  132509. get replacement(): NodeMaterialConnectionPoint;
  132510. /**
  132511. * Gets the output component
  132512. */
  132513. get output(): NodeMaterialConnectionPoint;
  132514. protected _buildBlock(state: NodeMaterialBuildState): this;
  132515. }
  132516. }
  132517. declare module BABYLON {
  132518. /**
  132519. * Block used to posterize a value
  132520. * @see https://en.wikipedia.org/wiki/Posterization
  132521. */
  132522. export class PosterizeBlock extends NodeMaterialBlock {
  132523. /**
  132524. * Creates a new PosterizeBlock
  132525. * @param name defines the block name
  132526. */
  132527. constructor(name: string);
  132528. /**
  132529. * Gets the current class name
  132530. * @returns the class name
  132531. */
  132532. getClassName(): string;
  132533. /**
  132534. * Gets the value input component
  132535. */
  132536. get value(): NodeMaterialConnectionPoint;
  132537. /**
  132538. * Gets the steps input component
  132539. */
  132540. get steps(): NodeMaterialConnectionPoint;
  132541. /**
  132542. * Gets the output component
  132543. */
  132544. get output(): NodeMaterialConnectionPoint;
  132545. protected _buildBlock(state: NodeMaterialBuildState): this;
  132546. }
  132547. }
  132548. declare module BABYLON {
  132549. /**
  132550. * Operations supported by the Wave block
  132551. */
  132552. export enum WaveBlockKind {
  132553. /** SawTooth */
  132554. SawTooth = 0,
  132555. /** Square */
  132556. Square = 1,
  132557. /** Triangle */
  132558. Triangle = 2
  132559. }
  132560. /**
  132561. * Block used to apply wave operation to floats
  132562. */
  132563. export class WaveBlock extends NodeMaterialBlock {
  132564. /**
  132565. * Gets or sets the kibnd of wave to be applied by the block
  132566. */
  132567. kind: WaveBlockKind;
  132568. /**
  132569. * Creates a new WaveBlock
  132570. * @param name defines the block name
  132571. */
  132572. constructor(name: string);
  132573. /**
  132574. * Gets the current class name
  132575. * @returns the class name
  132576. */
  132577. getClassName(): string;
  132578. /**
  132579. * Gets the input component
  132580. */
  132581. get input(): NodeMaterialConnectionPoint;
  132582. /**
  132583. * Gets the output component
  132584. */
  132585. get output(): NodeMaterialConnectionPoint;
  132586. protected _buildBlock(state: NodeMaterialBuildState): this;
  132587. serialize(): any;
  132588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132589. }
  132590. }
  132591. declare module BABYLON {
  132592. /**
  132593. * Class used to store a color step for the GradientBlock
  132594. */
  132595. export class GradientBlockColorStep {
  132596. /**
  132597. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132598. */
  132599. step: number;
  132600. /**
  132601. * Gets or sets the color associated with this step
  132602. */
  132603. color: Color3;
  132604. /**
  132605. * Creates a new GradientBlockColorStep
  132606. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132607. * @param color defines the color associated with this step
  132608. */
  132609. constructor(
  132610. /**
  132611. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132612. */
  132613. step: number,
  132614. /**
  132615. * Gets or sets the color associated with this step
  132616. */
  132617. color: Color3);
  132618. }
  132619. /**
  132620. * Block used to return a color from a gradient based on an input value between 0 and 1
  132621. */
  132622. export class GradientBlock extends NodeMaterialBlock {
  132623. /**
  132624. * Gets or sets the list of color steps
  132625. */
  132626. colorSteps: GradientBlockColorStep[];
  132627. /**
  132628. * Creates a new GradientBlock
  132629. * @param name defines the block name
  132630. */
  132631. constructor(name: string);
  132632. /**
  132633. * Gets the current class name
  132634. * @returns the class name
  132635. */
  132636. getClassName(): string;
  132637. /**
  132638. * Gets the gradient input component
  132639. */
  132640. get gradient(): NodeMaterialConnectionPoint;
  132641. /**
  132642. * Gets the output component
  132643. */
  132644. get output(): NodeMaterialConnectionPoint;
  132645. private _writeColorConstant;
  132646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132647. serialize(): any;
  132648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132649. protected _dumpPropertiesCode(): string;
  132650. }
  132651. }
  132652. declare module BABYLON {
  132653. /**
  132654. * Block used to normalize lerp between 2 values
  132655. */
  132656. export class NLerpBlock extends NodeMaterialBlock {
  132657. /**
  132658. * Creates a new NLerpBlock
  132659. * @param name defines the block name
  132660. */
  132661. constructor(name: string);
  132662. /**
  132663. * Gets the current class name
  132664. * @returns the class name
  132665. */
  132666. getClassName(): string;
  132667. /**
  132668. * Gets the left operand input component
  132669. */
  132670. get left(): NodeMaterialConnectionPoint;
  132671. /**
  132672. * Gets the right operand input component
  132673. */
  132674. get right(): NodeMaterialConnectionPoint;
  132675. /**
  132676. * Gets the gradient operand input component
  132677. */
  132678. get gradient(): NodeMaterialConnectionPoint;
  132679. /**
  132680. * Gets the output component
  132681. */
  132682. get output(): NodeMaterialConnectionPoint;
  132683. protected _buildBlock(state: NodeMaterialBuildState): this;
  132684. }
  132685. }
  132686. declare module BABYLON {
  132687. /**
  132688. * block used to Generate a Worley Noise 3D Noise Pattern
  132689. */
  132690. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  132691. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132692. manhattanDistance: boolean;
  132693. /**
  132694. * Creates a new WorleyNoise3DBlock
  132695. * @param name defines the block name
  132696. */
  132697. constructor(name: string);
  132698. /**
  132699. * Gets the current class name
  132700. * @returns the class name
  132701. */
  132702. getClassName(): string;
  132703. /**
  132704. * Gets the seed input component
  132705. */
  132706. get seed(): NodeMaterialConnectionPoint;
  132707. /**
  132708. * Gets the jitter input component
  132709. */
  132710. get jitter(): NodeMaterialConnectionPoint;
  132711. /**
  132712. * Gets the output component
  132713. */
  132714. get output(): NodeMaterialConnectionPoint;
  132715. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132716. /**
  132717. * Exposes the properties to the UI?
  132718. */
  132719. protected _dumpPropertiesCode(): string;
  132720. /**
  132721. * Exposes the properties to the Seralize?
  132722. */
  132723. serialize(): any;
  132724. /**
  132725. * Exposes the properties to the deseralize?
  132726. */
  132727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132728. }
  132729. }
  132730. declare module BABYLON {
  132731. /**
  132732. * block used to Generate a Simplex Perlin 3d Noise Pattern
  132733. */
  132734. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  132735. /**
  132736. * Creates a new SimplexPerlin3DBlock
  132737. * @param name defines the block name
  132738. */
  132739. constructor(name: string);
  132740. /**
  132741. * Gets the current class name
  132742. * @returns the class name
  132743. */
  132744. getClassName(): string;
  132745. /**
  132746. * Gets the seed operand input component
  132747. */
  132748. get seed(): NodeMaterialConnectionPoint;
  132749. /**
  132750. * Gets the output component
  132751. */
  132752. get output(): NodeMaterialConnectionPoint;
  132753. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132754. }
  132755. }
  132756. declare module BABYLON {
  132757. /**
  132758. * Block used to blend normals
  132759. */
  132760. export class NormalBlendBlock extends NodeMaterialBlock {
  132761. /**
  132762. * Creates a new NormalBlendBlock
  132763. * @param name defines the block name
  132764. */
  132765. constructor(name: string);
  132766. /**
  132767. * Gets the current class name
  132768. * @returns the class name
  132769. */
  132770. getClassName(): string;
  132771. /**
  132772. * Gets the first input component
  132773. */
  132774. get normalMap0(): NodeMaterialConnectionPoint;
  132775. /**
  132776. * Gets the second input component
  132777. */
  132778. get normalMap1(): NodeMaterialConnectionPoint;
  132779. /**
  132780. * Gets the output component
  132781. */
  132782. get output(): NodeMaterialConnectionPoint;
  132783. protected _buildBlock(state: NodeMaterialBuildState): this;
  132784. }
  132785. }
  132786. declare module BABYLON {
  132787. /**
  132788. * Block used to rotate a 2d vector by a given angle
  132789. */
  132790. export class Rotate2dBlock extends NodeMaterialBlock {
  132791. /**
  132792. * Creates a new Rotate2dBlock
  132793. * @param name defines the block name
  132794. */
  132795. constructor(name: string);
  132796. /**
  132797. * Gets the current class name
  132798. * @returns the class name
  132799. */
  132800. getClassName(): string;
  132801. /**
  132802. * Gets the input vector
  132803. */
  132804. get input(): NodeMaterialConnectionPoint;
  132805. /**
  132806. * Gets the input angle
  132807. */
  132808. get angle(): NodeMaterialConnectionPoint;
  132809. /**
  132810. * Gets the output component
  132811. */
  132812. get output(): NodeMaterialConnectionPoint;
  132813. autoConfigure(material: NodeMaterial): void;
  132814. protected _buildBlock(state: NodeMaterialBuildState): this;
  132815. }
  132816. }
  132817. declare module BABYLON {
  132818. /**
  132819. * Block used to get the reflected vector from a direction and a normal
  132820. */
  132821. export class ReflectBlock extends NodeMaterialBlock {
  132822. /**
  132823. * Creates a new ReflectBlock
  132824. * @param name defines the block name
  132825. */
  132826. constructor(name: string);
  132827. /**
  132828. * Gets the current class name
  132829. * @returns the class name
  132830. */
  132831. getClassName(): string;
  132832. /**
  132833. * Gets the incident component
  132834. */
  132835. get incident(): NodeMaterialConnectionPoint;
  132836. /**
  132837. * Gets the normal component
  132838. */
  132839. get normal(): NodeMaterialConnectionPoint;
  132840. /**
  132841. * Gets the output component
  132842. */
  132843. get output(): NodeMaterialConnectionPoint;
  132844. protected _buildBlock(state: NodeMaterialBuildState): this;
  132845. }
  132846. }
  132847. declare module BABYLON {
  132848. /**
  132849. * Block used to get the refracted vector from a direction and a normal
  132850. */
  132851. export class RefractBlock extends NodeMaterialBlock {
  132852. /**
  132853. * Creates a new RefractBlock
  132854. * @param name defines the block name
  132855. */
  132856. constructor(name: string);
  132857. /**
  132858. * Gets the current class name
  132859. * @returns the class name
  132860. */
  132861. getClassName(): string;
  132862. /**
  132863. * Gets the incident component
  132864. */
  132865. get incident(): NodeMaterialConnectionPoint;
  132866. /**
  132867. * Gets the normal component
  132868. */
  132869. get normal(): NodeMaterialConnectionPoint;
  132870. /**
  132871. * Gets the index of refraction component
  132872. */
  132873. get ior(): NodeMaterialConnectionPoint;
  132874. /**
  132875. * Gets the output component
  132876. */
  132877. get output(): NodeMaterialConnectionPoint;
  132878. protected _buildBlock(state: NodeMaterialBuildState): this;
  132879. }
  132880. }
  132881. declare module BABYLON {
  132882. /**
  132883. * Block used to desaturate a color
  132884. */
  132885. export class DesaturateBlock extends NodeMaterialBlock {
  132886. /**
  132887. * Creates a new DesaturateBlock
  132888. * @param name defines the block name
  132889. */
  132890. constructor(name: string);
  132891. /**
  132892. * Gets the current class name
  132893. * @returns the class name
  132894. */
  132895. getClassName(): string;
  132896. /**
  132897. * Gets the color operand input component
  132898. */
  132899. get color(): NodeMaterialConnectionPoint;
  132900. /**
  132901. * Gets the level operand input component
  132902. */
  132903. get level(): NodeMaterialConnectionPoint;
  132904. /**
  132905. * Gets the output component
  132906. */
  132907. get output(): NodeMaterialConnectionPoint;
  132908. protected _buildBlock(state: NodeMaterialBuildState): this;
  132909. }
  132910. }
  132911. declare module BABYLON {
  132912. /**
  132913. * Effect Render Options
  132914. */
  132915. export interface IEffectRendererOptions {
  132916. /**
  132917. * Defines the vertices positions.
  132918. */
  132919. positions?: number[];
  132920. /**
  132921. * Defines the indices.
  132922. */
  132923. indices?: number[];
  132924. }
  132925. /**
  132926. * Helper class to render one or more effects
  132927. */
  132928. export class EffectRenderer {
  132929. private engine;
  132930. private static _DefaultOptions;
  132931. private _vertexBuffers;
  132932. private _indexBuffer;
  132933. private _ringBufferIndex;
  132934. private _ringScreenBuffer;
  132935. private _fullscreenViewport;
  132936. private _getNextFrameBuffer;
  132937. /**
  132938. * Creates an effect renderer
  132939. * @param engine the engine to use for rendering
  132940. * @param options defines the options of the effect renderer
  132941. */
  132942. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  132943. /**
  132944. * Sets the current viewport in normalized coordinates 0-1
  132945. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  132946. */
  132947. setViewport(viewport?: Viewport): void;
  132948. /**
  132949. * Binds the embedded attributes buffer to the effect.
  132950. * @param effect Defines the effect to bind the attributes for
  132951. */
  132952. bindBuffers(effect: Effect): void;
  132953. /**
  132954. * Sets the current effect wrapper to use during draw.
  132955. * The effect needs to be ready before calling this api.
  132956. * This also sets the default full screen position attribute.
  132957. * @param effectWrapper Defines the effect to draw with
  132958. */
  132959. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  132960. /**
  132961. * Draws a full screen quad.
  132962. */
  132963. draw(): void;
  132964. /**
  132965. * renders one or more effects to a specified texture
  132966. * @param effectWrappers list of effects to renderer
  132967. * @param outputTexture texture to draw to, if null it will render to the screen
  132968. */
  132969. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  132970. /**
  132971. * Disposes of the effect renderer
  132972. */
  132973. dispose(): void;
  132974. }
  132975. /**
  132976. * Options to create an EffectWrapper
  132977. */
  132978. interface EffectWrapperCreationOptions {
  132979. /**
  132980. * Engine to use to create the effect
  132981. */
  132982. engine: ThinEngine;
  132983. /**
  132984. * Fragment shader for the effect
  132985. */
  132986. fragmentShader: string;
  132987. /**
  132988. * Vertex shader for the effect
  132989. */
  132990. vertexShader?: string;
  132991. /**
  132992. * Attributes to use in the shader
  132993. */
  132994. attributeNames?: Array<string>;
  132995. /**
  132996. * Uniforms to use in the shader
  132997. */
  132998. uniformNames?: Array<string>;
  132999. /**
  133000. * Texture sampler names to use in the shader
  133001. */
  133002. samplerNames?: Array<string>;
  133003. /**
  133004. * The friendly name of the effect displayed in Spector.
  133005. */
  133006. name?: string;
  133007. }
  133008. /**
  133009. * Wraps an effect to be used for rendering
  133010. */
  133011. export class EffectWrapper {
  133012. /**
  133013. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133014. */
  133015. onApplyObservable: Observable<{}>;
  133016. /**
  133017. * The underlying effect
  133018. */
  133019. effect: Effect;
  133020. /**
  133021. * Creates an effect to be renderer
  133022. * @param creationOptions options to create the effect
  133023. */
  133024. constructor(creationOptions: EffectWrapperCreationOptions);
  133025. /**
  133026. * Disposes of the effect wrapper
  133027. */
  133028. dispose(): void;
  133029. }
  133030. }
  133031. declare module BABYLON {
  133032. /**
  133033. * Helper class to push actions to a pool of workers.
  133034. */
  133035. export class WorkerPool implements IDisposable {
  133036. private _workerInfos;
  133037. private _pendingActions;
  133038. /**
  133039. * Constructor
  133040. * @param workers Array of workers to use for actions
  133041. */
  133042. constructor(workers: Array<Worker>);
  133043. /**
  133044. * Terminates all workers and clears any pending actions.
  133045. */
  133046. dispose(): void;
  133047. /**
  133048. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133049. * pended until a worker has completed its action.
  133050. * @param action The action to perform. Call onComplete when the action is complete.
  133051. */
  133052. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133053. private _execute;
  133054. }
  133055. }
  133056. declare module BABYLON {
  133057. /**
  133058. * Configuration for Draco compression
  133059. */
  133060. export interface IDracoCompressionConfiguration {
  133061. /**
  133062. * Configuration for the decoder.
  133063. */
  133064. decoder: {
  133065. /**
  133066. * The url to the WebAssembly module.
  133067. */
  133068. wasmUrl?: string;
  133069. /**
  133070. * The url to the WebAssembly binary.
  133071. */
  133072. wasmBinaryUrl?: string;
  133073. /**
  133074. * The url to the fallback JavaScript module.
  133075. */
  133076. fallbackUrl?: string;
  133077. };
  133078. }
  133079. /**
  133080. * Draco compression (https://google.github.io/draco/)
  133081. *
  133082. * This class wraps the Draco module.
  133083. *
  133084. * **Encoder**
  133085. *
  133086. * The encoder is not currently implemented.
  133087. *
  133088. * **Decoder**
  133089. *
  133090. * 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.
  133091. *
  133092. * To update the configuration, use the following code:
  133093. * ```javascript
  133094. * DracoCompression.Configuration = {
  133095. * decoder: {
  133096. * wasmUrl: "<url to the WebAssembly library>",
  133097. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133098. * fallbackUrl: "<url to the fallback JavaScript library>",
  133099. * }
  133100. * };
  133101. * ```
  133102. *
  133103. * 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.
  133104. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133105. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133106. *
  133107. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133108. * ```javascript
  133109. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133110. * ```
  133111. *
  133112. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133113. */
  133114. export class DracoCompression implements IDisposable {
  133115. private _workerPoolPromise?;
  133116. private _decoderModulePromise?;
  133117. /**
  133118. * The configuration. Defaults to the following urls:
  133119. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133120. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133121. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133122. */
  133123. static Configuration: IDracoCompressionConfiguration;
  133124. /**
  133125. * Returns true if the decoder configuration is available.
  133126. */
  133127. static get DecoderAvailable(): boolean;
  133128. /**
  133129. * Default number of workers to create when creating the draco compression object.
  133130. */
  133131. static DefaultNumWorkers: number;
  133132. private static GetDefaultNumWorkers;
  133133. private static _Default;
  133134. /**
  133135. * Default instance for the draco compression object.
  133136. */
  133137. static get Default(): DracoCompression;
  133138. /**
  133139. * Constructor
  133140. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133141. */
  133142. constructor(numWorkers?: number);
  133143. /**
  133144. * Stop all async operations and release resources.
  133145. */
  133146. dispose(): void;
  133147. /**
  133148. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133149. * @returns a promise that resolves when ready
  133150. */
  133151. whenReadyAsync(): Promise<void>;
  133152. /**
  133153. * Decode Draco compressed mesh data to vertex data.
  133154. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133155. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133156. * @returns A promise that resolves with the decoded vertex data
  133157. */
  133158. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133159. [kind: string]: number;
  133160. }): Promise<VertexData>;
  133161. }
  133162. }
  133163. declare module BABYLON {
  133164. /**
  133165. * Class for building Constructive Solid Geometry
  133166. */
  133167. export class CSG {
  133168. private polygons;
  133169. /**
  133170. * The world matrix
  133171. */
  133172. matrix: Matrix;
  133173. /**
  133174. * Stores the position
  133175. */
  133176. position: Vector3;
  133177. /**
  133178. * Stores the rotation
  133179. */
  133180. rotation: Vector3;
  133181. /**
  133182. * Stores the rotation quaternion
  133183. */
  133184. rotationQuaternion: Nullable<Quaternion>;
  133185. /**
  133186. * Stores the scaling vector
  133187. */
  133188. scaling: Vector3;
  133189. /**
  133190. * Convert the Mesh to CSG
  133191. * @param mesh The Mesh to convert to CSG
  133192. * @returns A new CSG from the Mesh
  133193. */
  133194. static FromMesh(mesh: Mesh): CSG;
  133195. /**
  133196. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133197. * @param polygons Polygons used to construct a CSG solid
  133198. */
  133199. private static FromPolygons;
  133200. /**
  133201. * Clones, or makes a deep copy, of the CSG
  133202. * @returns A new CSG
  133203. */
  133204. clone(): CSG;
  133205. /**
  133206. * Unions this CSG with another CSG
  133207. * @param csg The CSG to union against this CSG
  133208. * @returns The unioned CSG
  133209. */
  133210. union(csg: CSG): CSG;
  133211. /**
  133212. * Unions this CSG with another CSG in place
  133213. * @param csg The CSG to union against this CSG
  133214. */
  133215. unionInPlace(csg: CSG): void;
  133216. /**
  133217. * Subtracts this CSG with another CSG
  133218. * @param csg The CSG to subtract against this CSG
  133219. * @returns A new CSG
  133220. */
  133221. subtract(csg: CSG): CSG;
  133222. /**
  133223. * Subtracts this CSG with another CSG in place
  133224. * @param csg The CSG to subtact against this CSG
  133225. */
  133226. subtractInPlace(csg: CSG): void;
  133227. /**
  133228. * Intersect this CSG with another CSG
  133229. * @param csg The CSG to intersect against this CSG
  133230. * @returns A new CSG
  133231. */
  133232. intersect(csg: CSG): CSG;
  133233. /**
  133234. * Intersects this CSG with another CSG in place
  133235. * @param csg The CSG to intersect against this CSG
  133236. */
  133237. intersectInPlace(csg: CSG): void;
  133238. /**
  133239. * Return a new CSG solid with solid and empty space switched. This solid is
  133240. * not modified.
  133241. * @returns A new CSG solid with solid and empty space switched
  133242. */
  133243. inverse(): CSG;
  133244. /**
  133245. * Inverses the CSG in place
  133246. */
  133247. inverseInPlace(): void;
  133248. /**
  133249. * This is used to keep meshes transformations so they can be restored
  133250. * when we build back a Babylon Mesh
  133251. * NB : All CSG operations are performed in world coordinates
  133252. * @param csg The CSG to copy the transform attributes from
  133253. * @returns This CSG
  133254. */
  133255. copyTransformAttributes(csg: CSG): CSG;
  133256. /**
  133257. * Build Raw mesh from CSG
  133258. * Coordinates here are in world space
  133259. * @param name The name of the mesh geometry
  133260. * @param scene The Scene
  133261. * @param keepSubMeshes Specifies if the submeshes should be kept
  133262. * @returns A new Mesh
  133263. */
  133264. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133265. /**
  133266. * Build Mesh from CSG taking material and transforms into account
  133267. * @param name The name of the Mesh
  133268. * @param material The material of the Mesh
  133269. * @param scene The Scene
  133270. * @param keepSubMeshes Specifies if submeshes should be kept
  133271. * @returns The new Mesh
  133272. */
  133273. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133274. }
  133275. }
  133276. declare module BABYLON {
  133277. /**
  133278. * Class used to create a trail following a mesh
  133279. */
  133280. export class TrailMesh extends Mesh {
  133281. private _generator;
  133282. private _autoStart;
  133283. private _running;
  133284. private _diameter;
  133285. private _length;
  133286. private _sectionPolygonPointsCount;
  133287. private _sectionVectors;
  133288. private _sectionNormalVectors;
  133289. private _beforeRenderObserver;
  133290. /**
  133291. * @constructor
  133292. * @param name The value used by scene.getMeshByName() to do a lookup.
  133293. * @param generator The mesh to generate a trail.
  133294. * @param scene The scene to add this mesh to.
  133295. * @param diameter Diameter of trailing mesh. Default is 1.
  133296. * @param length Length of trailing mesh. Default is 60.
  133297. * @param autoStart Automatically start trailing mesh. Default true.
  133298. */
  133299. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133300. /**
  133301. * "TrailMesh"
  133302. * @returns "TrailMesh"
  133303. */
  133304. getClassName(): string;
  133305. private _createMesh;
  133306. /**
  133307. * Start trailing mesh.
  133308. */
  133309. start(): void;
  133310. /**
  133311. * Stop trailing mesh.
  133312. */
  133313. stop(): void;
  133314. /**
  133315. * Update trailing mesh geometry.
  133316. */
  133317. update(): void;
  133318. /**
  133319. * Returns a new TrailMesh object.
  133320. * @param name is a string, the name given to the new mesh
  133321. * @param newGenerator use new generator object for cloned trail mesh
  133322. * @returns a new mesh
  133323. */
  133324. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  133325. /**
  133326. * Serializes this trail mesh
  133327. * @param serializationObject object to write serialization to
  133328. */
  133329. serialize(serializationObject: any): void;
  133330. /**
  133331. * Parses a serialized trail mesh
  133332. * @param parsedMesh the serialized mesh
  133333. * @param scene the scene to create the trail mesh in
  133334. * @returns the created trail mesh
  133335. */
  133336. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133337. }
  133338. }
  133339. declare module BABYLON {
  133340. /**
  133341. * Class containing static functions to help procedurally build meshes
  133342. */
  133343. export class TiledBoxBuilder {
  133344. /**
  133345. * Creates a box mesh
  133346. * 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)
  133347. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133351. * @param name defines the name of the mesh
  133352. * @param options defines the options used to create the mesh
  133353. * @param scene defines the hosting scene
  133354. * @returns the box mesh
  133355. */
  133356. static CreateTiledBox(name: string, options: {
  133357. pattern?: number;
  133358. width?: number;
  133359. height?: number;
  133360. depth?: number;
  133361. tileSize?: number;
  133362. tileWidth?: number;
  133363. tileHeight?: number;
  133364. alignHorizontal?: number;
  133365. alignVertical?: number;
  133366. faceUV?: Vector4[];
  133367. faceColors?: Color4[];
  133368. sideOrientation?: number;
  133369. updatable?: boolean;
  133370. }, scene?: Nullable<Scene>): Mesh;
  133371. }
  133372. }
  133373. declare module BABYLON {
  133374. /**
  133375. * Class containing static functions to help procedurally build meshes
  133376. */
  133377. export class TorusKnotBuilder {
  133378. /**
  133379. * Creates a torus knot mesh
  133380. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133381. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133382. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133383. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133387. * @param name defines the name of the mesh
  133388. * @param options defines the options used to create the mesh
  133389. * @param scene defines the hosting scene
  133390. * @returns the torus knot mesh
  133391. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133392. */
  133393. static CreateTorusKnot(name: string, options: {
  133394. radius?: number;
  133395. tube?: number;
  133396. radialSegments?: number;
  133397. tubularSegments?: number;
  133398. p?: number;
  133399. q?: number;
  133400. updatable?: boolean;
  133401. sideOrientation?: number;
  133402. frontUVs?: Vector4;
  133403. backUVs?: Vector4;
  133404. }, scene: any): Mesh;
  133405. }
  133406. }
  133407. declare module BABYLON {
  133408. /**
  133409. * Polygon
  133410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133411. */
  133412. export class Polygon {
  133413. /**
  133414. * Creates a rectangle
  133415. * @param xmin bottom X coord
  133416. * @param ymin bottom Y coord
  133417. * @param xmax top X coord
  133418. * @param ymax top Y coord
  133419. * @returns points that make the resulting rectation
  133420. */
  133421. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133422. /**
  133423. * Creates a circle
  133424. * @param radius radius of circle
  133425. * @param cx scale in x
  133426. * @param cy scale in y
  133427. * @param numberOfSides number of sides that make up the circle
  133428. * @returns points that make the resulting circle
  133429. */
  133430. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133431. /**
  133432. * Creates a polygon from input string
  133433. * @param input Input polygon data
  133434. * @returns the parsed points
  133435. */
  133436. static Parse(input: string): Vector2[];
  133437. /**
  133438. * Starts building a polygon from x and y coordinates
  133439. * @param x x coordinate
  133440. * @param y y coordinate
  133441. * @returns the started path2
  133442. */
  133443. static StartingAt(x: number, y: number): Path2;
  133444. }
  133445. /**
  133446. * Builds a polygon
  133447. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133448. */
  133449. export class PolygonMeshBuilder {
  133450. private _points;
  133451. private _outlinepoints;
  133452. private _holes;
  133453. private _name;
  133454. private _scene;
  133455. private _epoints;
  133456. private _eholes;
  133457. private _addToepoint;
  133458. /**
  133459. * Babylon reference to the earcut plugin.
  133460. */
  133461. bjsEarcut: any;
  133462. /**
  133463. * Creates a PolygonMeshBuilder
  133464. * @param name name of the builder
  133465. * @param contours Path of the polygon
  133466. * @param scene scene to add to when creating the mesh
  133467. * @param earcutInjection can be used to inject your own earcut reference
  133468. */
  133469. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133470. /**
  133471. * Adds a whole within the polygon
  133472. * @param hole Array of points defining the hole
  133473. * @returns this
  133474. */
  133475. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133476. /**
  133477. * Creates the polygon
  133478. * @param updatable If the mesh should be updatable
  133479. * @param depth The depth of the mesh created
  133480. * @returns the created mesh
  133481. */
  133482. build(updatable?: boolean, depth?: number): Mesh;
  133483. /**
  133484. * Creates the polygon
  133485. * @param depth The depth of the mesh created
  133486. * @returns the created VertexData
  133487. */
  133488. buildVertexData(depth?: number): VertexData;
  133489. /**
  133490. * Adds a side to the polygon
  133491. * @param positions points that make the polygon
  133492. * @param normals normals of the polygon
  133493. * @param uvs uvs of the polygon
  133494. * @param indices indices of the polygon
  133495. * @param bounds bounds of the polygon
  133496. * @param points points of the polygon
  133497. * @param depth depth of the polygon
  133498. * @param flip flip of the polygon
  133499. */
  133500. private addSide;
  133501. }
  133502. }
  133503. declare module BABYLON {
  133504. /**
  133505. * Class containing static functions to help procedurally build meshes
  133506. */
  133507. export class PolygonBuilder {
  133508. /**
  133509. * Creates a polygon mesh
  133510. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133511. * * 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
  133512. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133515. * * Remember you can only change the shape positions, not their number when updating a polygon
  133516. * @param name defines the name of the mesh
  133517. * @param options defines the options used to create the mesh
  133518. * @param scene defines the hosting scene
  133519. * @param earcutInjection can be used to inject your own earcut reference
  133520. * @returns the polygon mesh
  133521. */
  133522. static CreatePolygon(name: string, options: {
  133523. shape: Vector3[];
  133524. holes?: Vector3[][];
  133525. depth?: number;
  133526. faceUV?: Vector4[];
  133527. faceColors?: Color4[];
  133528. updatable?: boolean;
  133529. sideOrientation?: number;
  133530. frontUVs?: Vector4;
  133531. backUVs?: Vector4;
  133532. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133533. /**
  133534. * Creates an extruded polygon mesh, with depth in the Y direction.
  133535. * * 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)
  133536. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133537. * @param name defines the name of the mesh
  133538. * @param options defines the options used to create the mesh
  133539. * @param scene defines the hosting scene
  133540. * @param earcutInjection can be used to inject your own earcut reference
  133541. * @returns the polygon mesh
  133542. */
  133543. static ExtrudePolygon(name: string, options: {
  133544. shape: Vector3[];
  133545. holes?: Vector3[][];
  133546. depth?: number;
  133547. faceUV?: Vector4[];
  133548. faceColors?: Color4[];
  133549. updatable?: boolean;
  133550. sideOrientation?: number;
  133551. frontUVs?: Vector4;
  133552. backUVs?: Vector4;
  133553. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133554. }
  133555. }
  133556. declare module BABYLON {
  133557. /**
  133558. * Class containing static functions to help procedurally build meshes
  133559. */
  133560. export class LatheBuilder {
  133561. /**
  133562. * Creates lathe mesh.
  133563. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133564. * * 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
  133565. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133566. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133567. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133568. * * 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
  133569. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133570. * * 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
  133571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133575. * @param name defines the name of the mesh
  133576. * @param options defines the options used to create the mesh
  133577. * @param scene defines the hosting scene
  133578. * @returns the lathe mesh
  133579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133580. */
  133581. static CreateLathe(name: string, options: {
  133582. shape: Vector3[];
  133583. radius?: number;
  133584. tessellation?: number;
  133585. clip?: number;
  133586. arc?: number;
  133587. closed?: boolean;
  133588. updatable?: boolean;
  133589. sideOrientation?: number;
  133590. frontUVs?: Vector4;
  133591. backUVs?: Vector4;
  133592. cap?: number;
  133593. invertUV?: boolean;
  133594. }, scene?: Nullable<Scene>): Mesh;
  133595. }
  133596. }
  133597. declare module BABYLON {
  133598. /**
  133599. * Class containing static functions to help procedurally build meshes
  133600. */
  133601. export class TiledPlaneBuilder {
  133602. /**
  133603. * Creates a tiled plane mesh
  133604. * * The parameter `pattern` will, depending on value, do nothing or
  133605. * * * flip (reflect about central vertical) alternate tiles across and up
  133606. * * * flip every tile on alternate rows
  133607. * * * rotate (180 degs) alternate tiles across and up
  133608. * * * rotate every tile on alternate rows
  133609. * * * flip and rotate alternate tiles across and up
  133610. * * * flip and rotate every tile on alternate rows
  133611. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133612. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133615. * * 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)
  133616. * * 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)
  133617. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133618. * @param name defines the name of the mesh
  133619. * @param options defines the options used to create the mesh
  133620. * @param scene defines the hosting scene
  133621. * @returns the box mesh
  133622. */
  133623. static CreateTiledPlane(name: string, options: {
  133624. pattern?: number;
  133625. tileSize?: number;
  133626. tileWidth?: number;
  133627. tileHeight?: number;
  133628. size?: number;
  133629. width?: number;
  133630. height?: number;
  133631. alignHorizontal?: number;
  133632. alignVertical?: number;
  133633. sideOrientation?: number;
  133634. frontUVs?: Vector4;
  133635. backUVs?: Vector4;
  133636. updatable?: boolean;
  133637. }, scene?: Nullable<Scene>): Mesh;
  133638. }
  133639. }
  133640. declare module BABYLON {
  133641. /**
  133642. * Class containing static functions to help procedurally build meshes
  133643. */
  133644. export class TubeBuilder {
  133645. /**
  133646. * Creates a tube mesh.
  133647. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133648. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  133649. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  133650. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  133651. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  133652. * * 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)
  133653. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  133654. * * 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
  133655. * * 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
  133656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133660. * @param name defines the name of the mesh
  133661. * @param options defines the options used to create the mesh
  133662. * @param scene defines the hosting scene
  133663. * @returns the tube mesh
  133664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133665. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  133666. */
  133667. static CreateTube(name: string, options: {
  133668. path: Vector3[];
  133669. radius?: number;
  133670. tessellation?: number;
  133671. radiusFunction?: {
  133672. (i: number, distance: number): number;
  133673. };
  133674. cap?: number;
  133675. arc?: number;
  133676. updatable?: boolean;
  133677. sideOrientation?: number;
  133678. frontUVs?: Vector4;
  133679. backUVs?: Vector4;
  133680. instance?: Mesh;
  133681. invertUV?: boolean;
  133682. }, scene?: Nullable<Scene>): Mesh;
  133683. }
  133684. }
  133685. declare module BABYLON {
  133686. /**
  133687. * Class containing static functions to help procedurally build meshes
  133688. */
  133689. export class IcoSphereBuilder {
  133690. /**
  133691. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133692. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133693. * * 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`)
  133694. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133695. * * 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
  133696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133699. * @param name defines the name of the mesh
  133700. * @param options defines the options used to create the mesh
  133701. * @param scene defines the hosting scene
  133702. * @returns the icosahedron mesh
  133703. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133704. */
  133705. static CreateIcoSphere(name: string, options: {
  133706. radius?: number;
  133707. radiusX?: number;
  133708. radiusY?: number;
  133709. radiusZ?: number;
  133710. flat?: boolean;
  133711. subdivisions?: number;
  133712. sideOrientation?: number;
  133713. frontUVs?: Vector4;
  133714. backUVs?: Vector4;
  133715. updatable?: boolean;
  133716. }, scene?: Nullable<Scene>): Mesh;
  133717. }
  133718. }
  133719. declare module BABYLON {
  133720. /**
  133721. * Class containing static functions to help procedurally build meshes
  133722. */
  133723. export class DecalBuilder {
  133724. /**
  133725. * Creates a decal mesh.
  133726. * 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
  133727. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  133728. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  133729. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  133730. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  133731. * @param name defines the name of the mesh
  133732. * @param sourceMesh defines the mesh where the decal must be applied
  133733. * @param options defines the options used to create the mesh
  133734. * @param scene defines the hosting scene
  133735. * @returns the decal mesh
  133736. * @see https://doc.babylonjs.com/how_to/decals
  133737. */
  133738. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  133739. position?: Vector3;
  133740. normal?: Vector3;
  133741. size?: Vector3;
  133742. angle?: number;
  133743. }): Mesh;
  133744. }
  133745. }
  133746. declare module BABYLON {
  133747. /**
  133748. * Class containing static functions to help procedurally build meshes
  133749. */
  133750. export class MeshBuilder {
  133751. /**
  133752. * Creates a box mesh
  133753. * * The parameter `size` sets the size (float) of each box side (default 1)
  133754. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  133755. * * 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)
  133756. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133760. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133761. * @param name defines the name of the mesh
  133762. * @param options defines the options used to create the mesh
  133763. * @param scene defines the hosting scene
  133764. * @returns the box mesh
  133765. */
  133766. static CreateBox(name: string, options: {
  133767. size?: number;
  133768. width?: number;
  133769. height?: number;
  133770. depth?: number;
  133771. faceUV?: Vector4[];
  133772. faceColors?: Color4[];
  133773. sideOrientation?: number;
  133774. frontUVs?: Vector4;
  133775. backUVs?: Vector4;
  133776. updatable?: boolean;
  133777. }, scene?: Nullable<Scene>): Mesh;
  133778. /**
  133779. * Creates a tiled box mesh
  133780. * * faceTiles sets the pattern, tile size and number of tiles for a face
  133781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133782. * @param name defines the name of the mesh
  133783. * @param options defines the options used to create the mesh
  133784. * @param scene defines the hosting scene
  133785. * @returns the tiled box mesh
  133786. */
  133787. static CreateTiledBox(name: string, options: {
  133788. pattern?: number;
  133789. size?: number;
  133790. width?: number;
  133791. height?: number;
  133792. depth: number;
  133793. tileSize?: number;
  133794. tileWidth?: number;
  133795. tileHeight?: number;
  133796. faceUV?: Vector4[];
  133797. faceColors?: Color4[];
  133798. alignHorizontal?: number;
  133799. alignVertical?: number;
  133800. sideOrientation?: number;
  133801. updatable?: boolean;
  133802. }, scene?: Nullable<Scene>): Mesh;
  133803. /**
  133804. * Creates a sphere mesh
  133805. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133806. * * 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`)
  133807. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133808. * * 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
  133809. * * 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)
  133810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133813. * @param name defines the name of the mesh
  133814. * @param options defines the options used to create the mesh
  133815. * @param scene defines the hosting scene
  133816. * @returns the sphere mesh
  133817. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133818. */
  133819. static CreateSphere(name: string, options: {
  133820. segments?: number;
  133821. diameter?: number;
  133822. diameterX?: number;
  133823. diameterY?: number;
  133824. diameterZ?: number;
  133825. arc?: number;
  133826. slice?: number;
  133827. sideOrientation?: number;
  133828. frontUVs?: Vector4;
  133829. backUVs?: Vector4;
  133830. updatable?: boolean;
  133831. }, scene?: Nullable<Scene>): Mesh;
  133832. /**
  133833. * Creates a plane polygonal mesh. By default, this is a disc
  133834. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  133835. * * 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
  133836. * * 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
  133837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133840. * @param name defines the name of the mesh
  133841. * @param options defines the options used to create the mesh
  133842. * @param scene defines the hosting scene
  133843. * @returns the plane polygonal mesh
  133844. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  133845. */
  133846. static CreateDisc(name: string, options: {
  133847. radius?: number;
  133848. tessellation?: number;
  133849. arc?: number;
  133850. updatable?: boolean;
  133851. sideOrientation?: number;
  133852. frontUVs?: Vector4;
  133853. backUVs?: Vector4;
  133854. }, scene?: Nullable<Scene>): Mesh;
  133855. /**
  133856. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133857. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133858. * * 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`)
  133859. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133860. * * 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
  133861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 icosahedron mesh
  133868. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133869. */
  133870. static CreateIcoSphere(name: string, options: {
  133871. radius?: number;
  133872. radiusX?: number;
  133873. radiusY?: number;
  133874. radiusZ?: number;
  133875. flat?: boolean;
  133876. subdivisions?: number;
  133877. sideOrientation?: number;
  133878. frontUVs?: Vector4;
  133879. backUVs?: Vector4;
  133880. updatable?: boolean;
  133881. }, scene?: Nullable<Scene>): Mesh;
  133882. /**
  133883. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133884. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  133885. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  133886. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  133887. * * 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
  133888. * * 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
  133889. * * 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
  133890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133893. * * 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
  133894. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  133895. * * 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
  133896. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  133897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133898. * @param name defines the name of the mesh
  133899. * @param options defines the options used to create the mesh
  133900. * @param scene defines the hosting scene
  133901. * @returns the ribbon mesh
  133902. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  133903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133904. */
  133905. static CreateRibbon(name: string, options: {
  133906. pathArray: Vector3[][];
  133907. closeArray?: boolean;
  133908. closePath?: boolean;
  133909. offset?: number;
  133910. updatable?: boolean;
  133911. sideOrientation?: number;
  133912. frontUVs?: Vector4;
  133913. backUVs?: Vector4;
  133914. instance?: Mesh;
  133915. invertUV?: boolean;
  133916. uvs?: Vector2[];
  133917. colors?: Color4[];
  133918. }, scene?: Nullable<Scene>): Mesh;
  133919. /**
  133920. * Creates a cylinder or a cone mesh
  133921. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  133922. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  133923. * * 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.
  133924. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  133925. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  133926. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  133927. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  133928. * * 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).
  133929. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  133930. * * 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).
  133931. * * 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
  133932. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  133933. * * 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
  133934. * * 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.
  133935. * * If `enclose` is false, a ring surface is one element.
  133936. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  133937. * * 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
  133938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133941. * @param name defines the name of the mesh
  133942. * @param options defines the options used to create the mesh
  133943. * @param scene defines the hosting scene
  133944. * @returns the cylinder mesh
  133945. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  133946. */
  133947. static CreateCylinder(name: string, options: {
  133948. height?: number;
  133949. diameterTop?: number;
  133950. diameterBottom?: number;
  133951. diameter?: number;
  133952. tessellation?: number;
  133953. subdivisions?: number;
  133954. arc?: number;
  133955. faceColors?: Color4[];
  133956. faceUV?: Vector4[];
  133957. updatable?: boolean;
  133958. hasRings?: boolean;
  133959. enclose?: boolean;
  133960. cap?: number;
  133961. sideOrientation?: number;
  133962. frontUVs?: Vector4;
  133963. backUVs?: Vector4;
  133964. }, scene?: Nullable<Scene>): Mesh;
  133965. /**
  133966. * Creates a torus mesh
  133967. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  133968. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  133969. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  133970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133973. * @param name defines the name of the mesh
  133974. * @param options defines the options used to create the mesh
  133975. * @param scene defines the hosting scene
  133976. * @returns the torus mesh
  133977. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  133978. */
  133979. static CreateTorus(name: string, options: {
  133980. diameter?: number;
  133981. thickness?: number;
  133982. tessellation?: number;
  133983. updatable?: boolean;
  133984. sideOrientation?: number;
  133985. frontUVs?: Vector4;
  133986. backUVs?: Vector4;
  133987. }, scene?: Nullable<Scene>): Mesh;
  133988. /**
  133989. * Creates a torus knot mesh
  133990. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133991. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133992. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133993. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133997. * @param name defines the name of the mesh
  133998. * @param options defines the options used to create the mesh
  133999. * @param scene defines the hosting scene
  134000. * @returns the torus knot mesh
  134001. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134002. */
  134003. static CreateTorusKnot(name: string, options: {
  134004. radius?: number;
  134005. tube?: number;
  134006. radialSegments?: number;
  134007. tubularSegments?: number;
  134008. p?: number;
  134009. q?: number;
  134010. updatable?: boolean;
  134011. sideOrientation?: number;
  134012. frontUVs?: Vector4;
  134013. backUVs?: Vector4;
  134014. }, scene?: Nullable<Scene>): Mesh;
  134015. /**
  134016. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134017. * * 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
  134018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134019. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134020. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134021. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134022. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134023. * * 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
  134024. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134027. * @param name defines the name of the new line system
  134028. * @param options defines the options used to create the line system
  134029. * @param scene defines the hosting scene
  134030. * @returns a new line system mesh
  134031. */
  134032. static CreateLineSystem(name: string, options: {
  134033. lines: Vector3[][];
  134034. updatable?: boolean;
  134035. instance?: Nullable<LinesMesh>;
  134036. colors?: Nullable<Color4[][]>;
  134037. useVertexAlpha?: boolean;
  134038. }, scene: Nullable<Scene>): LinesMesh;
  134039. /**
  134040. * Creates a line mesh
  134041. * 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
  134042. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134043. * * The parameter `points` is an array successive Vector3
  134044. * * 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
  134045. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134046. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134047. * * When updating an instance, remember that only point positions can change, not the number of points
  134048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134050. * @param name defines the name of the new line system
  134051. * @param options defines the options used to create the line system
  134052. * @param scene defines the hosting scene
  134053. * @returns a new line mesh
  134054. */
  134055. static CreateLines(name: string, options: {
  134056. points: Vector3[];
  134057. updatable?: boolean;
  134058. instance?: Nullable<LinesMesh>;
  134059. colors?: Color4[];
  134060. useVertexAlpha?: boolean;
  134061. }, scene?: Nullable<Scene>): LinesMesh;
  134062. /**
  134063. * Creates a dashed line mesh
  134064. * * 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
  134065. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134066. * * The parameter `points` is an array successive Vector3
  134067. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134068. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134069. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134070. * * 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
  134071. * * When updating an instance, remember that only point positions can change, not the number of points
  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 dashed line mesh
  134077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134078. */
  134079. static CreateDashedLines(name: string, options: {
  134080. points: Vector3[];
  134081. dashSize?: number;
  134082. gapSize?: number;
  134083. dashNb?: number;
  134084. updatable?: boolean;
  134085. instance?: LinesMesh;
  134086. }, scene?: Nullable<Scene>): LinesMesh;
  134087. /**
  134088. * 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.
  134089. * * 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.
  134090. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134091. * * 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.
  134092. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134093. * * 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
  134094. * * 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
  134095. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134100. * @param name defines the name of the mesh
  134101. * @param options defines the options used to create the mesh
  134102. * @param scene defines the hosting scene
  134103. * @returns the extruded shape mesh
  134104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134106. */
  134107. static ExtrudeShape(name: string, options: {
  134108. shape: Vector3[];
  134109. path: Vector3[];
  134110. scale?: number;
  134111. rotation?: number;
  134112. cap?: number;
  134113. updatable?: boolean;
  134114. sideOrientation?: number;
  134115. frontUVs?: Vector4;
  134116. backUVs?: Vector4;
  134117. instance?: Mesh;
  134118. invertUV?: boolean;
  134119. }, scene?: Nullable<Scene>): Mesh;
  134120. /**
  134121. * Creates an custom extruded shape mesh.
  134122. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134123. * * 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.
  134124. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134125. * * 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
  134126. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134127. * * 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
  134128. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134129. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134130. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134131. * * 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
  134132. * * 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
  134133. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134138. * @param name defines the name of the mesh
  134139. * @param options defines the options used to create the mesh
  134140. * @param scene defines the hosting scene
  134141. * @returns the custom extruded shape mesh
  134142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134143. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134145. */
  134146. static ExtrudeShapeCustom(name: string, options: {
  134147. shape: Vector3[];
  134148. path: Vector3[];
  134149. scaleFunction?: any;
  134150. rotationFunction?: any;
  134151. ribbonCloseArray?: boolean;
  134152. ribbonClosePath?: boolean;
  134153. cap?: number;
  134154. updatable?: boolean;
  134155. sideOrientation?: number;
  134156. frontUVs?: Vector4;
  134157. backUVs?: Vector4;
  134158. instance?: Mesh;
  134159. invertUV?: boolean;
  134160. }, scene?: Nullable<Scene>): Mesh;
  134161. /**
  134162. * Creates lathe mesh.
  134163. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134164. * * 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
  134165. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134166. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134167. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134168. * * 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
  134169. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134170. * * 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
  134171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134175. * @param name defines the name of the mesh
  134176. * @param options defines the options used to create the mesh
  134177. * @param scene defines the hosting scene
  134178. * @returns the lathe mesh
  134179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134180. */
  134181. static CreateLathe(name: string, options: {
  134182. shape: Vector3[];
  134183. radius?: number;
  134184. tessellation?: number;
  134185. clip?: number;
  134186. arc?: number;
  134187. closed?: boolean;
  134188. updatable?: boolean;
  134189. sideOrientation?: number;
  134190. frontUVs?: Vector4;
  134191. backUVs?: Vector4;
  134192. cap?: number;
  134193. invertUV?: boolean;
  134194. }, scene?: Nullable<Scene>): Mesh;
  134195. /**
  134196. * Creates a tiled plane mesh
  134197. * * You can set a limited pattern arrangement with the tiles
  134198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134201. * @param name defines the name of the mesh
  134202. * @param options defines the options used to create the mesh
  134203. * @param scene defines the hosting scene
  134204. * @returns the plane mesh
  134205. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134206. */
  134207. static CreateTiledPlane(name: string, options: {
  134208. pattern?: number;
  134209. tileSize?: number;
  134210. tileWidth?: number;
  134211. tileHeight?: number;
  134212. size?: number;
  134213. width?: number;
  134214. height?: number;
  134215. alignHorizontal?: number;
  134216. alignVertical?: number;
  134217. sideOrientation?: number;
  134218. frontUVs?: Vector4;
  134219. backUVs?: Vector4;
  134220. updatable?: boolean;
  134221. }, scene?: Nullable<Scene>): Mesh;
  134222. /**
  134223. * Creates a plane mesh
  134224. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134225. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134226. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134230. * @param name defines the name of the mesh
  134231. * @param options defines the options used to create the mesh
  134232. * @param scene defines the hosting scene
  134233. * @returns the plane mesh
  134234. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134235. */
  134236. static CreatePlane(name: string, options: {
  134237. size?: number;
  134238. width?: number;
  134239. height?: number;
  134240. sideOrientation?: number;
  134241. frontUVs?: Vector4;
  134242. backUVs?: Vector4;
  134243. updatable?: boolean;
  134244. sourcePlane?: Plane;
  134245. }, scene?: Nullable<Scene>): Mesh;
  134246. /**
  134247. * Creates a ground mesh
  134248. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134249. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134251. * @param name defines the name of the mesh
  134252. * @param options defines the options used to create the mesh
  134253. * @param scene defines the hosting scene
  134254. * @returns the ground mesh
  134255. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134256. */
  134257. static CreateGround(name: string, options: {
  134258. width?: number;
  134259. height?: number;
  134260. subdivisions?: number;
  134261. subdivisionsX?: number;
  134262. subdivisionsY?: number;
  134263. updatable?: boolean;
  134264. }, scene?: Nullable<Scene>): Mesh;
  134265. /**
  134266. * Creates a tiled ground mesh
  134267. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134268. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134269. * * 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
  134270. * * 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
  134271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134272. * @param name defines the name of the mesh
  134273. * @param options defines the options used to create the mesh
  134274. * @param scene defines the hosting scene
  134275. * @returns the tiled ground mesh
  134276. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134277. */
  134278. static CreateTiledGround(name: string, options: {
  134279. xmin: number;
  134280. zmin: number;
  134281. xmax: number;
  134282. zmax: number;
  134283. subdivisions?: {
  134284. w: number;
  134285. h: number;
  134286. };
  134287. precision?: {
  134288. w: number;
  134289. h: number;
  134290. };
  134291. updatable?: boolean;
  134292. }, scene?: Nullable<Scene>): Mesh;
  134293. /**
  134294. * Creates a ground mesh from a height map
  134295. * * The parameter `url` sets the URL of the height map image resource.
  134296. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134297. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134298. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134299. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134300. * * 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.
  134301. * * 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).
  134302. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134304. * @param name defines the name of the mesh
  134305. * @param url defines the url to the height map
  134306. * @param options defines the options used to create the mesh
  134307. * @param scene defines the hosting scene
  134308. * @returns the ground mesh
  134309. * @see https://doc.babylonjs.com/babylon101/height_map
  134310. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134311. */
  134312. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134313. width?: number;
  134314. height?: number;
  134315. subdivisions?: number;
  134316. minHeight?: number;
  134317. maxHeight?: number;
  134318. colorFilter?: Color3;
  134319. alphaFilter?: number;
  134320. updatable?: boolean;
  134321. onReady?: (mesh: GroundMesh) => void;
  134322. }, scene?: Nullable<Scene>): GroundMesh;
  134323. /**
  134324. * Creates a polygon mesh
  134325. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134326. * * 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
  134327. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134330. * * Remember you can only change the shape positions, not their number when updating a polygon
  134331. * @param name defines the name of the mesh
  134332. * @param options defines the options used to create the mesh
  134333. * @param scene defines the hosting scene
  134334. * @param earcutInjection can be used to inject your own earcut reference
  134335. * @returns the polygon mesh
  134336. */
  134337. static CreatePolygon(name: string, options: {
  134338. shape: Vector3[];
  134339. holes?: Vector3[][];
  134340. depth?: number;
  134341. faceUV?: Vector4[];
  134342. faceColors?: Color4[];
  134343. updatable?: boolean;
  134344. sideOrientation?: number;
  134345. frontUVs?: Vector4;
  134346. backUVs?: Vector4;
  134347. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134348. /**
  134349. * Creates an extruded polygon mesh, with depth in the Y direction.
  134350. * * 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)
  134351. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134352. * @param name defines the name of the mesh
  134353. * @param options defines the options used to create the mesh
  134354. * @param scene defines the hosting scene
  134355. * @param earcutInjection can be used to inject your own earcut reference
  134356. * @returns the polygon mesh
  134357. */
  134358. static ExtrudePolygon(name: string, options: {
  134359. shape: Vector3[];
  134360. holes?: Vector3[][];
  134361. depth?: number;
  134362. faceUV?: Vector4[];
  134363. faceColors?: Color4[];
  134364. updatable?: boolean;
  134365. sideOrientation?: number;
  134366. frontUVs?: Vector4;
  134367. backUVs?: Vector4;
  134368. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134369. /**
  134370. * Creates a tube mesh.
  134371. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134372. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134373. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134374. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134375. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134376. * * 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)
  134377. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134378. * * 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
  134379. * * 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
  134380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134382. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134384. * @param name defines the name of the mesh
  134385. * @param options defines the options used to create the mesh
  134386. * @param scene defines the hosting scene
  134387. * @returns the tube mesh
  134388. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134389. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134390. */
  134391. static CreateTube(name: string, options: {
  134392. path: Vector3[];
  134393. radius?: number;
  134394. tessellation?: number;
  134395. radiusFunction?: {
  134396. (i: number, distance: number): number;
  134397. };
  134398. cap?: number;
  134399. arc?: number;
  134400. updatable?: boolean;
  134401. sideOrientation?: number;
  134402. frontUVs?: Vector4;
  134403. backUVs?: Vector4;
  134404. instance?: Mesh;
  134405. invertUV?: boolean;
  134406. }, scene?: Nullable<Scene>): Mesh;
  134407. /**
  134408. * Creates a polyhedron mesh
  134409. * * 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
  134410. * * The parameter `size` (positive float, default 1) sets the polygon size
  134411. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134412. * * 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`
  134413. * * 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
  134414. * * 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)`)
  134415. * * 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
  134416. * * 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
  134417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134420. * @param name defines the name of the mesh
  134421. * @param options defines the options used to create the mesh
  134422. * @param scene defines the hosting scene
  134423. * @returns the polyhedron mesh
  134424. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134425. */
  134426. static CreatePolyhedron(name: string, options: {
  134427. type?: number;
  134428. size?: number;
  134429. sizeX?: number;
  134430. sizeY?: number;
  134431. sizeZ?: number;
  134432. custom?: any;
  134433. faceUV?: Vector4[];
  134434. faceColors?: Color4[];
  134435. flat?: boolean;
  134436. updatable?: boolean;
  134437. sideOrientation?: number;
  134438. frontUVs?: Vector4;
  134439. backUVs?: Vector4;
  134440. }, scene?: Nullable<Scene>): Mesh;
  134441. /**
  134442. * Creates a decal mesh.
  134443. * 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
  134444. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134445. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134446. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134447. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134448. * @param name defines the name of the mesh
  134449. * @param sourceMesh defines the mesh where the decal must be applied
  134450. * @param options defines the options used to create the mesh
  134451. * @param scene defines the hosting scene
  134452. * @returns the decal mesh
  134453. * @see https://doc.babylonjs.com/how_to/decals
  134454. */
  134455. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134456. position?: Vector3;
  134457. normal?: Vector3;
  134458. size?: Vector3;
  134459. angle?: number;
  134460. }): Mesh;
  134461. }
  134462. }
  134463. declare module BABYLON {
  134464. /**
  134465. * A simplifier interface for future simplification implementations
  134466. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134467. */
  134468. export interface ISimplifier {
  134469. /**
  134470. * Simplification of a given mesh according to the given settings.
  134471. * Since this requires computation, it is assumed that the function runs async.
  134472. * @param settings The settings of the simplification, including quality and distance
  134473. * @param successCallback A callback that will be called after the mesh was simplified.
  134474. * @param errorCallback in case of an error, this callback will be called. optional.
  134475. */
  134476. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134477. }
  134478. /**
  134479. * Expected simplification settings.
  134480. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134481. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134482. */
  134483. export interface ISimplificationSettings {
  134484. /**
  134485. * Gets or sets the expected quality
  134486. */
  134487. quality: number;
  134488. /**
  134489. * Gets or sets the distance when this optimized version should be used
  134490. */
  134491. distance: number;
  134492. /**
  134493. * Gets an already optimized mesh
  134494. */
  134495. optimizeMesh?: boolean;
  134496. }
  134497. /**
  134498. * Class used to specify simplification options
  134499. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134500. */
  134501. export class SimplificationSettings implements ISimplificationSettings {
  134502. /** expected quality */
  134503. quality: number;
  134504. /** distance when this optimized version should be used */
  134505. distance: number;
  134506. /** already optimized mesh */
  134507. optimizeMesh?: boolean | undefined;
  134508. /**
  134509. * Creates a SimplificationSettings
  134510. * @param quality expected quality
  134511. * @param distance distance when this optimized version should be used
  134512. * @param optimizeMesh already optimized mesh
  134513. */
  134514. constructor(
  134515. /** expected quality */
  134516. quality: number,
  134517. /** distance when this optimized version should be used */
  134518. distance: number,
  134519. /** already optimized mesh */
  134520. optimizeMesh?: boolean | undefined);
  134521. }
  134522. /**
  134523. * Interface used to define a simplification task
  134524. */
  134525. export interface ISimplificationTask {
  134526. /**
  134527. * Array of settings
  134528. */
  134529. settings: Array<ISimplificationSettings>;
  134530. /**
  134531. * Simplification type
  134532. */
  134533. simplificationType: SimplificationType;
  134534. /**
  134535. * Mesh to simplify
  134536. */
  134537. mesh: Mesh;
  134538. /**
  134539. * Callback called on success
  134540. */
  134541. successCallback?: () => void;
  134542. /**
  134543. * Defines if parallel processing can be used
  134544. */
  134545. parallelProcessing: boolean;
  134546. }
  134547. /**
  134548. * Queue used to order the simplification tasks
  134549. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134550. */
  134551. export class SimplificationQueue {
  134552. private _simplificationArray;
  134553. /**
  134554. * Gets a boolean indicating that the process is still running
  134555. */
  134556. running: boolean;
  134557. /**
  134558. * Creates a new queue
  134559. */
  134560. constructor();
  134561. /**
  134562. * Adds a new simplification task
  134563. * @param task defines a task to add
  134564. */
  134565. addTask(task: ISimplificationTask): void;
  134566. /**
  134567. * Execute next task
  134568. */
  134569. executeNext(): void;
  134570. /**
  134571. * Execute a simplification task
  134572. * @param task defines the task to run
  134573. */
  134574. runSimplification(task: ISimplificationTask): void;
  134575. private getSimplifier;
  134576. }
  134577. /**
  134578. * The implemented types of simplification
  134579. * At the moment only Quadratic Error Decimation is implemented
  134580. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134581. */
  134582. export enum SimplificationType {
  134583. /** Quadratic error decimation */
  134584. QUADRATIC = 0
  134585. }
  134586. }
  134587. declare module BABYLON {
  134588. interface Scene {
  134589. /** @hidden (Backing field) */
  134590. _simplificationQueue: SimplificationQueue;
  134591. /**
  134592. * Gets or sets the simplification queue attached to the scene
  134593. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134594. */
  134595. simplificationQueue: SimplificationQueue;
  134596. }
  134597. interface Mesh {
  134598. /**
  134599. * Simplify the mesh according to the given array of settings.
  134600. * Function will return immediately and will simplify async
  134601. * @param settings a collection of simplification settings
  134602. * @param parallelProcessing should all levels calculate parallel or one after the other
  134603. * @param simplificationType the type of simplification to run
  134604. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134605. * @returns the current mesh
  134606. */
  134607. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134608. }
  134609. /**
  134610. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134611. * created in a scene
  134612. */
  134613. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134614. /**
  134615. * The component name helpfull to identify the component in the list of scene components.
  134616. */
  134617. readonly name: string;
  134618. /**
  134619. * The scene the component belongs to.
  134620. */
  134621. scene: Scene;
  134622. /**
  134623. * Creates a new instance of the component for the given scene
  134624. * @param scene Defines the scene to register the component in
  134625. */
  134626. constructor(scene: Scene);
  134627. /**
  134628. * Registers the component in a given scene
  134629. */
  134630. register(): void;
  134631. /**
  134632. * Rebuilds the elements related to this component in case of
  134633. * context lost for instance.
  134634. */
  134635. rebuild(): void;
  134636. /**
  134637. * Disposes the component and the associated ressources
  134638. */
  134639. dispose(): void;
  134640. private _beforeCameraUpdate;
  134641. }
  134642. }
  134643. declare module BABYLON {
  134644. /**
  134645. * Navigation plugin interface to add navigation constrained by a navigation mesh
  134646. */
  134647. export interface INavigationEnginePlugin {
  134648. /**
  134649. * plugin name
  134650. */
  134651. name: string;
  134652. /**
  134653. * Creates a navigation mesh
  134654. * @param meshes array of all the geometry used to compute the navigatio mesh
  134655. * @param parameters bunch of parameters used to filter geometry
  134656. */
  134657. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134658. /**
  134659. * Create a navigation mesh debug mesh
  134660. * @param scene is where the mesh will be added
  134661. * @returns debug display mesh
  134662. */
  134663. createDebugNavMesh(scene: Scene): Mesh;
  134664. /**
  134665. * Get a navigation mesh constrained position, closest to the parameter position
  134666. * @param position world position
  134667. * @returns the closest point to position constrained by the navigation mesh
  134668. */
  134669. getClosestPoint(position: Vector3): Vector3;
  134670. /**
  134671. * Get a navigation mesh constrained position, within a particular radius
  134672. * @param position world position
  134673. * @param maxRadius the maximum distance to the constrained world position
  134674. * @returns the closest point to position constrained by the navigation mesh
  134675. */
  134676. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134677. /**
  134678. * Compute the final position from a segment made of destination-position
  134679. * @param position world position
  134680. * @param destination world position
  134681. * @returns the resulting point along the navmesh
  134682. */
  134683. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134684. /**
  134685. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134686. * @param start world position
  134687. * @param end world position
  134688. * @returns array containing world position composing the path
  134689. */
  134690. computePath(start: Vector3, end: Vector3): Vector3[];
  134691. /**
  134692. * If this plugin is supported
  134693. * @returns true if plugin is supported
  134694. */
  134695. isSupported(): boolean;
  134696. /**
  134697. * Create a new Crowd so you can add agents
  134698. * @param maxAgents the maximum agent count in the crowd
  134699. * @param maxAgentRadius the maximum radius an agent can have
  134700. * @param scene to attach the crowd to
  134701. * @returns the crowd you can add agents to
  134702. */
  134703. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134704. /**
  134705. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134706. * The queries will try to find a solution within those bounds
  134707. * default is (1,1,1)
  134708. * @param extent x,y,z value that define the extent around the queries point of reference
  134709. */
  134710. setDefaultQueryExtent(extent: Vector3): void;
  134711. /**
  134712. * Get the Bounding box extent specified by setDefaultQueryExtent
  134713. * @returns the box extent values
  134714. */
  134715. getDefaultQueryExtent(): Vector3;
  134716. /**
  134717. * Release all resources
  134718. */
  134719. dispose(): void;
  134720. }
  134721. /**
  134722. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  134723. */
  134724. export interface ICrowd {
  134725. /**
  134726. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134727. * You can attach anything to that node. The node position is updated in the scene update tick.
  134728. * @param pos world position that will be constrained by the navigation mesh
  134729. * @param parameters agent parameters
  134730. * @param transform hooked to the agent that will be update by the scene
  134731. * @returns agent index
  134732. */
  134733. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134734. /**
  134735. * Returns the agent position in world space
  134736. * @param index agent index returned by addAgent
  134737. * @returns world space position
  134738. */
  134739. getAgentPosition(index: number): Vector3;
  134740. /**
  134741. * Gets the agent velocity in world space
  134742. * @param index agent index returned by addAgent
  134743. * @returns world space velocity
  134744. */
  134745. getAgentVelocity(index: number): Vector3;
  134746. /**
  134747. * remove a particular agent previously created
  134748. * @param index agent index returned by addAgent
  134749. */
  134750. removeAgent(index: number): void;
  134751. /**
  134752. * get the list of all agents attached to this crowd
  134753. * @returns list of agent indices
  134754. */
  134755. getAgents(): number[];
  134756. /**
  134757. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134758. * @param deltaTime in seconds
  134759. */
  134760. update(deltaTime: number): void;
  134761. /**
  134762. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134763. * @param index agent index returned by addAgent
  134764. * @param destination targeted world position
  134765. */
  134766. agentGoto(index: number, destination: Vector3): void;
  134767. /**
  134768. * Teleport the agent to a new position
  134769. * @param index agent index returned by addAgent
  134770. * @param destination targeted world position
  134771. */
  134772. agentTeleport(index: number, destination: Vector3): void;
  134773. /**
  134774. * Update agent parameters
  134775. * @param index agent index returned by addAgent
  134776. * @param parameters agent parameters
  134777. */
  134778. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134779. /**
  134780. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134781. * The queries will try to find a solution within those bounds
  134782. * default is (1,1,1)
  134783. * @param extent x,y,z value that define the extent around the queries point of reference
  134784. */
  134785. setDefaultQueryExtent(extent: Vector3): void;
  134786. /**
  134787. * Get the Bounding box extent specified by setDefaultQueryExtent
  134788. * @returns the box extent values
  134789. */
  134790. getDefaultQueryExtent(): Vector3;
  134791. /**
  134792. * Release all resources
  134793. */
  134794. dispose(): void;
  134795. }
  134796. /**
  134797. * Configures an agent
  134798. */
  134799. export interface IAgentParameters {
  134800. /**
  134801. * Agent radius. [Limit: >= 0]
  134802. */
  134803. radius: number;
  134804. /**
  134805. * Agent height. [Limit: > 0]
  134806. */
  134807. height: number;
  134808. /**
  134809. * Maximum allowed acceleration. [Limit: >= 0]
  134810. */
  134811. maxAcceleration: number;
  134812. /**
  134813. * Maximum allowed speed. [Limit: >= 0]
  134814. */
  134815. maxSpeed: number;
  134816. /**
  134817. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  134818. */
  134819. collisionQueryRange: number;
  134820. /**
  134821. * The path visibility optimization range. [Limit: > 0]
  134822. */
  134823. pathOptimizationRange: number;
  134824. /**
  134825. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  134826. */
  134827. separationWeight: number;
  134828. }
  134829. /**
  134830. * Configures the navigation mesh creation
  134831. */
  134832. export interface INavMeshParameters {
  134833. /**
  134834. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  134835. */
  134836. cs: number;
  134837. /**
  134838. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  134839. */
  134840. ch: number;
  134841. /**
  134842. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  134843. */
  134844. walkableSlopeAngle: number;
  134845. /**
  134846. * Minimum floor to 'ceiling' height that will still allow the floor area to
  134847. * be considered walkable. [Limit: >= 3] [Units: vx]
  134848. */
  134849. walkableHeight: number;
  134850. /**
  134851. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  134852. */
  134853. walkableClimb: number;
  134854. /**
  134855. * The distance to erode/shrink the walkable area of the heightfield away from
  134856. * obstructions. [Limit: >=0] [Units: vx]
  134857. */
  134858. walkableRadius: number;
  134859. /**
  134860. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  134861. */
  134862. maxEdgeLen: number;
  134863. /**
  134864. * The maximum distance a simplfied contour's border edges should deviate
  134865. * the original raw contour. [Limit: >=0] [Units: vx]
  134866. */
  134867. maxSimplificationError: number;
  134868. /**
  134869. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  134870. */
  134871. minRegionArea: number;
  134872. /**
  134873. * Any regions with a span count smaller than this value will, if possible,
  134874. * be merged with larger regions. [Limit: >=0] [Units: vx]
  134875. */
  134876. mergeRegionArea: number;
  134877. /**
  134878. * The maximum number of vertices allowed for polygons generated during the
  134879. * contour to polygon conversion process. [Limit: >= 3]
  134880. */
  134881. maxVertsPerPoly: number;
  134882. /**
  134883. * Sets the sampling distance to use when generating the detail mesh.
  134884. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  134885. */
  134886. detailSampleDist: number;
  134887. /**
  134888. * The maximum distance the detail mesh surface should deviate from heightfield
  134889. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  134890. */
  134891. detailSampleMaxError: number;
  134892. }
  134893. }
  134894. declare module BABYLON {
  134895. /**
  134896. * RecastJS navigation plugin
  134897. */
  134898. export class RecastJSPlugin implements INavigationEnginePlugin {
  134899. /**
  134900. * Reference to the Recast library
  134901. */
  134902. bjsRECAST: any;
  134903. /**
  134904. * plugin name
  134905. */
  134906. name: string;
  134907. /**
  134908. * the first navmesh created. We might extend this to support multiple navmeshes
  134909. */
  134910. navMesh: any;
  134911. /**
  134912. * Initializes the recastJS plugin
  134913. * @param recastInjection can be used to inject your own recast reference
  134914. */
  134915. constructor(recastInjection?: any);
  134916. /**
  134917. * Creates a navigation mesh
  134918. * @param meshes array of all the geometry used to compute the navigatio mesh
  134919. * @param parameters bunch of parameters used to filter geometry
  134920. */
  134921. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134922. /**
  134923. * Create a navigation mesh debug mesh
  134924. * @param scene is where the mesh will be added
  134925. * @returns debug display mesh
  134926. */
  134927. createDebugNavMesh(scene: Scene): Mesh;
  134928. /**
  134929. * Get a navigation mesh constrained position, closest to the parameter position
  134930. * @param position world position
  134931. * @returns the closest point to position constrained by the navigation mesh
  134932. */
  134933. getClosestPoint(position: Vector3): Vector3;
  134934. /**
  134935. * Get a navigation mesh constrained position, within a particular radius
  134936. * @param position world position
  134937. * @param maxRadius the maximum distance to the constrained world position
  134938. * @returns the closest point to position constrained by the navigation mesh
  134939. */
  134940. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134941. /**
  134942. * Compute the final position from a segment made of destination-position
  134943. * @param position world position
  134944. * @param destination world position
  134945. * @returns the resulting point along the navmesh
  134946. */
  134947. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134948. /**
  134949. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134950. * @param start world position
  134951. * @param end world position
  134952. * @returns array containing world position composing the path
  134953. */
  134954. computePath(start: Vector3, end: Vector3): Vector3[];
  134955. /**
  134956. * Create a new Crowd so you can add agents
  134957. * @param maxAgents the maximum agent count in the crowd
  134958. * @param maxAgentRadius the maximum radius an agent can have
  134959. * @param scene to attach the crowd to
  134960. * @returns the crowd you can add agents to
  134961. */
  134962. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134963. /**
  134964. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134965. * The queries will try to find a solution within those bounds
  134966. * default is (1,1,1)
  134967. * @param extent x,y,z value that define the extent around the queries point of reference
  134968. */
  134969. setDefaultQueryExtent(extent: Vector3): void;
  134970. /**
  134971. * Get the Bounding box extent specified by setDefaultQueryExtent
  134972. * @returns the box extent values
  134973. */
  134974. getDefaultQueryExtent(): Vector3;
  134975. /**
  134976. * Disposes
  134977. */
  134978. dispose(): void;
  134979. /**
  134980. * If this plugin is supported
  134981. * @returns true if plugin is supported
  134982. */
  134983. isSupported(): boolean;
  134984. }
  134985. /**
  134986. * Recast detour crowd implementation
  134987. */
  134988. export class RecastJSCrowd implements ICrowd {
  134989. /**
  134990. * Recast/detour plugin
  134991. */
  134992. bjsRECASTPlugin: RecastJSPlugin;
  134993. /**
  134994. * Link to the detour crowd
  134995. */
  134996. recastCrowd: any;
  134997. /**
  134998. * One transform per agent
  134999. */
  135000. transforms: TransformNode[];
  135001. /**
  135002. * All agents created
  135003. */
  135004. agents: number[];
  135005. /**
  135006. * Link to the scene is kept to unregister the crowd from the scene
  135007. */
  135008. private _scene;
  135009. /**
  135010. * Observer for crowd updates
  135011. */
  135012. private _onBeforeAnimationsObserver;
  135013. /**
  135014. * Constructor
  135015. * @param plugin recastJS plugin
  135016. * @param maxAgents the maximum agent count in the crowd
  135017. * @param maxAgentRadius the maximum radius an agent can have
  135018. * @param scene to attach the crowd to
  135019. * @returns the crowd you can add agents to
  135020. */
  135021. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135022. /**
  135023. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135024. * You can attach anything to that node. The node position is updated in the scene update tick.
  135025. * @param pos world position that will be constrained by the navigation mesh
  135026. * @param parameters agent parameters
  135027. * @param transform hooked to the agent that will be update by the scene
  135028. * @returns agent index
  135029. */
  135030. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135031. /**
  135032. * Returns the agent position in world space
  135033. * @param index agent index returned by addAgent
  135034. * @returns world space position
  135035. */
  135036. getAgentPosition(index: number): Vector3;
  135037. /**
  135038. * Returns the agent velocity in world space
  135039. * @param index agent index returned by addAgent
  135040. * @returns world space velocity
  135041. */
  135042. getAgentVelocity(index: number): Vector3;
  135043. /**
  135044. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135045. * @param index agent index returned by addAgent
  135046. * @param destination targeted world position
  135047. */
  135048. agentGoto(index: number, destination: Vector3): void;
  135049. /**
  135050. * Teleport the agent to a new position
  135051. * @param index agent index returned by addAgent
  135052. * @param destination targeted world position
  135053. */
  135054. agentTeleport(index: number, destination: Vector3): void;
  135055. /**
  135056. * Update agent parameters
  135057. * @param index agent index returned by addAgent
  135058. * @param parameters agent parameters
  135059. */
  135060. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135061. /**
  135062. * remove a particular agent previously created
  135063. * @param index agent index returned by addAgent
  135064. */
  135065. removeAgent(index: number): void;
  135066. /**
  135067. * get the list of all agents attached to this crowd
  135068. * @returns list of agent indices
  135069. */
  135070. getAgents(): number[];
  135071. /**
  135072. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135073. * @param deltaTime in seconds
  135074. */
  135075. update(deltaTime: number): void;
  135076. /**
  135077. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135078. * The queries will try to find a solution within those bounds
  135079. * default is (1,1,1)
  135080. * @param extent x,y,z value that define the extent around the queries point of reference
  135081. */
  135082. setDefaultQueryExtent(extent: Vector3): void;
  135083. /**
  135084. * Get the Bounding box extent specified by setDefaultQueryExtent
  135085. * @returns the box extent values
  135086. */
  135087. getDefaultQueryExtent(): Vector3;
  135088. /**
  135089. * Release all resources
  135090. */
  135091. dispose(): void;
  135092. }
  135093. }
  135094. declare module BABYLON {
  135095. /**
  135096. * Class used to enable access to IndexedDB
  135097. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135098. */
  135099. export class Database implements IOfflineProvider {
  135100. private _callbackManifestChecked;
  135101. private _currentSceneUrl;
  135102. private _db;
  135103. private _enableSceneOffline;
  135104. private _enableTexturesOffline;
  135105. private _manifestVersionFound;
  135106. private _mustUpdateRessources;
  135107. private _hasReachedQuota;
  135108. private _isSupported;
  135109. private _idbFactory;
  135110. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135111. private static IsUASupportingBlobStorage;
  135112. /**
  135113. * Gets a boolean indicating if Database storate is enabled (off by default)
  135114. */
  135115. static IDBStorageEnabled: boolean;
  135116. /**
  135117. * Gets a boolean indicating if scene must be saved in the database
  135118. */
  135119. get enableSceneOffline(): boolean;
  135120. /**
  135121. * Gets a boolean indicating if textures must be saved in the database
  135122. */
  135123. get enableTexturesOffline(): boolean;
  135124. /**
  135125. * Creates a new Database
  135126. * @param urlToScene defines the url to load the scene
  135127. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135128. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135129. */
  135130. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135131. private static _ParseURL;
  135132. private static _ReturnFullUrlLocation;
  135133. private _checkManifestFile;
  135134. /**
  135135. * Open the database and make it available
  135136. * @param successCallback defines the callback to call on success
  135137. * @param errorCallback defines the callback to call on error
  135138. */
  135139. open(successCallback: () => void, errorCallback: () => void): void;
  135140. /**
  135141. * Loads an image from the database
  135142. * @param url defines the url to load from
  135143. * @param image defines the target DOM image
  135144. */
  135145. loadImage(url: string, image: HTMLImageElement): void;
  135146. private _loadImageFromDBAsync;
  135147. private _saveImageIntoDBAsync;
  135148. private _checkVersionFromDB;
  135149. private _loadVersionFromDBAsync;
  135150. private _saveVersionIntoDBAsync;
  135151. /**
  135152. * Loads a file from database
  135153. * @param url defines the URL to load from
  135154. * @param sceneLoaded defines a callback to call on success
  135155. * @param progressCallBack defines a callback to call when progress changed
  135156. * @param errorCallback defines a callback to call on error
  135157. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135158. */
  135159. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135160. private _loadFileAsync;
  135161. private _saveFileAsync;
  135162. /**
  135163. * Validates if xhr data is correct
  135164. * @param xhr defines the request to validate
  135165. * @param dataType defines the expected data type
  135166. * @returns true if data is correct
  135167. */
  135168. private static _ValidateXHRData;
  135169. }
  135170. }
  135171. declare module BABYLON {
  135172. /** @hidden */
  135173. export var gpuUpdateParticlesPixelShader: {
  135174. name: string;
  135175. shader: string;
  135176. };
  135177. }
  135178. declare module BABYLON {
  135179. /** @hidden */
  135180. export var gpuUpdateParticlesVertexShader: {
  135181. name: string;
  135182. shader: string;
  135183. };
  135184. }
  135185. declare module BABYLON {
  135186. /** @hidden */
  135187. export var clipPlaneFragmentDeclaration2: {
  135188. name: string;
  135189. shader: string;
  135190. };
  135191. }
  135192. declare module BABYLON {
  135193. /** @hidden */
  135194. export var gpuRenderParticlesPixelShader: {
  135195. name: string;
  135196. shader: string;
  135197. };
  135198. }
  135199. declare module BABYLON {
  135200. /** @hidden */
  135201. export var clipPlaneVertexDeclaration2: {
  135202. name: string;
  135203. shader: string;
  135204. };
  135205. }
  135206. declare module BABYLON {
  135207. /** @hidden */
  135208. export var gpuRenderParticlesVertexShader: {
  135209. name: string;
  135210. shader: string;
  135211. };
  135212. }
  135213. declare module BABYLON {
  135214. /**
  135215. * This represents a GPU particle system in Babylon
  135216. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135217. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135218. */
  135219. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135220. /**
  135221. * The layer mask we are rendering the particles through.
  135222. */
  135223. layerMask: number;
  135224. private _capacity;
  135225. private _activeCount;
  135226. private _currentActiveCount;
  135227. private _accumulatedCount;
  135228. private _renderEffect;
  135229. private _updateEffect;
  135230. private _buffer0;
  135231. private _buffer1;
  135232. private _spriteBuffer;
  135233. private _updateVAO;
  135234. private _renderVAO;
  135235. private _targetIndex;
  135236. private _sourceBuffer;
  135237. private _targetBuffer;
  135238. private _engine;
  135239. private _currentRenderId;
  135240. private _started;
  135241. private _stopped;
  135242. private _timeDelta;
  135243. private _randomTexture;
  135244. private _randomTexture2;
  135245. private _attributesStrideSize;
  135246. private _updateEffectOptions;
  135247. private _randomTextureSize;
  135248. private _actualFrame;
  135249. private readonly _rawTextureWidth;
  135250. /**
  135251. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135252. */
  135253. static get IsSupported(): boolean;
  135254. /**
  135255. * An event triggered when the system is disposed.
  135256. */
  135257. onDisposeObservable: Observable<GPUParticleSystem>;
  135258. /**
  135259. * Gets the maximum number of particles active at the same time.
  135260. * @returns The max number of active particles.
  135261. */
  135262. getCapacity(): number;
  135263. /**
  135264. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135265. * to override the particles.
  135266. */
  135267. forceDepthWrite: boolean;
  135268. /**
  135269. * Gets or set the number of active particles
  135270. */
  135271. get activeParticleCount(): number;
  135272. set activeParticleCount(value: number);
  135273. private _preWarmDone;
  135274. /**
  135275. * Is this system ready to be used/rendered
  135276. * @return true if the system is ready
  135277. */
  135278. isReady(): boolean;
  135279. /**
  135280. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135281. * @returns True if it has been started, otherwise false.
  135282. */
  135283. isStarted(): boolean;
  135284. /**
  135285. * Starts the particle system and begins to emit
  135286. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135287. */
  135288. start(delay?: number): void;
  135289. /**
  135290. * Stops the particle system.
  135291. */
  135292. stop(): void;
  135293. /**
  135294. * Remove all active particles
  135295. */
  135296. reset(): void;
  135297. /**
  135298. * Returns the string "GPUParticleSystem"
  135299. * @returns a string containing the class name
  135300. */
  135301. getClassName(): string;
  135302. private _colorGradientsTexture;
  135303. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135304. /**
  135305. * Adds a new color gradient
  135306. * @param gradient defines the gradient to use (between 0 and 1)
  135307. * @param color1 defines the color to affect to the specified gradient
  135308. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135309. * @returns the current particle system
  135310. */
  135311. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135312. /**
  135313. * Remove a specific color gradient
  135314. * @param gradient defines the gradient to remove
  135315. * @returns the current particle system
  135316. */
  135317. removeColorGradient(gradient: number): GPUParticleSystem;
  135318. private _angularSpeedGradientsTexture;
  135319. private _sizeGradientsTexture;
  135320. private _velocityGradientsTexture;
  135321. private _limitVelocityGradientsTexture;
  135322. private _dragGradientsTexture;
  135323. private _addFactorGradient;
  135324. /**
  135325. * Adds a new size gradient
  135326. * @param gradient defines the gradient to use (between 0 and 1)
  135327. * @param factor defines the size factor to affect to the specified gradient
  135328. * @returns the current particle system
  135329. */
  135330. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135331. /**
  135332. * Remove a specific size gradient
  135333. * @param gradient defines the gradient to remove
  135334. * @returns the current particle system
  135335. */
  135336. removeSizeGradient(gradient: number): GPUParticleSystem;
  135337. /**
  135338. * Adds a new angular speed gradient
  135339. * @param gradient defines the gradient to use (between 0 and 1)
  135340. * @param factor defines the angular speed to affect to the specified gradient
  135341. * @returns the current particle system
  135342. */
  135343. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135344. /**
  135345. * Remove a specific angular speed gradient
  135346. * @param gradient defines the gradient to remove
  135347. * @returns the current particle system
  135348. */
  135349. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135350. /**
  135351. * Adds a new velocity gradient
  135352. * @param gradient defines the gradient to use (between 0 and 1)
  135353. * @param factor defines the velocity to affect to the specified gradient
  135354. * @returns the current particle system
  135355. */
  135356. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135357. /**
  135358. * Remove a specific velocity gradient
  135359. * @param gradient defines the gradient to remove
  135360. * @returns the current particle system
  135361. */
  135362. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135363. /**
  135364. * Adds a new limit velocity gradient
  135365. * @param gradient defines the gradient to use (between 0 and 1)
  135366. * @param factor defines the limit velocity value to affect to the specified gradient
  135367. * @returns the current particle system
  135368. */
  135369. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135370. /**
  135371. * Remove a specific limit velocity gradient
  135372. * @param gradient defines the gradient to remove
  135373. * @returns the current particle system
  135374. */
  135375. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135376. /**
  135377. * Adds a new drag gradient
  135378. * @param gradient defines the gradient to use (between 0 and 1)
  135379. * @param factor defines the drag value to affect to the specified gradient
  135380. * @returns the current particle system
  135381. */
  135382. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135383. /**
  135384. * Remove a specific drag gradient
  135385. * @param gradient defines the gradient to remove
  135386. * @returns the current particle system
  135387. */
  135388. removeDragGradient(gradient: number): GPUParticleSystem;
  135389. /**
  135390. * Not supported by GPUParticleSystem
  135391. * @param gradient defines the gradient to use (between 0 and 1)
  135392. * @param factor defines the emit rate value to affect to the specified gradient
  135393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135394. * @returns the current particle system
  135395. */
  135396. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135397. /**
  135398. * Not supported by GPUParticleSystem
  135399. * @param gradient defines the gradient to remove
  135400. * @returns the current particle system
  135401. */
  135402. removeEmitRateGradient(gradient: number): IParticleSystem;
  135403. /**
  135404. * Not supported by GPUParticleSystem
  135405. * @param gradient defines the gradient to use (between 0 and 1)
  135406. * @param factor defines the start size value to affect to the specified gradient
  135407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135408. * @returns the current particle system
  135409. */
  135410. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135411. /**
  135412. * Not supported by GPUParticleSystem
  135413. * @param gradient defines the gradient to remove
  135414. * @returns the current particle system
  135415. */
  135416. removeStartSizeGradient(gradient: number): IParticleSystem;
  135417. /**
  135418. * Not supported by GPUParticleSystem
  135419. * @param gradient defines the gradient to use (between 0 and 1)
  135420. * @param min defines the color remap minimal range
  135421. * @param max defines the color remap maximal range
  135422. * @returns the current particle system
  135423. */
  135424. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135425. /**
  135426. * Not supported by GPUParticleSystem
  135427. * @param gradient defines the gradient to remove
  135428. * @returns the current particle system
  135429. */
  135430. removeColorRemapGradient(): IParticleSystem;
  135431. /**
  135432. * Not supported by GPUParticleSystem
  135433. * @param gradient defines the gradient to use (between 0 and 1)
  135434. * @param min defines the alpha remap minimal range
  135435. * @param max defines the alpha remap maximal range
  135436. * @returns the current particle system
  135437. */
  135438. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135439. /**
  135440. * Not supported by GPUParticleSystem
  135441. * @param gradient defines the gradient to remove
  135442. * @returns the current particle system
  135443. */
  135444. removeAlphaRemapGradient(): IParticleSystem;
  135445. /**
  135446. * Not supported by GPUParticleSystem
  135447. * @param gradient defines the gradient to use (between 0 and 1)
  135448. * @param color defines the color to affect to the specified gradient
  135449. * @returns the current particle system
  135450. */
  135451. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135452. /**
  135453. * Not supported by GPUParticleSystem
  135454. * @param gradient defines the gradient to remove
  135455. * @returns the current particle system
  135456. */
  135457. removeRampGradient(): IParticleSystem;
  135458. /**
  135459. * Not supported by GPUParticleSystem
  135460. * @returns the list of ramp gradients
  135461. */
  135462. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135463. /**
  135464. * Not supported by GPUParticleSystem
  135465. * Gets or sets a boolean indicating that ramp gradients must be used
  135466. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135467. */
  135468. get useRampGradients(): boolean;
  135469. set useRampGradients(value: boolean);
  135470. /**
  135471. * Not supported by GPUParticleSystem
  135472. * @param gradient defines the gradient to use (between 0 and 1)
  135473. * @param factor defines the life time factor to affect to the specified gradient
  135474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135475. * @returns the current particle system
  135476. */
  135477. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135478. /**
  135479. * Not supported by GPUParticleSystem
  135480. * @param gradient defines the gradient to remove
  135481. * @returns the current particle system
  135482. */
  135483. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135484. /**
  135485. * Instantiates a GPU particle system.
  135486. * 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.
  135487. * @param name The name of the particle system
  135488. * @param options The options used to create the system
  135489. * @param scene The scene the particle system belongs to
  135490. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135491. */
  135492. constructor(name: string, options: Partial<{
  135493. capacity: number;
  135494. randomTextureSize: number;
  135495. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135496. protected _reset(): void;
  135497. private _createUpdateVAO;
  135498. private _createRenderVAO;
  135499. private _initialize;
  135500. /** @hidden */
  135501. _recreateUpdateEffect(): void;
  135502. /** @hidden */
  135503. _recreateRenderEffect(): void;
  135504. /**
  135505. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135506. * @param preWarm defines if we are in the pre-warmimg phase
  135507. */
  135508. animate(preWarm?: boolean): void;
  135509. private _createFactorGradientTexture;
  135510. private _createSizeGradientTexture;
  135511. private _createAngularSpeedGradientTexture;
  135512. private _createVelocityGradientTexture;
  135513. private _createLimitVelocityGradientTexture;
  135514. private _createDragGradientTexture;
  135515. private _createColorGradientTexture;
  135516. /**
  135517. * Renders the particle system in its current state
  135518. * @param preWarm defines if the system should only update the particles but not render them
  135519. * @returns the current number of particles
  135520. */
  135521. render(preWarm?: boolean): number;
  135522. /**
  135523. * Rebuilds the particle system
  135524. */
  135525. rebuild(): void;
  135526. private _releaseBuffers;
  135527. private _releaseVAOs;
  135528. /**
  135529. * Disposes the particle system and free the associated resources
  135530. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135531. */
  135532. dispose(disposeTexture?: boolean): void;
  135533. /**
  135534. * Clones the particle system.
  135535. * @param name The name of the cloned object
  135536. * @param newEmitter The new emitter to use
  135537. * @returns the cloned particle system
  135538. */
  135539. clone(name: string, newEmitter: any): GPUParticleSystem;
  135540. /**
  135541. * Serializes the particle system to a JSON object.
  135542. * @returns the JSON object
  135543. */
  135544. serialize(): any;
  135545. /**
  135546. * Parses a JSON object to create a GPU particle system.
  135547. * @param parsedParticleSystem The JSON object to parse
  135548. * @param scene The scene to create the particle system in
  135549. * @param rootUrl The root url to use to load external dependencies like texture
  135550. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135551. * @returns the parsed GPU particle system
  135552. */
  135553. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135554. }
  135555. }
  135556. declare module BABYLON {
  135557. /**
  135558. * Represents a set of particle systems working together to create a specific effect
  135559. */
  135560. export class ParticleSystemSet implements IDisposable {
  135561. /**
  135562. * Gets or sets base Assets URL
  135563. */
  135564. static BaseAssetsUrl: string;
  135565. private _emitterCreationOptions;
  135566. private _emitterNode;
  135567. /**
  135568. * Gets the particle system list
  135569. */
  135570. systems: IParticleSystem[];
  135571. /**
  135572. * Gets the emitter node used with this set
  135573. */
  135574. get emitterNode(): Nullable<TransformNode>;
  135575. /**
  135576. * Creates a new emitter mesh as a sphere
  135577. * @param options defines the options used to create the sphere
  135578. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135579. * @param scene defines the hosting scene
  135580. */
  135581. setEmitterAsSphere(options: {
  135582. diameter: number;
  135583. segments: number;
  135584. color: Color3;
  135585. }, renderingGroupId: number, scene: Scene): void;
  135586. /**
  135587. * Starts all particle systems of the set
  135588. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135589. */
  135590. start(emitter?: AbstractMesh): void;
  135591. /**
  135592. * Release all associated resources
  135593. */
  135594. dispose(): void;
  135595. /**
  135596. * Serialize the set into a JSON compatible object
  135597. * @returns a JSON compatible representation of the set
  135598. */
  135599. serialize(): any;
  135600. /**
  135601. * Parse a new ParticleSystemSet from a serialized source
  135602. * @param data defines a JSON compatible representation of the set
  135603. * @param scene defines the hosting scene
  135604. * @param gpu defines if we want GPU particles or CPU particles
  135605. * @returns a new ParticleSystemSet
  135606. */
  135607. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135608. }
  135609. }
  135610. declare module BABYLON {
  135611. /**
  135612. * This class is made for on one-liner static method to help creating particle system set.
  135613. */
  135614. export class ParticleHelper {
  135615. /**
  135616. * Gets or sets base Assets URL
  135617. */
  135618. static BaseAssetsUrl: string;
  135619. /**
  135620. * Create a default particle system that you can tweak
  135621. * @param emitter defines the emitter to use
  135622. * @param capacity defines the system capacity (default is 500 particles)
  135623. * @param scene defines the hosting scene
  135624. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135625. * @returns the new Particle system
  135626. */
  135627. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135628. /**
  135629. * This is the main static method (one-liner) of this helper to create different particle systems
  135630. * @param type This string represents the type to the particle system to create
  135631. * @param scene The scene where the particle system should live
  135632. * @param gpu If the system will use gpu
  135633. * @returns the ParticleSystemSet created
  135634. */
  135635. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135636. /**
  135637. * Static function used to export a particle system to a ParticleSystemSet variable.
  135638. * Please note that the emitter shape is not exported
  135639. * @param systems defines the particle systems to export
  135640. * @returns the created particle system set
  135641. */
  135642. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  135643. }
  135644. }
  135645. declare module BABYLON {
  135646. interface Engine {
  135647. /**
  135648. * Create an effect to use with particle systems.
  135649. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  135650. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  135651. * @param uniformsNames defines a list of attribute names
  135652. * @param samplers defines an array of string used to represent textures
  135653. * @param defines defines the string containing the defines to use to compile the shaders
  135654. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  135655. * @param onCompiled defines a function to call when the effect creation is successful
  135656. * @param onError defines a function to call when the effect creation has failed
  135657. * @returns the new Effect
  135658. */
  135659. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  135660. }
  135661. interface Mesh {
  135662. /**
  135663. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  135664. * @returns an array of IParticleSystem
  135665. */
  135666. getEmittedParticleSystems(): IParticleSystem[];
  135667. /**
  135668. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  135669. * @returns an array of IParticleSystem
  135670. */
  135671. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  135672. }
  135673. /**
  135674. * @hidden
  135675. */
  135676. export var _IDoNeedToBeInTheBuild: number;
  135677. }
  135678. declare module BABYLON {
  135679. /** Defines the 4 color options */
  135680. export enum PointColor {
  135681. /** color value */
  135682. Color = 2,
  135683. /** uv value */
  135684. UV = 1,
  135685. /** random value */
  135686. Random = 0,
  135687. /** stated value */
  135688. Stated = 3
  135689. }
  135690. /**
  135691. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  135692. * 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.
  135693. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  135694. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  135695. *
  135696. * Full documentation here : TO BE ENTERED
  135697. */
  135698. export class PointsCloudSystem implements IDisposable {
  135699. /**
  135700. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  135701. * Example : var p = SPS.particles[i];
  135702. */
  135703. particles: CloudPoint[];
  135704. /**
  135705. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  135706. */
  135707. nbParticles: number;
  135708. /**
  135709. * This a counter for your own usage. It's not set by any SPS functions.
  135710. */
  135711. counter: number;
  135712. /**
  135713. * The PCS name. This name is also given to the underlying mesh.
  135714. */
  135715. name: string;
  135716. /**
  135717. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  135718. */
  135719. mesh: Mesh;
  135720. /**
  135721. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  135722. * Please read :
  135723. */
  135724. vars: any;
  135725. /**
  135726. * @hidden
  135727. */
  135728. _size: number;
  135729. private _scene;
  135730. private _promises;
  135731. private _positions;
  135732. private _indices;
  135733. private _normals;
  135734. private _colors;
  135735. private _uvs;
  135736. private _indices32;
  135737. private _positions32;
  135738. private _colors32;
  135739. private _uvs32;
  135740. private _updatable;
  135741. private _isVisibilityBoxLocked;
  135742. private _alwaysVisible;
  135743. private _groups;
  135744. private _groupCounter;
  135745. private _computeParticleColor;
  135746. private _computeParticleTexture;
  135747. private _computeParticleRotation;
  135748. private _computeBoundingBox;
  135749. private _isReady;
  135750. /**
  135751. * Creates a PCS (Points Cloud System) object
  135752. * @param name (String) is the PCS name, this will be the underlying mesh name
  135753. * @param pointSize (number) is the size for each point
  135754. * @param scene (Scene) is the scene in which the PCS is added
  135755. * @param options defines the options of the PCS e.g.
  135756. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  135757. */
  135758. constructor(name: string, pointSize: number, scene: Scene, options?: {
  135759. updatable?: boolean;
  135760. });
  135761. /**
  135762. * Builds the PCS underlying mesh. Returns a standard Mesh.
  135763. * If no points were added to the PCS, the returned mesh is just a single point.
  135764. * @returns a promise for the created mesh
  135765. */
  135766. buildMeshAsync(): Promise<Mesh>;
  135767. /**
  135768. * @hidden
  135769. */
  135770. private _buildMesh;
  135771. private _addParticle;
  135772. private _randomUnitVector;
  135773. private _getColorIndicesForCoord;
  135774. private _setPointsColorOrUV;
  135775. private _colorFromTexture;
  135776. private _calculateDensity;
  135777. /**
  135778. * Adds points to the PCS in random positions within a unit sphere
  135779. * @param nb (positive integer) the number of particles to be created from this model
  135780. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  135781. * @returns the number of groups in the system
  135782. */
  135783. addPoints(nb: number, pointFunction?: any): number;
  135784. /**
  135785. * Adds points to the PCS from the surface of the model shape
  135786. * @param mesh is any Mesh object that will be used as a surface model for the points
  135787. * @param nb (positive integer) the number of particles to be created from this model
  135788. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135789. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135790. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135791. * @returns the number of groups in the system
  135792. */
  135793. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135794. /**
  135795. * Adds points to the PCS inside the model shape
  135796. * @param mesh is any Mesh object that will be used as a surface model for the points
  135797. * @param nb (positive integer) the number of particles to be created from this model
  135798. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135799. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135800. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135801. * @returns the number of groups in the system
  135802. */
  135803. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135804. /**
  135805. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  135806. * This method calls `updateParticle()` for each particle of the SPS.
  135807. * For an animated SPS, it is usually called within the render loop.
  135808. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  135809. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  135810. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  135811. * @returns the PCS.
  135812. */
  135813. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  135814. /**
  135815. * Disposes the PCS.
  135816. */
  135817. dispose(): void;
  135818. /**
  135819. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  135820. * doc :
  135821. * @returns the PCS.
  135822. */
  135823. refreshVisibleSize(): PointsCloudSystem;
  135824. /**
  135825. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  135826. * @param size the size (float) of the visibility box
  135827. * note : this doesn't lock the PCS mesh bounding box.
  135828. * doc :
  135829. */
  135830. setVisibilityBox(size: number): void;
  135831. /**
  135832. * Gets whether the PCS is always visible or not
  135833. * doc :
  135834. */
  135835. get isAlwaysVisible(): boolean;
  135836. /**
  135837. * Sets the PCS as always visible or not
  135838. * doc :
  135839. */
  135840. set isAlwaysVisible(val: boolean);
  135841. /**
  135842. * Tells to `setParticles()` to compute the particle rotations or not
  135843. * Default value : false. The PCS is faster when it's set to false
  135844. * Note : particle rotations are only applied to parent particles
  135845. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  135846. */
  135847. set computeParticleRotation(val: boolean);
  135848. /**
  135849. * Tells to `setParticles()` to compute the particle colors or not.
  135850. * Default value : true. The PCS is faster when it's set to false.
  135851. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135852. */
  135853. set computeParticleColor(val: boolean);
  135854. set computeParticleTexture(val: boolean);
  135855. /**
  135856. * Gets if `setParticles()` computes the particle colors or not.
  135857. * Default value : false. The PCS is faster when it's set to false.
  135858. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135859. */
  135860. get computeParticleColor(): boolean;
  135861. /**
  135862. * Gets if `setParticles()` computes the particle textures or not.
  135863. * Default value : false. The PCS is faster when it's set to false.
  135864. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  135865. */
  135866. get computeParticleTexture(): boolean;
  135867. /**
  135868. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  135869. */
  135870. set computeBoundingBox(val: boolean);
  135871. /**
  135872. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  135873. */
  135874. get computeBoundingBox(): boolean;
  135875. /**
  135876. * This function does nothing. It may be overwritten to set all the particle first values.
  135877. * The PCS doesn't call this function, you may have to call it by your own.
  135878. * doc :
  135879. */
  135880. initParticles(): void;
  135881. /**
  135882. * This function does nothing. It may be overwritten to recycle a particle
  135883. * The PCS doesn't call this function, you can to call it
  135884. * doc :
  135885. * @param particle The particle to recycle
  135886. * @returns the recycled particle
  135887. */
  135888. recycleParticle(particle: CloudPoint): CloudPoint;
  135889. /**
  135890. * Updates a particle : this function should be overwritten by the user.
  135891. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  135892. * doc :
  135893. * @example : just set a particle position or velocity and recycle conditions
  135894. * @param particle The particle to update
  135895. * @returns the updated particle
  135896. */
  135897. updateParticle(particle: CloudPoint): CloudPoint;
  135898. /**
  135899. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  135900. * This does nothing and may be overwritten by the user.
  135901. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135903. * @param update the boolean update value actually passed to setParticles()
  135904. */
  135905. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135906. /**
  135907. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  135908. * This will be passed three parameters.
  135909. * This does nothing and may be overwritten by the user.
  135910. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135911. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135912. * @param update the boolean update value actually passed to setParticles()
  135913. */
  135914. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135915. }
  135916. }
  135917. declare module BABYLON {
  135918. /**
  135919. * Represents one particle of a points cloud system.
  135920. */
  135921. export class CloudPoint {
  135922. /**
  135923. * particle global index
  135924. */
  135925. idx: number;
  135926. /**
  135927. * The color of the particle
  135928. */
  135929. color: Nullable<Color4>;
  135930. /**
  135931. * The world space position of the particle.
  135932. */
  135933. position: Vector3;
  135934. /**
  135935. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  135936. */
  135937. rotation: Vector3;
  135938. /**
  135939. * The world space rotation quaternion of the particle.
  135940. */
  135941. rotationQuaternion: Nullable<Quaternion>;
  135942. /**
  135943. * The uv of the particle.
  135944. */
  135945. uv: Nullable<Vector2>;
  135946. /**
  135947. * The current speed of the particle.
  135948. */
  135949. velocity: Vector3;
  135950. /**
  135951. * The pivot point in the particle local space.
  135952. */
  135953. pivot: Vector3;
  135954. /**
  135955. * Must the particle be translated from its pivot point in its local space ?
  135956. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  135957. * Default : false
  135958. */
  135959. translateFromPivot: boolean;
  135960. /**
  135961. * Index of this particle in the global "positions" array (Internal use)
  135962. * @hidden
  135963. */
  135964. _pos: number;
  135965. /**
  135966. * @hidden Index of this particle in the global "indices" array (Internal use)
  135967. */
  135968. _ind: number;
  135969. /**
  135970. * Group this particle belongs to
  135971. */
  135972. _group: PointsGroup;
  135973. /**
  135974. * Group id of this particle
  135975. */
  135976. groupId: number;
  135977. /**
  135978. * Index of the particle in its group id (Internal use)
  135979. */
  135980. idxInGroup: number;
  135981. /**
  135982. * @hidden Particle BoundingInfo object (Internal use)
  135983. */
  135984. _boundingInfo: BoundingInfo;
  135985. /**
  135986. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  135987. */
  135988. _pcs: PointsCloudSystem;
  135989. /**
  135990. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  135991. */
  135992. _stillInvisible: boolean;
  135993. /**
  135994. * @hidden Last computed particle rotation matrix
  135995. */
  135996. _rotationMatrix: number[];
  135997. /**
  135998. * Parent particle Id, if any.
  135999. * Default null.
  136000. */
  136001. parentId: Nullable<number>;
  136002. /**
  136003. * @hidden Internal global position in the PCS.
  136004. */
  136005. _globalPosition: Vector3;
  136006. /**
  136007. * Creates a Point Cloud object.
  136008. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136009. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136010. * @param group (PointsGroup) is the group the particle belongs to
  136011. * @param groupId (integer) is the group identifier in the PCS.
  136012. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136013. * @param pcs defines the PCS it is associated to
  136014. */
  136015. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136016. /**
  136017. * get point size
  136018. */
  136019. get size(): Vector3;
  136020. /**
  136021. * Set point size
  136022. */
  136023. set size(scale: Vector3);
  136024. /**
  136025. * Legacy support, changed quaternion to rotationQuaternion
  136026. */
  136027. get quaternion(): Nullable<Quaternion>;
  136028. /**
  136029. * Legacy support, changed quaternion to rotationQuaternion
  136030. */
  136031. set quaternion(q: Nullable<Quaternion>);
  136032. /**
  136033. * Returns a boolean. True if the particle intersects a mesh, else false
  136034. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136035. * @param target is the object (point or mesh) what the intersection is computed against
  136036. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136037. * @returns true if it intersects
  136038. */
  136039. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136040. /**
  136041. * get the rotation matrix of the particle
  136042. * @hidden
  136043. */
  136044. getRotationMatrix(m: Matrix): void;
  136045. }
  136046. /**
  136047. * Represents a group of points in a points cloud system
  136048. * * PCS internal tool, don't use it manually.
  136049. */
  136050. export class PointsGroup {
  136051. /**
  136052. * The group id
  136053. * @hidden
  136054. */
  136055. groupID: number;
  136056. /**
  136057. * image data for group (internal use)
  136058. * @hidden
  136059. */
  136060. _groupImageData: Nullable<ArrayBufferView>;
  136061. /**
  136062. * Image Width (internal use)
  136063. * @hidden
  136064. */
  136065. _groupImgWidth: number;
  136066. /**
  136067. * Image Height (internal use)
  136068. * @hidden
  136069. */
  136070. _groupImgHeight: number;
  136071. /**
  136072. * Custom position function (internal use)
  136073. * @hidden
  136074. */
  136075. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136076. /**
  136077. * density per facet for surface points
  136078. * @hidden
  136079. */
  136080. _groupDensity: number[];
  136081. /**
  136082. * Only when points are colored by texture carries pointer to texture list array
  136083. * @hidden
  136084. */
  136085. _textureNb: number;
  136086. /**
  136087. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136088. * PCS internal tool, don't use it manually.
  136089. * @hidden
  136090. */
  136091. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136092. }
  136093. }
  136094. declare module BABYLON {
  136095. interface Scene {
  136096. /** @hidden (Backing field) */
  136097. _physicsEngine: Nullable<IPhysicsEngine>;
  136098. /** @hidden */
  136099. _physicsTimeAccumulator: number;
  136100. /**
  136101. * Gets the current physics engine
  136102. * @returns a IPhysicsEngine or null if none attached
  136103. */
  136104. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136105. /**
  136106. * Enables physics to the current scene
  136107. * @param gravity defines the scene's gravity for the physics engine
  136108. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136109. * @return a boolean indicating if the physics engine was initialized
  136110. */
  136111. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136112. /**
  136113. * Disables and disposes the physics engine associated with the scene
  136114. */
  136115. disablePhysicsEngine(): void;
  136116. /**
  136117. * Gets a boolean indicating if there is an active physics engine
  136118. * @returns a boolean indicating if there is an active physics engine
  136119. */
  136120. isPhysicsEnabled(): boolean;
  136121. /**
  136122. * Deletes a physics compound impostor
  136123. * @param compound defines the compound to delete
  136124. */
  136125. deleteCompoundImpostor(compound: any): void;
  136126. /**
  136127. * An event triggered when physic simulation is about to be run
  136128. */
  136129. onBeforePhysicsObservable: Observable<Scene>;
  136130. /**
  136131. * An event triggered when physic simulation has been done
  136132. */
  136133. onAfterPhysicsObservable: Observable<Scene>;
  136134. }
  136135. interface AbstractMesh {
  136136. /** @hidden */
  136137. _physicsImpostor: Nullable<PhysicsImpostor>;
  136138. /**
  136139. * Gets or sets impostor used for physic simulation
  136140. * @see http://doc.babylonjs.com/features/physics_engine
  136141. */
  136142. physicsImpostor: Nullable<PhysicsImpostor>;
  136143. /**
  136144. * Gets the current physics impostor
  136145. * @see http://doc.babylonjs.com/features/physics_engine
  136146. * @returns a physics impostor or null
  136147. */
  136148. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136149. /** Apply a physic impulse to the mesh
  136150. * @param force defines the force to apply
  136151. * @param contactPoint defines where to apply the force
  136152. * @returns the current mesh
  136153. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136154. */
  136155. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136156. /**
  136157. * Creates a physic joint between two meshes
  136158. * @param otherMesh defines the other mesh to use
  136159. * @param pivot1 defines the pivot to use on this mesh
  136160. * @param pivot2 defines the pivot to use on the other mesh
  136161. * @param options defines additional options (can be plugin dependent)
  136162. * @returns the current mesh
  136163. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136164. */
  136165. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136166. /** @hidden */
  136167. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136168. }
  136169. /**
  136170. * Defines the physics engine scene component responsible to manage a physics engine
  136171. */
  136172. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136173. /**
  136174. * The component name helpful to identify the component in the list of scene components.
  136175. */
  136176. readonly name: string;
  136177. /**
  136178. * The scene the component belongs to.
  136179. */
  136180. scene: Scene;
  136181. /**
  136182. * Creates a new instance of the component for the given scene
  136183. * @param scene Defines the scene to register the component in
  136184. */
  136185. constructor(scene: Scene);
  136186. /**
  136187. * Registers the component in a given scene
  136188. */
  136189. register(): void;
  136190. /**
  136191. * Rebuilds the elements related to this component in case of
  136192. * context lost for instance.
  136193. */
  136194. rebuild(): void;
  136195. /**
  136196. * Disposes the component and the associated ressources
  136197. */
  136198. dispose(): void;
  136199. }
  136200. }
  136201. declare module BABYLON {
  136202. /**
  136203. * A helper for physics simulations
  136204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136205. */
  136206. export class PhysicsHelper {
  136207. private _scene;
  136208. private _physicsEngine;
  136209. /**
  136210. * Initializes the Physics helper
  136211. * @param scene Babylon.js scene
  136212. */
  136213. constructor(scene: Scene);
  136214. /**
  136215. * Applies a radial explosion impulse
  136216. * @param origin the origin of the explosion
  136217. * @param radiusOrEventOptions the radius or the options of radial explosion
  136218. * @param strength the explosion strength
  136219. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136220. * @returns A physics radial explosion event, or null
  136221. */
  136222. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136223. /**
  136224. * Applies a radial explosion force
  136225. * @param origin the origin of the explosion
  136226. * @param radiusOrEventOptions the radius or the options of radial explosion
  136227. * @param strength the explosion strength
  136228. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136229. * @returns A physics radial explosion event, or null
  136230. */
  136231. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136232. /**
  136233. * Creates a gravitational field
  136234. * @param origin the origin of the explosion
  136235. * @param radiusOrEventOptions the radius or the options of radial explosion
  136236. * @param strength the explosion strength
  136237. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136238. * @returns A physics gravitational field event, or null
  136239. */
  136240. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136241. /**
  136242. * Creates a physics updraft event
  136243. * @param origin the origin of the updraft
  136244. * @param radiusOrEventOptions the radius or the options of the updraft
  136245. * @param strength the strength of the updraft
  136246. * @param height the height of the updraft
  136247. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136248. * @returns A physics updraft event, or null
  136249. */
  136250. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136251. /**
  136252. * Creates a physics vortex event
  136253. * @param origin the of the vortex
  136254. * @param radiusOrEventOptions the radius or the options of the vortex
  136255. * @param strength the strength of the vortex
  136256. * @param height the height of the vortex
  136257. * @returns a Physics vortex event, or null
  136258. * A physics vortex event or null
  136259. */
  136260. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136261. }
  136262. /**
  136263. * Represents a physics radial explosion event
  136264. */
  136265. class PhysicsRadialExplosionEvent {
  136266. private _scene;
  136267. private _options;
  136268. private _sphere;
  136269. private _dataFetched;
  136270. /**
  136271. * Initializes a radial explosioin event
  136272. * @param _scene BabylonJS scene
  136273. * @param _options The options for the vortex event
  136274. */
  136275. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136276. /**
  136277. * Returns the data related to the radial explosion event (sphere).
  136278. * @returns The radial explosion event data
  136279. */
  136280. getData(): PhysicsRadialExplosionEventData;
  136281. /**
  136282. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136283. * @param impostor A physics imposter
  136284. * @param origin the origin of the explosion
  136285. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136286. */
  136287. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136288. /**
  136289. * Triggers affecterd impostors callbacks
  136290. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136291. */
  136292. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136293. /**
  136294. * Disposes the sphere.
  136295. * @param force Specifies if the sphere should be disposed by force
  136296. */
  136297. dispose(force?: boolean): void;
  136298. /*** Helpers ***/
  136299. private _prepareSphere;
  136300. private _intersectsWithSphere;
  136301. }
  136302. /**
  136303. * Represents a gravitational field event
  136304. */
  136305. class PhysicsGravitationalFieldEvent {
  136306. private _physicsHelper;
  136307. private _scene;
  136308. private _origin;
  136309. private _options;
  136310. private _tickCallback;
  136311. private _sphere;
  136312. private _dataFetched;
  136313. /**
  136314. * Initializes the physics gravitational field event
  136315. * @param _physicsHelper A physics helper
  136316. * @param _scene BabylonJS scene
  136317. * @param _origin The origin position of the gravitational field event
  136318. * @param _options The options for the vortex event
  136319. */
  136320. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136321. /**
  136322. * Returns the data related to the gravitational field event (sphere).
  136323. * @returns A gravitational field event
  136324. */
  136325. getData(): PhysicsGravitationalFieldEventData;
  136326. /**
  136327. * Enables the gravitational field.
  136328. */
  136329. enable(): void;
  136330. /**
  136331. * Disables the gravitational field.
  136332. */
  136333. disable(): void;
  136334. /**
  136335. * Disposes the sphere.
  136336. * @param force The force to dispose from the gravitational field event
  136337. */
  136338. dispose(force?: boolean): void;
  136339. private _tick;
  136340. }
  136341. /**
  136342. * Represents a physics updraft event
  136343. */
  136344. class PhysicsUpdraftEvent {
  136345. private _scene;
  136346. private _origin;
  136347. private _options;
  136348. private _physicsEngine;
  136349. private _originTop;
  136350. private _originDirection;
  136351. private _tickCallback;
  136352. private _cylinder;
  136353. private _cylinderPosition;
  136354. private _dataFetched;
  136355. /**
  136356. * Initializes the physics updraft event
  136357. * @param _scene BabylonJS scene
  136358. * @param _origin The origin position of the updraft
  136359. * @param _options The options for the updraft event
  136360. */
  136361. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136362. /**
  136363. * Returns the data related to the updraft event (cylinder).
  136364. * @returns A physics updraft event
  136365. */
  136366. getData(): PhysicsUpdraftEventData;
  136367. /**
  136368. * Enables the updraft.
  136369. */
  136370. enable(): void;
  136371. /**
  136372. * Disables the updraft.
  136373. */
  136374. disable(): void;
  136375. /**
  136376. * Disposes the cylinder.
  136377. * @param force Specifies if the updraft should be disposed by force
  136378. */
  136379. dispose(force?: boolean): void;
  136380. private getImpostorHitData;
  136381. private _tick;
  136382. /*** Helpers ***/
  136383. private _prepareCylinder;
  136384. private _intersectsWithCylinder;
  136385. }
  136386. /**
  136387. * Represents a physics vortex event
  136388. */
  136389. class PhysicsVortexEvent {
  136390. private _scene;
  136391. private _origin;
  136392. private _options;
  136393. private _physicsEngine;
  136394. private _originTop;
  136395. private _tickCallback;
  136396. private _cylinder;
  136397. private _cylinderPosition;
  136398. private _dataFetched;
  136399. /**
  136400. * Initializes the physics vortex event
  136401. * @param _scene The BabylonJS scene
  136402. * @param _origin The origin position of the vortex
  136403. * @param _options The options for the vortex event
  136404. */
  136405. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136406. /**
  136407. * Returns the data related to the vortex event (cylinder).
  136408. * @returns The physics vortex event data
  136409. */
  136410. getData(): PhysicsVortexEventData;
  136411. /**
  136412. * Enables the vortex.
  136413. */
  136414. enable(): void;
  136415. /**
  136416. * Disables the cortex.
  136417. */
  136418. disable(): void;
  136419. /**
  136420. * Disposes the sphere.
  136421. * @param force
  136422. */
  136423. dispose(force?: boolean): void;
  136424. private getImpostorHitData;
  136425. private _tick;
  136426. /*** Helpers ***/
  136427. private _prepareCylinder;
  136428. private _intersectsWithCylinder;
  136429. }
  136430. /**
  136431. * Options fot the radial explosion event
  136432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136433. */
  136434. export class PhysicsRadialExplosionEventOptions {
  136435. /**
  136436. * The radius of the sphere for the radial explosion.
  136437. */
  136438. radius: number;
  136439. /**
  136440. * The strenth of the explosion.
  136441. */
  136442. strength: number;
  136443. /**
  136444. * The strenght of the force in correspondence to the distance of the affected object
  136445. */
  136446. falloff: PhysicsRadialImpulseFalloff;
  136447. /**
  136448. * Sphere options for the radial explosion.
  136449. */
  136450. sphere: {
  136451. segments: number;
  136452. diameter: number;
  136453. };
  136454. /**
  136455. * Sphere options for the radial explosion.
  136456. */
  136457. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136458. }
  136459. /**
  136460. * Options fot the updraft event
  136461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136462. */
  136463. export class PhysicsUpdraftEventOptions {
  136464. /**
  136465. * The radius of the cylinder for the vortex
  136466. */
  136467. radius: number;
  136468. /**
  136469. * The strenth of the updraft.
  136470. */
  136471. strength: number;
  136472. /**
  136473. * The height of the cylinder for the updraft.
  136474. */
  136475. height: number;
  136476. /**
  136477. * The mode for the the updraft.
  136478. */
  136479. updraftMode: PhysicsUpdraftMode;
  136480. }
  136481. /**
  136482. * Options fot the vortex event
  136483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136484. */
  136485. export class PhysicsVortexEventOptions {
  136486. /**
  136487. * The radius of the cylinder for the vortex
  136488. */
  136489. radius: number;
  136490. /**
  136491. * The strenth of the vortex.
  136492. */
  136493. strength: number;
  136494. /**
  136495. * The height of the cylinder for the vortex.
  136496. */
  136497. height: number;
  136498. /**
  136499. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136500. */
  136501. centripetalForceThreshold: number;
  136502. /**
  136503. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136504. */
  136505. centripetalForceMultiplier: number;
  136506. /**
  136507. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136508. */
  136509. centrifugalForceMultiplier: number;
  136510. /**
  136511. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136512. */
  136513. updraftForceMultiplier: number;
  136514. }
  136515. /**
  136516. * The strenght of the force in correspondence to the distance of the affected object
  136517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136518. */
  136519. export enum PhysicsRadialImpulseFalloff {
  136520. /** Defines that impulse is constant in strength across it's whole radius */
  136521. Constant = 0,
  136522. /** Defines that impulse gets weaker if it's further from the origin */
  136523. Linear = 1
  136524. }
  136525. /**
  136526. * The strength of the force in correspondence to the distance of the affected object
  136527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136528. */
  136529. export enum PhysicsUpdraftMode {
  136530. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136531. Center = 0,
  136532. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136533. Perpendicular = 1
  136534. }
  136535. /**
  136536. * Interface for a physics hit data
  136537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136538. */
  136539. export interface PhysicsHitData {
  136540. /**
  136541. * The force applied at the contact point
  136542. */
  136543. force: Vector3;
  136544. /**
  136545. * The contact point
  136546. */
  136547. contactPoint: Vector3;
  136548. /**
  136549. * The distance from the origin to the contact point
  136550. */
  136551. distanceFromOrigin: number;
  136552. }
  136553. /**
  136554. * Interface for radial explosion event data
  136555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136556. */
  136557. export interface PhysicsRadialExplosionEventData {
  136558. /**
  136559. * A sphere used for the radial explosion event
  136560. */
  136561. sphere: Mesh;
  136562. }
  136563. /**
  136564. * Interface for gravitational field event data
  136565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136566. */
  136567. export interface PhysicsGravitationalFieldEventData {
  136568. /**
  136569. * A sphere mesh used for the gravitational field event
  136570. */
  136571. sphere: Mesh;
  136572. }
  136573. /**
  136574. * Interface for updraft event data
  136575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136576. */
  136577. export interface PhysicsUpdraftEventData {
  136578. /**
  136579. * A cylinder used for the updraft event
  136580. */
  136581. cylinder: Mesh;
  136582. }
  136583. /**
  136584. * Interface for vortex event data
  136585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136586. */
  136587. export interface PhysicsVortexEventData {
  136588. /**
  136589. * A cylinder used for the vortex event
  136590. */
  136591. cylinder: Mesh;
  136592. }
  136593. /**
  136594. * Interface for an affected physics impostor
  136595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136596. */
  136597. export interface PhysicsAffectedImpostorWithData {
  136598. /**
  136599. * The impostor affected by the effect
  136600. */
  136601. impostor: PhysicsImpostor;
  136602. /**
  136603. * The data about the hit/horce from the explosion
  136604. */
  136605. hitData: PhysicsHitData;
  136606. }
  136607. }
  136608. declare module BABYLON {
  136609. /** @hidden */
  136610. export var blackAndWhitePixelShader: {
  136611. name: string;
  136612. shader: string;
  136613. };
  136614. }
  136615. declare module BABYLON {
  136616. /**
  136617. * Post process used to render in black and white
  136618. */
  136619. export class BlackAndWhitePostProcess extends PostProcess {
  136620. /**
  136621. * Linear about to convert he result to black and white (default: 1)
  136622. */
  136623. degree: number;
  136624. /**
  136625. * Creates a black and white post process
  136626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136627. * @param name The name of the effect.
  136628. * @param options The required width/height ratio to downsize to before computing the render pass.
  136629. * @param camera The camera to apply the render pass to.
  136630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136631. * @param engine The engine which the post process will be applied. (default: current engine)
  136632. * @param reusable If the post process can be reused on the same frame. (default: false)
  136633. */
  136634. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136635. }
  136636. }
  136637. declare module BABYLON {
  136638. /**
  136639. * This represents a set of one or more post processes in Babylon.
  136640. * A post process can be used to apply a shader to a texture after it is rendered.
  136641. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  136642. */
  136643. export class PostProcessRenderEffect {
  136644. private _postProcesses;
  136645. private _getPostProcesses;
  136646. private _singleInstance;
  136647. private _cameras;
  136648. private _indicesForCamera;
  136649. /**
  136650. * Name of the effect
  136651. * @hidden
  136652. */
  136653. _name: string;
  136654. /**
  136655. * Instantiates a post process render effect.
  136656. * A post process can be used to apply a shader to a texture after it is rendered.
  136657. * @param engine The engine the effect is tied to
  136658. * @param name The name of the effect
  136659. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  136660. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  136661. */
  136662. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  136663. /**
  136664. * Checks if all the post processes in the effect are supported.
  136665. */
  136666. get isSupported(): boolean;
  136667. /**
  136668. * Updates the current state of the effect
  136669. * @hidden
  136670. */
  136671. _update(): void;
  136672. /**
  136673. * Attaches the effect on cameras
  136674. * @param cameras The camera to attach to.
  136675. * @hidden
  136676. */
  136677. _attachCameras(cameras: Camera): void;
  136678. /**
  136679. * Attaches the effect on cameras
  136680. * @param cameras The camera to attach to.
  136681. * @hidden
  136682. */
  136683. _attachCameras(cameras: Camera[]): void;
  136684. /**
  136685. * Detaches the effect on cameras
  136686. * @param cameras The camera to detatch from.
  136687. * @hidden
  136688. */
  136689. _detachCameras(cameras: Camera): void;
  136690. /**
  136691. * Detatches the effect on cameras
  136692. * @param cameras The camera to detatch from.
  136693. * @hidden
  136694. */
  136695. _detachCameras(cameras: Camera[]): void;
  136696. /**
  136697. * Enables the effect on given cameras
  136698. * @param cameras The camera to enable.
  136699. * @hidden
  136700. */
  136701. _enable(cameras: Camera): void;
  136702. /**
  136703. * Enables the effect on given cameras
  136704. * @param cameras The camera to enable.
  136705. * @hidden
  136706. */
  136707. _enable(cameras: Nullable<Camera[]>): void;
  136708. /**
  136709. * Disables the effect on the given cameras
  136710. * @param cameras The camera to disable.
  136711. * @hidden
  136712. */
  136713. _disable(cameras: Camera): void;
  136714. /**
  136715. * Disables the effect on the given cameras
  136716. * @param cameras The camera to disable.
  136717. * @hidden
  136718. */
  136719. _disable(cameras: Nullable<Camera[]>): void;
  136720. /**
  136721. * Gets a list of the post processes contained in the effect.
  136722. * @param camera The camera to get the post processes on.
  136723. * @returns The list of the post processes in the effect.
  136724. */
  136725. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  136726. }
  136727. }
  136728. declare module BABYLON {
  136729. /** @hidden */
  136730. export var extractHighlightsPixelShader: {
  136731. name: string;
  136732. shader: string;
  136733. };
  136734. }
  136735. declare module BABYLON {
  136736. /**
  136737. * 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.
  136738. */
  136739. export class ExtractHighlightsPostProcess extends PostProcess {
  136740. /**
  136741. * The luminance threshold, pixels below this value will be set to black.
  136742. */
  136743. threshold: number;
  136744. /** @hidden */
  136745. _exposure: number;
  136746. /**
  136747. * Post process which has the input texture to be used when performing highlight extraction
  136748. * @hidden
  136749. */
  136750. _inputPostProcess: Nullable<PostProcess>;
  136751. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136752. }
  136753. }
  136754. declare module BABYLON {
  136755. /** @hidden */
  136756. export var bloomMergePixelShader: {
  136757. name: string;
  136758. shader: string;
  136759. };
  136760. }
  136761. declare module BABYLON {
  136762. /**
  136763. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136764. */
  136765. export class BloomMergePostProcess extends PostProcess {
  136766. /** Weight of the bloom to be added to the original input. */
  136767. weight: number;
  136768. /**
  136769. * Creates a new instance of @see BloomMergePostProcess
  136770. * @param name The name of the effect.
  136771. * @param originalFromInput Post process which's input will be used for the merge.
  136772. * @param blurred Blurred highlights post process which's output will be used.
  136773. * @param weight Weight of the bloom to be added to the original input.
  136774. * @param options The required width/height ratio to downsize to before computing the render pass.
  136775. * @param camera The camera to apply the render pass to.
  136776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136777. * @param engine The engine which the post process will be applied. (default: current engine)
  136778. * @param reusable If the post process can be reused on the same frame. (default: false)
  136779. * @param textureType Type of textures used when performing the post process. (default: 0)
  136780. * @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)
  136781. */
  136782. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  136783. /** Weight of the bloom to be added to the original input. */
  136784. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136785. }
  136786. }
  136787. declare module BABYLON {
  136788. /**
  136789. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  136790. */
  136791. export class BloomEffect extends PostProcessRenderEffect {
  136792. private bloomScale;
  136793. /**
  136794. * @hidden Internal
  136795. */
  136796. _effects: Array<PostProcess>;
  136797. /**
  136798. * @hidden Internal
  136799. */
  136800. _downscale: ExtractHighlightsPostProcess;
  136801. private _blurX;
  136802. private _blurY;
  136803. private _merge;
  136804. /**
  136805. * The luminance threshold to find bright areas of the image to bloom.
  136806. */
  136807. get threshold(): number;
  136808. set threshold(value: number);
  136809. /**
  136810. * The strength of the bloom.
  136811. */
  136812. get weight(): number;
  136813. set weight(value: number);
  136814. /**
  136815. * Specifies the size of the bloom blur kernel, relative to the final output size
  136816. */
  136817. get kernel(): number;
  136818. set kernel(value: number);
  136819. /**
  136820. * Creates a new instance of @see BloomEffect
  136821. * @param scene The scene the effect belongs to.
  136822. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  136823. * @param bloomKernel The size of the kernel to be used when applying the blur.
  136824. * @param bloomWeight The the strength of bloom.
  136825. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136826. * @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)
  136827. */
  136828. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  136829. /**
  136830. * Disposes each of the internal effects for a given camera.
  136831. * @param camera The camera to dispose the effect on.
  136832. */
  136833. disposeEffects(camera: Camera): void;
  136834. /**
  136835. * @hidden Internal
  136836. */
  136837. _updateEffects(): void;
  136838. /**
  136839. * Internal
  136840. * @returns if all the contained post processes are ready.
  136841. * @hidden
  136842. */
  136843. _isReady(): boolean;
  136844. }
  136845. }
  136846. declare module BABYLON {
  136847. /** @hidden */
  136848. export var chromaticAberrationPixelShader: {
  136849. name: string;
  136850. shader: string;
  136851. };
  136852. }
  136853. declare module BABYLON {
  136854. /**
  136855. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  136856. */
  136857. export class ChromaticAberrationPostProcess extends PostProcess {
  136858. /**
  136859. * The amount of seperation of rgb channels (default: 30)
  136860. */
  136861. aberrationAmount: number;
  136862. /**
  136863. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  136864. */
  136865. radialIntensity: number;
  136866. /**
  136867. * 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))
  136868. */
  136869. direction: Vector2;
  136870. /**
  136871. * 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))
  136872. */
  136873. centerPosition: Vector2;
  136874. /**
  136875. * Creates a new instance ChromaticAberrationPostProcess
  136876. * @param name The name of the effect.
  136877. * @param screenWidth The width of the screen to apply the effect on.
  136878. * @param screenHeight The height of the screen to apply the effect on.
  136879. * @param options The required width/height ratio to downsize to before computing the render pass.
  136880. * @param camera The camera to apply the render pass to.
  136881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136882. * @param engine The engine which the post process will be applied. (default: current engine)
  136883. * @param reusable If the post process can be reused on the same frame. (default: false)
  136884. * @param textureType Type of textures used when performing the post process. (default: 0)
  136885. * @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)
  136886. */
  136887. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136888. }
  136889. }
  136890. declare module BABYLON {
  136891. /** @hidden */
  136892. export var circleOfConfusionPixelShader: {
  136893. name: string;
  136894. shader: string;
  136895. };
  136896. }
  136897. declare module BABYLON {
  136898. /**
  136899. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  136900. */
  136901. export class CircleOfConfusionPostProcess extends PostProcess {
  136902. /**
  136903. * 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.
  136904. */
  136905. lensSize: number;
  136906. /**
  136907. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136908. */
  136909. fStop: number;
  136910. /**
  136911. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136912. */
  136913. focusDistance: number;
  136914. /**
  136915. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  136916. */
  136917. focalLength: number;
  136918. private _depthTexture;
  136919. /**
  136920. * Creates a new instance CircleOfConfusionPostProcess
  136921. * @param name The name of the effect.
  136922. * @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.
  136923. * @param options The required width/height ratio to downsize to before computing the render pass.
  136924. * @param camera The camera to apply the render pass to.
  136925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136926. * @param engine The engine which the post process will be applied. (default: current engine)
  136927. * @param reusable If the post process can be reused on the same frame. (default: false)
  136928. * @param textureType Type of textures used when performing the post process. (default: 0)
  136929. * @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)
  136930. */
  136931. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136932. /**
  136933. * 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.
  136934. */
  136935. set depthTexture(value: RenderTargetTexture);
  136936. }
  136937. }
  136938. declare module BABYLON {
  136939. /** @hidden */
  136940. export var colorCorrectionPixelShader: {
  136941. name: string;
  136942. shader: string;
  136943. };
  136944. }
  136945. declare module BABYLON {
  136946. /**
  136947. *
  136948. * This post-process allows the modification of rendered colors by using
  136949. * a 'look-up table' (LUT). This effect is also called Color Grading.
  136950. *
  136951. * The object needs to be provided an url to a texture containing the color
  136952. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  136953. * Use an image editing software to tweak the LUT to match your needs.
  136954. *
  136955. * For an example of a color LUT, see here:
  136956. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  136957. * For explanations on color grading, see here:
  136958. * @see http://udn.epicgames.com/Three/ColorGrading.html
  136959. *
  136960. */
  136961. export class ColorCorrectionPostProcess extends PostProcess {
  136962. private _colorTableTexture;
  136963. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136964. }
  136965. }
  136966. declare module BABYLON {
  136967. /** @hidden */
  136968. export var convolutionPixelShader: {
  136969. name: string;
  136970. shader: string;
  136971. };
  136972. }
  136973. declare module BABYLON {
  136974. /**
  136975. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  136976. * input texture to perform effects such as edge detection or sharpening
  136977. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  136978. */
  136979. export class ConvolutionPostProcess extends PostProcess {
  136980. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136981. kernel: number[];
  136982. /**
  136983. * Creates a new instance ConvolutionPostProcess
  136984. * @param name The name of the effect.
  136985. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  136986. * @param options The required width/height ratio to downsize to before computing the render pass.
  136987. * @param camera The camera to apply the render pass to.
  136988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136989. * @param engine The engine which the post process will be applied. (default: current engine)
  136990. * @param reusable If the post process can be reused on the same frame. (default: false)
  136991. * @param textureType Type of textures used when performing the post process. (default: 0)
  136992. */
  136993. constructor(name: string,
  136994. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136995. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136996. /**
  136997. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136998. */
  136999. static EdgeDetect0Kernel: number[];
  137000. /**
  137001. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137002. */
  137003. static EdgeDetect1Kernel: number[];
  137004. /**
  137005. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137006. */
  137007. static EdgeDetect2Kernel: number[];
  137008. /**
  137009. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137010. */
  137011. static SharpenKernel: number[];
  137012. /**
  137013. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137014. */
  137015. static EmbossKernel: number[];
  137016. /**
  137017. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137018. */
  137019. static GaussianKernel: number[];
  137020. }
  137021. }
  137022. declare module BABYLON {
  137023. /**
  137024. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137025. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137026. * based on samples that have a large difference in distance than the center pixel.
  137027. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137028. */
  137029. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137030. direction: Vector2;
  137031. /**
  137032. * Creates a new instance CircleOfConfusionPostProcess
  137033. * @param name The name of the effect.
  137034. * @param scene The scene the effect belongs to.
  137035. * @param direction The direction the blur should be applied.
  137036. * @param kernel The size of the kernel used to blur.
  137037. * @param options The required width/height ratio to downsize to before computing the render pass.
  137038. * @param camera The camera to apply the render pass to.
  137039. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137040. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137042. * @param engine The engine which the post process will be applied. (default: current engine)
  137043. * @param reusable If the post process can be reused on the same frame. (default: false)
  137044. * @param textureType Type of textures used when performing the post process. (default: 0)
  137045. * @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)
  137046. */
  137047. 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);
  137048. }
  137049. }
  137050. declare module BABYLON {
  137051. /** @hidden */
  137052. export var depthOfFieldMergePixelShader: {
  137053. name: string;
  137054. shader: string;
  137055. };
  137056. }
  137057. declare module BABYLON {
  137058. /**
  137059. * Options to be set when merging outputs from the default pipeline.
  137060. */
  137061. export class DepthOfFieldMergePostProcessOptions {
  137062. /**
  137063. * The original image to merge on top of
  137064. */
  137065. originalFromInput: PostProcess;
  137066. /**
  137067. * Parameters to perform the merge of the depth of field effect
  137068. */
  137069. depthOfField?: {
  137070. circleOfConfusion: PostProcess;
  137071. blurSteps: Array<PostProcess>;
  137072. };
  137073. /**
  137074. * Parameters to perform the merge of bloom effect
  137075. */
  137076. bloom?: {
  137077. blurred: PostProcess;
  137078. weight: number;
  137079. };
  137080. }
  137081. /**
  137082. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137083. */
  137084. export class DepthOfFieldMergePostProcess extends PostProcess {
  137085. private blurSteps;
  137086. /**
  137087. * Creates a new instance of DepthOfFieldMergePostProcess
  137088. * @param name The name of the effect.
  137089. * @param originalFromInput Post process which's input will be used for the merge.
  137090. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137091. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137092. * @param options The required width/height ratio to downsize to before computing the render pass.
  137093. * @param camera The camera to apply the render pass to.
  137094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137095. * @param engine The engine which the post process will be applied. (default: current engine)
  137096. * @param reusable If the post process can be reused on the same frame. (default: false)
  137097. * @param textureType Type of textures used when performing the post process. (default: 0)
  137098. * @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)
  137099. */
  137100. 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);
  137101. /**
  137102. * Updates the effect with the current post process compile time values and recompiles the shader.
  137103. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137104. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137105. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137106. * @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
  137107. * @param onCompiled Called when the shader has been compiled.
  137108. * @param onError Called if there is an error when compiling a shader.
  137109. */
  137110. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137111. }
  137112. }
  137113. declare module BABYLON {
  137114. /**
  137115. * Specifies the level of max blur that should be applied when using the depth of field effect
  137116. */
  137117. export enum DepthOfFieldEffectBlurLevel {
  137118. /**
  137119. * Subtle blur
  137120. */
  137121. Low = 0,
  137122. /**
  137123. * Medium blur
  137124. */
  137125. Medium = 1,
  137126. /**
  137127. * Large blur
  137128. */
  137129. High = 2
  137130. }
  137131. /**
  137132. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137133. */
  137134. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137135. private _circleOfConfusion;
  137136. /**
  137137. * @hidden Internal, blurs from high to low
  137138. */
  137139. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137140. private _depthOfFieldBlurY;
  137141. private _dofMerge;
  137142. /**
  137143. * @hidden Internal post processes in depth of field effect
  137144. */
  137145. _effects: Array<PostProcess>;
  137146. /**
  137147. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137148. */
  137149. set focalLength(value: number);
  137150. get focalLength(): number;
  137151. /**
  137152. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137153. */
  137154. set fStop(value: number);
  137155. get fStop(): number;
  137156. /**
  137157. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137158. */
  137159. set focusDistance(value: number);
  137160. get focusDistance(): number;
  137161. /**
  137162. * 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.
  137163. */
  137164. set lensSize(value: number);
  137165. get lensSize(): number;
  137166. /**
  137167. * Creates a new instance DepthOfFieldEffect
  137168. * @param scene The scene the effect belongs to.
  137169. * @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.
  137170. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137171. * @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)
  137172. */
  137173. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137174. /**
  137175. * Get the current class name of the current effet
  137176. * @returns "DepthOfFieldEffect"
  137177. */
  137178. getClassName(): string;
  137179. /**
  137180. * 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.
  137181. */
  137182. set depthTexture(value: RenderTargetTexture);
  137183. /**
  137184. * Disposes each of the internal effects for a given camera.
  137185. * @param camera The camera to dispose the effect on.
  137186. */
  137187. disposeEffects(camera: Camera): void;
  137188. /**
  137189. * @hidden Internal
  137190. */
  137191. _updateEffects(): void;
  137192. /**
  137193. * Internal
  137194. * @returns if all the contained post processes are ready.
  137195. * @hidden
  137196. */
  137197. _isReady(): boolean;
  137198. }
  137199. }
  137200. declare module BABYLON {
  137201. /** @hidden */
  137202. export var displayPassPixelShader: {
  137203. name: string;
  137204. shader: string;
  137205. };
  137206. }
  137207. declare module BABYLON {
  137208. /**
  137209. * DisplayPassPostProcess which produces an output the same as it's input
  137210. */
  137211. export class DisplayPassPostProcess extends PostProcess {
  137212. /**
  137213. * Creates the DisplayPassPostProcess
  137214. * @param name The name of the effect.
  137215. * @param options The required width/height ratio to downsize to before computing the render pass.
  137216. * @param camera The camera to apply the render pass to.
  137217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137218. * @param engine The engine which the post process will be applied. (default: current engine)
  137219. * @param reusable If the post process can be reused on the same frame. (default: false)
  137220. */
  137221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137222. }
  137223. }
  137224. declare module BABYLON {
  137225. /** @hidden */
  137226. export var filterPixelShader: {
  137227. name: string;
  137228. shader: string;
  137229. };
  137230. }
  137231. declare module BABYLON {
  137232. /**
  137233. * Applies a kernel filter to the image
  137234. */
  137235. export class FilterPostProcess extends PostProcess {
  137236. /** The matrix to be applied to the image */
  137237. kernelMatrix: Matrix;
  137238. /**
  137239. *
  137240. * @param name The name of the effect.
  137241. * @param kernelMatrix The matrix to be applied to the image
  137242. * @param options The required width/height ratio to downsize to before computing the render pass.
  137243. * @param camera The camera to apply the render pass to.
  137244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137245. * @param engine The engine which the post process will be applied. (default: current engine)
  137246. * @param reusable If the post process can be reused on the same frame. (default: false)
  137247. */
  137248. constructor(name: string,
  137249. /** The matrix to be applied to the image */
  137250. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137251. }
  137252. }
  137253. declare module BABYLON {
  137254. /** @hidden */
  137255. export var fxaaPixelShader: {
  137256. name: string;
  137257. shader: string;
  137258. };
  137259. }
  137260. declare module BABYLON {
  137261. /** @hidden */
  137262. export var fxaaVertexShader: {
  137263. name: string;
  137264. shader: string;
  137265. };
  137266. }
  137267. declare module BABYLON {
  137268. /**
  137269. * Fxaa post process
  137270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137271. */
  137272. export class FxaaPostProcess extends PostProcess {
  137273. /** @hidden */
  137274. texelWidth: number;
  137275. /** @hidden */
  137276. texelHeight: number;
  137277. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137278. private _getDefines;
  137279. }
  137280. }
  137281. declare module BABYLON {
  137282. /** @hidden */
  137283. export var grainPixelShader: {
  137284. name: string;
  137285. shader: string;
  137286. };
  137287. }
  137288. declare module BABYLON {
  137289. /**
  137290. * The GrainPostProcess adds noise to the image at mid luminance levels
  137291. */
  137292. export class GrainPostProcess extends PostProcess {
  137293. /**
  137294. * The intensity of the grain added (default: 30)
  137295. */
  137296. intensity: number;
  137297. /**
  137298. * If the grain should be randomized on every frame
  137299. */
  137300. animated: boolean;
  137301. /**
  137302. * Creates a new instance of @see GrainPostProcess
  137303. * @param name The name of the effect.
  137304. * @param options The required width/height ratio to downsize to before computing the render pass.
  137305. * @param camera The camera to apply the render pass to.
  137306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137307. * @param engine The engine which the post process will be applied. (default: current engine)
  137308. * @param reusable If the post process can be reused on the same frame. (default: false)
  137309. * @param textureType Type of textures used when performing the post process. (default: 0)
  137310. * @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)
  137311. */
  137312. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137313. }
  137314. }
  137315. declare module BABYLON {
  137316. /** @hidden */
  137317. export var highlightsPixelShader: {
  137318. name: string;
  137319. shader: string;
  137320. };
  137321. }
  137322. declare module BABYLON {
  137323. /**
  137324. * Extracts highlights from the image
  137325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137326. */
  137327. export class HighlightsPostProcess extends PostProcess {
  137328. /**
  137329. * Extracts highlights from the image
  137330. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137331. * @param name The name of the effect.
  137332. * @param options The required width/height ratio to downsize to before computing the render pass.
  137333. * @param camera The camera to apply the render pass to.
  137334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137335. * @param engine The engine which the post process will be applied. (default: current engine)
  137336. * @param reusable If the post process can be reused on the same frame. (default: false)
  137337. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137338. */
  137339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137340. }
  137341. }
  137342. declare module BABYLON {
  137343. /** @hidden */
  137344. export var mrtFragmentDeclaration: {
  137345. name: string;
  137346. shader: string;
  137347. };
  137348. }
  137349. declare module BABYLON {
  137350. /** @hidden */
  137351. export var geometryPixelShader: {
  137352. name: string;
  137353. shader: string;
  137354. };
  137355. }
  137356. declare module BABYLON {
  137357. /** @hidden */
  137358. export var geometryVertexShader: {
  137359. name: string;
  137360. shader: string;
  137361. };
  137362. }
  137363. declare module BABYLON {
  137364. /** @hidden */
  137365. interface ISavedTransformationMatrix {
  137366. world: Matrix;
  137367. viewProjection: Matrix;
  137368. }
  137369. /**
  137370. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137371. */
  137372. export class GeometryBufferRenderer {
  137373. /**
  137374. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137375. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137376. */
  137377. static readonly POSITION_TEXTURE_TYPE: number;
  137378. /**
  137379. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137380. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137381. */
  137382. static readonly VELOCITY_TEXTURE_TYPE: number;
  137383. /**
  137384. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137385. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137386. */
  137387. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137388. /**
  137389. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137390. * in order to compute objects velocities when enableVelocity is set to "true"
  137391. * @hidden
  137392. */
  137393. _previousTransformationMatrices: {
  137394. [index: number]: ISavedTransformationMatrix;
  137395. };
  137396. /**
  137397. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137398. * in order to compute objects velocities when enableVelocity is set to "true"
  137399. * @hidden
  137400. */
  137401. _previousBonesTransformationMatrices: {
  137402. [index: number]: Float32Array;
  137403. };
  137404. /**
  137405. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137406. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137407. */
  137408. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137409. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137410. renderTransparentMeshes: boolean;
  137411. private _scene;
  137412. private _multiRenderTarget;
  137413. private _ratio;
  137414. private _enablePosition;
  137415. private _enableVelocity;
  137416. private _enableReflectivity;
  137417. private _positionIndex;
  137418. private _velocityIndex;
  137419. private _reflectivityIndex;
  137420. protected _effect: Effect;
  137421. protected _cachedDefines: string;
  137422. /**
  137423. * Set the render list (meshes to be rendered) used in the G buffer.
  137424. */
  137425. set renderList(meshes: Mesh[]);
  137426. /**
  137427. * Gets wether or not G buffer are supported by the running hardware.
  137428. * This requires draw buffer supports
  137429. */
  137430. get isSupported(): boolean;
  137431. /**
  137432. * Returns the index of the given texture type in the G-Buffer textures array
  137433. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137434. * @returns the index of the given texture type in the G-Buffer textures array
  137435. */
  137436. getTextureIndex(textureType: number): number;
  137437. /**
  137438. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137439. */
  137440. get enablePosition(): boolean;
  137441. /**
  137442. * Sets whether or not objects positions are enabled for the G buffer.
  137443. */
  137444. set enablePosition(enable: boolean);
  137445. /**
  137446. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137447. */
  137448. get enableVelocity(): boolean;
  137449. /**
  137450. * Sets wether or not objects velocities are enabled for the G buffer.
  137451. */
  137452. set enableVelocity(enable: boolean);
  137453. /**
  137454. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137455. */
  137456. get enableReflectivity(): boolean;
  137457. /**
  137458. * Sets wether or not objects roughness are enabled for the G buffer.
  137459. */
  137460. set enableReflectivity(enable: boolean);
  137461. /**
  137462. * Gets the scene associated with the buffer.
  137463. */
  137464. get scene(): Scene;
  137465. /**
  137466. * Gets the ratio used by the buffer during its creation.
  137467. * How big is the buffer related to the main canvas.
  137468. */
  137469. get ratio(): number;
  137470. /** @hidden */
  137471. static _SceneComponentInitialization: (scene: Scene) => void;
  137472. /**
  137473. * Creates a new G Buffer for the scene
  137474. * @param scene The scene the buffer belongs to
  137475. * @param ratio How big is the buffer related to the main canvas.
  137476. */
  137477. constructor(scene: Scene, ratio?: number);
  137478. /**
  137479. * Checks wether everything is ready to render a submesh to the G buffer.
  137480. * @param subMesh the submesh to check readiness for
  137481. * @param useInstances is the mesh drawn using instance or not
  137482. * @returns true if ready otherwise false
  137483. */
  137484. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137485. /**
  137486. * Gets the current underlying G Buffer.
  137487. * @returns the buffer
  137488. */
  137489. getGBuffer(): MultiRenderTarget;
  137490. /**
  137491. * Gets the number of samples used to render the buffer (anti aliasing).
  137492. */
  137493. get samples(): number;
  137494. /**
  137495. * Sets the number of samples used to render the buffer (anti aliasing).
  137496. */
  137497. set samples(value: number);
  137498. /**
  137499. * Disposes the renderer and frees up associated resources.
  137500. */
  137501. dispose(): void;
  137502. protected _createRenderTargets(): void;
  137503. private _copyBonesTransformationMatrices;
  137504. }
  137505. }
  137506. declare module BABYLON {
  137507. interface Scene {
  137508. /** @hidden (Backing field) */
  137509. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137510. /**
  137511. * Gets or Sets the current geometry buffer associated to the scene.
  137512. */
  137513. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137514. /**
  137515. * Enables a GeometryBufferRender and associates it with the scene
  137516. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137517. * @returns the GeometryBufferRenderer
  137518. */
  137519. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137520. /**
  137521. * Disables the GeometryBufferRender associated with the scene
  137522. */
  137523. disableGeometryBufferRenderer(): void;
  137524. }
  137525. /**
  137526. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137527. * in several rendering techniques.
  137528. */
  137529. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137530. /**
  137531. * The component name helpful to identify the component in the list of scene components.
  137532. */
  137533. readonly name: string;
  137534. /**
  137535. * The scene the component belongs to.
  137536. */
  137537. scene: Scene;
  137538. /**
  137539. * Creates a new instance of the component for the given scene
  137540. * @param scene Defines the scene to register the component in
  137541. */
  137542. constructor(scene: Scene);
  137543. /**
  137544. * Registers the component in a given scene
  137545. */
  137546. register(): void;
  137547. /**
  137548. * Rebuilds the elements related to this component in case of
  137549. * context lost for instance.
  137550. */
  137551. rebuild(): void;
  137552. /**
  137553. * Disposes the component and the associated ressources
  137554. */
  137555. dispose(): void;
  137556. private _gatherRenderTargets;
  137557. }
  137558. }
  137559. declare module BABYLON {
  137560. /** @hidden */
  137561. export var motionBlurPixelShader: {
  137562. name: string;
  137563. shader: string;
  137564. };
  137565. }
  137566. declare module BABYLON {
  137567. /**
  137568. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137569. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137570. * As an example, all you have to do is to create the post-process:
  137571. * var mb = new BABYLON.MotionBlurPostProcess(
  137572. * 'mb', // The name of the effect.
  137573. * scene, // The scene containing the objects to blur according to their velocity.
  137574. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137575. * camera // The camera to apply the render pass to.
  137576. * );
  137577. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137578. */
  137579. export class MotionBlurPostProcess extends PostProcess {
  137580. /**
  137581. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137582. */
  137583. motionStrength: number;
  137584. /**
  137585. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137586. */
  137587. get motionBlurSamples(): number;
  137588. /**
  137589. * Sets the number of iterations to be used for motion blur quality
  137590. */
  137591. set motionBlurSamples(samples: number);
  137592. private _motionBlurSamples;
  137593. private _geometryBufferRenderer;
  137594. /**
  137595. * Creates a new instance MotionBlurPostProcess
  137596. * @param name The name of the effect.
  137597. * @param scene The scene containing the objects to blur according to their velocity.
  137598. * @param options The required width/height ratio to downsize to before computing the render pass.
  137599. * @param camera The camera to apply the render pass to.
  137600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137601. * @param engine The engine which the post process will be applied. (default: current engine)
  137602. * @param reusable If the post process can be reused on the same frame. (default: false)
  137603. * @param textureType Type of textures used when performing the post process. (default: 0)
  137604. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  137605. */
  137606. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137607. /**
  137608. * Excludes the given skinned mesh from computing bones velocities.
  137609. * 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.
  137610. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137611. */
  137612. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137613. /**
  137614. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137615. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137616. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137617. */
  137618. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137619. /**
  137620. * Disposes the post process.
  137621. * @param camera The camera to dispose the post process on.
  137622. */
  137623. dispose(camera?: Camera): void;
  137624. }
  137625. }
  137626. declare module BABYLON {
  137627. /** @hidden */
  137628. export var refractionPixelShader: {
  137629. name: string;
  137630. shader: string;
  137631. };
  137632. }
  137633. declare module BABYLON {
  137634. /**
  137635. * Post process which applies a refractin texture
  137636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137637. */
  137638. export class RefractionPostProcess extends PostProcess {
  137639. /** the base color of the refraction (used to taint the rendering) */
  137640. color: Color3;
  137641. /** simulated refraction depth */
  137642. depth: number;
  137643. /** the coefficient of the base color (0 to remove base color tainting) */
  137644. colorLevel: number;
  137645. private _refTexture;
  137646. private _ownRefractionTexture;
  137647. /**
  137648. * Gets or sets the refraction texture
  137649. * Please note that you are responsible for disposing the texture if you set it manually
  137650. */
  137651. get refractionTexture(): Texture;
  137652. set refractionTexture(value: Texture);
  137653. /**
  137654. * Initializes the RefractionPostProcess
  137655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137656. * @param name The name of the effect.
  137657. * @param refractionTextureUrl Url of the refraction texture to use
  137658. * @param color the base color of the refraction (used to taint the rendering)
  137659. * @param depth simulated refraction depth
  137660. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  137661. * @param camera The camera to apply the render pass to.
  137662. * @param options The required width/height ratio to downsize to before computing the render pass.
  137663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137664. * @param engine The engine which the post process will be applied. (default: current engine)
  137665. * @param reusable If the post process can be reused on the same frame. (default: false)
  137666. */
  137667. constructor(name: string, refractionTextureUrl: string,
  137668. /** the base color of the refraction (used to taint the rendering) */
  137669. color: Color3,
  137670. /** simulated refraction depth */
  137671. depth: number,
  137672. /** the coefficient of the base color (0 to remove base color tainting) */
  137673. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137674. /**
  137675. * Disposes of the post process
  137676. * @param camera Camera to dispose post process on
  137677. */
  137678. dispose(camera: Camera): void;
  137679. }
  137680. }
  137681. declare module BABYLON {
  137682. /** @hidden */
  137683. export var sharpenPixelShader: {
  137684. name: string;
  137685. shader: string;
  137686. };
  137687. }
  137688. declare module BABYLON {
  137689. /**
  137690. * The SharpenPostProcess applies a sharpen kernel to every pixel
  137691. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137692. */
  137693. export class SharpenPostProcess extends PostProcess {
  137694. /**
  137695. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  137696. */
  137697. colorAmount: number;
  137698. /**
  137699. * How much sharpness should be applied (default: 0.3)
  137700. */
  137701. edgeAmount: number;
  137702. /**
  137703. * Creates a new instance ConvolutionPostProcess
  137704. * @param name The name of the effect.
  137705. * @param options The required width/height ratio to downsize to before computing the render pass.
  137706. * @param camera The camera to apply the render pass to.
  137707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137708. * @param engine The engine which the post process will be applied. (default: current engine)
  137709. * @param reusable If the post process can be reused on the same frame. (default: false)
  137710. * @param textureType Type of textures used when performing the post process. (default: 0)
  137711. * @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)
  137712. */
  137713. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137714. }
  137715. }
  137716. declare module BABYLON {
  137717. /**
  137718. * PostProcessRenderPipeline
  137719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137720. */
  137721. export class PostProcessRenderPipeline {
  137722. private engine;
  137723. private _renderEffects;
  137724. private _renderEffectsForIsolatedPass;
  137725. /**
  137726. * List of inspectable custom properties (used by the Inspector)
  137727. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  137728. */
  137729. inspectableCustomProperties: IInspectable[];
  137730. /**
  137731. * @hidden
  137732. */
  137733. protected _cameras: Camera[];
  137734. /** @hidden */
  137735. _name: string;
  137736. /**
  137737. * Gets pipeline name
  137738. */
  137739. get name(): string;
  137740. /** Gets the list of attached cameras */
  137741. get cameras(): Camera[];
  137742. /**
  137743. * Initializes a PostProcessRenderPipeline
  137744. * @param engine engine to add the pipeline to
  137745. * @param name name of the pipeline
  137746. */
  137747. constructor(engine: Engine, name: string);
  137748. /**
  137749. * Gets the class name
  137750. * @returns "PostProcessRenderPipeline"
  137751. */
  137752. getClassName(): string;
  137753. /**
  137754. * If all the render effects in the pipeline are supported
  137755. */
  137756. get isSupported(): boolean;
  137757. /**
  137758. * Adds an effect to the pipeline
  137759. * @param renderEffect the effect to add
  137760. */
  137761. addEffect(renderEffect: PostProcessRenderEffect): void;
  137762. /** @hidden */
  137763. _rebuild(): void;
  137764. /** @hidden */
  137765. _enableEffect(renderEffectName: string, cameras: Camera): void;
  137766. /** @hidden */
  137767. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  137768. /** @hidden */
  137769. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137770. /** @hidden */
  137771. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137772. /** @hidden */
  137773. _attachCameras(cameras: Camera, unique: boolean): void;
  137774. /** @hidden */
  137775. _attachCameras(cameras: Camera[], unique: boolean): void;
  137776. /** @hidden */
  137777. _detachCameras(cameras: Camera): void;
  137778. /** @hidden */
  137779. _detachCameras(cameras: Nullable<Camera[]>): void;
  137780. /** @hidden */
  137781. _update(): void;
  137782. /** @hidden */
  137783. _reset(): void;
  137784. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  137785. /**
  137786. * Disposes of the pipeline
  137787. */
  137788. dispose(): void;
  137789. }
  137790. }
  137791. declare module BABYLON {
  137792. /**
  137793. * PostProcessRenderPipelineManager class
  137794. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137795. */
  137796. export class PostProcessRenderPipelineManager {
  137797. private _renderPipelines;
  137798. /**
  137799. * Initializes a PostProcessRenderPipelineManager
  137800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137801. */
  137802. constructor();
  137803. /**
  137804. * Gets the list of supported render pipelines
  137805. */
  137806. get supportedPipelines(): PostProcessRenderPipeline[];
  137807. /**
  137808. * Adds a pipeline to the manager
  137809. * @param renderPipeline The pipeline to add
  137810. */
  137811. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  137812. /**
  137813. * Attaches a camera to the pipeline
  137814. * @param renderPipelineName The name of the pipeline to attach to
  137815. * @param cameras the camera to attach
  137816. * @param unique if the camera can be attached multiple times to the pipeline
  137817. */
  137818. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  137819. /**
  137820. * Detaches a camera from the pipeline
  137821. * @param renderPipelineName The name of the pipeline to detach from
  137822. * @param cameras the camera to detach
  137823. */
  137824. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  137825. /**
  137826. * Enables an effect by name on a pipeline
  137827. * @param renderPipelineName the name of the pipeline to enable the effect in
  137828. * @param renderEffectName the name of the effect to enable
  137829. * @param cameras the cameras that the effect should be enabled on
  137830. */
  137831. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137832. /**
  137833. * Disables an effect by name on a pipeline
  137834. * @param renderPipelineName the name of the pipeline to disable the effect in
  137835. * @param renderEffectName the name of the effect to disable
  137836. * @param cameras the cameras that the effect should be disabled on
  137837. */
  137838. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137839. /**
  137840. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  137841. */
  137842. update(): void;
  137843. /** @hidden */
  137844. _rebuild(): void;
  137845. /**
  137846. * Disposes of the manager and pipelines
  137847. */
  137848. dispose(): void;
  137849. }
  137850. }
  137851. declare module BABYLON {
  137852. interface Scene {
  137853. /** @hidden (Backing field) */
  137854. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137855. /**
  137856. * Gets the postprocess render pipeline manager
  137857. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137858. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137859. */
  137860. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137861. }
  137862. /**
  137863. * Defines the Render Pipeline scene component responsible to rendering pipelines
  137864. */
  137865. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  137866. /**
  137867. * The component name helpfull to identify the component in the list of scene components.
  137868. */
  137869. readonly name: string;
  137870. /**
  137871. * The scene the component belongs to.
  137872. */
  137873. scene: Scene;
  137874. /**
  137875. * Creates a new instance of the component for the given scene
  137876. * @param scene Defines the scene to register the component in
  137877. */
  137878. constructor(scene: Scene);
  137879. /**
  137880. * Registers the component in a given scene
  137881. */
  137882. register(): void;
  137883. /**
  137884. * Rebuilds the elements related to this component in case of
  137885. * context lost for instance.
  137886. */
  137887. rebuild(): void;
  137888. /**
  137889. * Disposes the component and the associated ressources
  137890. */
  137891. dispose(): void;
  137892. private _gatherRenderTargets;
  137893. }
  137894. }
  137895. declare module BABYLON {
  137896. /**
  137897. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  137898. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137899. */
  137900. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  137901. private _scene;
  137902. private _camerasToBeAttached;
  137903. /**
  137904. * ID of the sharpen post process,
  137905. */
  137906. private readonly SharpenPostProcessId;
  137907. /**
  137908. * @ignore
  137909. * ID of the image processing post process;
  137910. */
  137911. readonly ImageProcessingPostProcessId: string;
  137912. /**
  137913. * @ignore
  137914. * ID of the Fast Approximate Anti-Aliasing post process;
  137915. */
  137916. readonly FxaaPostProcessId: string;
  137917. /**
  137918. * ID of the chromatic aberration post process,
  137919. */
  137920. private readonly ChromaticAberrationPostProcessId;
  137921. /**
  137922. * ID of the grain post process
  137923. */
  137924. private readonly GrainPostProcessId;
  137925. /**
  137926. * Sharpen post process which will apply a sharpen convolution to enhance edges
  137927. */
  137928. sharpen: SharpenPostProcess;
  137929. private _sharpenEffect;
  137930. private bloom;
  137931. /**
  137932. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  137933. */
  137934. depthOfField: DepthOfFieldEffect;
  137935. /**
  137936. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  137937. */
  137938. fxaa: FxaaPostProcess;
  137939. /**
  137940. * Image post processing pass used to perform operations such as tone mapping or color grading.
  137941. */
  137942. imageProcessing: ImageProcessingPostProcess;
  137943. /**
  137944. * Chromatic aberration post process which will shift rgb colors in the image
  137945. */
  137946. chromaticAberration: ChromaticAberrationPostProcess;
  137947. private _chromaticAberrationEffect;
  137948. /**
  137949. * Grain post process which add noise to the image
  137950. */
  137951. grain: GrainPostProcess;
  137952. private _grainEffect;
  137953. /**
  137954. * Glow post process which adds a glow to emissive areas of the image
  137955. */
  137956. private _glowLayer;
  137957. /**
  137958. * Animations which can be used to tweak settings over a period of time
  137959. */
  137960. animations: Animation[];
  137961. private _imageProcessingConfigurationObserver;
  137962. private _sharpenEnabled;
  137963. private _bloomEnabled;
  137964. private _depthOfFieldEnabled;
  137965. private _depthOfFieldBlurLevel;
  137966. private _fxaaEnabled;
  137967. private _imageProcessingEnabled;
  137968. private _defaultPipelineTextureType;
  137969. private _bloomScale;
  137970. private _chromaticAberrationEnabled;
  137971. private _grainEnabled;
  137972. private _buildAllowed;
  137973. /**
  137974. * Gets active scene
  137975. */
  137976. get scene(): Scene;
  137977. /**
  137978. * Enable or disable the sharpen process from the pipeline
  137979. */
  137980. set sharpenEnabled(enabled: boolean);
  137981. get sharpenEnabled(): boolean;
  137982. private _resizeObserver;
  137983. private _hardwareScaleLevel;
  137984. private _bloomKernel;
  137985. /**
  137986. * Specifies the size of the bloom blur kernel, relative to the final output size
  137987. */
  137988. get bloomKernel(): number;
  137989. set bloomKernel(value: number);
  137990. /**
  137991. * Specifies the weight of the bloom in the final rendering
  137992. */
  137993. private _bloomWeight;
  137994. /**
  137995. * Specifies the luma threshold for the area that will be blurred by the bloom
  137996. */
  137997. private _bloomThreshold;
  137998. private _hdr;
  137999. /**
  138000. * The strength of the bloom.
  138001. */
  138002. set bloomWeight(value: number);
  138003. get bloomWeight(): number;
  138004. /**
  138005. * The strength of the bloom.
  138006. */
  138007. set bloomThreshold(value: number);
  138008. get bloomThreshold(): number;
  138009. /**
  138010. * The scale of the bloom, lower value will provide better performance.
  138011. */
  138012. set bloomScale(value: number);
  138013. get bloomScale(): number;
  138014. /**
  138015. * Enable or disable the bloom from the pipeline
  138016. */
  138017. set bloomEnabled(enabled: boolean);
  138018. get bloomEnabled(): boolean;
  138019. private _rebuildBloom;
  138020. /**
  138021. * If the depth of field is enabled.
  138022. */
  138023. get depthOfFieldEnabled(): boolean;
  138024. set depthOfFieldEnabled(enabled: boolean);
  138025. /**
  138026. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138027. */
  138028. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138029. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138030. /**
  138031. * If the anti aliasing is enabled.
  138032. */
  138033. set fxaaEnabled(enabled: boolean);
  138034. get fxaaEnabled(): boolean;
  138035. private _samples;
  138036. /**
  138037. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138038. */
  138039. set samples(sampleCount: number);
  138040. get samples(): number;
  138041. /**
  138042. * If image processing is enabled.
  138043. */
  138044. set imageProcessingEnabled(enabled: boolean);
  138045. get imageProcessingEnabled(): boolean;
  138046. /**
  138047. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138048. */
  138049. set glowLayerEnabled(enabled: boolean);
  138050. get glowLayerEnabled(): boolean;
  138051. /**
  138052. * Gets the glow layer (or null if not defined)
  138053. */
  138054. get glowLayer(): Nullable<GlowLayer>;
  138055. /**
  138056. * Enable or disable the chromaticAberration process from the pipeline
  138057. */
  138058. set chromaticAberrationEnabled(enabled: boolean);
  138059. get chromaticAberrationEnabled(): boolean;
  138060. /**
  138061. * Enable or disable the grain process from the pipeline
  138062. */
  138063. set grainEnabled(enabled: boolean);
  138064. get grainEnabled(): boolean;
  138065. /**
  138066. * @constructor
  138067. * @param name - The rendering pipeline name (default: "")
  138068. * @param hdr - If high dynamic range textures should be used (default: true)
  138069. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138070. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138071. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138072. */
  138073. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138074. /**
  138075. * Get the class name
  138076. * @returns "DefaultRenderingPipeline"
  138077. */
  138078. getClassName(): string;
  138079. /**
  138080. * Force the compilation of the entire pipeline.
  138081. */
  138082. prepare(): void;
  138083. private _hasCleared;
  138084. private _prevPostProcess;
  138085. private _prevPrevPostProcess;
  138086. private _setAutoClearAndTextureSharing;
  138087. private _depthOfFieldSceneObserver;
  138088. private _buildPipeline;
  138089. private _disposePostProcesses;
  138090. /**
  138091. * Adds a camera to the pipeline
  138092. * @param camera the camera to be added
  138093. */
  138094. addCamera(camera: Camera): void;
  138095. /**
  138096. * Removes a camera from the pipeline
  138097. * @param camera the camera to remove
  138098. */
  138099. removeCamera(camera: Camera): void;
  138100. /**
  138101. * Dispose of the pipeline and stop all post processes
  138102. */
  138103. dispose(): void;
  138104. /**
  138105. * Serialize the rendering pipeline (Used when exporting)
  138106. * @returns the serialized object
  138107. */
  138108. serialize(): any;
  138109. /**
  138110. * Parse the serialized pipeline
  138111. * @param source Source pipeline.
  138112. * @param scene The scene to load the pipeline to.
  138113. * @param rootUrl The URL of the serialized pipeline.
  138114. * @returns An instantiated pipeline from the serialized object.
  138115. */
  138116. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138117. }
  138118. }
  138119. declare module BABYLON {
  138120. /** @hidden */
  138121. export var lensHighlightsPixelShader: {
  138122. name: string;
  138123. shader: string;
  138124. };
  138125. }
  138126. declare module BABYLON {
  138127. /** @hidden */
  138128. export var depthOfFieldPixelShader: {
  138129. name: string;
  138130. shader: string;
  138131. };
  138132. }
  138133. declare module BABYLON {
  138134. /**
  138135. * BABYLON.JS Chromatic Aberration GLSL Shader
  138136. * Author: Olivier Guyot
  138137. * Separates very slightly R, G and B colors on the edges of the screen
  138138. * Inspired by Francois Tarlier & Martins Upitis
  138139. */
  138140. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138141. /**
  138142. * @ignore
  138143. * The chromatic aberration PostProcess id in the pipeline
  138144. */
  138145. LensChromaticAberrationEffect: string;
  138146. /**
  138147. * @ignore
  138148. * The highlights enhancing PostProcess id in the pipeline
  138149. */
  138150. HighlightsEnhancingEffect: string;
  138151. /**
  138152. * @ignore
  138153. * The depth-of-field PostProcess id in the pipeline
  138154. */
  138155. LensDepthOfFieldEffect: string;
  138156. private _scene;
  138157. private _depthTexture;
  138158. private _grainTexture;
  138159. private _chromaticAberrationPostProcess;
  138160. private _highlightsPostProcess;
  138161. private _depthOfFieldPostProcess;
  138162. private _edgeBlur;
  138163. private _grainAmount;
  138164. private _chromaticAberration;
  138165. private _distortion;
  138166. private _highlightsGain;
  138167. private _highlightsThreshold;
  138168. private _dofDistance;
  138169. private _dofAperture;
  138170. private _dofDarken;
  138171. private _dofPentagon;
  138172. private _blurNoise;
  138173. /**
  138174. * @constructor
  138175. *
  138176. * Effect parameters are as follow:
  138177. * {
  138178. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138179. * edge_blur: number; // from 0 to x (1 for realism)
  138180. * distortion: number; // from 0 to x (1 for realism)
  138181. * grain_amount: number; // from 0 to 1
  138182. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138183. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138184. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138185. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138186. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138187. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138188. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138189. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138190. * }
  138191. * Note: if an effect parameter is unset, effect is disabled
  138192. *
  138193. * @param name The rendering pipeline name
  138194. * @param parameters - An object containing all parameters (see above)
  138195. * @param scene The scene linked to this pipeline
  138196. * @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)
  138197. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138198. */
  138199. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138200. /**
  138201. * Get the class name
  138202. * @returns "LensRenderingPipeline"
  138203. */
  138204. getClassName(): string;
  138205. /**
  138206. * Gets associated scene
  138207. */
  138208. get scene(): Scene;
  138209. /**
  138210. * Gets or sets the edge blur
  138211. */
  138212. get edgeBlur(): number;
  138213. set edgeBlur(value: number);
  138214. /**
  138215. * Gets or sets the grain amount
  138216. */
  138217. get grainAmount(): number;
  138218. set grainAmount(value: number);
  138219. /**
  138220. * Gets or sets the chromatic aberration amount
  138221. */
  138222. get chromaticAberration(): number;
  138223. set chromaticAberration(value: number);
  138224. /**
  138225. * Gets or sets the depth of field aperture
  138226. */
  138227. get dofAperture(): number;
  138228. set dofAperture(value: number);
  138229. /**
  138230. * Gets or sets the edge distortion
  138231. */
  138232. get edgeDistortion(): number;
  138233. set edgeDistortion(value: number);
  138234. /**
  138235. * Gets or sets the depth of field distortion
  138236. */
  138237. get dofDistortion(): number;
  138238. set dofDistortion(value: number);
  138239. /**
  138240. * Gets or sets the darken out of focus amount
  138241. */
  138242. get darkenOutOfFocus(): number;
  138243. set darkenOutOfFocus(value: number);
  138244. /**
  138245. * Gets or sets a boolean indicating if blur noise is enabled
  138246. */
  138247. get blurNoise(): boolean;
  138248. set blurNoise(value: boolean);
  138249. /**
  138250. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138251. */
  138252. get pentagonBokeh(): boolean;
  138253. set pentagonBokeh(value: boolean);
  138254. /**
  138255. * Gets or sets the highlight grain amount
  138256. */
  138257. get highlightsGain(): number;
  138258. set highlightsGain(value: number);
  138259. /**
  138260. * Gets or sets the highlight threshold
  138261. */
  138262. get highlightsThreshold(): number;
  138263. set highlightsThreshold(value: number);
  138264. /**
  138265. * Sets the amount of blur at the edges
  138266. * @param amount blur amount
  138267. */
  138268. setEdgeBlur(amount: number): void;
  138269. /**
  138270. * Sets edge blur to 0
  138271. */
  138272. disableEdgeBlur(): void;
  138273. /**
  138274. * Sets the amout of grain
  138275. * @param amount Amount of grain
  138276. */
  138277. setGrainAmount(amount: number): void;
  138278. /**
  138279. * Set grain amount to 0
  138280. */
  138281. disableGrain(): void;
  138282. /**
  138283. * Sets the chromatic aberration amount
  138284. * @param amount amount of chromatic aberration
  138285. */
  138286. setChromaticAberration(amount: number): void;
  138287. /**
  138288. * Sets chromatic aberration amount to 0
  138289. */
  138290. disableChromaticAberration(): void;
  138291. /**
  138292. * Sets the EdgeDistortion amount
  138293. * @param amount amount of EdgeDistortion
  138294. */
  138295. setEdgeDistortion(amount: number): void;
  138296. /**
  138297. * Sets edge distortion to 0
  138298. */
  138299. disableEdgeDistortion(): void;
  138300. /**
  138301. * Sets the FocusDistance amount
  138302. * @param amount amount of FocusDistance
  138303. */
  138304. setFocusDistance(amount: number): void;
  138305. /**
  138306. * Disables depth of field
  138307. */
  138308. disableDepthOfField(): void;
  138309. /**
  138310. * Sets the Aperture amount
  138311. * @param amount amount of Aperture
  138312. */
  138313. setAperture(amount: number): void;
  138314. /**
  138315. * Sets the DarkenOutOfFocus amount
  138316. * @param amount amount of DarkenOutOfFocus
  138317. */
  138318. setDarkenOutOfFocus(amount: number): void;
  138319. private _pentagonBokehIsEnabled;
  138320. /**
  138321. * Creates a pentagon bokeh effect
  138322. */
  138323. enablePentagonBokeh(): void;
  138324. /**
  138325. * Disables the pentagon bokeh effect
  138326. */
  138327. disablePentagonBokeh(): void;
  138328. /**
  138329. * Enables noise blur
  138330. */
  138331. enableNoiseBlur(): void;
  138332. /**
  138333. * Disables noise blur
  138334. */
  138335. disableNoiseBlur(): void;
  138336. /**
  138337. * Sets the HighlightsGain amount
  138338. * @param amount amount of HighlightsGain
  138339. */
  138340. setHighlightsGain(amount: number): void;
  138341. /**
  138342. * Sets the HighlightsThreshold amount
  138343. * @param amount amount of HighlightsThreshold
  138344. */
  138345. setHighlightsThreshold(amount: number): void;
  138346. /**
  138347. * Disables highlights
  138348. */
  138349. disableHighlights(): void;
  138350. /**
  138351. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138352. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138353. */
  138354. dispose(disableDepthRender?: boolean): void;
  138355. private _createChromaticAberrationPostProcess;
  138356. private _createHighlightsPostProcess;
  138357. private _createDepthOfFieldPostProcess;
  138358. private _createGrainTexture;
  138359. }
  138360. }
  138361. declare module BABYLON {
  138362. /** @hidden */
  138363. export var ssao2PixelShader: {
  138364. name: string;
  138365. shader: string;
  138366. };
  138367. }
  138368. declare module BABYLON {
  138369. /** @hidden */
  138370. export var ssaoCombinePixelShader: {
  138371. name: string;
  138372. shader: string;
  138373. };
  138374. }
  138375. declare module BABYLON {
  138376. /**
  138377. * Render pipeline to produce ssao effect
  138378. */
  138379. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138380. /**
  138381. * @ignore
  138382. * The PassPostProcess id in the pipeline that contains the original scene color
  138383. */
  138384. SSAOOriginalSceneColorEffect: string;
  138385. /**
  138386. * @ignore
  138387. * The SSAO PostProcess id in the pipeline
  138388. */
  138389. SSAORenderEffect: string;
  138390. /**
  138391. * @ignore
  138392. * The horizontal blur PostProcess id in the pipeline
  138393. */
  138394. SSAOBlurHRenderEffect: string;
  138395. /**
  138396. * @ignore
  138397. * The vertical blur PostProcess id in the pipeline
  138398. */
  138399. SSAOBlurVRenderEffect: string;
  138400. /**
  138401. * @ignore
  138402. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138403. */
  138404. SSAOCombineRenderEffect: string;
  138405. /**
  138406. * The output strength of the SSAO post-process. Default value is 1.0.
  138407. */
  138408. totalStrength: number;
  138409. /**
  138410. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138411. */
  138412. maxZ: number;
  138413. /**
  138414. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138415. */
  138416. minZAspect: number;
  138417. private _samples;
  138418. /**
  138419. * Number of samples used for the SSAO calculations. Default value is 8
  138420. */
  138421. set samples(n: number);
  138422. get samples(): number;
  138423. private _textureSamples;
  138424. /**
  138425. * Number of samples to use for antialiasing
  138426. */
  138427. set textureSamples(n: number);
  138428. get textureSamples(): number;
  138429. /**
  138430. * Ratio object used for SSAO ratio and blur ratio
  138431. */
  138432. private _ratio;
  138433. /**
  138434. * Dynamically generated sphere sampler.
  138435. */
  138436. private _sampleSphere;
  138437. /**
  138438. * Blur filter offsets
  138439. */
  138440. private _samplerOffsets;
  138441. private _expensiveBlur;
  138442. /**
  138443. * If bilateral blur should be used
  138444. */
  138445. set expensiveBlur(b: boolean);
  138446. get expensiveBlur(): boolean;
  138447. /**
  138448. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138449. */
  138450. radius: number;
  138451. /**
  138452. * The base color of the SSAO post-process
  138453. * The final result is "base + ssao" between [0, 1]
  138454. */
  138455. base: number;
  138456. /**
  138457. * Support test.
  138458. */
  138459. static get IsSupported(): boolean;
  138460. private _scene;
  138461. private _depthTexture;
  138462. private _normalTexture;
  138463. private _randomTexture;
  138464. private _originalColorPostProcess;
  138465. private _ssaoPostProcess;
  138466. private _blurHPostProcess;
  138467. private _blurVPostProcess;
  138468. private _ssaoCombinePostProcess;
  138469. /**
  138470. * Gets active scene
  138471. */
  138472. get scene(): Scene;
  138473. /**
  138474. * @constructor
  138475. * @param name The rendering pipeline name
  138476. * @param scene The scene linked to this pipeline
  138477. * @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 }
  138478. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138479. */
  138480. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138481. /**
  138482. * Get the class name
  138483. * @returns "SSAO2RenderingPipeline"
  138484. */
  138485. getClassName(): string;
  138486. /**
  138487. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138488. */
  138489. dispose(disableGeometryBufferRenderer?: boolean): void;
  138490. private _createBlurPostProcess;
  138491. /** @hidden */
  138492. _rebuild(): void;
  138493. private _bits;
  138494. private _radicalInverse_VdC;
  138495. private _hammersley;
  138496. private _hemisphereSample_uniform;
  138497. private _generateHemisphere;
  138498. private _createSSAOPostProcess;
  138499. private _createSSAOCombinePostProcess;
  138500. private _createRandomTexture;
  138501. /**
  138502. * Serialize the rendering pipeline (Used when exporting)
  138503. * @returns the serialized object
  138504. */
  138505. serialize(): any;
  138506. /**
  138507. * Parse the serialized pipeline
  138508. * @param source Source pipeline.
  138509. * @param scene The scene to load the pipeline to.
  138510. * @param rootUrl The URL of the serialized pipeline.
  138511. * @returns An instantiated pipeline from the serialized object.
  138512. */
  138513. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138514. }
  138515. }
  138516. declare module BABYLON {
  138517. /** @hidden */
  138518. export var ssaoPixelShader: {
  138519. name: string;
  138520. shader: string;
  138521. };
  138522. }
  138523. declare module BABYLON {
  138524. /**
  138525. * Render pipeline to produce ssao effect
  138526. */
  138527. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138528. /**
  138529. * @ignore
  138530. * The PassPostProcess id in the pipeline that contains the original scene color
  138531. */
  138532. SSAOOriginalSceneColorEffect: string;
  138533. /**
  138534. * @ignore
  138535. * The SSAO PostProcess id in the pipeline
  138536. */
  138537. SSAORenderEffect: string;
  138538. /**
  138539. * @ignore
  138540. * The horizontal blur PostProcess id in the pipeline
  138541. */
  138542. SSAOBlurHRenderEffect: string;
  138543. /**
  138544. * @ignore
  138545. * The vertical blur PostProcess id in the pipeline
  138546. */
  138547. SSAOBlurVRenderEffect: string;
  138548. /**
  138549. * @ignore
  138550. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138551. */
  138552. SSAOCombineRenderEffect: string;
  138553. /**
  138554. * The output strength of the SSAO post-process. Default value is 1.0.
  138555. */
  138556. totalStrength: number;
  138557. /**
  138558. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138559. */
  138560. radius: number;
  138561. /**
  138562. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138563. * Must not be equal to fallOff and superior to fallOff.
  138564. * Default value is 0.0075
  138565. */
  138566. area: number;
  138567. /**
  138568. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138569. * Must not be equal to area and inferior to area.
  138570. * Default value is 0.000001
  138571. */
  138572. fallOff: number;
  138573. /**
  138574. * The base color of the SSAO post-process
  138575. * The final result is "base + ssao" between [0, 1]
  138576. */
  138577. base: number;
  138578. private _scene;
  138579. private _depthTexture;
  138580. private _randomTexture;
  138581. private _originalColorPostProcess;
  138582. private _ssaoPostProcess;
  138583. private _blurHPostProcess;
  138584. private _blurVPostProcess;
  138585. private _ssaoCombinePostProcess;
  138586. private _firstUpdate;
  138587. /**
  138588. * Gets active scene
  138589. */
  138590. get scene(): Scene;
  138591. /**
  138592. * @constructor
  138593. * @param name - The rendering pipeline name
  138594. * @param scene - The scene linked to this pipeline
  138595. * @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 }
  138596. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138597. */
  138598. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138599. /**
  138600. * Get the class name
  138601. * @returns "SSAORenderingPipeline"
  138602. */
  138603. getClassName(): string;
  138604. /**
  138605. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138606. */
  138607. dispose(disableDepthRender?: boolean): void;
  138608. private _createBlurPostProcess;
  138609. /** @hidden */
  138610. _rebuild(): void;
  138611. private _createSSAOPostProcess;
  138612. private _createSSAOCombinePostProcess;
  138613. private _createRandomTexture;
  138614. }
  138615. }
  138616. declare module BABYLON {
  138617. /** @hidden */
  138618. export var screenSpaceReflectionPixelShader: {
  138619. name: string;
  138620. shader: string;
  138621. };
  138622. }
  138623. declare module BABYLON {
  138624. /**
  138625. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138626. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138627. */
  138628. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138629. /**
  138630. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138631. */
  138632. threshold: number;
  138633. /**
  138634. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  138635. */
  138636. strength: number;
  138637. /**
  138638. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  138639. */
  138640. reflectionSpecularFalloffExponent: number;
  138641. /**
  138642. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  138643. */
  138644. step: number;
  138645. /**
  138646. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  138647. */
  138648. roughnessFactor: number;
  138649. private _geometryBufferRenderer;
  138650. private _enableSmoothReflections;
  138651. private _reflectionSamples;
  138652. private _smoothSteps;
  138653. /**
  138654. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  138655. * @param name The name of the effect.
  138656. * @param scene The scene containing the objects to calculate reflections.
  138657. * @param options The required width/height ratio to downsize to before computing the render pass.
  138658. * @param camera The camera to apply the render pass to.
  138659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138660. * @param engine The engine which the post process will be applied. (default: current engine)
  138661. * @param reusable If the post process can be reused on the same frame. (default: false)
  138662. * @param textureType Type of textures used when performing the post process. (default: 0)
  138663. * @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)
  138664. */
  138665. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138666. /**
  138667. * Gets wether or not smoothing reflections is enabled.
  138668. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138669. */
  138670. get enableSmoothReflections(): boolean;
  138671. /**
  138672. * Sets wether or not smoothing reflections is enabled.
  138673. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138674. */
  138675. set enableSmoothReflections(enabled: boolean);
  138676. /**
  138677. * Gets the number of samples taken while computing reflections. More samples count is high,
  138678. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138679. */
  138680. get reflectionSamples(): number;
  138681. /**
  138682. * Sets the number of samples taken while computing reflections. More samples count is high,
  138683. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138684. */
  138685. set reflectionSamples(samples: number);
  138686. /**
  138687. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  138688. * more the post-process will require GPU power and can generate a drop in FPS.
  138689. * Default value (5.0) work pretty well in all cases but can be adjusted.
  138690. */
  138691. get smoothSteps(): number;
  138692. set smoothSteps(steps: number);
  138693. private _updateEffectDefines;
  138694. }
  138695. }
  138696. declare module BABYLON {
  138697. /** @hidden */
  138698. export var standardPixelShader: {
  138699. name: string;
  138700. shader: string;
  138701. };
  138702. }
  138703. declare module BABYLON {
  138704. /**
  138705. * Standard rendering pipeline
  138706. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138707. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  138708. */
  138709. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138710. /**
  138711. * Public members
  138712. */
  138713. /**
  138714. * Post-process which contains the original scene color before the pipeline applies all the effects
  138715. */
  138716. originalPostProcess: Nullable<PostProcess>;
  138717. /**
  138718. * Post-process used to down scale an image x4
  138719. */
  138720. downSampleX4PostProcess: Nullable<PostProcess>;
  138721. /**
  138722. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  138723. */
  138724. brightPassPostProcess: Nullable<PostProcess>;
  138725. /**
  138726. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  138727. */
  138728. blurHPostProcesses: PostProcess[];
  138729. /**
  138730. * Post-process array storing all the vertical blur post-processes used by the pipeline
  138731. */
  138732. blurVPostProcesses: PostProcess[];
  138733. /**
  138734. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  138735. */
  138736. textureAdderPostProcess: Nullable<PostProcess>;
  138737. /**
  138738. * Post-process used to create volumetric lighting effect
  138739. */
  138740. volumetricLightPostProcess: Nullable<PostProcess>;
  138741. /**
  138742. * Post-process used to smooth the previous volumetric light post-process on the X axis
  138743. */
  138744. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  138745. /**
  138746. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  138747. */
  138748. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  138749. /**
  138750. * Post-process used to merge the volumetric light effect and the real scene color
  138751. */
  138752. volumetricLightMergePostProces: Nullable<PostProcess>;
  138753. /**
  138754. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  138755. */
  138756. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  138757. /**
  138758. * Base post-process used to calculate the average luminance of the final image for HDR
  138759. */
  138760. luminancePostProcess: Nullable<PostProcess>;
  138761. /**
  138762. * Post-processes used to create down sample post-processes in order to get
  138763. * the average luminance of the final image for HDR
  138764. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  138765. */
  138766. luminanceDownSamplePostProcesses: PostProcess[];
  138767. /**
  138768. * Post-process used to create a HDR effect (light adaptation)
  138769. */
  138770. hdrPostProcess: Nullable<PostProcess>;
  138771. /**
  138772. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  138773. */
  138774. textureAdderFinalPostProcess: Nullable<PostProcess>;
  138775. /**
  138776. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  138777. */
  138778. lensFlareFinalPostProcess: Nullable<PostProcess>;
  138779. /**
  138780. * Post-process used to merge the final HDR post-process and the real scene color
  138781. */
  138782. hdrFinalPostProcess: Nullable<PostProcess>;
  138783. /**
  138784. * Post-process used to create a lens flare effect
  138785. */
  138786. lensFlarePostProcess: Nullable<PostProcess>;
  138787. /**
  138788. * Post-process that merges the result of the lens flare post-process and the real scene color
  138789. */
  138790. lensFlareComposePostProcess: Nullable<PostProcess>;
  138791. /**
  138792. * Post-process used to create a motion blur effect
  138793. */
  138794. motionBlurPostProcess: Nullable<PostProcess>;
  138795. /**
  138796. * Post-process used to create a depth of field effect
  138797. */
  138798. depthOfFieldPostProcess: Nullable<PostProcess>;
  138799. /**
  138800. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138801. */
  138802. fxaaPostProcess: Nullable<FxaaPostProcess>;
  138803. /**
  138804. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  138805. */
  138806. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  138807. /**
  138808. * Represents the brightness threshold in order to configure the illuminated surfaces
  138809. */
  138810. brightThreshold: number;
  138811. /**
  138812. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  138813. */
  138814. blurWidth: number;
  138815. /**
  138816. * Sets if the blur for highlighted surfaces must be only horizontal
  138817. */
  138818. horizontalBlur: boolean;
  138819. /**
  138820. * Gets the overall exposure used by the pipeline
  138821. */
  138822. get exposure(): number;
  138823. /**
  138824. * Sets the overall exposure used by the pipeline
  138825. */
  138826. set exposure(value: number);
  138827. /**
  138828. * Texture used typically to simulate "dirty" on camera lens
  138829. */
  138830. lensTexture: Nullable<Texture>;
  138831. /**
  138832. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  138833. */
  138834. volumetricLightCoefficient: number;
  138835. /**
  138836. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  138837. */
  138838. volumetricLightPower: number;
  138839. /**
  138840. * Used the set the blur intensity to smooth the volumetric lights
  138841. */
  138842. volumetricLightBlurScale: number;
  138843. /**
  138844. * Light (spot or directional) used to generate the volumetric lights rays
  138845. * The source light must have a shadow generate so the pipeline can get its
  138846. * depth map
  138847. */
  138848. sourceLight: Nullable<SpotLight | DirectionalLight>;
  138849. /**
  138850. * For eye adaptation, represents the minimum luminance the eye can see
  138851. */
  138852. hdrMinimumLuminance: number;
  138853. /**
  138854. * For eye adaptation, represents the decrease luminance speed
  138855. */
  138856. hdrDecreaseRate: number;
  138857. /**
  138858. * For eye adaptation, represents the increase luminance speed
  138859. */
  138860. hdrIncreaseRate: number;
  138861. /**
  138862. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138863. */
  138864. get hdrAutoExposure(): boolean;
  138865. /**
  138866. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138867. */
  138868. set hdrAutoExposure(value: boolean);
  138869. /**
  138870. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  138871. */
  138872. lensColorTexture: Nullable<Texture>;
  138873. /**
  138874. * The overall strengh for the lens flare effect
  138875. */
  138876. lensFlareStrength: number;
  138877. /**
  138878. * Dispersion coefficient for lens flare ghosts
  138879. */
  138880. lensFlareGhostDispersal: number;
  138881. /**
  138882. * Main lens flare halo width
  138883. */
  138884. lensFlareHaloWidth: number;
  138885. /**
  138886. * Based on the lens distortion effect, defines how much the lens flare result
  138887. * is distorted
  138888. */
  138889. lensFlareDistortionStrength: number;
  138890. /**
  138891. * Configures the blur intensity used for for lens flare (halo)
  138892. */
  138893. lensFlareBlurWidth: number;
  138894. /**
  138895. * Lens star texture must be used to simulate rays on the flares and is available
  138896. * in the documentation
  138897. */
  138898. lensStarTexture: Nullable<Texture>;
  138899. /**
  138900. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  138901. * flare effect by taking account of the dirt texture
  138902. */
  138903. lensFlareDirtTexture: Nullable<Texture>;
  138904. /**
  138905. * Represents the focal length for the depth of field effect
  138906. */
  138907. depthOfFieldDistance: number;
  138908. /**
  138909. * Represents the blur intensity for the blurred part of the depth of field effect
  138910. */
  138911. depthOfFieldBlurWidth: number;
  138912. /**
  138913. * Gets how much the image is blurred by the movement while using the motion blur post-process
  138914. */
  138915. get motionStrength(): number;
  138916. /**
  138917. * Sets how much the image is blurred by the movement while using the motion blur post-process
  138918. */
  138919. set motionStrength(strength: number);
  138920. /**
  138921. * Gets wether or not the motion blur post-process is object based or screen based.
  138922. */
  138923. get objectBasedMotionBlur(): boolean;
  138924. /**
  138925. * Sets wether or not the motion blur post-process should be object based or screen based
  138926. */
  138927. set objectBasedMotionBlur(value: boolean);
  138928. /**
  138929. * List of animations for the pipeline (IAnimatable implementation)
  138930. */
  138931. animations: Animation[];
  138932. /**
  138933. * Private members
  138934. */
  138935. private _scene;
  138936. private _currentDepthOfFieldSource;
  138937. private _basePostProcess;
  138938. private _fixedExposure;
  138939. private _currentExposure;
  138940. private _hdrAutoExposure;
  138941. private _hdrCurrentLuminance;
  138942. private _motionStrength;
  138943. private _isObjectBasedMotionBlur;
  138944. private _floatTextureType;
  138945. private _camerasToBeAttached;
  138946. private _ratio;
  138947. private _bloomEnabled;
  138948. private _depthOfFieldEnabled;
  138949. private _vlsEnabled;
  138950. private _lensFlareEnabled;
  138951. private _hdrEnabled;
  138952. private _motionBlurEnabled;
  138953. private _fxaaEnabled;
  138954. private _screenSpaceReflectionsEnabled;
  138955. private _motionBlurSamples;
  138956. private _volumetricLightStepsCount;
  138957. private _samples;
  138958. /**
  138959. * @ignore
  138960. * Specifies if the bloom pipeline is enabled
  138961. */
  138962. get BloomEnabled(): boolean;
  138963. set BloomEnabled(enabled: boolean);
  138964. /**
  138965. * @ignore
  138966. * Specifies if the depth of field pipeline is enabed
  138967. */
  138968. get DepthOfFieldEnabled(): boolean;
  138969. set DepthOfFieldEnabled(enabled: boolean);
  138970. /**
  138971. * @ignore
  138972. * Specifies if the lens flare pipeline is enabed
  138973. */
  138974. get LensFlareEnabled(): boolean;
  138975. set LensFlareEnabled(enabled: boolean);
  138976. /**
  138977. * @ignore
  138978. * Specifies if the HDR pipeline is enabled
  138979. */
  138980. get HDREnabled(): boolean;
  138981. set HDREnabled(enabled: boolean);
  138982. /**
  138983. * @ignore
  138984. * Specifies if the volumetric lights scattering effect is enabled
  138985. */
  138986. get VLSEnabled(): boolean;
  138987. set VLSEnabled(enabled: boolean);
  138988. /**
  138989. * @ignore
  138990. * Specifies if the motion blur effect is enabled
  138991. */
  138992. get MotionBlurEnabled(): boolean;
  138993. set MotionBlurEnabled(enabled: boolean);
  138994. /**
  138995. * Specifies if anti-aliasing is enabled
  138996. */
  138997. get fxaaEnabled(): boolean;
  138998. set fxaaEnabled(enabled: boolean);
  138999. /**
  139000. * Specifies if screen space reflections are enabled.
  139001. */
  139002. get screenSpaceReflectionsEnabled(): boolean;
  139003. set screenSpaceReflectionsEnabled(enabled: boolean);
  139004. /**
  139005. * Specifies the number of steps used to calculate the volumetric lights
  139006. * Typically in interval [50, 200]
  139007. */
  139008. get volumetricLightStepsCount(): number;
  139009. set volumetricLightStepsCount(count: number);
  139010. /**
  139011. * Specifies the number of samples used for the motion blur effect
  139012. * Typically in interval [16, 64]
  139013. */
  139014. get motionBlurSamples(): number;
  139015. set motionBlurSamples(samples: number);
  139016. /**
  139017. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139018. */
  139019. get samples(): number;
  139020. set samples(sampleCount: number);
  139021. /**
  139022. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139023. * @constructor
  139024. * @param name The rendering pipeline name
  139025. * @param scene The scene linked to this pipeline
  139026. * @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)
  139027. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139028. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139029. */
  139030. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139031. private _buildPipeline;
  139032. private _createDownSampleX4PostProcess;
  139033. private _createBrightPassPostProcess;
  139034. private _createBlurPostProcesses;
  139035. private _createTextureAdderPostProcess;
  139036. private _createVolumetricLightPostProcess;
  139037. private _createLuminancePostProcesses;
  139038. private _createHdrPostProcess;
  139039. private _createLensFlarePostProcess;
  139040. private _createDepthOfFieldPostProcess;
  139041. private _createMotionBlurPostProcess;
  139042. private _getDepthTexture;
  139043. private _disposePostProcesses;
  139044. /**
  139045. * Dispose of the pipeline and stop all post processes
  139046. */
  139047. dispose(): void;
  139048. /**
  139049. * Serialize the rendering pipeline (Used when exporting)
  139050. * @returns the serialized object
  139051. */
  139052. serialize(): any;
  139053. /**
  139054. * Parse the serialized pipeline
  139055. * @param source Source pipeline.
  139056. * @param scene The scene to load the pipeline to.
  139057. * @param rootUrl The URL of the serialized pipeline.
  139058. * @returns An instantiated pipeline from the serialized object.
  139059. */
  139060. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139061. /**
  139062. * Luminance steps
  139063. */
  139064. static LuminanceSteps: number;
  139065. }
  139066. }
  139067. declare module BABYLON {
  139068. /** @hidden */
  139069. export var tonemapPixelShader: {
  139070. name: string;
  139071. shader: string;
  139072. };
  139073. }
  139074. declare module BABYLON {
  139075. /** Defines operator used for tonemapping */
  139076. export enum TonemappingOperator {
  139077. /** Hable */
  139078. Hable = 0,
  139079. /** Reinhard */
  139080. Reinhard = 1,
  139081. /** HejiDawson */
  139082. HejiDawson = 2,
  139083. /** Photographic */
  139084. Photographic = 3
  139085. }
  139086. /**
  139087. * Defines a post process to apply tone mapping
  139088. */
  139089. export class TonemapPostProcess extends PostProcess {
  139090. private _operator;
  139091. /** Defines the required exposure adjustement */
  139092. exposureAdjustment: number;
  139093. /**
  139094. * Creates a new TonemapPostProcess
  139095. * @param name defines the name of the postprocess
  139096. * @param _operator defines the operator to use
  139097. * @param exposureAdjustment defines the required exposure adjustement
  139098. * @param camera defines the camera to use (can be null)
  139099. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139100. * @param engine defines the hosting engine (can be ignore if camera is set)
  139101. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139102. */
  139103. constructor(name: string, _operator: TonemappingOperator,
  139104. /** Defines the required exposure adjustement */
  139105. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139106. }
  139107. }
  139108. declare module BABYLON {
  139109. /** @hidden */
  139110. export var volumetricLightScatteringPixelShader: {
  139111. name: string;
  139112. shader: string;
  139113. };
  139114. }
  139115. declare module BABYLON {
  139116. /** @hidden */
  139117. export var volumetricLightScatteringPassVertexShader: {
  139118. name: string;
  139119. shader: string;
  139120. };
  139121. }
  139122. declare module BABYLON {
  139123. /** @hidden */
  139124. export var volumetricLightScatteringPassPixelShader: {
  139125. name: string;
  139126. shader: string;
  139127. };
  139128. }
  139129. declare module BABYLON {
  139130. /**
  139131. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139132. */
  139133. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139134. private _volumetricLightScatteringPass;
  139135. private _volumetricLightScatteringRTT;
  139136. private _viewPort;
  139137. private _screenCoordinates;
  139138. private _cachedDefines;
  139139. /**
  139140. * If not undefined, the mesh position is computed from the attached node position
  139141. */
  139142. attachedNode: {
  139143. position: Vector3;
  139144. };
  139145. /**
  139146. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139147. */
  139148. customMeshPosition: Vector3;
  139149. /**
  139150. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139151. */
  139152. useCustomMeshPosition: boolean;
  139153. /**
  139154. * If the post-process should inverse the light scattering direction
  139155. */
  139156. invert: boolean;
  139157. /**
  139158. * The internal mesh used by the post-process
  139159. */
  139160. mesh: Mesh;
  139161. /**
  139162. * @hidden
  139163. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139164. */
  139165. get useDiffuseColor(): boolean;
  139166. set useDiffuseColor(useDiffuseColor: boolean);
  139167. /**
  139168. * Array containing the excluded meshes not rendered in the internal pass
  139169. */
  139170. excludedMeshes: AbstractMesh[];
  139171. /**
  139172. * Controls the overall intensity of the post-process
  139173. */
  139174. exposure: number;
  139175. /**
  139176. * Dissipates each sample's contribution in range [0, 1]
  139177. */
  139178. decay: number;
  139179. /**
  139180. * Controls the overall intensity of each sample
  139181. */
  139182. weight: number;
  139183. /**
  139184. * Controls the density of each sample
  139185. */
  139186. density: number;
  139187. /**
  139188. * @constructor
  139189. * @param name The post-process name
  139190. * @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)
  139191. * @param camera The camera that the post-process will be attached to
  139192. * @param mesh The mesh used to create the light scattering
  139193. * @param samples The post-process quality, default 100
  139194. * @param samplingModeThe post-process filtering mode
  139195. * @param engine The babylon engine
  139196. * @param reusable If the post-process is reusable
  139197. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139198. */
  139199. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139200. /**
  139201. * Returns the string "VolumetricLightScatteringPostProcess"
  139202. * @returns "VolumetricLightScatteringPostProcess"
  139203. */
  139204. getClassName(): string;
  139205. private _isReady;
  139206. /**
  139207. * Sets the new light position for light scattering effect
  139208. * @param position The new custom light position
  139209. */
  139210. setCustomMeshPosition(position: Vector3): void;
  139211. /**
  139212. * Returns the light position for light scattering effect
  139213. * @return Vector3 The custom light position
  139214. */
  139215. getCustomMeshPosition(): Vector3;
  139216. /**
  139217. * Disposes the internal assets and detaches the post-process from the camera
  139218. */
  139219. dispose(camera: Camera): void;
  139220. /**
  139221. * Returns the render target texture used by the post-process
  139222. * @return the render target texture used by the post-process
  139223. */
  139224. getPass(): RenderTargetTexture;
  139225. private _meshExcluded;
  139226. private _createPass;
  139227. private _updateMeshScreenCoordinates;
  139228. /**
  139229. * Creates a default mesh for the Volumeric Light Scattering post-process
  139230. * @param name The mesh name
  139231. * @param scene The scene where to create the mesh
  139232. * @return the default mesh
  139233. */
  139234. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139235. }
  139236. }
  139237. declare module BABYLON {
  139238. interface Scene {
  139239. /** @hidden (Backing field) */
  139240. _boundingBoxRenderer: BoundingBoxRenderer;
  139241. /** @hidden (Backing field) */
  139242. _forceShowBoundingBoxes: boolean;
  139243. /**
  139244. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139245. */
  139246. forceShowBoundingBoxes: boolean;
  139247. /**
  139248. * Gets the bounding box renderer associated with the scene
  139249. * @returns a BoundingBoxRenderer
  139250. */
  139251. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139252. }
  139253. interface AbstractMesh {
  139254. /** @hidden (Backing field) */
  139255. _showBoundingBox: boolean;
  139256. /**
  139257. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139258. */
  139259. showBoundingBox: boolean;
  139260. }
  139261. /**
  139262. * Component responsible of rendering the bounding box of the meshes in a scene.
  139263. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139264. */
  139265. export class BoundingBoxRenderer implements ISceneComponent {
  139266. /**
  139267. * The component name helpfull to identify the component in the list of scene components.
  139268. */
  139269. readonly name: string;
  139270. /**
  139271. * The scene the component belongs to.
  139272. */
  139273. scene: Scene;
  139274. /**
  139275. * Color of the bounding box lines placed in front of an object
  139276. */
  139277. frontColor: Color3;
  139278. /**
  139279. * Color of the bounding box lines placed behind an object
  139280. */
  139281. backColor: Color3;
  139282. /**
  139283. * Defines if the renderer should show the back lines or not
  139284. */
  139285. showBackLines: boolean;
  139286. /**
  139287. * @hidden
  139288. */
  139289. renderList: SmartArray<BoundingBox>;
  139290. private _colorShader;
  139291. private _vertexBuffers;
  139292. private _indexBuffer;
  139293. private _fillIndexBuffer;
  139294. private _fillIndexData;
  139295. /**
  139296. * Instantiates a new bounding box renderer in a scene.
  139297. * @param scene the scene the renderer renders in
  139298. */
  139299. constructor(scene: Scene);
  139300. /**
  139301. * Registers the component in a given scene
  139302. */
  139303. register(): void;
  139304. private _evaluateSubMesh;
  139305. private _activeMesh;
  139306. private _prepareRessources;
  139307. private _createIndexBuffer;
  139308. /**
  139309. * Rebuilds the elements related to this component in case of
  139310. * context lost for instance.
  139311. */
  139312. rebuild(): void;
  139313. /**
  139314. * @hidden
  139315. */
  139316. reset(): void;
  139317. /**
  139318. * Render the bounding boxes of a specific rendering group
  139319. * @param renderingGroupId defines the rendering group to render
  139320. */
  139321. render(renderingGroupId: number): void;
  139322. /**
  139323. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139324. * @param mesh Define the mesh to render the occlusion bounding box for
  139325. */
  139326. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139327. /**
  139328. * Dispose and release the resources attached to this renderer.
  139329. */
  139330. dispose(): void;
  139331. }
  139332. }
  139333. declare module BABYLON {
  139334. interface Scene {
  139335. /** @hidden (Backing field) */
  139336. _depthRenderer: {
  139337. [id: string]: DepthRenderer;
  139338. };
  139339. /**
  139340. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139341. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139342. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139343. * @returns the created depth renderer
  139344. */
  139345. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139346. /**
  139347. * Disables a depth renderer for a given camera
  139348. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139349. */
  139350. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139351. }
  139352. /**
  139353. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139354. * in several rendering techniques.
  139355. */
  139356. export class DepthRendererSceneComponent implements ISceneComponent {
  139357. /**
  139358. * The component name helpfull to identify the component in the list of scene components.
  139359. */
  139360. readonly name: string;
  139361. /**
  139362. * The scene the component belongs to.
  139363. */
  139364. scene: Scene;
  139365. /**
  139366. * Creates a new instance of the component for the given scene
  139367. * @param scene Defines the scene to register the component in
  139368. */
  139369. constructor(scene: Scene);
  139370. /**
  139371. * Registers the component in a given scene
  139372. */
  139373. register(): void;
  139374. /**
  139375. * Rebuilds the elements related to this component in case of
  139376. * context lost for instance.
  139377. */
  139378. rebuild(): void;
  139379. /**
  139380. * Disposes the component and the associated ressources
  139381. */
  139382. dispose(): void;
  139383. private _gatherRenderTargets;
  139384. private _gatherActiveCameraRenderTargets;
  139385. }
  139386. }
  139387. declare module BABYLON {
  139388. /** @hidden */
  139389. export var outlinePixelShader: {
  139390. name: string;
  139391. shader: string;
  139392. };
  139393. }
  139394. declare module BABYLON {
  139395. /** @hidden */
  139396. export var outlineVertexShader: {
  139397. name: string;
  139398. shader: string;
  139399. };
  139400. }
  139401. declare module BABYLON {
  139402. interface Scene {
  139403. /** @hidden */
  139404. _outlineRenderer: OutlineRenderer;
  139405. /**
  139406. * Gets the outline renderer associated with the scene
  139407. * @returns a OutlineRenderer
  139408. */
  139409. getOutlineRenderer(): OutlineRenderer;
  139410. }
  139411. interface AbstractMesh {
  139412. /** @hidden (Backing field) */
  139413. _renderOutline: boolean;
  139414. /**
  139415. * Gets or sets a boolean indicating if the outline must be rendered as well
  139416. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139417. */
  139418. renderOutline: boolean;
  139419. /** @hidden (Backing field) */
  139420. _renderOverlay: boolean;
  139421. /**
  139422. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139423. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139424. */
  139425. renderOverlay: boolean;
  139426. }
  139427. /**
  139428. * This class is responsible to draw bothe outline/overlay of meshes.
  139429. * It should not be used directly but through the available method on mesh.
  139430. */
  139431. export class OutlineRenderer implements ISceneComponent {
  139432. /**
  139433. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139434. */
  139435. private static _StencilReference;
  139436. /**
  139437. * The name of the component. Each component must have a unique name.
  139438. */
  139439. name: string;
  139440. /**
  139441. * The scene the component belongs to.
  139442. */
  139443. scene: Scene;
  139444. /**
  139445. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139446. */
  139447. zOffset: number;
  139448. private _engine;
  139449. private _effect;
  139450. private _cachedDefines;
  139451. private _savedDepthWrite;
  139452. /**
  139453. * Instantiates a new outline renderer. (There could be only one per scene).
  139454. * @param scene Defines the scene it belongs to
  139455. */
  139456. constructor(scene: Scene);
  139457. /**
  139458. * Register the component to one instance of a scene.
  139459. */
  139460. register(): void;
  139461. /**
  139462. * Rebuilds the elements related to this component in case of
  139463. * context lost for instance.
  139464. */
  139465. rebuild(): void;
  139466. /**
  139467. * Disposes the component and the associated ressources.
  139468. */
  139469. dispose(): void;
  139470. /**
  139471. * Renders the outline in the canvas.
  139472. * @param subMesh Defines the sumesh to render
  139473. * @param batch Defines the batch of meshes in case of instances
  139474. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139475. */
  139476. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139477. /**
  139478. * Returns whether or not the outline renderer is ready for a given submesh.
  139479. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139480. * @param subMesh Defines the submesh to check readyness for
  139481. * @param useInstances Defines wheter wee are trying to render instances or not
  139482. * @returns true if ready otherwise false
  139483. */
  139484. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139485. private _beforeRenderingMesh;
  139486. private _afterRenderingMesh;
  139487. }
  139488. }
  139489. declare module BABYLON {
  139490. /**
  139491. * Defines the basic options interface of a Sprite Frame Source Size.
  139492. */
  139493. export interface ISpriteJSONSpriteSourceSize {
  139494. /**
  139495. * number of the original width of the Frame
  139496. */
  139497. w: number;
  139498. /**
  139499. * number of the original height of the Frame
  139500. */
  139501. h: number;
  139502. }
  139503. /**
  139504. * Defines the basic options interface of a Sprite Frame Data.
  139505. */
  139506. export interface ISpriteJSONSpriteFrameData {
  139507. /**
  139508. * number of the x offset of the Frame
  139509. */
  139510. x: number;
  139511. /**
  139512. * number of the y offset of the Frame
  139513. */
  139514. y: number;
  139515. /**
  139516. * number of the width of the Frame
  139517. */
  139518. w: number;
  139519. /**
  139520. * number of the height of the Frame
  139521. */
  139522. h: number;
  139523. }
  139524. /**
  139525. * Defines the basic options interface of a JSON Sprite.
  139526. */
  139527. export interface ISpriteJSONSprite {
  139528. /**
  139529. * string name of the Frame
  139530. */
  139531. filename: string;
  139532. /**
  139533. * ISpriteJSONSpriteFrame basic object of the frame data
  139534. */
  139535. frame: ISpriteJSONSpriteFrameData;
  139536. /**
  139537. * boolean to flag is the frame was rotated.
  139538. */
  139539. rotated: boolean;
  139540. /**
  139541. * boolean to flag is the frame was trimmed.
  139542. */
  139543. trimmed: boolean;
  139544. /**
  139545. * ISpriteJSONSpriteFrame basic object of the source data
  139546. */
  139547. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139548. /**
  139549. * ISpriteJSONSpriteFrame basic object of the source data
  139550. */
  139551. sourceSize: ISpriteJSONSpriteSourceSize;
  139552. }
  139553. /**
  139554. * Defines the basic options interface of a JSON atlas.
  139555. */
  139556. export interface ISpriteJSONAtlas {
  139557. /**
  139558. * Array of objects that contain the frame data.
  139559. */
  139560. frames: Array<ISpriteJSONSprite>;
  139561. /**
  139562. * object basic object containing the sprite meta data.
  139563. */
  139564. meta?: object;
  139565. }
  139566. }
  139567. declare module BABYLON {
  139568. /** @hidden */
  139569. export var spriteMapPixelShader: {
  139570. name: string;
  139571. shader: string;
  139572. };
  139573. }
  139574. declare module BABYLON {
  139575. /** @hidden */
  139576. export var spriteMapVertexShader: {
  139577. name: string;
  139578. shader: string;
  139579. };
  139580. }
  139581. declare module BABYLON {
  139582. /**
  139583. * Defines the basic options interface of a SpriteMap
  139584. */
  139585. export interface ISpriteMapOptions {
  139586. /**
  139587. * Vector2 of the number of cells in the grid.
  139588. */
  139589. stageSize?: Vector2;
  139590. /**
  139591. * Vector2 of the size of the output plane in World Units.
  139592. */
  139593. outputSize?: Vector2;
  139594. /**
  139595. * Vector3 of the position of the output plane in World Units.
  139596. */
  139597. outputPosition?: Vector3;
  139598. /**
  139599. * Vector3 of the rotation of the output plane.
  139600. */
  139601. outputRotation?: Vector3;
  139602. /**
  139603. * number of layers that the system will reserve in resources.
  139604. */
  139605. layerCount?: number;
  139606. /**
  139607. * number of max animation frames a single cell will reserve in resources.
  139608. */
  139609. maxAnimationFrames?: number;
  139610. /**
  139611. * number cell index of the base tile when the system compiles.
  139612. */
  139613. baseTile?: number;
  139614. /**
  139615. * boolean flip the sprite after its been repositioned by the framing data.
  139616. */
  139617. flipU?: boolean;
  139618. /**
  139619. * Vector3 scalar of the global RGB values of the SpriteMap.
  139620. */
  139621. colorMultiply?: Vector3;
  139622. }
  139623. /**
  139624. * Defines the IDisposable interface in order to be cleanable from resources.
  139625. */
  139626. export interface ISpriteMap extends IDisposable {
  139627. /**
  139628. * String name of the SpriteMap.
  139629. */
  139630. name: string;
  139631. /**
  139632. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139633. */
  139634. atlasJSON: ISpriteJSONAtlas;
  139635. /**
  139636. * Texture of the SpriteMap.
  139637. */
  139638. spriteSheet: Texture;
  139639. /**
  139640. * The parameters to initialize the SpriteMap with.
  139641. */
  139642. options: ISpriteMapOptions;
  139643. }
  139644. /**
  139645. * Class used to manage a grid restricted sprite deployment on an Output plane.
  139646. */
  139647. export class SpriteMap implements ISpriteMap {
  139648. /** The Name of the spriteMap */
  139649. name: string;
  139650. /** The JSON file with the frame and meta data */
  139651. atlasJSON: ISpriteJSONAtlas;
  139652. /** The systems Sprite Sheet Texture */
  139653. spriteSheet: Texture;
  139654. /** Arguments passed with the Constructor */
  139655. options: ISpriteMapOptions;
  139656. /** Public Sprite Storage array, parsed from atlasJSON */
  139657. sprites: Array<ISpriteJSONSprite>;
  139658. /** Returns the Number of Sprites in the System */
  139659. get spriteCount(): number;
  139660. /** Returns the Position of Output Plane*/
  139661. get position(): Vector3;
  139662. /** Returns the Position of Output Plane*/
  139663. set position(v: Vector3);
  139664. /** Returns the Rotation of Output Plane*/
  139665. get rotation(): Vector3;
  139666. /** Returns the Rotation of Output Plane*/
  139667. set rotation(v: Vector3);
  139668. /** Sets the AnimationMap*/
  139669. get animationMap(): RawTexture;
  139670. /** Sets the AnimationMap*/
  139671. set animationMap(v: RawTexture);
  139672. /** Scene that the SpriteMap was created in */
  139673. private _scene;
  139674. /** Texture Buffer of Float32 that holds tile frame data*/
  139675. private _frameMap;
  139676. /** Texture Buffers of Float32 that holds tileMap data*/
  139677. private _tileMaps;
  139678. /** Texture Buffer of Float32 that holds Animation Data*/
  139679. private _animationMap;
  139680. /** Custom ShaderMaterial Central to the System*/
  139681. private _material;
  139682. /** Custom ShaderMaterial Central to the System*/
  139683. private _output;
  139684. /** Systems Time Ticker*/
  139685. private _time;
  139686. /**
  139687. * Creates a new SpriteMap
  139688. * @param name defines the SpriteMaps Name
  139689. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  139690. * @param spriteSheet is the Texture that the Sprites are on.
  139691. * @param options a basic deployment configuration
  139692. * @param scene The Scene that the map is deployed on
  139693. */
  139694. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  139695. /**
  139696. * Returns tileID location
  139697. * @returns Vector2 the cell position ID
  139698. */
  139699. getTileID(): Vector2;
  139700. /**
  139701. * Gets the UV location of the mouse over the SpriteMap.
  139702. * @returns Vector2 the UV position of the mouse interaction
  139703. */
  139704. getMousePosition(): Vector2;
  139705. /**
  139706. * Creates the "frame" texture Buffer
  139707. * -------------------------------------
  139708. * Structure of frames
  139709. * "filename": "Falling-Water-2.png",
  139710. * "frame": {"x":69,"y":103,"w":24,"h":32},
  139711. * "rotated": true,
  139712. * "trimmed": true,
  139713. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  139714. * "sourceSize": {"w":32,"h":32}
  139715. * @returns RawTexture of the frameMap
  139716. */
  139717. private _createFrameBuffer;
  139718. /**
  139719. * Creates the tileMap texture Buffer
  139720. * @param buffer normally and array of numbers, or a false to generate from scratch
  139721. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  139722. * @returns RawTexture of the tileMap
  139723. */
  139724. private _createTileBuffer;
  139725. /**
  139726. * Modifies the data of the tileMaps
  139727. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  139728. * @param pos is the iVector2 Coordinates of the Tile
  139729. * @param tile The SpriteIndex of the new Tile
  139730. */
  139731. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  139732. /**
  139733. * Creates the animationMap texture Buffer
  139734. * @param buffer normally and array of numbers, or a false to generate from scratch
  139735. * @returns RawTexture of the animationMap
  139736. */
  139737. private _createTileAnimationBuffer;
  139738. /**
  139739. * Modifies the data of the animationMap
  139740. * @param cellID is the Index of the Sprite
  139741. * @param _frame is the target Animation frame
  139742. * @param toCell is the Target Index of the next frame of the animation
  139743. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  139744. * @param speed is a global scalar of the time variable on the map.
  139745. */
  139746. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  139747. /**
  139748. * Exports the .tilemaps file
  139749. */
  139750. saveTileMaps(): void;
  139751. /**
  139752. * Imports the .tilemaps file
  139753. * @param url of the .tilemaps file
  139754. */
  139755. loadTileMaps(url: string): void;
  139756. /**
  139757. * Release associated resources
  139758. */
  139759. dispose(): void;
  139760. }
  139761. }
  139762. declare module BABYLON {
  139763. /**
  139764. * Class used to manage multiple sprites of different sizes on the same spritesheet
  139765. * @see http://doc.babylonjs.com/babylon101/sprites
  139766. */
  139767. export class SpritePackedManager extends SpriteManager {
  139768. /** defines the packed manager's name */
  139769. name: string;
  139770. /**
  139771. * Creates a new sprite manager from a packed sprite sheet
  139772. * @param name defines the manager's name
  139773. * @param imgUrl defines the sprite sheet url
  139774. * @param capacity defines the maximum allowed number of sprites
  139775. * @param scene defines the hosting scene
  139776. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  139777. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  139778. * @param samplingMode defines the smapling mode to use with spritesheet
  139779. * @param fromPacked set to true; do not alter
  139780. */
  139781. constructor(
  139782. /** defines the packed manager's name */
  139783. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  139784. }
  139785. }
  139786. declare module BABYLON {
  139787. /**
  139788. * Defines the list of states available for a task inside a AssetsManager
  139789. */
  139790. export enum AssetTaskState {
  139791. /**
  139792. * Initialization
  139793. */
  139794. INIT = 0,
  139795. /**
  139796. * Running
  139797. */
  139798. RUNNING = 1,
  139799. /**
  139800. * Done
  139801. */
  139802. DONE = 2,
  139803. /**
  139804. * Error
  139805. */
  139806. ERROR = 3
  139807. }
  139808. /**
  139809. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  139810. */
  139811. export abstract class AbstractAssetTask {
  139812. /**
  139813. * Task name
  139814. */ name: string;
  139815. /**
  139816. * Callback called when the task is successful
  139817. */
  139818. onSuccess: (task: any) => void;
  139819. /**
  139820. * Callback called when the task is not successful
  139821. */
  139822. onError: (task: any, message?: string, exception?: any) => void;
  139823. /**
  139824. * Creates a new AssetsManager
  139825. * @param name defines the name of the task
  139826. */
  139827. constructor(
  139828. /**
  139829. * Task name
  139830. */ name: string);
  139831. private _isCompleted;
  139832. private _taskState;
  139833. private _errorObject;
  139834. /**
  139835. * Get if the task is completed
  139836. */
  139837. get isCompleted(): boolean;
  139838. /**
  139839. * Gets the current state of the task
  139840. */
  139841. get taskState(): AssetTaskState;
  139842. /**
  139843. * Gets the current error object (if task is in error)
  139844. */
  139845. get errorObject(): {
  139846. message?: string;
  139847. exception?: any;
  139848. };
  139849. /**
  139850. * Internal only
  139851. * @hidden
  139852. */
  139853. _setErrorObject(message?: string, exception?: any): void;
  139854. /**
  139855. * Execute the current task
  139856. * @param scene defines the scene where you want your assets to be loaded
  139857. * @param onSuccess is a callback called when the task is successfully executed
  139858. * @param onError is a callback called if an error occurs
  139859. */
  139860. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139861. /**
  139862. * Execute the current task
  139863. * @param scene defines the scene where you want your assets to be loaded
  139864. * @param onSuccess is a callback called when the task is successfully executed
  139865. * @param onError is a callback called if an error occurs
  139866. */
  139867. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139868. /**
  139869. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  139870. * This can be used with failed tasks that have the reason for failure fixed.
  139871. */
  139872. reset(): void;
  139873. private onErrorCallback;
  139874. private onDoneCallback;
  139875. }
  139876. /**
  139877. * Define the interface used by progress events raised during assets loading
  139878. */
  139879. export interface IAssetsProgressEvent {
  139880. /**
  139881. * Defines the number of remaining tasks to process
  139882. */
  139883. remainingCount: number;
  139884. /**
  139885. * Defines the total number of tasks
  139886. */
  139887. totalCount: number;
  139888. /**
  139889. * Defines the task that was just processed
  139890. */
  139891. task: AbstractAssetTask;
  139892. }
  139893. /**
  139894. * Class used to share progress information about assets loading
  139895. */
  139896. export class AssetsProgressEvent implements IAssetsProgressEvent {
  139897. /**
  139898. * Defines the number of remaining tasks to process
  139899. */
  139900. remainingCount: number;
  139901. /**
  139902. * Defines the total number of tasks
  139903. */
  139904. totalCount: number;
  139905. /**
  139906. * Defines the task that was just processed
  139907. */
  139908. task: AbstractAssetTask;
  139909. /**
  139910. * Creates a AssetsProgressEvent
  139911. * @param remainingCount defines the number of remaining tasks to process
  139912. * @param totalCount defines the total number of tasks
  139913. * @param task defines the task that was just processed
  139914. */
  139915. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  139916. }
  139917. /**
  139918. * Define a task used by AssetsManager to load meshes
  139919. */
  139920. export class MeshAssetTask extends AbstractAssetTask {
  139921. /**
  139922. * Defines the name of the task
  139923. */
  139924. name: string;
  139925. /**
  139926. * Defines the list of mesh's names you want to load
  139927. */
  139928. meshesNames: any;
  139929. /**
  139930. * Defines the root url to use as a base to load your meshes and associated resources
  139931. */
  139932. rootUrl: string;
  139933. /**
  139934. * Defines the filename of the scene to load from
  139935. */
  139936. sceneFilename: string;
  139937. /**
  139938. * Gets the list of loaded meshes
  139939. */
  139940. loadedMeshes: Array<AbstractMesh>;
  139941. /**
  139942. * Gets the list of loaded particle systems
  139943. */
  139944. loadedParticleSystems: Array<IParticleSystem>;
  139945. /**
  139946. * Gets the list of loaded skeletons
  139947. */
  139948. loadedSkeletons: Array<Skeleton>;
  139949. /**
  139950. * Gets the list of loaded animation groups
  139951. */
  139952. loadedAnimationGroups: Array<AnimationGroup>;
  139953. /**
  139954. * Callback called when the task is successful
  139955. */
  139956. onSuccess: (task: MeshAssetTask) => void;
  139957. /**
  139958. * Callback called when the task is successful
  139959. */
  139960. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  139961. /**
  139962. * Creates a new MeshAssetTask
  139963. * @param name defines the name of the task
  139964. * @param meshesNames defines the list of mesh's names you want to load
  139965. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  139966. * @param sceneFilename defines the filename of the scene to load from
  139967. */
  139968. constructor(
  139969. /**
  139970. * Defines the name of the task
  139971. */
  139972. name: string,
  139973. /**
  139974. * Defines the list of mesh's names you want to load
  139975. */
  139976. meshesNames: any,
  139977. /**
  139978. * Defines the root url to use as a base to load your meshes and associated resources
  139979. */
  139980. rootUrl: string,
  139981. /**
  139982. * Defines the filename of the scene to load from
  139983. */
  139984. sceneFilename: string);
  139985. /**
  139986. * Execute the current task
  139987. * @param scene defines the scene where you want your assets to be loaded
  139988. * @param onSuccess is a callback called when the task is successfully executed
  139989. * @param onError is a callback called if an error occurs
  139990. */
  139991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139992. }
  139993. /**
  139994. * Define a task used by AssetsManager to load text content
  139995. */
  139996. export class TextFileAssetTask extends AbstractAssetTask {
  139997. /**
  139998. * Defines the name of the task
  139999. */
  140000. name: string;
  140001. /**
  140002. * Defines the location of the file to load
  140003. */
  140004. url: string;
  140005. /**
  140006. * Gets the loaded text string
  140007. */
  140008. text: string;
  140009. /**
  140010. * Callback called when the task is successful
  140011. */
  140012. onSuccess: (task: TextFileAssetTask) => void;
  140013. /**
  140014. * Callback called when the task is successful
  140015. */
  140016. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140017. /**
  140018. * Creates a new TextFileAssetTask object
  140019. * @param name defines the name of the task
  140020. * @param url defines the location of the file to load
  140021. */
  140022. constructor(
  140023. /**
  140024. * Defines the name of the task
  140025. */
  140026. name: string,
  140027. /**
  140028. * Defines the location of the file to load
  140029. */
  140030. url: string);
  140031. /**
  140032. * Execute the current task
  140033. * @param scene defines the scene where you want your assets to be loaded
  140034. * @param onSuccess is a callback called when the task is successfully executed
  140035. * @param onError is a callback called if an error occurs
  140036. */
  140037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140038. }
  140039. /**
  140040. * Define a task used by AssetsManager to load binary data
  140041. */
  140042. export class BinaryFileAssetTask extends AbstractAssetTask {
  140043. /**
  140044. * Defines the name of the task
  140045. */
  140046. name: string;
  140047. /**
  140048. * Defines the location of the file to load
  140049. */
  140050. url: string;
  140051. /**
  140052. * Gets the lodaded data (as an array buffer)
  140053. */
  140054. data: ArrayBuffer;
  140055. /**
  140056. * Callback called when the task is successful
  140057. */
  140058. onSuccess: (task: BinaryFileAssetTask) => void;
  140059. /**
  140060. * Callback called when the task is successful
  140061. */
  140062. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140063. /**
  140064. * Creates a new BinaryFileAssetTask object
  140065. * @param name defines the name of the new task
  140066. * @param url defines the location of the file to load
  140067. */
  140068. constructor(
  140069. /**
  140070. * Defines the name of the task
  140071. */
  140072. name: string,
  140073. /**
  140074. * Defines the location of the file to load
  140075. */
  140076. url: string);
  140077. /**
  140078. * Execute the current task
  140079. * @param scene defines the scene where you want your assets to be loaded
  140080. * @param onSuccess is a callback called when the task is successfully executed
  140081. * @param onError is a callback called if an error occurs
  140082. */
  140083. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140084. }
  140085. /**
  140086. * Define a task used by AssetsManager to load images
  140087. */
  140088. export class ImageAssetTask extends AbstractAssetTask {
  140089. /**
  140090. * Defines the name of the task
  140091. */
  140092. name: string;
  140093. /**
  140094. * Defines the location of the image to load
  140095. */
  140096. url: string;
  140097. /**
  140098. * Gets the loaded images
  140099. */
  140100. image: HTMLImageElement;
  140101. /**
  140102. * Callback called when the task is successful
  140103. */
  140104. onSuccess: (task: ImageAssetTask) => void;
  140105. /**
  140106. * Callback called when the task is successful
  140107. */
  140108. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140109. /**
  140110. * Creates a new ImageAssetTask
  140111. * @param name defines the name of the task
  140112. * @param url defines the location of the image to load
  140113. */
  140114. constructor(
  140115. /**
  140116. * Defines the name of the task
  140117. */
  140118. name: string,
  140119. /**
  140120. * Defines the location of the image to load
  140121. */
  140122. url: string);
  140123. /**
  140124. * Execute the current task
  140125. * @param scene defines the scene where you want your assets to be loaded
  140126. * @param onSuccess is a callback called when the task is successfully executed
  140127. * @param onError is a callback called if an error occurs
  140128. */
  140129. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140130. }
  140131. /**
  140132. * Defines the interface used by texture loading tasks
  140133. */
  140134. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140135. /**
  140136. * Gets the loaded texture
  140137. */
  140138. texture: TEX;
  140139. }
  140140. /**
  140141. * Define a task used by AssetsManager to load 2D textures
  140142. */
  140143. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140144. /**
  140145. * Defines the name of the task
  140146. */
  140147. name: string;
  140148. /**
  140149. * Defines the location of the file to load
  140150. */
  140151. url: string;
  140152. /**
  140153. * Defines if mipmap should not be generated (default is false)
  140154. */
  140155. noMipmap?: boolean | undefined;
  140156. /**
  140157. * Defines if texture must be inverted on Y axis (default is false)
  140158. */
  140159. invertY?: boolean | undefined;
  140160. /**
  140161. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140162. */
  140163. samplingMode: number;
  140164. /**
  140165. * Gets the loaded texture
  140166. */
  140167. texture: Texture;
  140168. /**
  140169. * Callback called when the task is successful
  140170. */
  140171. onSuccess: (task: TextureAssetTask) => void;
  140172. /**
  140173. * Callback called when the task is successful
  140174. */
  140175. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140176. /**
  140177. * Creates a new TextureAssetTask object
  140178. * @param name defines the name of the task
  140179. * @param url defines the location of the file to load
  140180. * @param noMipmap defines if mipmap should not be generated (default is false)
  140181. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140182. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140183. */
  140184. constructor(
  140185. /**
  140186. * Defines the name of the task
  140187. */
  140188. name: string,
  140189. /**
  140190. * Defines the location of the file to load
  140191. */
  140192. url: string,
  140193. /**
  140194. * Defines if mipmap should not be generated (default is false)
  140195. */
  140196. noMipmap?: boolean | undefined,
  140197. /**
  140198. * Defines if texture must be inverted on Y axis (default is false)
  140199. */
  140200. invertY?: boolean | undefined,
  140201. /**
  140202. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140203. */
  140204. samplingMode?: number);
  140205. /**
  140206. * Execute the current task
  140207. * @param scene defines the scene where you want your assets to be loaded
  140208. * @param onSuccess is a callback called when the task is successfully executed
  140209. * @param onError is a callback called if an error occurs
  140210. */
  140211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140212. }
  140213. /**
  140214. * Define a task used by AssetsManager to load cube textures
  140215. */
  140216. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140217. /**
  140218. * Defines the name of the task
  140219. */
  140220. name: string;
  140221. /**
  140222. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140223. */
  140224. url: string;
  140225. /**
  140226. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140227. */
  140228. extensions?: string[] | undefined;
  140229. /**
  140230. * Defines if mipmaps should not be generated (default is false)
  140231. */
  140232. noMipmap?: boolean | undefined;
  140233. /**
  140234. * Defines the explicit list of files (undefined by default)
  140235. */
  140236. files?: string[] | undefined;
  140237. /**
  140238. * Gets the loaded texture
  140239. */
  140240. texture: CubeTexture;
  140241. /**
  140242. * Callback called when the task is successful
  140243. */
  140244. onSuccess: (task: CubeTextureAssetTask) => void;
  140245. /**
  140246. * Callback called when the task is successful
  140247. */
  140248. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140249. /**
  140250. * Creates a new CubeTextureAssetTask
  140251. * @param name defines the name of the task
  140252. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140253. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140254. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140255. * @param files defines the explicit list of files (undefined by default)
  140256. */
  140257. constructor(
  140258. /**
  140259. * Defines the name of the task
  140260. */
  140261. name: string,
  140262. /**
  140263. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140264. */
  140265. url: string,
  140266. /**
  140267. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140268. */
  140269. extensions?: string[] | undefined,
  140270. /**
  140271. * Defines if mipmaps should not be generated (default is false)
  140272. */
  140273. noMipmap?: boolean | undefined,
  140274. /**
  140275. * Defines the explicit list of files (undefined by default)
  140276. */
  140277. files?: string[] | undefined);
  140278. /**
  140279. * Execute the current task
  140280. * @param scene defines the scene where you want your assets to be loaded
  140281. * @param onSuccess is a callback called when the task is successfully executed
  140282. * @param onError is a callback called if an error occurs
  140283. */
  140284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140285. }
  140286. /**
  140287. * Define a task used by AssetsManager to load HDR cube textures
  140288. */
  140289. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140290. /**
  140291. * Defines the name of the task
  140292. */
  140293. name: string;
  140294. /**
  140295. * Defines the location of the file to load
  140296. */
  140297. url: string;
  140298. /**
  140299. * Defines the desired size (the more it increases the longer the generation will be)
  140300. */
  140301. size: number;
  140302. /**
  140303. * Defines if mipmaps should not be generated (default is false)
  140304. */
  140305. noMipmap: boolean;
  140306. /**
  140307. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140308. */
  140309. generateHarmonics: boolean;
  140310. /**
  140311. * 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)
  140312. */
  140313. gammaSpace: boolean;
  140314. /**
  140315. * Internal Use Only
  140316. */
  140317. reserved: boolean;
  140318. /**
  140319. * Gets the loaded texture
  140320. */
  140321. texture: HDRCubeTexture;
  140322. /**
  140323. * Callback called when the task is successful
  140324. */
  140325. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140326. /**
  140327. * Callback called when the task is successful
  140328. */
  140329. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140330. /**
  140331. * Creates a new HDRCubeTextureAssetTask object
  140332. * @param name defines the name of the task
  140333. * @param url defines the location of the file to load
  140334. * @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.
  140335. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140336. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140337. * @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)
  140338. * @param reserved Internal use only
  140339. */
  140340. constructor(
  140341. /**
  140342. * Defines the name of the task
  140343. */
  140344. name: string,
  140345. /**
  140346. * Defines the location of the file to load
  140347. */
  140348. url: string,
  140349. /**
  140350. * Defines the desired size (the more it increases the longer the generation will be)
  140351. */
  140352. size: number,
  140353. /**
  140354. * Defines if mipmaps should not be generated (default is false)
  140355. */
  140356. noMipmap?: boolean,
  140357. /**
  140358. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140359. */
  140360. generateHarmonics?: boolean,
  140361. /**
  140362. * 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)
  140363. */
  140364. gammaSpace?: boolean,
  140365. /**
  140366. * Internal Use Only
  140367. */
  140368. reserved?: boolean);
  140369. /**
  140370. * Execute the current task
  140371. * @param scene defines the scene where you want your assets to be loaded
  140372. * @param onSuccess is a callback called when the task is successfully executed
  140373. * @param onError is a callback called if an error occurs
  140374. */
  140375. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140376. }
  140377. /**
  140378. * Define a task used by AssetsManager to load Equirectangular cube textures
  140379. */
  140380. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140381. /**
  140382. * Defines the name of the task
  140383. */
  140384. name: string;
  140385. /**
  140386. * Defines the location of the file to load
  140387. */
  140388. url: string;
  140389. /**
  140390. * Defines the desired size (the more it increases the longer the generation will be)
  140391. */
  140392. size: number;
  140393. /**
  140394. * Defines if mipmaps should not be generated (default is false)
  140395. */
  140396. noMipmap: boolean;
  140397. /**
  140398. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140399. * but the standard material would require them in Gamma space) (default is true)
  140400. */
  140401. gammaSpace: boolean;
  140402. /**
  140403. * Gets the loaded texture
  140404. */
  140405. texture: EquiRectangularCubeTexture;
  140406. /**
  140407. * Callback called when the task is successful
  140408. */
  140409. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140410. /**
  140411. * Callback called when the task is successful
  140412. */
  140413. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140414. /**
  140415. * Creates a new EquiRectangularCubeTextureAssetTask object
  140416. * @param name defines the name of the task
  140417. * @param url defines the location of the file to load
  140418. * @param size defines the desired size (the more it increases the longer the generation will be)
  140419. * If the size is omitted this implies you are using a preprocessed cubemap.
  140420. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140421. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140422. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140423. * (default is true)
  140424. */
  140425. constructor(
  140426. /**
  140427. * Defines the name of the task
  140428. */
  140429. name: string,
  140430. /**
  140431. * Defines the location of the file to load
  140432. */
  140433. url: string,
  140434. /**
  140435. * Defines the desired size (the more it increases the longer the generation will be)
  140436. */
  140437. size: number,
  140438. /**
  140439. * Defines if mipmaps should not be generated (default is false)
  140440. */
  140441. noMipmap?: boolean,
  140442. /**
  140443. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140444. * but the standard material would require them in Gamma space) (default is true)
  140445. */
  140446. gammaSpace?: boolean);
  140447. /**
  140448. * Execute the current task
  140449. * @param scene defines the scene where you want your assets to be loaded
  140450. * @param onSuccess is a callback called when the task is successfully executed
  140451. * @param onError is a callback called if an error occurs
  140452. */
  140453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140454. }
  140455. /**
  140456. * This class can be used to easily import assets into a scene
  140457. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140458. */
  140459. export class AssetsManager {
  140460. private _scene;
  140461. private _isLoading;
  140462. protected _tasks: AbstractAssetTask[];
  140463. protected _waitingTasksCount: number;
  140464. protected _totalTasksCount: number;
  140465. /**
  140466. * Callback called when all tasks are processed
  140467. */
  140468. onFinish: (tasks: AbstractAssetTask[]) => void;
  140469. /**
  140470. * Callback called when a task is successful
  140471. */
  140472. onTaskSuccess: (task: AbstractAssetTask) => void;
  140473. /**
  140474. * Callback called when a task had an error
  140475. */
  140476. onTaskError: (task: AbstractAssetTask) => void;
  140477. /**
  140478. * Callback called when a task is done (whatever the result is)
  140479. */
  140480. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140481. /**
  140482. * Observable called when all tasks are processed
  140483. */
  140484. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140485. /**
  140486. * Observable called when a task had an error
  140487. */
  140488. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140489. /**
  140490. * Observable called when all tasks were executed
  140491. */
  140492. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140493. /**
  140494. * Observable called when a task is done (whatever the result is)
  140495. */
  140496. onProgressObservable: Observable<IAssetsProgressEvent>;
  140497. /**
  140498. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140499. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140500. */
  140501. useDefaultLoadingScreen: boolean;
  140502. /**
  140503. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140504. * when all assets have been downloaded.
  140505. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140506. */
  140507. autoHideLoadingUI: boolean;
  140508. /**
  140509. * Creates a new AssetsManager
  140510. * @param scene defines the scene to work on
  140511. */
  140512. constructor(scene: Scene);
  140513. /**
  140514. * Add a MeshAssetTask to the list of active tasks
  140515. * @param taskName defines the name of the new task
  140516. * @param meshesNames defines the name of meshes to load
  140517. * @param rootUrl defines the root url to use to locate files
  140518. * @param sceneFilename defines the filename of the scene file
  140519. * @returns a new MeshAssetTask object
  140520. */
  140521. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140522. /**
  140523. * Add a TextFileAssetTask to the list of active tasks
  140524. * @param taskName defines the name of the new task
  140525. * @param url defines the url of the file to load
  140526. * @returns a new TextFileAssetTask object
  140527. */
  140528. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140529. /**
  140530. * Add a BinaryFileAssetTask to the list of active tasks
  140531. * @param taskName defines the name of the new task
  140532. * @param url defines the url of the file to load
  140533. * @returns a new BinaryFileAssetTask object
  140534. */
  140535. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140536. /**
  140537. * Add a ImageAssetTask to the list of active tasks
  140538. * @param taskName defines the name of the new task
  140539. * @param url defines the url of the file to load
  140540. * @returns a new ImageAssetTask object
  140541. */
  140542. addImageTask(taskName: string, url: string): ImageAssetTask;
  140543. /**
  140544. * Add a TextureAssetTask to the list of active tasks
  140545. * @param taskName defines the name of the new task
  140546. * @param url defines the url of the file to load
  140547. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140548. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140549. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140550. * @returns a new TextureAssetTask object
  140551. */
  140552. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140553. /**
  140554. * Add a CubeTextureAssetTask to the list of active tasks
  140555. * @param taskName defines the name of the new task
  140556. * @param url defines the url of the file to load
  140557. * @param extensions defines the extension to use to load the cube map (can be null)
  140558. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140559. * @param files defines the list of files to load (can be null)
  140560. * @returns a new CubeTextureAssetTask object
  140561. */
  140562. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140563. /**
  140564. *
  140565. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140566. * @param taskName defines the name of the new task
  140567. * @param url defines the url of the file to load
  140568. * @param size defines the size you want for the cubemap (can be null)
  140569. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140570. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140571. * @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)
  140572. * @param reserved Internal use only
  140573. * @returns a new HDRCubeTextureAssetTask object
  140574. */
  140575. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140576. /**
  140577. *
  140578. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140579. * @param taskName defines the name of the new task
  140580. * @param url defines the url of the file to load
  140581. * @param size defines the size you want for the cubemap (can be null)
  140582. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140583. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140584. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140585. * @returns a new EquiRectangularCubeTextureAssetTask object
  140586. */
  140587. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140588. /**
  140589. * Remove a task from the assets manager.
  140590. * @param task the task to remove
  140591. */
  140592. removeTask(task: AbstractAssetTask): void;
  140593. private _decreaseWaitingTasksCount;
  140594. private _runTask;
  140595. /**
  140596. * Reset the AssetsManager and remove all tasks
  140597. * @return the current instance of the AssetsManager
  140598. */
  140599. reset(): AssetsManager;
  140600. /**
  140601. * Start the loading process
  140602. * @return the current instance of the AssetsManager
  140603. */
  140604. load(): AssetsManager;
  140605. /**
  140606. * Start the loading process as an async operation
  140607. * @return a promise returning the list of failed tasks
  140608. */
  140609. loadAsync(): Promise<void>;
  140610. }
  140611. }
  140612. declare module BABYLON {
  140613. /**
  140614. * Wrapper class for promise with external resolve and reject.
  140615. */
  140616. export class Deferred<T> {
  140617. /**
  140618. * The promise associated with this deferred object.
  140619. */
  140620. readonly promise: Promise<T>;
  140621. private _resolve;
  140622. private _reject;
  140623. /**
  140624. * The resolve method of the promise associated with this deferred object.
  140625. */
  140626. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140627. /**
  140628. * The reject method of the promise associated with this deferred object.
  140629. */
  140630. get reject(): (reason?: any) => void;
  140631. /**
  140632. * Constructor for this deferred object.
  140633. */
  140634. constructor();
  140635. }
  140636. }
  140637. declare module BABYLON {
  140638. /**
  140639. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  140640. */
  140641. export class MeshExploder {
  140642. private _centerMesh;
  140643. private _meshes;
  140644. private _meshesOrigins;
  140645. private _toCenterVectors;
  140646. private _scaledDirection;
  140647. private _newPosition;
  140648. private _centerPosition;
  140649. /**
  140650. * Explodes meshes from a center mesh.
  140651. * @param meshes The meshes to explode.
  140652. * @param centerMesh The mesh to be center of explosion.
  140653. */
  140654. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  140655. private _setCenterMesh;
  140656. /**
  140657. * Get class name
  140658. * @returns "MeshExploder"
  140659. */
  140660. getClassName(): string;
  140661. /**
  140662. * "Exploded meshes"
  140663. * @returns Array of meshes with the centerMesh at index 0.
  140664. */
  140665. getMeshes(): Array<Mesh>;
  140666. /**
  140667. * Explodes meshes giving a specific direction
  140668. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  140669. */
  140670. explode(direction?: number): void;
  140671. }
  140672. }
  140673. declare module BABYLON {
  140674. /**
  140675. * Class used to help managing file picking and drag'n'drop
  140676. */
  140677. export class FilesInput {
  140678. /**
  140679. * List of files ready to be loaded
  140680. */
  140681. static get FilesToLoad(): {
  140682. [key: string]: File;
  140683. };
  140684. /**
  140685. * Callback called when a file is processed
  140686. */
  140687. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  140688. private _engine;
  140689. private _currentScene;
  140690. private _sceneLoadedCallback;
  140691. private _progressCallback;
  140692. private _additionalRenderLoopLogicCallback;
  140693. private _textureLoadingCallback;
  140694. private _startingProcessingFilesCallback;
  140695. private _onReloadCallback;
  140696. private _errorCallback;
  140697. private _elementToMonitor;
  140698. private _sceneFileToLoad;
  140699. private _filesToLoad;
  140700. /**
  140701. * Creates a new FilesInput
  140702. * @param engine defines the rendering engine
  140703. * @param scene defines the hosting scene
  140704. * @param sceneLoadedCallback callback called when scene is loaded
  140705. * @param progressCallback callback called to track progress
  140706. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  140707. * @param textureLoadingCallback callback called when a texture is loading
  140708. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  140709. * @param onReloadCallback callback called when a reload is requested
  140710. * @param errorCallback callback call if an error occurs
  140711. */
  140712. 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);
  140713. private _dragEnterHandler;
  140714. private _dragOverHandler;
  140715. private _dropHandler;
  140716. /**
  140717. * Calls this function to listen to drag'n'drop events on a specific DOM element
  140718. * @param elementToMonitor defines the DOM element to track
  140719. */
  140720. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  140721. /**
  140722. * Release all associated resources
  140723. */
  140724. dispose(): void;
  140725. private renderFunction;
  140726. private drag;
  140727. private drop;
  140728. private _traverseFolder;
  140729. private _processFiles;
  140730. /**
  140731. * Load files from a drop event
  140732. * @param event defines the drop event to use as source
  140733. */
  140734. loadFiles(event: any): void;
  140735. private _processReload;
  140736. /**
  140737. * Reload the current scene from the loaded files
  140738. */
  140739. reload(): void;
  140740. }
  140741. }
  140742. declare module BABYLON {
  140743. /**
  140744. * Defines the root class used to create scene optimization to use with SceneOptimizer
  140745. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140746. */
  140747. export class SceneOptimization {
  140748. /**
  140749. * Defines the priority of this optimization (0 by default which means first in the list)
  140750. */
  140751. priority: number;
  140752. /**
  140753. * Gets a string describing the action executed by the current optimization
  140754. * @returns description string
  140755. */
  140756. getDescription(): string;
  140757. /**
  140758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140759. * @param scene defines the current scene where to apply this optimization
  140760. * @param optimizer defines the current optimizer
  140761. * @returns true if everything that can be done was applied
  140762. */
  140763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140764. /**
  140765. * Creates the SceneOptimization object
  140766. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140767. * @param desc defines the description associated with the optimization
  140768. */
  140769. constructor(
  140770. /**
  140771. * Defines the priority of this optimization (0 by default which means first in the list)
  140772. */
  140773. priority?: number);
  140774. }
  140775. /**
  140776. * Defines an optimization used to reduce the size of render target textures
  140777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140778. */
  140779. export class TextureOptimization extends SceneOptimization {
  140780. /**
  140781. * Defines the priority of this optimization (0 by default which means first in the list)
  140782. */
  140783. priority: number;
  140784. /**
  140785. * 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
  140786. */
  140787. maximumSize: number;
  140788. /**
  140789. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140790. */
  140791. step: number;
  140792. /**
  140793. * Gets a string describing the action executed by the current optimization
  140794. * @returns description string
  140795. */
  140796. getDescription(): string;
  140797. /**
  140798. * Creates the TextureOptimization object
  140799. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140800. * @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
  140801. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140802. */
  140803. constructor(
  140804. /**
  140805. * Defines the priority of this optimization (0 by default which means first in the list)
  140806. */
  140807. priority?: number,
  140808. /**
  140809. * 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
  140810. */
  140811. maximumSize?: number,
  140812. /**
  140813. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140814. */
  140815. step?: number);
  140816. /**
  140817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140818. * @param scene defines the current scene where to apply this optimization
  140819. * @param optimizer defines the current optimizer
  140820. * @returns true if everything that can be done was applied
  140821. */
  140822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140823. }
  140824. /**
  140825. * Defines an optimization used to increase or decrease the rendering resolution
  140826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140827. */
  140828. export class HardwareScalingOptimization extends SceneOptimization {
  140829. /**
  140830. * Defines the priority of this optimization (0 by default which means first in the list)
  140831. */
  140832. priority: number;
  140833. /**
  140834. * Defines the maximum scale to use (2 by default)
  140835. */
  140836. maximumScale: number;
  140837. /**
  140838. * Defines the step to use between two passes (0.5 by default)
  140839. */
  140840. step: number;
  140841. private _currentScale;
  140842. private _directionOffset;
  140843. /**
  140844. * Gets a string describing the action executed by the current optimization
  140845. * @return description string
  140846. */
  140847. getDescription(): string;
  140848. /**
  140849. * Creates the HardwareScalingOptimization object
  140850. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140851. * @param maximumScale defines the maximum scale to use (2 by default)
  140852. * @param step defines the step to use between two passes (0.5 by default)
  140853. */
  140854. constructor(
  140855. /**
  140856. * Defines the priority of this optimization (0 by default which means first in the list)
  140857. */
  140858. priority?: number,
  140859. /**
  140860. * Defines the maximum scale to use (2 by default)
  140861. */
  140862. maximumScale?: number,
  140863. /**
  140864. * Defines the step to use between two passes (0.5 by default)
  140865. */
  140866. step?: number);
  140867. /**
  140868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140869. * @param scene defines the current scene where to apply this optimization
  140870. * @param optimizer defines the current optimizer
  140871. * @returns true if everything that can be done was applied
  140872. */
  140873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140874. }
  140875. /**
  140876. * Defines an optimization used to remove shadows
  140877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140878. */
  140879. export class ShadowsOptimization extends SceneOptimization {
  140880. /**
  140881. * Gets a string describing the action executed by the current optimization
  140882. * @return description string
  140883. */
  140884. getDescription(): string;
  140885. /**
  140886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140887. * @param scene defines the current scene where to apply this optimization
  140888. * @param optimizer defines the current optimizer
  140889. * @returns true if everything that can be done was applied
  140890. */
  140891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140892. }
  140893. /**
  140894. * Defines an optimization used to turn post-processes off
  140895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140896. */
  140897. export class PostProcessesOptimization extends SceneOptimization {
  140898. /**
  140899. * Gets a string describing the action executed by the current optimization
  140900. * @return description string
  140901. */
  140902. getDescription(): string;
  140903. /**
  140904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140905. * @param scene defines the current scene where to apply this optimization
  140906. * @param optimizer defines the current optimizer
  140907. * @returns true if everything that can be done was applied
  140908. */
  140909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140910. }
  140911. /**
  140912. * Defines an optimization used to turn lens flares off
  140913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140914. */
  140915. export class LensFlaresOptimization extends SceneOptimization {
  140916. /**
  140917. * Gets a string describing the action executed by the current optimization
  140918. * @return description string
  140919. */
  140920. getDescription(): string;
  140921. /**
  140922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140923. * @param scene defines the current scene where to apply this optimization
  140924. * @param optimizer defines the current optimizer
  140925. * @returns true if everything that can be done was applied
  140926. */
  140927. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140928. }
  140929. /**
  140930. * Defines an optimization based on user defined callback.
  140931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140932. */
  140933. export class CustomOptimization extends SceneOptimization {
  140934. /**
  140935. * Callback called to apply the custom optimization.
  140936. */
  140937. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  140938. /**
  140939. * Callback called to get custom description
  140940. */
  140941. onGetDescription: () => string;
  140942. /**
  140943. * Gets a string describing the action executed by the current optimization
  140944. * @returns description string
  140945. */
  140946. getDescription(): string;
  140947. /**
  140948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140949. * @param scene defines the current scene where to apply this optimization
  140950. * @param optimizer defines the current optimizer
  140951. * @returns true if everything that can be done was applied
  140952. */
  140953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140954. }
  140955. /**
  140956. * Defines an optimization used to turn particles off
  140957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140958. */
  140959. export class ParticlesOptimization extends SceneOptimization {
  140960. /**
  140961. * Gets a string describing the action executed by the current optimization
  140962. * @return description string
  140963. */
  140964. getDescription(): string;
  140965. /**
  140966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140967. * @param scene defines the current scene where to apply this optimization
  140968. * @param optimizer defines the current optimizer
  140969. * @returns true if everything that can be done was applied
  140970. */
  140971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140972. }
  140973. /**
  140974. * Defines an optimization used to turn render targets off
  140975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140976. */
  140977. export class RenderTargetsOptimization extends SceneOptimization {
  140978. /**
  140979. * Gets a string describing the action executed by the current optimization
  140980. * @return description string
  140981. */
  140982. getDescription(): string;
  140983. /**
  140984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140985. * @param scene defines the current scene where to apply this optimization
  140986. * @param optimizer defines the current optimizer
  140987. * @returns true if everything that can be done was applied
  140988. */
  140989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140990. }
  140991. /**
  140992. * Defines an optimization used to merge meshes with compatible materials
  140993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140994. */
  140995. export class MergeMeshesOptimization extends SceneOptimization {
  140996. private static _UpdateSelectionTree;
  140997. /**
  140998. * Gets or sets a boolean which defines if optimization octree has to be updated
  140999. */
  141000. static get UpdateSelectionTree(): boolean;
  141001. /**
  141002. * Gets or sets a boolean which defines if optimization octree has to be updated
  141003. */
  141004. static set UpdateSelectionTree(value: boolean);
  141005. /**
  141006. * Gets a string describing the action executed by the current optimization
  141007. * @return description string
  141008. */
  141009. getDescription(): string;
  141010. private _canBeMerged;
  141011. /**
  141012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141013. * @param scene defines the current scene where to apply this optimization
  141014. * @param optimizer defines the current optimizer
  141015. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141016. * @returns true if everything that can be done was applied
  141017. */
  141018. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141019. }
  141020. /**
  141021. * Defines a list of options used by SceneOptimizer
  141022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141023. */
  141024. export class SceneOptimizerOptions {
  141025. /**
  141026. * Defines the target frame rate to reach (60 by default)
  141027. */
  141028. targetFrameRate: number;
  141029. /**
  141030. * Defines the interval between two checkes (2000ms by default)
  141031. */
  141032. trackerDuration: number;
  141033. /**
  141034. * Gets the list of optimizations to apply
  141035. */
  141036. optimizations: SceneOptimization[];
  141037. /**
  141038. * Creates a new list of options used by SceneOptimizer
  141039. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141040. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141041. */
  141042. constructor(
  141043. /**
  141044. * Defines the target frame rate to reach (60 by default)
  141045. */
  141046. targetFrameRate?: number,
  141047. /**
  141048. * Defines the interval between two checkes (2000ms by default)
  141049. */
  141050. trackerDuration?: number);
  141051. /**
  141052. * Add a new optimization
  141053. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141054. * @returns the current SceneOptimizerOptions
  141055. */
  141056. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141057. /**
  141058. * Add a new custom optimization
  141059. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141060. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141061. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141062. * @returns the current SceneOptimizerOptions
  141063. */
  141064. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141065. /**
  141066. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141067. * @param targetFrameRate defines the target frame rate (60 by default)
  141068. * @returns a SceneOptimizerOptions object
  141069. */
  141070. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141071. /**
  141072. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141073. * @param targetFrameRate defines the target frame rate (60 by default)
  141074. * @returns a SceneOptimizerOptions object
  141075. */
  141076. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141077. /**
  141078. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141079. * @param targetFrameRate defines the target frame rate (60 by default)
  141080. * @returns a SceneOptimizerOptions object
  141081. */
  141082. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141083. }
  141084. /**
  141085. * Class used to run optimizations in order to reach a target frame rate
  141086. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141087. */
  141088. export class SceneOptimizer implements IDisposable {
  141089. private _isRunning;
  141090. private _options;
  141091. private _scene;
  141092. private _currentPriorityLevel;
  141093. private _targetFrameRate;
  141094. private _trackerDuration;
  141095. private _currentFrameRate;
  141096. private _sceneDisposeObserver;
  141097. private _improvementMode;
  141098. /**
  141099. * Defines an observable called when the optimizer reaches the target frame rate
  141100. */
  141101. onSuccessObservable: Observable<SceneOptimizer>;
  141102. /**
  141103. * Defines an observable called when the optimizer enables an optimization
  141104. */
  141105. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141106. /**
  141107. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141108. */
  141109. onFailureObservable: Observable<SceneOptimizer>;
  141110. /**
  141111. * Gets a boolean indicating if the optimizer is in improvement mode
  141112. */
  141113. get isInImprovementMode(): boolean;
  141114. /**
  141115. * Gets the current priority level (0 at start)
  141116. */
  141117. get currentPriorityLevel(): number;
  141118. /**
  141119. * Gets the current frame rate checked by the SceneOptimizer
  141120. */
  141121. get currentFrameRate(): number;
  141122. /**
  141123. * Gets or sets the current target frame rate (60 by default)
  141124. */
  141125. get targetFrameRate(): number;
  141126. /**
  141127. * Gets or sets the current target frame rate (60 by default)
  141128. */
  141129. set targetFrameRate(value: number);
  141130. /**
  141131. * Gets or sets the current interval between two checks (every 2000ms by default)
  141132. */
  141133. get trackerDuration(): number;
  141134. /**
  141135. * Gets or sets the current interval between two checks (every 2000ms by default)
  141136. */
  141137. set trackerDuration(value: number);
  141138. /**
  141139. * Gets the list of active optimizations
  141140. */
  141141. get optimizations(): SceneOptimization[];
  141142. /**
  141143. * Creates a new SceneOptimizer
  141144. * @param scene defines the scene to work on
  141145. * @param options defines the options to use with the SceneOptimizer
  141146. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141147. * @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)
  141148. */
  141149. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141150. /**
  141151. * Stops the current optimizer
  141152. */
  141153. stop(): void;
  141154. /**
  141155. * Reset the optimizer to initial step (current priority level = 0)
  141156. */
  141157. reset(): void;
  141158. /**
  141159. * Start the optimizer. By default it will try to reach a specific framerate
  141160. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141161. */
  141162. start(): void;
  141163. private _checkCurrentState;
  141164. /**
  141165. * Release all resources
  141166. */
  141167. dispose(): void;
  141168. /**
  141169. * Helper function to create a SceneOptimizer with one single line of code
  141170. * @param scene defines the scene to work on
  141171. * @param options defines the options to use with the SceneOptimizer
  141172. * @param onSuccess defines a callback to call on success
  141173. * @param onFailure defines a callback to call on failure
  141174. * @returns the new SceneOptimizer object
  141175. */
  141176. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141177. }
  141178. }
  141179. declare module BABYLON {
  141180. /**
  141181. * Class used to serialize a scene into a string
  141182. */
  141183. export class SceneSerializer {
  141184. /**
  141185. * Clear cache used by a previous serialization
  141186. */
  141187. static ClearCache(): void;
  141188. /**
  141189. * Serialize a scene into a JSON compatible object
  141190. * @param scene defines the scene to serialize
  141191. * @returns a JSON compatible object
  141192. */
  141193. static Serialize(scene: Scene): any;
  141194. /**
  141195. * Serialize a mesh into a JSON compatible object
  141196. * @param toSerialize defines the mesh to serialize
  141197. * @param withParents defines if parents must be serialized as well
  141198. * @param withChildren defines if children must be serialized as well
  141199. * @returns a JSON compatible object
  141200. */
  141201. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141202. }
  141203. }
  141204. declare module BABYLON {
  141205. /**
  141206. * Class used to host texture specific utilities
  141207. */
  141208. export class TextureTools {
  141209. /**
  141210. * Uses the GPU to create a copy texture rescaled at a given size
  141211. * @param texture Texture to copy from
  141212. * @param width defines the desired width
  141213. * @param height defines the desired height
  141214. * @param useBilinearMode defines if bilinear mode has to be used
  141215. * @return the generated texture
  141216. */
  141217. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141218. }
  141219. }
  141220. declare module BABYLON {
  141221. /**
  141222. * This represents the different options available for the video capture.
  141223. */
  141224. export interface VideoRecorderOptions {
  141225. /** Defines the mime type of the video. */
  141226. mimeType: string;
  141227. /** Defines the FPS the video should be recorded at. */
  141228. fps: number;
  141229. /** Defines the chunk size for the recording data. */
  141230. recordChunckSize: number;
  141231. /** The audio tracks to attach to the recording. */
  141232. audioTracks?: MediaStreamTrack[];
  141233. }
  141234. /**
  141235. * This can help with recording videos from BabylonJS.
  141236. * This is based on the available WebRTC functionalities of the browser.
  141237. *
  141238. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141239. */
  141240. export class VideoRecorder {
  141241. private static readonly _defaultOptions;
  141242. /**
  141243. * Returns whether or not the VideoRecorder is available in your browser.
  141244. * @param engine Defines the Babylon Engine.
  141245. * @returns true if supported otherwise false.
  141246. */
  141247. static IsSupported(engine: Engine): boolean;
  141248. private readonly _options;
  141249. private _canvas;
  141250. private _mediaRecorder;
  141251. private _recordedChunks;
  141252. private _fileName;
  141253. private _resolve;
  141254. private _reject;
  141255. /**
  141256. * True when a recording is already in progress.
  141257. */
  141258. get isRecording(): boolean;
  141259. /**
  141260. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141261. * @param engine Defines the BabylonJS Engine you wish to record.
  141262. * @param options Defines options that can be used to customize the capture.
  141263. */
  141264. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141265. /**
  141266. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141267. */
  141268. stopRecording(): void;
  141269. /**
  141270. * Starts recording the canvas for a max duration specified in parameters.
  141271. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141272. * If null no automatic download will start and you can rely on the promise to get the data back.
  141273. * @param maxDuration Defines the maximum recording time in seconds.
  141274. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141275. * @return A promise callback at the end of the recording with the video data in Blob.
  141276. */
  141277. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141278. /**
  141279. * Releases internal resources used during the recording.
  141280. */
  141281. dispose(): void;
  141282. private _handleDataAvailable;
  141283. private _handleError;
  141284. private _handleStop;
  141285. }
  141286. }
  141287. declare module BABYLON {
  141288. /**
  141289. * Class containing a set of static utilities functions for screenshots
  141290. */
  141291. export class ScreenshotTools {
  141292. /**
  141293. * Captures a screenshot of the current rendering
  141294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141295. * @param engine defines the rendering engine
  141296. * @param camera defines the source camera
  141297. * @param size This parameter can be set to a single number or to an object with the
  141298. * following (optional) properties: precision, width, height. If a single number is passed,
  141299. * it will be used for both width and height. If an object is passed, the screenshot size
  141300. * will be derived from the parameters. The precision property is a multiplier allowing
  141301. * rendering at a higher or lower resolution
  141302. * @param successCallback defines the callback receives a single parameter which contains the
  141303. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141304. * src parameter of an <img> to display it
  141305. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141306. * Check your browser for supported MIME types
  141307. */
  141308. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141309. /**
  141310. * Captures a screenshot of the current rendering
  141311. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141312. * @param engine defines the rendering engine
  141313. * @param camera defines the source camera
  141314. * @param size This parameter can be set to a single number or to an object with the
  141315. * following (optional) properties: precision, width, height. If a single number is passed,
  141316. * it will be used for both width and height. If an object is passed, the screenshot size
  141317. * will be derived from the parameters. The precision property is a multiplier allowing
  141318. * rendering at a higher or lower resolution
  141319. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141320. * Check your browser for supported MIME types
  141321. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141322. * to the src parameter of an <img> to display it
  141323. */
  141324. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141325. /**
  141326. * Generates an image screenshot from the specified camera.
  141327. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141328. * @param engine The engine to use for rendering
  141329. * @param camera The camera to use for rendering
  141330. * @param size This parameter can be set to a single number or to an object with the
  141331. * following (optional) properties: precision, width, height. If a single number is passed,
  141332. * it will be used for both width and height. If an object is passed, the screenshot size
  141333. * will be derived from the parameters. The precision property is a multiplier allowing
  141334. * rendering at a higher or lower resolution
  141335. * @param successCallback The callback receives a single parameter which contains the
  141336. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141337. * src parameter of an <img> to display it
  141338. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141339. * Check your browser for supported MIME types
  141340. * @param samples Texture samples (default: 1)
  141341. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141342. * @param fileName A name for for the downloaded file.
  141343. */
  141344. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  141345. /**
  141346. * Generates an image screenshot from the specified camera.
  141347. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141348. * @param engine The engine to use for rendering
  141349. * @param camera The camera to use for rendering
  141350. * @param size This parameter can be set to a single number or to an object with the
  141351. * following (optional) properties: precision, width, height. If a single number is passed,
  141352. * it will be used for both width and height. If an object is passed, the screenshot size
  141353. * will be derived from the parameters. The precision property is a multiplier allowing
  141354. * rendering at a higher or lower resolution
  141355. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141356. * Check your browser for supported MIME types
  141357. * @param samples Texture samples (default: 1)
  141358. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141359. * @param fileName A name for for the downloaded file.
  141360. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141361. * to the src parameter of an <img> to display it
  141362. */
  141363. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141364. /**
  141365. * Gets height and width for screenshot size
  141366. * @private
  141367. */
  141368. private static _getScreenshotSize;
  141369. }
  141370. }
  141371. declare module BABYLON {
  141372. /**
  141373. * Interface for a data buffer
  141374. */
  141375. export interface IDataBuffer {
  141376. /**
  141377. * Reads bytes from the data buffer.
  141378. * @param byteOffset The byte offset to read
  141379. * @param byteLength The byte length to read
  141380. * @returns A promise that resolves when the bytes are read
  141381. */
  141382. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141383. /**
  141384. * The byte length of the buffer.
  141385. */
  141386. readonly byteLength: number;
  141387. }
  141388. /**
  141389. * Utility class for reading from a data buffer
  141390. */
  141391. export class DataReader {
  141392. /**
  141393. * The data buffer associated with this data reader.
  141394. */
  141395. readonly buffer: IDataBuffer;
  141396. /**
  141397. * The current byte offset from the beginning of the data buffer.
  141398. */
  141399. byteOffset: number;
  141400. private _dataView;
  141401. private _dataByteOffset;
  141402. /**
  141403. * Constructor
  141404. * @param buffer The buffer to read
  141405. */
  141406. constructor(buffer: IDataBuffer);
  141407. /**
  141408. * Loads the given byte length.
  141409. * @param byteLength The byte length to load
  141410. * @returns A promise that resolves when the load is complete
  141411. */
  141412. loadAsync(byteLength: number): Promise<void>;
  141413. /**
  141414. * Read a unsigned 32-bit integer from the currently loaded data range.
  141415. * @returns The 32-bit integer read
  141416. */
  141417. readUint32(): number;
  141418. /**
  141419. * Read a byte array from the currently loaded data range.
  141420. * @param byteLength The byte length to read
  141421. * @returns The byte array read
  141422. */
  141423. readUint8Array(byteLength: number): Uint8Array;
  141424. /**
  141425. * Read a string from the currently loaded data range.
  141426. * @param byteLength The byte length to read
  141427. * @returns The string read
  141428. */
  141429. readString(byteLength: number): string;
  141430. /**
  141431. * Skips the given byte length the currently loaded data range.
  141432. * @param byteLength The byte length to skip
  141433. */
  141434. skipBytes(byteLength: number): void;
  141435. }
  141436. }
  141437. declare module BABYLON {
  141438. /**
  141439. * A cursor which tracks a point on a path
  141440. */
  141441. export class PathCursor {
  141442. private path;
  141443. /**
  141444. * Stores path cursor callbacks for when an onchange event is triggered
  141445. */
  141446. private _onchange;
  141447. /**
  141448. * The value of the path cursor
  141449. */
  141450. value: number;
  141451. /**
  141452. * The animation array of the path cursor
  141453. */
  141454. animations: Animation[];
  141455. /**
  141456. * Initializes the path cursor
  141457. * @param path The path to track
  141458. */
  141459. constructor(path: Path2);
  141460. /**
  141461. * Gets the cursor point on the path
  141462. * @returns A point on the path cursor at the cursor location
  141463. */
  141464. getPoint(): Vector3;
  141465. /**
  141466. * Moves the cursor ahead by the step amount
  141467. * @param step The amount to move the cursor forward
  141468. * @returns This path cursor
  141469. */
  141470. moveAhead(step?: number): PathCursor;
  141471. /**
  141472. * Moves the cursor behind by the step amount
  141473. * @param step The amount to move the cursor back
  141474. * @returns This path cursor
  141475. */
  141476. moveBack(step?: number): PathCursor;
  141477. /**
  141478. * Moves the cursor by the step amount
  141479. * If the step amount is greater than one, an exception is thrown
  141480. * @param step The amount to move the cursor
  141481. * @returns This path cursor
  141482. */
  141483. move(step: number): PathCursor;
  141484. /**
  141485. * Ensures that the value is limited between zero and one
  141486. * @returns This path cursor
  141487. */
  141488. private ensureLimits;
  141489. /**
  141490. * Runs onchange callbacks on change (used by the animation engine)
  141491. * @returns This path cursor
  141492. */
  141493. private raiseOnChange;
  141494. /**
  141495. * Executes a function on change
  141496. * @param f A path cursor onchange callback
  141497. * @returns This path cursor
  141498. */
  141499. onchange(f: (cursor: PathCursor) => void): PathCursor;
  141500. }
  141501. }
  141502. declare module BABYLON {
  141503. /** @hidden */
  141504. export var blurPixelShader: {
  141505. name: string;
  141506. shader: string;
  141507. };
  141508. }
  141509. declare module BABYLON {
  141510. /** @hidden */
  141511. export var pointCloudVertexDeclaration: {
  141512. name: string;
  141513. shader: string;
  141514. };
  141515. }
  141516. // Mixins
  141517. interface Window {
  141518. mozIndexedDB: IDBFactory;
  141519. webkitIndexedDB: IDBFactory;
  141520. msIndexedDB: IDBFactory;
  141521. webkitURL: typeof URL;
  141522. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  141523. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  141524. WebGLRenderingContext: WebGLRenderingContext;
  141525. MSGesture: MSGesture;
  141526. CANNON: any;
  141527. AudioContext: AudioContext;
  141528. webkitAudioContext: AudioContext;
  141529. PointerEvent: any;
  141530. Math: Math;
  141531. Uint8Array: Uint8ArrayConstructor;
  141532. Float32Array: Float32ArrayConstructor;
  141533. mozURL: typeof URL;
  141534. msURL: typeof URL;
  141535. VRFrameData: any; // WebVR, from specs 1.1
  141536. DracoDecoderModule: any;
  141537. setImmediate(handler: (...args: any[]) => void): number;
  141538. }
  141539. interface HTMLCanvasElement {
  141540. requestPointerLock(): void;
  141541. msRequestPointerLock?(): void;
  141542. mozRequestPointerLock?(): void;
  141543. webkitRequestPointerLock?(): void;
  141544. /** Track wether a record is in progress */
  141545. isRecording: boolean;
  141546. /** Capture Stream method defined by some browsers */
  141547. captureStream(fps?: number): MediaStream;
  141548. }
  141549. interface CanvasRenderingContext2D {
  141550. msImageSmoothingEnabled: boolean;
  141551. }
  141552. interface MouseEvent {
  141553. mozMovementX: number;
  141554. mozMovementY: number;
  141555. webkitMovementX: number;
  141556. webkitMovementY: number;
  141557. msMovementX: number;
  141558. msMovementY: number;
  141559. }
  141560. interface Navigator {
  141561. mozGetVRDevices: (any: any) => any;
  141562. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141563. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141564. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141565. webkitGetGamepads(): Gamepad[];
  141566. msGetGamepads(): Gamepad[];
  141567. webkitGamepads(): Gamepad[];
  141568. }
  141569. interface HTMLVideoElement {
  141570. mozSrcObject: any;
  141571. }
  141572. interface Math {
  141573. fround(x: number): number;
  141574. imul(a: number, b: number): number;
  141575. }
  141576. interface WebGLRenderingContext {
  141577. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  141578. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  141579. vertexAttribDivisor(index: number, divisor: number): void;
  141580. createVertexArray(): any;
  141581. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  141582. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  141583. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  141584. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  141585. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  141586. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  141587. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  141588. // Queries
  141589. createQuery(): WebGLQuery;
  141590. deleteQuery(query: WebGLQuery): void;
  141591. beginQuery(target: number, query: WebGLQuery): void;
  141592. endQuery(target: number): void;
  141593. getQueryParameter(query: WebGLQuery, pname: number): any;
  141594. getQuery(target: number, pname: number): any;
  141595. MAX_SAMPLES: number;
  141596. RGBA8: number;
  141597. READ_FRAMEBUFFER: number;
  141598. DRAW_FRAMEBUFFER: number;
  141599. UNIFORM_BUFFER: number;
  141600. HALF_FLOAT_OES: number;
  141601. RGBA16F: number;
  141602. RGBA32F: number;
  141603. R32F: number;
  141604. RG32F: number;
  141605. RGB32F: number;
  141606. R16F: number;
  141607. RG16F: number;
  141608. RGB16F: number;
  141609. RED: number;
  141610. RG: number;
  141611. R8: number;
  141612. RG8: number;
  141613. UNSIGNED_INT_24_8: number;
  141614. DEPTH24_STENCIL8: number;
  141615. MIN: number;
  141616. MAX: number;
  141617. /* Multiple Render Targets */
  141618. drawBuffers(buffers: number[]): void;
  141619. readBuffer(src: number): void;
  141620. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  141621. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  141622. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  141623. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  141624. // Occlusion Query
  141625. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  141626. ANY_SAMPLES_PASSED: number;
  141627. QUERY_RESULT_AVAILABLE: number;
  141628. QUERY_RESULT: number;
  141629. }
  141630. interface WebGLProgram {
  141631. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  141632. }
  141633. interface EXT_disjoint_timer_query {
  141634. QUERY_COUNTER_BITS_EXT: number;
  141635. TIME_ELAPSED_EXT: number;
  141636. TIMESTAMP_EXT: number;
  141637. GPU_DISJOINT_EXT: number;
  141638. QUERY_RESULT_EXT: number;
  141639. QUERY_RESULT_AVAILABLE_EXT: number;
  141640. queryCounterEXT(query: WebGLQuery, target: number): void;
  141641. createQueryEXT(): WebGLQuery;
  141642. beginQueryEXT(target: number, query: WebGLQuery): void;
  141643. endQueryEXT(target: number): void;
  141644. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  141645. deleteQueryEXT(query: WebGLQuery): void;
  141646. }
  141647. interface WebGLUniformLocation {
  141648. _currentState: any;
  141649. }
  141650. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  141651. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  141652. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  141653. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141654. interface WebGLRenderingContext {
  141655. readonly RASTERIZER_DISCARD: number;
  141656. readonly DEPTH_COMPONENT24: number;
  141657. readonly TEXTURE_3D: number;
  141658. readonly TEXTURE_2D_ARRAY: number;
  141659. readonly TEXTURE_COMPARE_FUNC: number;
  141660. readonly TEXTURE_COMPARE_MODE: number;
  141661. readonly COMPARE_REF_TO_TEXTURE: number;
  141662. readonly TEXTURE_WRAP_R: number;
  141663. readonly HALF_FLOAT: number;
  141664. readonly RGB8: number;
  141665. readonly RED_INTEGER: number;
  141666. readonly RG_INTEGER: number;
  141667. readonly RGB_INTEGER: number;
  141668. readonly RGBA_INTEGER: number;
  141669. readonly R8_SNORM: number;
  141670. readonly RG8_SNORM: number;
  141671. readonly RGB8_SNORM: number;
  141672. readonly RGBA8_SNORM: number;
  141673. readonly R8I: number;
  141674. readonly RG8I: number;
  141675. readonly RGB8I: number;
  141676. readonly RGBA8I: number;
  141677. readonly R8UI: number;
  141678. readonly RG8UI: number;
  141679. readonly RGB8UI: number;
  141680. readonly RGBA8UI: number;
  141681. readonly R16I: number;
  141682. readonly RG16I: number;
  141683. readonly RGB16I: number;
  141684. readonly RGBA16I: number;
  141685. readonly R16UI: number;
  141686. readonly RG16UI: number;
  141687. readonly RGB16UI: number;
  141688. readonly RGBA16UI: number;
  141689. readonly R32I: number;
  141690. readonly RG32I: number;
  141691. readonly RGB32I: number;
  141692. readonly RGBA32I: number;
  141693. readonly R32UI: number;
  141694. readonly RG32UI: number;
  141695. readonly RGB32UI: number;
  141696. readonly RGBA32UI: number;
  141697. readonly RGB10_A2UI: number;
  141698. readonly R11F_G11F_B10F: number;
  141699. readonly RGB9_E5: number;
  141700. readonly RGB10_A2: number;
  141701. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  141702. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  141703. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  141704. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  141705. readonly DEPTH_COMPONENT32F: number;
  141706. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  141707. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  141708. 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;
  141709. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  141710. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  141711. readonly TRANSFORM_FEEDBACK: number;
  141712. readonly INTERLEAVED_ATTRIBS: number;
  141713. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  141714. createTransformFeedback(): WebGLTransformFeedback;
  141715. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  141716. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  141717. beginTransformFeedback(primitiveMode: number): void;
  141718. endTransformFeedback(): void;
  141719. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  141720. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141721. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141722. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141723. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  141724. }
  141725. interface ImageBitmap {
  141726. readonly width: number;
  141727. readonly height: number;
  141728. close(): void;
  141729. }
  141730. interface WebGLQuery extends WebGLObject {
  141731. }
  141732. declare var WebGLQuery: {
  141733. prototype: WebGLQuery;
  141734. new(): WebGLQuery;
  141735. };
  141736. interface WebGLSampler extends WebGLObject {
  141737. }
  141738. declare var WebGLSampler: {
  141739. prototype: WebGLSampler;
  141740. new(): WebGLSampler;
  141741. };
  141742. interface WebGLSync extends WebGLObject {
  141743. }
  141744. declare var WebGLSync: {
  141745. prototype: WebGLSync;
  141746. new(): WebGLSync;
  141747. };
  141748. interface WebGLTransformFeedback extends WebGLObject {
  141749. }
  141750. declare var WebGLTransformFeedback: {
  141751. prototype: WebGLTransformFeedback;
  141752. new(): WebGLTransformFeedback;
  141753. };
  141754. interface WebGLVertexArrayObject extends WebGLObject {
  141755. }
  141756. declare var WebGLVertexArrayObject: {
  141757. prototype: WebGLVertexArrayObject;
  141758. new(): WebGLVertexArrayObject;
  141759. };
  141760. // Type definitions for WebVR API
  141761. // Project: https://w3c.github.io/webvr/
  141762. // Definitions by: six a <https://github.com/lostfictions>
  141763. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141764. interface VRDisplay extends EventTarget {
  141765. /**
  141766. * Dictionary of capabilities describing the VRDisplay.
  141767. */
  141768. readonly capabilities: VRDisplayCapabilities;
  141769. /**
  141770. * z-depth defining the far plane of the eye view frustum
  141771. * enables mapping of values in the render target depth
  141772. * attachment to scene coordinates. Initially set to 10000.0.
  141773. */
  141774. depthFar: number;
  141775. /**
  141776. * z-depth defining the near plane of the eye view frustum
  141777. * enables mapping of values in the render target depth
  141778. * attachment to scene coordinates. Initially set to 0.01.
  141779. */
  141780. depthNear: number;
  141781. /**
  141782. * An identifier for this distinct VRDisplay. Used as an
  141783. * association point in the Gamepad API.
  141784. */
  141785. readonly displayId: number;
  141786. /**
  141787. * A display name, a user-readable name identifying it.
  141788. */
  141789. readonly displayName: string;
  141790. readonly isConnected: boolean;
  141791. readonly isPresenting: boolean;
  141792. /**
  141793. * If this VRDisplay supports room-scale experiences, the optional
  141794. * stage attribute contains details on the room-scale parameters.
  141795. */
  141796. readonly stageParameters: VRStageParameters | null;
  141797. /**
  141798. * Passing the value returned by `requestAnimationFrame` to
  141799. * `cancelAnimationFrame` will unregister the callback.
  141800. * @param handle Define the hanle of the request to cancel
  141801. */
  141802. cancelAnimationFrame(handle: number): void;
  141803. /**
  141804. * Stops presenting to the VRDisplay.
  141805. * @returns a promise to know when it stopped
  141806. */
  141807. exitPresent(): Promise<void>;
  141808. /**
  141809. * Return the current VREyeParameters for the given eye.
  141810. * @param whichEye Define the eye we want the parameter for
  141811. * @returns the eye parameters
  141812. */
  141813. getEyeParameters(whichEye: string): VREyeParameters;
  141814. /**
  141815. * Populates the passed VRFrameData with the information required to render
  141816. * the current frame.
  141817. * @param frameData Define the data structure to populate
  141818. * @returns true if ok otherwise false
  141819. */
  141820. getFrameData(frameData: VRFrameData): boolean;
  141821. /**
  141822. * Get the layers currently being presented.
  141823. * @returns the list of VR layers
  141824. */
  141825. getLayers(): VRLayer[];
  141826. /**
  141827. * Return a VRPose containing the future predicted pose of the VRDisplay
  141828. * when the current frame will be presented. The value returned will not
  141829. * change until JavaScript has returned control to the browser.
  141830. *
  141831. * The VRPose will contain the position, orientation, velocity,
  141832. * and acceleration of each of these properties.
  141833. * @returns the pose object
  141834. */
  141835. getPose(): VRPose;
  141836. /**
  141837. * Return the current instantaneous pose of the VRDisplay, with no
  141838. * prediction applied.
  141839. * @returns the current instantaneous pose
  141840. */
  141841. getImmediatePose(): VRPose;
  141842. /**
  141843. * The callback passed to `requestAnimationFrame` will be called
  141844. * any time a new frame should be rendered. When the VRDisplay is
  141845. * presenting the callback will be called at the native refresh
  141846. * rate of the HMD. When not presenting this function acts
  141847. * identically to how window.requestAnimationFrame acts. Content should
  141848. * make no assumptions of frame rate or vsync behavior as the HMD runs
  141849. * asynchronously from other displays and at differing refresh rates.
  141850. * @param callback Define the eaction to run next frame
  141851. * @returns the request handle it
  141852. */
  141853. requestAnimationFrame(callback: FrameRequestCallback): number;
  141854. /**
  141855. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  141856. * Repeat calls while already presenting will update the VRLayers being displayed.
  141857. * @param layers Define the list of layer to present
  141858. * @returns a promise to know when the request has been fulfilled
  141859. */
  141860. requestPresent(layers: VRLayer[]): Promise<void>;
  141861. /**
  141862. * Reset the pose for this display, treating its current position and
  141863. * orientation as the "origin/zero" values. VRPose.position,
  141864. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  141865. * updated when calling resetPose(). This should be called in only
  141866. * sitting-space experiences.
  141867. */
  141868. resetPose(): void;
  141869. /**
  141870. * The VRLayer provided to the VRDisplay will be captured and presented
  141871. * in the HMD. Calling this function has the same effect on the source
  141872. * canvas as any other operation that uses its source image, and canvases
  141873. * created without preserveDrawingBuffer set to true will be cleared.
  141874. * @param pose Define the pose to submit
  141875. */
  141876. submitFrame(pose?: VRPose): void;
  141877. }
  141878. declare var VRDisplay: {
  141879. prototype: VRDisplay;
  141880. new(): VRDisplay;
  141881. };
  141882. interface VRLayer {
  141883. leftBounds?: number[] | Float32Array | null;
  141884. rightBounds?: number[] | Float32Array | null;
  141885. source?: HTMLCanvasElement | null;
  141886. }
  141887. interface VRDisplayCapabilities {
  141888. readonly canPresent: boolean;
  141889. readonly hasExternalDisplay: boolean;
  141890. readonly hasOrientation: boolean;
  141891. readonly hasPosition: boolean;
  141892. readonly maxLayers: number;
  141893. }
  141894. interface VREyeParameters {
  141895. /** @deprecated */
  141896. readonly fieldOfView: VRFieldOfView;
  141897. readonly offset: Float32Array;
  141898. readonly renderHeight: number;
  141899. readonly renderWidth: number;
  141900. }
  141901. interface VRFieldOfView {
  141902. readonly downDegrees: number;
  141903. readonly leftDegrees: number;
  141904. readonly rightDegrees: number;
  141905. readonly upDegrees: number;
  141906. }
  141907. interface VRFrameData {
  141908. readonly leftProjectionMatrix: Float32Array;
  141909. readonly leftViewMatrix: Float32Array;
  141910. readonly pose: VRPose;
  141911. readonly rightProjectionMatrix: Float32Array;
  141912. readonly rightViewMatrix: Float32Array;
  141913. readonly timestamp: number;
  141914. }
  141915. interface VRPose {
  141916. readonly angularAcceleration: Float32Array | null;
  141917. readonly angularVelocity: Float32Array | null;
  141918. readonly linearAcceleration: Float32Array | null;
  141919. readonly linearVelocity: Float32Array | null;
  141920. readonly orientation: Float32Array | null;
  141921. readonly position: Float32Array | null;
  141922. readonly timestamp: number;
  141923. }
  141924. interface VRStageParameters {
  141925. sittingToStandingTransform?: Float32Array;
  141926. sizeX?: number;
  141927. sizeY?: number;
  141928. }
  141929. interface Navigator {
  141930. getVRDisplays(): Promise<VRDisplay[]>;
  141931. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  141932. }
  141933. interface Window {
  141934. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  141935. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  141936. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  141937. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141938. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141939. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  141940. }
  141941. interface Gamepad {
  141942. readonly displayId: number;
  141943. }
  141944. type XRSessionMode =
  141945. | "inline"
  141946. | "immersive-vr"
  141947. | "immersive-ar";
  141948. type XRReferenceSpaceType =
  141949. | "viewer"
  141950. | "local"
  141951. | "local-floor"
  141952. | "bounded-floor"
  141953. | "unbounded";
  141954. type XREnvironmentBlendMode =
  141955. | "opaque"
  141956. | "additive"
  141957. | "alpha-blend";
  141958. type XRVisibilityState =
  141959. | "visible"
  141960. | "visible-blurred"
  141961. | "hidden";
  141962. type XRHandedness =
  141963. | "none"
  141964. | "left"
  141965. | "right";
  141966. type XRTargetRayMode =
  141967. | "gaze"
  141968. | "tracked-pointer"
  141969. | "screen";
  141970. type XREye =
  141971. | "none"
  141972. | "left"
  141973. | "right";
  141974. interface XRSpace extends EventTarget {
  141975. }
  141976. interface XRRenderState {
  141977. depthNear?: number;
  141978. depthFar?: number;
  141979. inlineVerticalFieldOfView?: number;
  141980. baseLayer?: XRWebGLLayer;
  141981. }
  141982. interface XRInputSource {
  141983. handedness: XRHandedness;
  141984. targetRayMode: XRTargetRayMode;
  141985. targetRaySpace: XRSpace;
  141986. gripSpace: XRSpace | undefined;
  141987. gamepad: Gamepad | undefined;
  141988. profiles: Array<string>;
  141989. }
  141990. interface XRSessionInit {
  141991. optionalFeatures?: XRReferenceSpaceType[];
  141992. requiredFeatures?: XRReferenceSpaceType[];
  141993. }
  141994. interface XRSession extends XRAnchorCreator {
  141995. addEventListener: Function;
  141996. removeEventListener: Function;
  141997. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  141998. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  141999. requestAnimationFrame: Function;
  142000. end(): Promise<void>;
  142001. renderState: XRRenderState;
  142002. inputSources: Array<XRInputSource>;
  142003. // AR hit test
  142004. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142005. updateWorldTrackingState(options: {
  142006. planeDetectionState?: { enabled: boolean; }
  142007. }): void;
  142008. }
  142009. interface XRReferenceSpace extends XRSpace {
  142010. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  142011. onreset: any;
  142012. }
  142013. type XRPlaneSet = Set<XRPlane>;
  142014. type XRAnchorSet = Set<XRAnchor>;
  142015. interface XRFrame {
  142016. session: XRSession;
  142017. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  142018. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  142019. // Anchors
  142020. trackedAnchors?: XRAnchorSet;
  142021. // Planes
  142022. worldInformation: {
  142023. detectedPlanes?: XRPlaneSet;
  142024. };
  142025. }
  142026. interface XRViewerPose extends XRPose {
  142027. views: Array<XRView>;
  142028. }
  142029. interface XRPose {
  142030. transform: XRRigidTransform;
  142031. emulatedPosition: boolean;
  142032. }
  142033. interface XRWebGLLayerOptions {
  142034. antialias?: boolean;
  142035. depth?: boolean;
  142036. stencil?: boolean;
  142037. alpha?: boolean;
  142038. multiview?: boolean;
  142039. framebufferScaleFactor?: number;
  142040. }
  142041. declare var XRWebGLLayer: {
  142042. prototype: XRWebGLLayer;
  142043. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  142044. };
  142045. interface XRWebGLLayer {
  142046. framebuffer: WebGLFramebuffer;
  142047. framebufferWidth: number;
  142048. framebufferHeight: number;
  142049. getViewport: Function;
  142050. }
  142051. declare class XRRigidTransform {
  142052. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  142053. position: DOMPointReadOnly;
  142054. orientation: DOMPointReadOnly;
  142055. matrix: Float32Array;
  142056. inverse: XRRigidTransform;
  142057. }
  142058. interface XRView {
  142059. eye: XREye;
  142060. projectionMatrix: Float32Array;
  142061. transform: XRRigidTransform;
  142062. }
  142063. interface XRInputSourceChangeEvent {
  142064. session: XRSession;
  142065. removed: Array<XRInputSource>;
  142066. added: Array<XRInputSource>;
  142067. }
  142068. interface XRInputSourceEvent extends Event {
  142069. readonly frame: XRFrame;
  142070. readonly inputSource: XRInputSource;
  142071. }
  142072. // Experimental(er) features
  142073. declare class XRRay {
  142074. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  142075. origin: DOMPointReadOnly;
  142076. direction: DOMPointReadOnly;
  142077. matrix: Float32Array;
  142078. }
  142079. interface XRHitResult {
  142080. hitMatrix: Float32Array;
  142081. }
  142082. interface XRAnchor {
  142083. // remove?
  142084. id?: string;
  142085. anchorSpace: XRSpace;
  142086. lastChangedTime: number;
  142087. detach(): void;
  142088. }
  142089. interface XRPlane extends XRAnchorCreator {
  142090. orientation: "Horizontal" | "Vertical";
  142091. planeSpace: XRSpace;
  142092. polygon: Array<DOMPointReadOnly>;
  142093. lastChangedTime: number;
  142094. }
  142095. interface XRAnchorCreator {
  142096. // AR Anchors
  142097. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  142098. }